Changeset 76277 in webkit


Ignore:
Timestamp:
Jan 20, 2011 1:39:52 PM (13 years ago)
Author:
jamesr@google.com
Message:

2011-01-20 James Robinson <jamesr@chromium.org>

Reviewed by Nate Chapin.

[v8] CodeGeneratorV8 generates incorrect code for callbacks with no parameters
https://bugs.webkit.org/show_bug.cgi?id=52837

When generating code to invoke a callback with no parameters CodeGeneratorV8.pm was generating the following:
v8::Handle<v8::Value> argv[] = {}; which does not compile in visual studio. Instead, if the argument count
is 0, we can just pass a NULL pointer for the argv parameter.

Test added to bindings/scripts/test/TestCallback.idl and covered by run-bindings-tests. This
patch also includes some spurious changes to the bindings tests golden files (mostly GObject)
because the old golden files were out of date.

  • bindings/scripts/CodeGeneratorV8.pm:
  • bindings/scripts/test/CPP/WebDOMTestCallback.cpp: (WebDOMTestCallback::callbackWithNoParam):
  • bindings/scripts/test/CPP/WebDOMTestCallback.h:
  • bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp: (webkit_dom_test_callback_callback_with_no_param):
  • bindings/scripts/test/GObject/WebKitDOMTestCallback.h:
  • bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp:
  • bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp:
  • bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
  • bindings/scripts/test/JS/JSTestCallback.cpp: (WebCore::JSTestCallback::callbackWithNoParam):
  • bindings/scripts/test/JS/JSTestCallback.h:
  • bindings/scripts/test/JS/JSTestInterface.cpp:
  • bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
  • bindings/scripts/test/JS/JSTestObj.cpp:
  • bindings/scripts/test/ObjC/DOMTestCallback.h:
  • bindings/scripts/test/ObjC/DOMTestCallback.mm: (-[DOMTestCallback callbackWithNoParam]):
  • bindings/scripts/test/TestCallback.idl:
  • bindings/scripts/test/V8/V8TestCallback.cpp: (WebCore::V8TestCallback::callbackWithNoParam):
  • bindings/scripts/test/V8/V8TestCallback.h:
  • bindings/scripts/test/V8/V8TestObj.cpp: (WebCore::TestObjInternal::reflectedUnsignedIntegralAttrAttrGetter):
