Diff
Modified: trunk/Source/WebCore/ChangeLog (104642 => 104643)
--- trunk/Source/WebCore/ChangeLog 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/ChangeLog 2012-01-10 23:48:39 UTC (rev 104643)
@@ -1,5 +1,72 @@
2012-01-10 Kentaro Hara <[email protected]>
+ Support the [Supplemental] IDL on methods
+ https://bugs.webkit.org/show_bug.cgi?id=75944
+
+ Reviewed by Adam Barth.
+
+ The spec for the [Supplemental] IDL:
+ http://dev.w3.org/2006/webapi/WebIDL/#dfn-supplemental-interface
+
+ Currently the [Supplemental] IDL is supported on attributes but not supported
+ on methods. This patch makes a change to support it.
+
+ Specifically, assume the following IDL:
+
+ interface [Supplemental=X] Y {
+ void func();
+ }
+
+ Then the code generator generates the following V8X.cpp.
+
+ void funcCallback(Arguments& args) {
+ X* imp = V8X::toNative(args.Holder());
+ Y::func(imp);
+ }
+
+ Similar code is also generated for JS, ObjC, GObject and CPP bindings.
+
+ Test: bindings/scripts/test/TestSupplemental.idl
+
+ * bindings/scripts/CodeGeneratorCPP.pm: Modified as described above.
+ (GenerateImplementation):
+ * bindings/scripts/CodeGeneratorGObject.pm: Ditto.
+ (GenerateFunction):
+ * bindings/scripts/CodeGeneratorJS.pm: Ditto.
+ (GenerateParametersCheck):
+ * bindings/scripts/CodeGeneratorObjC.pm: Ditto.
+ (GenerateImplementation):
+ * bindings/scripts/CodeGeneratorV8.pm: Ditto.
+ (GenerateFunctionCallString):
+ * bindings/scripts/generate-bindings.pl: Ditto.
+
+ * bindings/scripts/test/TestSupplemental.idl: Added test cases for [Supplemental] methods.
+
+ * bindings/scripts/test/CPP/WebDOMTestInterface.cpp: Updated the test result.
+ (WebDOMTestInterface::supplementalMethod1):
+ (WebDOMTestInterface::supplementalMethod2):
+ * bindings/scripts/test/CPP/WebDOMTestInterface.h: Ditto.
+ * bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp: Ditto.
+ (webkit_dom_test_interface_supplemental_method1):
+ (webkit_dom_test_interface_supplemental_method2):
+ * bindings/scripts/test/GObject/WebKitDOMTestInterface.h: Ditto.
+ * bindings/scripts/test/JS/JSTestInterface.cpp: Ditto.
+ (WebCore::JSTestInterfacePrototype::getOwnPropertySlot):
+ (WebCore::JSTestInterfacePrototype::getOwnPropertyDescriptor):
+ (WebCore::jsTestInterfacePrototypeFunctionSupplementalMethod1):
+ (WebCore::jsTestInterfacePrototypeFunctionSupplementalMethod2):
+ * bindings/scripts/test/JS/JSTestInterface.h: Ditto.
+ * bindings/scripts/test/ObjC/DOMTestInterface.h: Ditto.
+ * bindings/scripts/test/ObjC/DOMTestInterface.mm: Ditto.
+ (-[DOMTestInterface supplementalMethod1]):
+ (-[DOMTestInterface supplementalMethod2:objArg:]):
+ * bindings/scripts/test/V8/V8TestInterface.cpp: Ditto.
+ (WebCore::TestInterfaceInternal::supplementalMethod1Callback):
+ (WebCore::TestInterfaceInternal::supplementalMethod2Callback):
+ (WebCore::ConfigureV8TestInterfaceTemplate):
+
+2012-01-10 Kentaro Hara <[email protected]>
+
[Refactoring] Rename attributes in TestSupplemental.idl to clarify
that they are supplemental attributes
https://bugs.webkit.org/show_bug.cgi?id=75942
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm 2012-01-10 23:48:39 UTC (rev 104643)
@@ -848,8 +848,17 @@
my @functionContent = ();
push(@parameterNames, "ec") if $raisesExceptions;
- my $content = "impl()->" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")";
+ my $content;
+ if ($function->signature->extendedAttributes->{"ImplementedBy"}) {
+ my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+ $implIncludes{"${implementedBy}.h"} = 1;
+ unshift(@parameterNames, "impl()");
+ $content = "${implementedBy}::" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")";
+ } else {
+ $content = "impl()->" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")";
+ }
+
if ($returnType eq "void") {
# Special case 'void' return type.
if ($raisesExceptions) {
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2012-01-10 23:48:39 UTC (rev 104643)
@@ -937,7 +937,15 @@
}
$getterContentHead = "${assign}convertToUTF8String(${functionName}(" . join(", ", @arguments) . "));\n";
} else {
- $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(" . join(", ", @callImplParams) . "));\n";
+ my @arguments = @callImplParams;
+ if ($function->signature->extendedAttributes->{"ImplementedBy"}) {
+ my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+ $implIncludes{"${implementedBy}.h"} = 1;
+ unshift(@arguments, "item");
+ $getterContentHead = "${assign}convertToUTF8String(${implementedBy}::${functionSigName}(" . join(", ", @arguments) . "));\n";
+ } else {
+ $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(" . join(", ", @arguments) . "));\n";
+ }
}
push(@cBody, " ${getterContentHead}");
} else {
@@ -968,7 +976,15 @@
$contentHead = "${assign}${assignPre}${functionName}(" . join(", ", @arguments) . "${assignPost});\n";
}
} else {
- $contentHead = "${assign}${assignPre}item->${functionSigName}(" . join(", ", @callImplParams) . "${assignPost});\n";
+ my @arguments = @callImplParams;
+ if ($function->signature->extendedAttributes->{"ImplementedBy"}) {
+ my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+ $implIncludes{"${implementedBy}.h"} = 1;
+ unshift(@arguments, "item");
+ $contentHead = "${assign}${assignPre}${implementedBy}::${functionSigName}(" . join(", ", @arguments) . "${assignPost});\n";
+ } else {
+ $contentHead = "${assign}${assignPre}item->${functionSigName}(" . join(", ", @arguments) . "${assignPost});\n";
+ }
}
push(@cBody, " ${contentHead}");
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-01-10 23:48:39 UTC (rev 104643)
@@ -2422,16 +2422,20 @@
my $argsIndex = 0;
my $hasOptionalArguments = 0;
- my $functionBase = "";
+ my @arguments;
+ my $functionName;
if ($function->isStatic) {
- $functionBase = "${implClassName}::";
+ $functionName = "${implClassName}::${functionImplementationName}";
+ } elsif ($function->signature->extendedAttributes->{"ImplementedBy"}) {
+ my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+ AddToImplIncludes("${implementedBy}.h");
+ unshift(@arguments, "impl");
+ $functionName = "${implementedBy}::${functionImplementationName}";
} elsif ($svgPropertyOrListPropertyType and !$svgListPropertyType) {
- $functionBase = "podImpl.";
+ $functionName = "podImpl.${functionImplementationName}";
} else {
- $functionBase = "impl->";
+ $functionName = "impl->${functionImplementationName}";
}
- my $functionName = "$functionBase$functionImplementationName";
- my @arguments;
if ($function->signature->extendedAttributes->{"CustomArgumentHandling"} and !$function->isStatic) {
push(@$outputArray, " RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n");
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm 2012-01-10 23:48:39 UTC (rev 104643)
@@ -1607,9 +1607,13 @@
splice(@parameterNames, $currentParameter, 1, "${paramName}Core->propertyReference()");
}
- my $content = $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")";
-
- if ($svgPropertyType) {
+ my $content;
+ if ($function->signature->extendedAttributes->{"ImplementedBy"}) {
+ my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+ $implIncludes{"${implementedBy}.h"} = 1;
+ unshift(@parameterNames, $caller);
+ $content = "${implementedBy}::" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")";
+ } elsif ($svgPropertyType) {
$implIncludes{"ExceptionCode.h"} = 1;
push(@functionContent, " if (IMPL->role() == WebCore::AnimValRole) {\n");
push(@functionContent, " WebCore::raiseOnDOMError(WebCore::NO_MODIFICATION_ALLOWED_ERR);\n");
@@ -1620,9 +1624,9 @@
}
push(@functionContent, " }\n");
push(@functionContent, " $svgPropertyType& podImpl = IMPL->propertyReference();\n");
- $content = "podImpl.$content";
+ $content = "podImpl." . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")";
} else {
- $content = $caller . "->$content";
+ $content = "$caller->" . $codeGenerator->WK_lcfirst($functionName) . "(" . join(", ", @parameterNames) . ")";
}
if ($returnType eq "void") {
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-01-10 23:48:39 UTC (rev 104643)
@@ -3182,10 +3182,22 @@
$name = $function->signature->extendedAttributes->{"ImplementationFunction"};
}
- my @arguments;
my $index = 0;
my $hasScriptState = 0;
+ my @arguments;
+ my $functionName;
+ if ($function->isStatic) {
+ $functionName = "${implClassName}::${name}";
+ } elsif ($function->signature->extendedAttributes->{"ImplementedBy"}) {
+ my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
+ AddToImplIncludes("${implementedBy}.h");
+ unshift(@arguments, "imp");
+ $functionName = "${implementedBy}::${name}";
+ } else {
+ $functionName = "imp->${name}";
+ }
+
my $callWith = $function->signature->extendedAttributes->{"CallWith"};
if ($callWith) {
my $callWithArg = "COMPILE_ASSERT(false)";
@@ -3235,7 +3247,7 @@
push @arguments, "ec";
}
- my $functionString = ($function->isStatic ? "${implClassName}::${name}(" : "imp->${name}(") . join(", ", @arguments) . ")";
+ my $functionString = "$functionName(" . join(", ", @arguments) . ")";
my $return = "result";
my $returnIsRef = IsRefPtrType($returnType);
Modified: trunk/Source/WebCore/bindings/scripts/generate-bindings.pl (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/generate-bindings.pl 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/generate-bindings.pl 2012-01-10 23:48:39 UTC (rev 104643)
@@ -159,6 +159,18 @@
}
push(@{$targetDataNode->attributes}, $attribute);
}
+
+ foreach my $function (@{$dataNode->functions}) {
+ # Record that this attribute is implemented by $interfaceName.
+ $function->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName;
+
+ # Add interface-wide extended attributes to each attribute.
+ foreach my $extendedAttributeName (keys %{$dataNode->extendedAttributes}) {
+ next if ($extendedAttributeName eq "Supplemental");
+ $function->signature->extendedAttributes->{$extendedAttributeName} = $dataNode->extendedAttributes->{$extendedAttributeName};
+ }
+ push(@{$targetDataNode->functions}, $function);
+ }
}
}
}
Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp 2012-01-10 23:48:39 UTC (rev 104643)
@@ -26,8 +26,10 @@
#include "KURL.h"
#include "TestInterface.h"
+#include "TestObj.h"
#include "TestSupplemental.h"
#include "WebDOMString.h"
+#include "WebDOMTestObj.h"
#include "WebExceptionHandler.h"
#include "wtf/text/AtomicString.h"
#include <wtf/GetPtr.h>
@@ -106,6 +108,33 @@
}
#endif
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+void WebDOMTestInterface::supplementalMethod1()
+{
+ if (!impl())
+ return;
+
+ TestSupplemental::supplementalMethod1(impl());
+}
+
+#endif
+
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+WebDOMTestObj WebDOMTestInterface::supplementalMethod2(const WebDOMString& strArg, const WebDOMTestObj& objArg)
+{
+ if (!impl())
+ return WebDOMTestObj();
+
+ WebCore::ExceptionCode ec = 0;
+ WebDOMTestObj result = toWebKit(WTF::getPtr(TestSupplemental::supplementalMethod2(impl(), strArg, toWebCore(objArg), ec)));
+ webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec));
+ return result;
+}
+
+#endif
+
WebCore::TestInterface* toWebCore(const WebDOMTestInterface& wrapper)
{
return wrapper.impl();
Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h 2012-01-10 23:48:39 UTC (rev 104643)
@@ -32,6 +32,7 @@
class TestInterface;
};
+class WebDOMTestObj;
class WebDOMTestInterface : public WebDOMObject {
public:
@@ -49,6 +50,9 @@
void setSupplementalStr2(const WebDOMString&);
#endif
+ void supplementalMethod1();
+ WebDOMTestObj supplementalMethod2(const WebDOMString& strArg, const WebDOMTestObj& objArg);
+
WebCore::TestInterface* impl() const;
protected:
Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp 2012-01-10 23:48:39 UTC (rev 104643)
@@ -29,11 +29,14 @@
#include "ExceptionCode.h"
#include "JSMainThreadExecState.h"
#include "TestInterface.h"
+#include "TestObj.h"
#include "TestSupplemental.h"
#include "WebKitDOMBinding.h"
#include "gobject/ConvertToUTF8String.h"
#include "webkit/WebKitDOMTestInterface.h"
#include "webkit/WebKitDOMTestInterfacePrivate.h"
+#include "webkit/WebKitDOMTestObj.h"
+#include "webkit/WebKitDOMTestObjPrivate.h"
#include "webkitdefines.h"
#include "webkitglobalsprivate.h"
#include "webkitmarshal.h"
@@ -52,6 +55,45 @@
} // namespace WebKit //
+void
+webkit_dom_test_interface_supplemental_method1(WebKitDOMTestInterface* self)
+{
+#if ENABLE(Condition11) || ENABLE(Condition12)
+ g_return_if_fail(self);
+ WebCore::JSMainThreadNullState state;
+ WebCore::TestInterface * item = WebKit::core(self);
+ TestSupplemental::supplementalMethod1(item);
+#endif /* ENABLE(Condition11) || ENABLE(Condition12) */
+}
+
+WebKitDOMTestObj*
+webkit_dom_test_interface_supplemental_method2(WebKitDOMTestInterface* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error)
+{
+#if ENABLE(Condition11) || ENABLE(Condition12)
+ g_return_val_if_fail(self, 0);
+ WebCore::JSMainThreadNullState state;
+ WebCore::TestInterface * item = WebKit::core(self);
+ g_return_val_if_fail(str_arg, 0);
+ g_return_val_if_fail(obj_arg, 0);
+ WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg);
+ WebCore::TestObj * converted_obj_arg = NULL;
+ if (obj_arg != NULL) {
+ converted_obj_arg = WebKit::core(obj_arg);
+ g_return_val_if_fail(converted_obj_arg, 0);
+ }
+ WebCore::ExceptionCode ec = 0;
+ PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(TestSupplemental::supplementalMethod2(item, converted_str_arg, converted_obj_arg, ec));
+ if (ec) {
+ WebCore::ExceptionCodeDescription ecdesc(ec);
+ g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+ }
+ WebKitDOMTestObj* res = WebKit::kit(g_res.get());
+ return res;
+#else
+ return NULL;
+#endif /* ENABLE(Condition11) || ENABLE(Condition12) */
+}
+
gchar*
webkit_dom_test_interface_get_supplemental_str1(WebKitDOMTestInterface* self)
{
Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h 2012-01-10 23:48:39 UTC (rev 104643)
@@ -47,6 +47,29 @@
webkit_dom_test_interface_get_type (void);
/**
+ * webkit_dom_test_interface_supplemental_method1:
+ * @self: A #WebKitDOMTestInterface
+ *
+ * Returns:
+ *
+**/
+WEBKIT_API void
+webkit_dom_test_interface_supplemental_method1(WebKitDOMTestInterface* self);
+
+/**
+ * webkit_dom_test_interface_supplemental_method2:
+ * @self: A #WebKitDOMTestInterface
+ * @str_arg: A #gchar
+ * @obj_arg: A #WebKitDOMTestObj
+ * @error: #GError
+ *
+ * Returns: (transfer none):
+ *
+**/
+WEBKIT_API WebKitDOMTestObj*
+webkit_dom_test_interface_supplemental_method2(WebKitDOMTestInterface* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error);
+
+/**
* webkit_dom_test_interface_get_supplemental_str1:
* @self: A #WebKitDOMTestInterface
*
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp 2012-01-10 23:48:39 UTC (rev 104643)
@@ -27,7 +27,9 @@
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSTestInterfaceCustom.h"
+#include "JSTestObj.h"
#include "TestInterface.h"
+#include "TestObj.h"
#include "TestSupplemental.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>
@@ -129,10 +131,16 @@
static const HashTableValue JSTestInterfacePrototypeTableValues[] =
{
+#if ENABLE(Condition11) || ENABLE(Condition12)
+ { "supplementalMethod1", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod1), (intptr_t)0, NoIntrinsic },
+#endif
+#if ENABLE(Condition11) || ENABLE(Condition12)
+ { "supplementalMethod2", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestInterfacePrototypeFunctionSupplementalMethod2), (intptr_t)2, NoIntrinsic },
+#endif
{ 0, 0, 0, 0, NoIntrinsic }
};
-static const HashTable JSTestInterfacePrototypeTable = { 1, 0, JSTestInterfacePrototypeTableValues, 0 };
+static const HashTable JSTestInterfacePrototypeTable = { 5, 3, JSTestInterfacePrototypeTableValues, 0 };
const ClassInfo JSTestInterfacePrototype::s_info = { "TestInterfacePrototype", &Base::s_info, &JSTestInterfacePrototypeTable, 0, CREATE_METHOD_TABLE(JSTestInterfacePrototype) };
JSObject* JSTestInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject)
@@ -140,6 +148,18 @@
return getDOMPrototype<JSTestInterface>(exec, globalObject);
}
+bool JSTestInterfacePrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+ JSTestInterfacePrototype* thisObject = jsCast<JSTestInterfacePrototype*>(cell);
+ return getStaticFunctionSlot<JSObject>(exec, &JSTestInterfacePrototypeTable, thisObject, propertyName, slot);
+}
+
+bool JSTestInterfacePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
+{
+ JSTestInterfacePrototype* thisObject = jsCast<JSTestInterfacePrototype*>(object);
+ return getStaticFunctionDescriptor<JSObject>(exec, &JSTestInterfacePrototypeTable, thisObject, propertyName, descriptor);
+}
+
const ClassInfo JSTestInterface::s_info = { "TestInterface", &Base::s_info, &JSTestInterfaceTable, 0 , CREATE_METHOD_TABLE(JSTestInterface) };
JSTestInterface::JSTestInterface(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestInterface> impl)
@@ -253,6 +273,50 @@
return getDOMConstructor<JSTestInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
}
+#if ENABLE(Condition11) || ENABLE(Condition12)
+EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod1(ExecState* exec)
+{
+ JSValue thisValue = exec->hostThisValue();
+ if (!thisValue.inherits(&JSTestInterface::s_info))
+ return throwVMTypeError(exec);
+ JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(thisValue));
+ ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestInterface::s_info);
+ TestInterface* impl = static_cast<TestInterface*>(castedThis->impl());
+ TestSupplemental::supplementalMethod1(impl);
+ return JSValue::encode(jsUndefined());
+}
+
+#endif
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod2(ExecState* exec)
+{
+ JSValue thisValue = exec->hostThisValue();
+ if (!thisValue.inherits(&JSTestInterface::s_info))
+ return throwVMTypeError(exec);
+ JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(thisValue));
+ ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestInterface::s_info);
+ TestInterface* impl = static_cast<TestInterface*>(castedThis->impl());
+ if (exec->argumentCount() < 2)
+ return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ ExceptionCode ec = 0;
+ ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
+ if (!scriptContext)
+ return JSValue::encode(jsUndefined());
+ const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+ TestObj* objArg(toTestObj(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined)));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+
+ JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(TestSupplemental::supplementalMethod2(impl, scriptContext, strArg, objArg, ec)));
+ setDOMException(exec, ec);
+ return JSValue::encode(result);
+}
+
+#endif
+
static inline bool isObservable(JSTestInterface* jsTestInterface)
{
if (jsTestInterface->hasCustomProperties())
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h 2012-01-10 23:48:39 UTC (rev 104643)
@@ -102,6 +102,8 @@
}
static const JSC::ClassInfo s_info;
+ static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
+ static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);
@@ -110,7 +112,7 @@
private:
JSTestInterfacePrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { }
protected:
- static const unsigned StructureFlags = Base::StructureFlags;
+ static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags;
};
class JSTestInterfaceConstructor : public DOMConstructorObject {
@@ -140,6 +142,10 @@
static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
};
+// Functions
+
+JSC::EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod1(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod2(JSC::ExecState*);
// Attributes
JSC::JSValue jsTestInterfaceSupplementalStr1(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h 2012-01-10 23:48:39 UTC (rev 104643)
@@ -28,6 +28,7 @@
#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST
+@class DOMTestObj;
@class NSString;
@interface DOMTestInterface : DOMObject
@@ -42,6 +43,8 @@
- (NSString *)supplementalStr3;
- (void)setSupplementalStr3:(NSString *)newSupplementalStr3;
#endif
+- (void)supplementalMethod1;
+- (DOMTestObj *)supplementalMethod2:(NSString *)strArg objArg:(DOMTestObj *)objArg;
@end
#endif
Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm 2012-01-10 23:48:39 UTC (rev 104643)
@@ -39,10 +39,12 @@
#import "DOMNodeInternal.h"
#import "DOMStyleSheetInternal.h"
#import "DOMTestInterfaceInternal.h"
+#import "DOMTestObjInternal.h"
#import "ExceptionHandlers.h"
#import "JSMainThreadExecState.h"
#import "KURL.h"
#import "TestInterface.h"
+#import "TestObj.h"
#import "TestSupplemental.h"
#import "ThreadCheck.h"
#import "WebCoreObjCExtras.h"
@@ -106,6 +108,29 @@
}
#endif
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+- (void)supplementalMethod1
+{
+ WebCore::JSMainThreadNullState state;
+ TestSupplemental::supplementalMethod1(IMPL);
+}
+
+#endif
+
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+- (DOMTestObj *)supplementalMethod2:(NSString *)strArg objArg:(DOMTestObj *)objArg
+{
+ WebCore::JSMainThreadNullState state;
+ WebCore::ExceptionCode ec = 0;
+ DOMTestObj *result = kit(WTF::getPtr(TestSupplemental::supplementalMethod2(IMPL, strArg, core(objArg), ec)));
+ WebCore::raiseOnDOMError(ec);
+ return result;
+}
+
+#endif
+
@end
WebCore::TestInterface* core(DOMTestInterface *wrapper)
Modified: trunk/Source/WebCore/bindings/scripts/test/TestSupplemental.idl (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/TestSupplemental.idl 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/TestSupplemental.idl 2012-01-10 23:48:39 UTC (rev 104643)
@@ -36,5 +36,8 @@
readonly attribute DOMString supplementalStr1;
attribute DOMString supplementalStr2;
attribute [CustomGetter, CustomSetter] DOMString supplementalStr3;
+
+ void supplementalMethod1();
+ [CallWith=ScriptExecutionContext] TestObj supplementalMethod2(in DOMString strArg, in TestObj objArg) raises(DOMException);
};
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (104642 => 104643)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2012-01-10 23:44:05 UTC (rev 104642)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2012-01-10 23:48:39 UTC (rev 104643)
@@ -32,7 +32,11 @@
#include "V8DOMWrapper.h"
#include "V8IsolatedContext.h"
#include "V8Proxy.h"
+#include "V8TestObj.h"
#include "V8TestSupplemental.h"
+#include <wtf/GetPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
#include <wtf/UnusedParam.h>
namespace WebCore {
@@ -78,6 +82,45 @@
#endif // ENABLE(Condition11) || ENABLE(Condition12)
+#if ENABLE(Condition11) || ENABLE(Condition12)
+
+static v8::Handle<v8::Value> supplementalMethod1Callback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.TestInterface.supplementalMethod1");
+ TestInterface* imp = V8TestInterface::toNative(args.Holder());
+ TestSupplemental::supplementalMethod1(imp);
+ return v8::Handle<v8::Value>();
+}
+
+#endif // ENABLE(Condition11) || ENABLE(Condition12)
+
+#if ENABLE(Condition11) || ENABLE(Condition12)
+
+static v8::Handle<v8::Value> supplementalMethod2Callback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.TestInterface.supplementalMethod2");
+ if (args.Length() < 2)
+ return throwError("Not enough arguments", V8Proxy::TypeError);
+ TestInterface* imp = V8TestInterface::toNative(args.Holder());
+ ExceptionCode ec = 0;
+ {
+ STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
+ EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined))) : 0);
+ ScriptExecutionContext* scriptContext = getScriptExecutionContext();
+ if (!scriptContext)
+ return v8::Undefined();
+ RefPtr<TestObj> result = TestSupplemental::supplementalMethod2(imp, scriptContext, strArg, objArg, ec);
+ if (UNLIKELY(ec))
+ goto fail;
+ return toV8(result.release());
+ }
+ fail:
+ V8Proxy::setDOMException(ec);
+ return v8::Handle<v8::Value>();
+}
+
+#endif // ENABLE(Condition11) || ENABLE(Condition12)
+
} // namespace TestInterfaceInternal
static const BatchedAttribute TestInterfaceAttrs[] = {
@@ -95,6 +138,12 @@
#endif // ENABLE(Condition11) || ENABLE(Condition12)
};
+static const BatchedCallback TestInterfaceCallbacks[] = {
+#if ENABLE(Condition11) || ENABLE(Condition12)
+ {"supplementalMethod1", TestInterfaceInternal::supplementalMethod1Callback},
+#endif
+};
+
v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.TestInterface.Constructor");
@@ -135,11 +184,23 @@
v8::Local<v8::Signature> defaultSignature;
defaultSignature = configureTemplate(desc, "TestInterface", v8::Persistent<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount,
TestInterfaceAttrs, WTF_ARRAY_LENGTH(TestInterfaceAttrs),
- 0, 0);
+ TestInterfaceCallbacks, WTF_ARRAY_LENGTH(TestInterfaceCallbacks));
UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
desc->SetCallHandler(V8TestInterface::constructorCallback);
+ v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
+ v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
+ UNUSED_PARAM(instance); // In some cases, it will not be used.
+ UNUSED_PARAM(proto); // In some cases, it will not be used.
+ // Custom Signature 'supplementalMethod2'
+ const int supplementalMethod2Argc = 2;
+ v8::Handle<v8::FunctionTemplate> supplementalMethod2Argv[supplementalMethod2Argc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() };
+ v8::Handle<v8::Signature> supplementalMethod2Signature = v8::Signature::New(desc, supplementalMethod2Argc, supplementalMethod2Argv);
+#if ENABLE(Condition11) || ENABLE(Condition12)
+ proto->Set(v8::String::New("supplementalMethod2"), v8::FunctionTemplate::New(TestInterfaceInternal::supplementalMethod2Callback, v8::Handle<v8::Value>(), supplementalMethod2Signature));
+#endif // ENABLE(Condition11) || ENABLE(Condition12)
+
// Custom toString template
desc->Set(getToStringName(), getToStringTemplate());
return desc;