Title: [111853] trunk/Source/WebCore
Revision
111853
Author
[email protected]
Date
2012-03-23 06:01:35 -0700 (Fri, 23 Mar 2012)

Log Message

The JSC code generator can't handle boolean arguments for Callbacks
https://bugs.webkit.org/show_bug.cgi?id=82045

Reviewed by Kentaro Hara.

CodeGeneratorJS.pm only handles DOMStrings and objects as arguments
for a Callback, so I added support for boolean values as well.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackImplementation):
* bindings/scripts/test/CPP/WebDOMTestCallback.cpp:
(WebDOMTestCallback::callbackWithBoolean):
* bindings/scripts/test/CPP/WebDOMTestCallback.h:
(WebDOMTestCallback):
* bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp:
(webkit_dom_test_callback_callback_with_boolean):
* bindings/scripts/test/GObject/WebKitDOMTestCallback.h:
* bindings/scripts/test/JS/JSTestCallback.cpp:
(WebCore::JSTestCallback::callbackWithBoolean):
(WebCore):
* bindings/scripts/test/JS/JSTestCallback.h:
(JSTestCallback):
* bindings/scripts/test/ObjC/DOMTestCallback.h:
* bindings/scripts/test/ObjC/DOMTestCallback.mm:
(-[DOMTestCallback callbackWithBoolean:]):
* bindings/scripts/test/TestCallback.idl:
* bindings/scripts/test/V8/V8TestCallback.cpp:
(WebCore::V8TestCallback::callbackWithBoolean):
(WebCore):
* bindings/scripts/test/V8/V8TestCallback.h:
(V8TestCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111852 => 111853)


--- trunk/Source/WebCore/ChangeLog	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/ChangeLog	2012-03-23 13:01:35 UTC (rev 111853)
@@ -1,3 +1,37 @@
+2012-03-23  Tommy Widenflycht  <[email protected]>
+
+        The JSC code generator can't handle boolean arguments for Callbacks
+        https://bugs.webkit.org/show_bug.cgi?id=82045
+
+        Reviewed by Kentaro Hara.
+
+        CodeGeneratorJS.pm only handles DOMStrings and objects as arguments
+        for a Callback, so I added support for boolean values as well.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallbackImplementation):
+        * bindings/scripts/test/CPP/WebDOMTestCallback.cpp:
+        (WebDOMTestCallback::callbackWithBoolean):
+        * bindings/scripts/test/CPP/WebDOMTestCallback.h:
+        (WebDOMTestCallback):
+        * bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp:
+        (webkit_dom_test_callback_callback_with_boolean):
+        * bindings/scripts/test/GObject/WebKitDOMTestCallback.h:
+        * bindings/scripts/test/JS/JSTestCallback.cpp:
+        (WebCore::JSTestCallback::callbackWithBoolean):
+        (WebCore):
+        * bindings/scripts/test/JS/JSTestCallback.h:
+        (JSTestCallback):
+        * bindings/scripts/test/ObjC/DOMTestCallback.h:
+        * bindings/scripts/test/ObjC/DOMTestCallback.mm:
+        (-[DOMTestCallback callbackWithBoolean:]):
+        * bindings/scripts/test/TestCallback.idl:
+        * bindings/scripts/test/V8/V8TestCallback.cpp:
+        (WebCore::V8TestCallback::callbackWithBoolean):
+        (WebCore):
+        * bindings/scripts/test/V8/V8TestCallback.h:
+        (V8TestCallback):
+
 2012-03-23  Allan Sandfeld Jensen  <[email protected]>
 
         Touch adjustment forgets some subtarget quads.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-03-23 13:01:35 UTC (rev 111853)
@@ -2715,6 +2715,8 @@
                 my $paramName = $param->name;
                 if ($param->type eq "DOMString") {
                     push(@implContent, "    args.append(jsString(exec, ${paramName}));\n");
+                } elsif ($param->type eq "boolean") {
+                    push(@implContent, "    args.append(jsBoolean(${paramName}));\n");
                 } else {
                     push(@implContent, "    args.append(toJS(exec, m_data->globalObject(), ${paramName}));\n");
                 }

Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp	2012-03-23 13:01:35 UTC (rev 111853)
@@ -125,6 +125,14 @@
     return impl()->callbackWithStringList(toWebCore(listParam));
 }
 
+bool WebDOMTestCallback::callbackWithBoolean(bool boolParam)
+{
+    if (!impl())
+        return false;
+
+    return impl()->callbackWithBoolean(boolParam);
+}
+
 WebCore::TestCallback* toWebCore(const WebDOMTestCallback& wrapper)
 {
     return wrapper.impl();

Modified: trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h	2012-03-23 13:01:35 UTC (rev 111853)
@@ -50,6 +50,7 @@
     bool callbackWithClass2Param(const WebDOMClass2& class2Param, const WebDOMString& strArg);
     int callbackWithNonBoolReturnType(const WebDOMClass3& class3Param);
     bool callbackWithStringList(const WebDOMDOMStringList& listParam);
+    bool callbackWithBoolean(bool boolParam);
 
     WebCore::TestCallback* impl() const;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp	2012-03-23 13:01:35 UTC (rev 111853)
@@ -135,7 +135,17 @@
     return res;
 }
 
