Title: [102351] trunk/Source/WebCore
Revision
102351
Author
commit-qu...@webkit.org
Date
2011-12-08 10:55:05 -0800 (Thu, 08 Dec 2011)

Log Message

Fixing support for static conditional overloaded functions.
https://bugs.webkit.org/show_bug.cgi?id=74068

Patch by Kaustubh Atrawalkar <kaust...@motorola.com> on 2011-12-08
Reviewed by Adam Barth.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation): Pushing "static" keyword after condition "#if".
* bindings/scripts/test/CPP/WebDOMTestObj.cpp:
(WebDOMTestObj::overloadedMethod1): Added newly generated bindings.
* bindings/scripts/test/CPP/WebDOMTestObj.h: Ditto.
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Ditto.
(webkit_dom_test_obj_overloaded_method1):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h: Ditto.
* bindings/scripts/test/JS/JSTestObj.cpp: Ditto.
(WebCore::jsTestObjConstructorFunctionOverloadedMethod11):
(WebCore::jsTestObjConstructorFunctionOverloadedMethod12):
(WebCore::jsTestObjConstructorFunctionOverloadedMethod1):
* bindings/scripts/test/JS/JSTestObj.h: Ditto.
* bindings/scripts/test/ObjC/DOMTestObj.h: Ditto.
* bindings/scripts/test/ObjC/DOMTestObj.mm: Ditto.
(-[DOMTestObj overloadedMethod1:]):
* bindings/scripts/test/TestObj.idl: Ditto.
* bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
(WebCore::TestObjInternal::overloadedMethod11Callback):
(WebCore::TestObjInternal::overloadedMethod12Callback):
(WebCore::TestObjInternal::overloadedMethod1Callback):
(WebCore::ConfigureV8TestObjTemplate):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102350 => 102351)


--- trunk/Source/WebCore/ChangeLog	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/ChangeLog	2011-12-08 18:55:05 UTC (rev 102351)
@@ -1,3 +1,33 @@
+2011-12-08  Kaustubh Atrawalkar  <kaust...@motorola.com>
+
+        Fixing support for static conditional overloaded functions.
+        https://bugs.webkit.org/show_bug.cgi?id=74068
+
+        Reviewed by Adam Barth.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation): Pushing "static" keyword after condition "#if".
+        * bindings/scripts/test/CPP/WebDOMTestObj.cpp:
+        (WebDOMTestObj::overloadedMethod1): Added newly generated bindings.
+        * bindings/scripts/test/CPP/WebDOMTestObj.h: Ditto.
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Ditto.
+        (webkit_dom_test_obj_overloaded_method1):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h: Ditto.
+        * bindings/scripts/test/JS/JSTestObj.cpp: Ditto.
+        (WebCore::jsTestObjConstructorFunctionOverloadedMethod11):
+        (WebCore::jsTestObjConstructorFunctionOverloadedMethod12):
+        (WebCore::jsTestObjConstructorFunctionOverloadedMethod1):
+        * bindings/scripts/test/JS/JSTestObj.h: Ditto.
+        * bindings/scripts/test/ObjC/DOMTestObj.h: Ditto.
+        * bindings/scripts/test/ObjC/DOMTestObj.mm: Ditto.
+        (-[DOMTestObj overloadedMethod1:]):
+        * bindings/scripts/test/TestObj.idl: Ditto.
+        * bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
+        (WebCore::TestObjInternal::overloadedMethod11Callback):
+        (WebCore::TestObjInternal::overloadedMethod12Callback):
+        (WebCore::TestObjInternal::overloadedMethod1Callback):
+        (WebCore::ConfigureV8TestObjTemplate):
+
 2011-12-08  Andreas Kling  <kl...@webkit.org>
 
         Remove EventListenerMap destructor.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-12-08 18:55:05 UTC (rev 102351)
@@ -2071,6 +2071,13 @@
 
             my $functionName = GetFunctionName($className, $function);
 
+            my $conditional = $function->signature->extendedAttributes->{"Conditional"};
+            if ($conditional) {
+                my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional);
+                push(@implContent, "#if ${conditionalString}\n");
+            }
+
+
             if (!$isCustom && $isOverloaded) {
                 # Append a number to an overloaded method's name to make it unique:
                 $functionName = $functionName . $function->{overloadIndex};
@@ -2078,15 +2085,9 @@
                 # don't generate a prototype for it in the header.
                 push(@implContent, "static ");
             }
-            
+
             my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementationFunction"} || $codeGenerator->WK_lcfirst($function->signature->name);
 