Location:
trunk/Source/WebCore
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76276 r76277  
     12011-01-20  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        [v8] CodeGeneratorV8 generates incorrect code for callbacks with no parameters
     6        https://bugs.webkit.org/show_bug.cgi?id=52837
     7
     8        When generating code to invoke a callback with no parameters CodeGeneratorV8.pm was generating the following:
     9        v8::Handle<v8::Value> argv[] = {}; which does not compile in visual studio.  Instead, if the argument count
     10        is 0, we can just pass a NULL pointer for the argv parameter.
     11
     12        Test added to bindings/scripts/test/TestCallback.idl and covered by run-bindings-tests.  This
     13        patch also includes some spurious changes to the bindings tests golden files (mostly GObject)
     14        because the old golden files were out of date.
     15
     16        * bindings/scripts/CodeGeneratorV8.pm:
     17        * bindings/scripts/test/CPP/WebDOMTestCallback.cpp:
     18        (WebDOMTestCallback::callbackWithNoParam):
     19        * bindings/scripts/test/CPP/WebDOMTestCallback.h:
     20        * bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp:
     21        (webkit_dom_test_callback_callback_with_no_param):
     22        * bindings/scripts/test/GObject/WebKitDOMTestCallback.h:
     23        * bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp:
     24        * bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp:
     25        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
     26        * bindings/scripts/test/JS/JSTestCallback.cpp:
     27        (WebCore::JSTestCallback::callbackWithNoParam):
     28        * bindings/scripts/test/JS/JSTestCallback.h:
     29        * bindings/scripts/test/JS/JSTestInterface.cpp:
     30        * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
     31        * bindings/scripts/test/JS/JSTestObj.cpp:
     32        * bindings/scripts/test/ObjC/DOMTestCallback.h:
     33        * bindings/scripts/test/ObjC/DOMTestCallback.mm:
     34        (-[DOMTestCallback callbackWithNoParam]):
     35        * bindings/scripts/test/TestCallback.idl:
     36        * bindings/scripts/test/V8/V8TestCallback.cpp:
     37        (WebCore::V8TestCallback::callbackWithNoParam):
     38        * bindings/scripts/test/V8/V8TestCallback.h:
     39        * bindings/scripts/test/V8/V8TestObj.cpp:
     40        (WebCore::TestObjInternal::reflectedUnsignedIntegralAttrAttrGetter):
     41
    1422011-01-20  James Robinson  <jamesr@chromium.org>
    243
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r76216 r76277  
    24022402            }
    24032403
    2404             push(@implContent, "\n    v8::Handle<v8::Value> argv[] = {\n");
    2405             push(@implContent, join(",\n", @args));
    2406             push(@implContent, "\n    };\n\n");
     2404            if (scalar(@args) > 0) {
     2405                push(@implContent, "\n    v8::Handle<v8::Value> argv[] = {\n");
     2406                push(@implContent, join(",\n", @args));
     2407                push(@implContent, "\n    };\n\n");
     2408            } else {
     2409                push(@implContent, "\n    v8::Handle<v8::Value> *argv = 0;\n\n");
     2410            }
    24072411            push(@implContent, "    bool callbackReturnValue = false;\n");
    24082412            push(@implContent, "    return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
  • trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp

    r65180 r76277  
    8484}
    8585
     86bool WebDOMTestCallback::callbackWithNoParam()
     87{
     88    if (!impl())
     89        return false;
     90
     91    return impl()->callbackWithNoParam();
     92}
     93
    8694bool WebDOMTestCallback::callbackWithClass1Param(const WebDOMClass1& class1Param)
    8795{
  • trunk/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h

    r66327 r76277  
    4747    virtual ~WebDOMTestCallback();
    4848
     49    bool callbackWithNoParam();
    4950    bool callbackWithClass1Param(const WebDOMClass1& class1Param);
    5051    bool callbackWithClass2Param(const WebDOMClass2& class2Param, const WebDOMString& strArg);
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp

    r73238 r76277  
    4040#include "webkit/WebKitDOMTestCallback.h"
    4141#include "webkit/WebKitDOMTestCallbackPrivate.h"
     42#include "webkitdefines.h"
     43#include "webkitglobalsprivate.h"
    4244#include "webkitmarshal.h"
    43 #include "webkitprivate.h"
    4445
    4546namespace WebKit {
     
    5657   
    5758} // namespace WebKit //
     59
     60gboolean
     61webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self)
     62{
     63    g_return_val_if_fail(self, 0);
     64    WebCore::JSMainThreadNullState state;
     65    WebCore::TestCallback * item = WebKit::core(self);
     66    gboolean res = item->callbackWithNoParam();
     67    return res;
     68}
    5869
    5970gboolean
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h

    r65333 r76277  
    4848
    4949WEBKIT_API gboolean
     50webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self);
     51
     52WEBKIT_API gboolean
    5053webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param);
    5154
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp

    r73238 r76277  
    3434#include "webkit/WebKitDOMTestInterface.h"
    3535#include "webkit/WebKitDOMTestInterfacePrivate.h"
     36#include "webkitdefines.h"
     37#include "webkitglobalsprivate.h"
    3638#include "webkitmarshal.h"
    37 #include "webkitprivate.h"
    3839
    3940namespace WebKit {
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp

    r73238 r76277  
    3232#include "webkit/WebKitDOMTestMediaQueryListListener.h"
    3333#include "webkit/WebKitDOMTestMediaQueryListListenerPrivate.h"
     34#include "webkitdefines.h"
     35#include "webkitglobalsprivate.h"
    3436#include "webkitmarshal.h"
    35 #include "webkitprivate.h"
    3637
    3738namespace WebKit {
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp

    r73564 r76277  
    3939#include "webkit/WebKitDOMTestObj.h"
    4040#include "webkit/WebKitDOMTestObjPrivate.h"
     41#include "webkitdefines.h"
     42#include "webkitglobalsprivate.h"
    4143#include "webkitmarshal.h"
    42 #include "webkitprivate.h"
    4344
    4445namespace WebKit {
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp

    r65005 r76277  
    5757// Functions
    5858
     59bool JSTestCallback::callbackWithNoParam()
     60{
     61    if (!canInvokeCallback())
     62        return true;
     63
     64    RefPtr<JSTestCallback> protect(this);
     65
     66    JSLock lock(SilenceAssertionsOnly);
     67
     68    ExecState* exec = m_data->globalObject()->globalExec();
     69    MarkedArgumentBuffer args;
     70
     71    bool raisedException = false;
     72    m_data->invokeCallback(args, &raisedException);
     73    return !raisedException;
     74}
     75
    5976bool JSTestCallback::callbackWithClass1Param(Class1* class1Param)
    6077{
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h

    r64537 r76277  
    4141
    4242    // Functions
     43    virtual bool callbackWithNoParam();
    4344    virtual bool callbackWithClass1Param(Class1* class1Param);
    4445    virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg);
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r61131 r76277  
    167167    return JSTestInterface::getConstructor(exec, domObject->globalObject());
    168168}
     169
    169170JSValue JSTestInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
    170171{
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp

    r72552 r76277  
    163163    return JSTestMediaQueryListListener::getConstructor(exec, domObject->globalObject());
    164164}
     165
    165166JSValue JSTestMediaQueryListListener::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
    166167{
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r73564 r76277  
    608608    return JSTestObj::getConstructor(exec, domObject->globalObject());
    609609}
     610
    610611void JSTestObj::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
    611612{
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h

    r58808 r76277  
    3737
    3838@interface DOMTestCallback : DOMObject
     39- (BOOL)callbackWithNoParam;
    3940- (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param;
    4041- (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg;
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm

    r59866 r76277  
    8080}
    8181
     82- (BOOL)callbackWithNoParam
     83{
     84    WebCore::JSMainThreadNullState state;
     85    return IMPL->callbackWithNoParam();
     86}
     87
    8288- (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param
    8389{
  • trunk/Source/WebCore/bindings/scripts/test/TestCallback.idl

    r58710 r76277  
    3434        Callback
    3535    ] TestCallback {
     36      boolean callbackWithNoParam();
    3637      boolean callbackWithClass1Param(in Class1 class1Param);
    3738      boolean callbackWithClass2Param(in Class2 class2Param, in DOMString strArg);
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp

    r64537 r76277  
    4848
    4949// Functions
     50
     51bool V8TestCallback::callbackWithNoParam()
     52{
     53    if (!canInvokeCallback())
     54        return true;
     55
     56    v8::HandleScope handleScope;
     57
     58    v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext);
     59    if (v8Context.IsEmpty())
     60        return true;
     61
     62    v8::Context::Scope scope(v8Context);
     63
     64
     65    v8::Handle<v8::Value> *argv = 0;
     66
     67    bool callbackReturnValue = false;
     68    return !invokeCallback(m_callback, 0, argv, callbackReturnValue, scriptExecutionContext());
     69}
    5070
    5171bool V8TestCallback::callbackWithClass1Param(Class1* class1Param)
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h

    r64537 r76277  
    4646
    4747    // Functions
     48    virtual bool callbackWithNoParam();
    4849    virtual bool callbackWithClass1Param(Class1* class1Param);
    4950    virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg);
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r73564 r76277  
    261261    INC_STATS("DOM.TestObj.reflectedUnsignedIntegralAttr._get");
    262262    TestObj* imp = V8TestObj::toNative(info.Holder());
    263     return v8::Integer::NewFromUnsigned(imp->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr));
     263    return v8::Integer::NewFromUnsigned(std::max(0, imp->getIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)));
    264264}
    265265
Note: See TracChangeset for help on using the changeset viewer.