+gboolean
+webkit_dom_test_callback_callback_with_boolean(WebKitDOMTestCallback* self, gboolean bool_param)
+{
+    g_return_val_if_fail(self, 0);
+    WebCore::JSMainThreadNullState state;
+    WebCore::TestCallback * item = WebKit::core(self);
+    gboolean res = item->callbackWithBoolean(bool_param);
+    return res;
+}
 
+
 G_DEFINE_TYPE(WebKitDOMTestCallback, webkit_dom_test_callback, WEBKIT_TYPE_DOM_OBJECT)
 
 namespace WebKit {

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h	2012-03-23 13:01:35 UTC (rev 111853)
@@ -101,6 +101,17 @@
 WEBKIT_API gboolean
 webkit_dom_test_callback_callback_with_string_list(WebKitDOMTestCallback* self, WebKitDOMDOMStringList* list_param);
 
+/**
+ * webkit_dom_test_callback_callback_with_boolean:
+ * @self: A #WebKitDOMTestCallback
+ * @bool_param: A #gboolean
+ *
+ * Returns:
+ *
+**/
+WEBKIT_API gboolean
+webkit_dom_test_callback_callback_with_boolean(WebKitDOMTestCallback* self, gboolean bool_param);
+
 G_END_DECLS
 
 #endif /* WebKitDOMTestCallback_h */

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp	2012-03-23 13:01:35 UTC (rev 111853)
@@ -128,6 +128,24 @@
     return !raisedException;
 }
 
+bool JSTestCallback::callbackWithBoolean(bool boolParam)
+{
+    if (!canInvokeCallback())
+        return true;
+
+    RefPtr<JSTestCallback> protect(this);
+
+    JSLock lock(SilenceAssertionsOnly);
+
+    ExecState* exec = m_data->globalObject()->globalExec();
+    MarkedArgumentBuffer args;
+    args.append(jsBoolean(boolParam));
+
+    bool raisedException = false;
+    m_data->invokeCallback(args, &raisedException);
+    return !raisedException;
 }
 
+}
+
 #endif // ENABLE(SQL_DATABASE)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h	2012-03-23 13:01:35 UTC (rev 111853)
@@ -46,6 +46,7 @@
     COMPILE_ASSERT(false)    virtual int callbackWithNonBoolReturnType(Class3* class3Param);
     virtual int customCallback(Class5* class5Param, Class6* class6Param);
     virtual bool callbackWithStringList(DOMStringList* listParam);
+    virtual bool callbackWithBoolean(bool boolParam);
 
 private:
     JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*);

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h	2012-03-23 13:01:35 UTC (rev 111853)
@@ -43,6 +43,7 @@
 - (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param;
 - (int)customCallback:(DOMClass5 *)class5Param class6Param:(DOMClass6 *)class6Param;
 - (BOOL)callbackWithStringList:(DOMDOMStringList *)listParam;
+- (BOOL)callbackWithBoolean:(BOOL)boolParam;
 @end
 
 #endif

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm	2012-03-23 13:01:35 UTC (rev 111853)
@@ -117,6 +117,12 @@
     return IMPL->callbackWithStringList(core(listParam));
 }
 
+- (BOOL)callbackWithBoolean:(BOOL)boolParam
+{
+    WebCore::JSMainThreadNullState state;
+    return IMPL->callbackWithBoolean(boolParam);
+}
+
 @end
 
 WebCore::TestCallback* core(DOMTestCallback *wrapper)

Modified: trunk/Source/WebCore/bindings/scripts/test/TestCallback.idl (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/TestCallback.idl	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/TestCallback.idl	2012-03-23 13:01:35 UTC (rev 111853)
@@ -39,5 +39,6 @@
       long callbackWithNonBoolReturnType(in Class3 class3Param);
       [Custom] long customCallback(in Class5 class5Param, in Class6 class6Param);
       boolean callbackWithStringList(in DOMStringList listParam);
+      boolean callbackWithBoolean(in boolean boolParam);
     };
 }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp	2012-03-23 13:01:35 UTC (rev 111853)
@@ -163,6 +163,34 @@
     return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
 }
 
+bool V8TestCallback::callbackWithBoolean(bool boolParam)
+{
+    if (!canInvokeCallback())
+        return true;
+
+    v8::HandleScope handleScope;
+
+    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
+    if (v8Context.IsEmpty())
+        return true;
+
+    v8::Context::Scope scope(v8Context);
+
+    v8::Handle<v8::Value> boolParamHandle = v8Boolean(boolParam);
+    if (boolParamHandle.IsEmpty()) {
+        if (!isScriptControllerTerminating())
+            CRASH();
+        return true;
+    }
+
+    v8::Handle<v8::Value> argv[] = {
+        boolParamHandle
+    };
+
+    bool callbackReturnValue = false;
+    return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SQL_DATABASE)

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h (111852 => 111853)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h	2012-03-23 12:41:07 UTC (rev 111852)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h	2012-03-23 13:01:35 UTC (rev 111853)
@@ -51,6 +51,7 @@
     COMPILE_ASSERT(false)    virtual int callbackWithNonBoolReturnType(Class3* class3Param);
     virtual int customCallback(Class5* class5Param, Class6* class6Param);
     virtual bool callbackWithStringList(RefPtr<DOMStringList> listParam);
+    virtual bool callbackWithBoolean(bool boolParam);
 
 private:
     V8TestCallback(v8::Local<v8::Object>, ScriptExecutionContext*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to