-            my $conditional = $function->signature->extendedAttributes->{"Conditional"};
-            if ($conditional) {
-                my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional);
-                push(@implContent, "#if ${conditionalString}\n");
-            }
-
             push(@implContent, "EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* exec)\n");
             push(@implContent, "{\n");
 

Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp	2011-12-08 18:55:05 UTC (rev 102351)
@@ -905,6 +905,30 @@
     return impl()->classMethodWithOptional(arg);
 }
 
+
+#if ENABLE(Condition1)
+void WebDOMTestObj::overloadedMethod1(int arg)
+{
+    if (!impl())
+        return;
+
+    impl()->overloadedMethod1(arg);
+}
+
+#endif
+
+
+#if ENABLE(Condition1)
+void WebDOMTestObj::overloadedMethod1(const WebDOMString& type)
+{
+    if (!impl())
+        return;
+
+    impl()->overloadedMethod1(type);
+}
+
+#endif
+
 WebCore::TestObj* toWebCore(const WebDOMTestObj& wrapper)
 {
     return wrapper.impl();

Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h	2011-12-08 18:55:05 UTC (rev 102351)
@@ -181,6 +181,8 @@
     void conditionalMethod3();
     void classMethod();
     int classMethodWithOptional(int arg);
+    void overloadedMethod1(int arg);
+    void overloadedMethod1(const WebDOMString& type);
 
     WebCore::TestObj* impl() const;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp	2011-12-08 18:55:05 UTC (rev 102351)
@@ -415,6 +415,30 @@
     return res;
 }
 
+void
+webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, glong arg)
+{
+#if ENABLE(Condition1)
+    g_return_if_fail(self);
+    WebCore::JSMainThreadNullState state;
+    WebCore::TestObj * item = WebKit::core(self);
+    item->overloadedMethod1(arg);
+#endif /* ENABLE(Condition1) */
+}
+
+void
+webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, const gchar* type)
+{
+#if ENABLE(Condition1)
+    g_return_if_fail(self);
+    WebCore::JSMainThreadNullState state;
+    WebCore::TestObj * item = WebKit::core(self);
+    g_return_if_fail(type);
+    WTF::String converted_type = WTF::String::fromUTF8(type);
+    item->overloadedMethod1(converted_type);
+#endif /* ENABLE(Condition1) */
+}
+
 glong
 webkit_dom_test_obj_get_read_only_int_attr(WebKitDOMTestObj* self)
 {

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h	2011-12-08 18:55:05 UTC (rev 102351)
@@ -369,6 +369,28 @@
 webkit_dom_test_obj_class_method_with_optional(WebKitDOMTestObj* self, glong arg);
 
 /**
+ * webkit_dom_test_obj_overloaded_method1:
+ * @self: A #WebKitDOMTestObj
+ * @arg: A #glong
+ *
+ * Returns:
+ *
+**/
+WEBKIT_API void
+webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, glong arg);
+
+/**
+ * webkit_dom_test_obj_overloaded_method1:
+ * @self: A #WebKitDOMTestObj
+ * @type: A #gchar
+ *
+ * Returns:
+ *
+**/
+WEBKIT_API void
+webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, const gchar* type);
+
+/**
  * webkit_dom_test_obj_get_read_only_int_attr:
  * @self: A #WebKitDOMTestObj
  *

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2011-12-08 18:55:05 UTC (rev 102351)
@@ -164,11 +164,14 @@
     { "CONST_JAVASCRIPT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_JAVASCRIPT), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
     { "classMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethod), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
     { "classMethodWithOptional", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethodWithOptional), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
+#if ENABLE(Condition1)
+    { "overloadedMethod1", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionOverloadedMethod1), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
+#endif
     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
 };
 
 #undef THUNK_GENERATOR
-static const HashTable JSTestObjConstructorTable = { 35, 31, JSTestObjConstructorTableValues, 0 };
+static const HashTable JSTestObjConstructorTable = { 36, 31, JSTestObjConstructorTableValues, 0 };
 
 #if ENABLE(Condition1)
 COMPILE_ASSERT(0 == TestObj::CONDITIONAL_CONST, TestObjEnumCONDITIONAL_CONSTIsWrongUseDontCheckEnums);
@@ -1889,6 +1892,45 @@
     return JSValue::encode(result);
 }
 
+#if ENABLE(Condition1)
+static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod11(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+    int arg(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toInt32(exec));
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+    TestObj::overloadedMethod1(arg);
+    return JSValue::encode(jsUndefined());
+}
+
+#endif
+
+#if ENABLE(Condition1)
+static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod12(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+    const String& type(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::overloadedMethod1(type);
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(ExecState* exec)
+{
+    size_t argsCount = exec->argumentCount();
+    if (argsCount == 1)
+        return jsTestObjConstructorFunctionOverloadedMethod11(exec);
+    JSValue arg0(exec->argument(0));
+    if ((argsCount == 1 && (arg0.isUndefinedOrNull() || arg0.isString() || arg0.isObject())))
+        return jsTestObjConstructorFunctionOverloadedMethod12(exec);
+    return throwVMTypeError(exec);
+}
+
+#endif
+
 void JSTestObj::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
     JSTestObj* thisObject = jsCast<JSTestObj*>(cell);

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2011-12-08 18:55:05 UTC (rev 102351)
@@ -185,6 +185,7 @@
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(JSC::ExecState*);
 // Attributes
 
 JSC::JSValue jsTestObjReadOnlyIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h	2011-12-08 18:55:05 UTC (rev 102351)
@@ -173,6 +173,8 @@
 - (void)conditionalMethod3;
 - (void)classMethod;
 - (int)classMethodWithOptional:(int)arg;
+- (void)overloadedMethod1:(int)arg;
+- (void)overloadedMethod1:(NSString *)type;
 @end
 
 #endif

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm	2011-12-08 18:55:05 UTC (rev 102351)
@@ -768,6 +768,26 @@
     return IMPL->classMethodWithOptional(arg);
 }
 
+
+#if ENABLE(Condition1)
+- (void)overloadedMethod1:(int)arg
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->overloadedMethod1(arg);
+}
+
+#endif
+
+
+#if ENABLE(Condition1)
+- (void)overloadedMethod1:(NSString *)type
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->overloadedMethod1(type);
+}
+
+#endif
+
 @end
 
 WebCore::TestObj* core(DOMTestObj *wrapper)

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2011-12-08 18:55:05 UTC (rev 102351)
@@ -165,6 +165,11 @@
         static void classMethod();
         static long classMethodWithOptional(in [Optional] long arg);
 
+        // Static method with conditional on overloaded methods
+
+        static [Conditional=Condition1] void overloadedMethod1(in long arg);
+        static [Conditional=Condition1] void overloadedMethod1(in DOMString type);
+
 #if defined(TESTING_V8)
         // 'EnabledAtRuntime' methods and attributes.
         [EnabledAtRuntime] void enabledAtRuntimeMethod1(in int intArg);

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (102350 => 102351)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2011-12-08 18:53:11 UTC (rev 102350)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2011-12-08 18:55:05 UTC (rev 102351)
@@ -1285,6 +1285,37 @@
     return v8::Integer::New(TestObj::classMethodWithOptional(arg));
 }
 
+static v8::Handle<v8::Value> overloadedMethod11Callback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.TestObj.overloadedMethod11");
+    if (args.Length() < 1)
+        return throwError("Not enough arguments", V8Proxy::TypeError);
+    EXCEPTION_BLOCK(int, arg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
+    TestObj::overloadedMethod1(arg);
+    return v8::Handle<v8::Value>();
+}
+
+static v8::Handle<v8::Value> overloadedMethod12Callback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.TestObj.overloadedMethod12");
+    if (args.Length() < 1)
+        return throwError("Not enough arguments", V8Proxy::TypeError);
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
+    TestObj::overloadedMethod1(type);
+    return v8::Handle<v8::Value>();
+}
+
+static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args)
+{
+    INC_STATS("DOM.TestObj.overloadedMethod1");
+    if (args.Length() == 1)
+        return overloadedMethod11Callback(args);
+    if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsUndefined() || args[0]->IsString() || args[0]->IsObject())))
+        return overloadedMethod12Callback(args);
+    V8Proxy::throwTypeError();
+    return notHandledByInterceptor();
+}
+
 static v8::Handle<v8::Value> enabledAtRuntimeMethod1Callback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestObj.enabledAtRuntimeMethod1");
@@ -1560,6 +1591,7 @@
     proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature));
     desc->Set(v8::String::New("classMethod"), v8::FunctionTemplate::New(TestObjInternal::classMethodCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
     desc->Set(v8::String::New("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjInternal::classMethodWithOptionalCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
+    desc->Set(v8::String::New("overloadedMethod1"), v8::FunctionTemplate::New(TestObjInternal::overloadedMethod1Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
     if (RuntimeEnabledFeatures::enabledAtRuntimeMethod1Enabled())
         proto->Set(v8::String::New("enabledAtRuntimeMethod1"), v8::FunctionTemplate::New(TestObjInternal::enabledAtRuntimeMethod1Callback, v8::Handle<v8::Value>(), defaultSignature));
     if (RuntimeEnabledFeatures::featureNameEnabled())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to