diff options
Diffstat (limited to 'WebCore/bindings/scripts/test')
-rw-r--r-- | WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp | 26 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp | 2 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp | 46 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/JS/JSTestCallback.cpp | 36 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/JS/JSTestCallback.h | 13 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/JS/JSTestObj.cpp | 105 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm | 2 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/V8/V8TestCallback.cpp | 23 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/V8/V8TestCallback.h | 20 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/V8/V8TestObj.cpp | 98 |
10 files changed, 216 insertions, 155 deletions
diff --git a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp index b8c551e..20de4fc 100644 --- a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp @@ -85,7 +85,7 @@ WebDOMString WebDOMTestObj::readOnlyStringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->readOnlyStringAttr()); + return static_cast<const WTF::String&>(impl()->readOnlyStringAttr()); } WebDOMTestObj WebDOMTestObj::readOnlyTestObjAttr() const @@ -149,7 +149,7 @@ WebDOMString WebDOMTestObj::stringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->stringAttr()); + return static_cast<const WTF::String&>(impl()->stringAttr()); } void WebDOMTestObj::setStringAttr(const WebDOMString& newStringAttr) @@ -213,7 +213,7 @@ WebDOMString WebDOMTestObj::reflectedStringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); + return static_cast<const WTF::String&>(impl()->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); } void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr) @@ -261,7 +261,7 @@ WebDOMString WebDOMTestObj::reflectedURLAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); + return static_cast<const WTF::String&>(impl()->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); } void WebDOMTestObj::setReflectedURLAttr(const WebDOMString& newReflectedURLAttr) @@ -277,7 +277,7 @@ WebDOMString WebDOMTestObj::reflectedNonEmptyURLAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr)); + return static_cast<const WTF::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr)); } void WebDOMTestObj::setReflectedNonEmptyURLAttr(const WebDOMString& newReflectedNonEmptyURLAttr) @@ -293,7 +293,7 @@ WebDOMString WebDOMTestObj::reflectedStringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); + return static_cast<const WTF::String&>(impl()->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); } void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr) @@ -341,7 +341,7 @@ WebDOMString WebDOMTestObj::reflectedCustomURLAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); + return static_cast<const WTF::String&>(impl()->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); } void WebDOMTestObj::setReflectedCustomURLAttr(const WebDOMString& newReflectedCustomURLAttr) @@ -357,7 +357,7 @@ WebDOMString WebDOMTestObj::reflectedCustomNonEmptyURLAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr)); + return static_cast<const WTF::String&>(impl()->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr)); } void WebDOMTestObj::setReflectedCustomNonEmptyURLAttr(const WebDOMString& newReflectedCustomNonEmptyURLAttr) @@ -415,7 +415,7 @@ WebDOMString WebDOMTestObj::stringAttrWithGetterException() const WebCore::ExceptionCode ec = 0; WebDOMString result = impl()->stringAttrWithGetterException(ec); webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); - return static_cast<const WebCore::String&>(result); + return static_cast<const WTF::String&>(result); } void WebDOMTestObj::setStringAttrWithGetterException(const WebDOMString& newStringAttrWithGetterException) @@ -433,7 +433,7 @@ WebDOMString WebDOMTestObj::stringAttrWithSetterException() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->stringAttrWithSetterException()); + return static_cast<const WTF::String&>(impl()->stringAttrWithSetterException()); } void WebDOMTestObj::setStringAttrWithSetterException(const WebDOMString& newStringAttrWithSetterException) @@ -451,7 +451,7 @@ WebDOMString WebDOMTestObj::scriptStringAttr() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->scriptStringAttr()); + return static_cast<const WTF::String&>(impl()->scriptStringAttr()); } #if ENABLE(Condition1) @@ -537,7 +537,7 @@ WebDOMString WebDOMTestObj::hash() const if (!impl()) return WebDOMString(); - return static_cast<const WebCore::String&>(impl()->hash()); + return static_cast<const WTF::String&>(impl()->hash()); } void WebDOMTestObj::voidMethod() @@ -612,7 +612,7 @@ void WebDOMTestObj::serializedValue(const WebDOMString& serializedArg) if (!impl()) return; - impl()->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); + impl()->serializedValue(WebCore::SerializedScriptValue::create(WTF::String(serializedArg))); } void WebDOMTestObj::idbKey(const WebDOMIDBKey& key) diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp index 6581b1f..8f69a9f 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -78,7 +78,7 @@ webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, g_return_val_if_fail(str_arg, 0); WebCore::Class2 * converted_class2param = WebKit::core(class2param); g_return_val_if_fail(converted_class2param, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); gboolean res = item->callbackWithClass2Param(converted_class2param, converted_str_arg); return res; } diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp index 6a8399e..8cad49d 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -69,7 +69,7 @@ webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong int_arg, WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(str_arg); g_return_if_fail(obj_arg); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_if_fail(converted_obj_arg); item->voidMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); @@ -93,7 +93,7 @@ webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong int_arg, WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); g_return_val_if_fail(obj_arg, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_val_if_fail(converted_obj_arg, 0); glong res = item->intMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); @@ -119,7 +119,7 @@ webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong int_arg, WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); g_return_val_if_fail(obj_arg, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_val_if_fail(converted_obj_arg, 0); PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg)); @@ -135,7 +135,7 @@ webkit_dom_test_obj_method_that_requires_all_args(WebKitDOMTestObj* self, gchar* WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); g_return_val_if_fail(obj_arg, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_val_if_fail(converted_obj_arg, 0); PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgs(converted_str_arg, converted_obj_arg)); @@ -151,7 +151,7 @@ webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* s WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); g_return_val_if_fail(obj_arg, 0); - WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); g_return_val_if_fail(converted_obj_arg, 0); WebCore::ExceptionCode ec = 0; @@ -448,7 +448,7 @@ webkit_dom_test_obj_set_string_attr(WebKitDOMTestObj* self, gchar* value) g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setStringAttr(converted_value); } @@ -534,7 +534,7 @@ webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* va g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, converted_value); } @@ -593,7 +593,7 @@ webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, converted_value); } @@ -614,7 +614,7 @@ webkit_dom_test_obj_set_reflected_non_empty_url_attr(WebKitDOMTestObj* self, gch g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, converted_value); } @@ -635,7 +635,7 @@ webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* va g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, converted_value); } @@ -694,7 +694,7 @@ webkit_dom_test_obj_set_reflected_custom_url_attr(WebKitDOMTestObj* self, gchar* g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, converted_value); } @@ -715,7 +715,7 @@ webkit_dom_test_obj_set_reflected_custom_non_empty_url_attr(WebKitDOMTestObj* se g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); item->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, converted_value); } @@ -793,7 +793,7 @@ webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); WebCore::ExceptionCode ec = 0; item->setStringAttrWithGetterException(converted_value, ec); if (ec) { @@ -820,7 +820,7 @@ webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); - WebCore::String converted_value = WebCore::String::fromUTF8(value); + WTF::String converted_value = WTF::String::fromUTF8(value); WebCore::ExceptionCode ec = 0; item->setStringAttrWithSetterException(converted_value, ec); if (ec) { @@ -1041,7 +1041,7 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_STRING_ATTR: { - coreSelf->setStringAttr(WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setStringAttr(WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_CREATE: @@ -1051,7 +1051,7 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_REFLECTED_STRING_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_INTEGRAL_ATTR: @@ -1066,17 +1066,17 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_REFLECTED_URL_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_NON_EMPTY_URL_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_STRING_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR: @@ -1091,12 +1091,12 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_REFLECTED_CUSTOM_URL_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_REFLECTED_CUSTOM_NON_EMPTY_URL_ATTR: { - coreSelf->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + coreSelf->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, WTF::String::fromUTF8(g_value_get_string(value))); break; } case PROP_ATTR_WITH_GETTER_EXCEPTION: @@ -1114,13 +1114,13 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con case PROP_STRING_ATTR_WITH_GETTER_EXCEPTION: { WebCore::ExceptionCode ec = 0; - coreSelf->setStringAttrWithGetterException(WebCore::String::fromUTF8(g_value_get_string(value)), ec); + coreSelf->setStringAttrWithGetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); break; } case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: { WebCore::ExceptionCode ec = 0; - coreSelf->setStringAttrWithSetterException(WebCore::String::fromUTF8(g_value_get_string(value)), ec); + coreSelf->setStringAttrWithSetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); break; } #if ENABLE(Condition1) diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp index 6f6b568..069b8ae 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -35,18 +35,20 @@ using namespace JSC; namespace WebCore { JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject) - : m_data(new JSCallbackData(callback, globalObject)) - , m_isolatedWorld(globalObject->world()) - , m_scriptExecutionContext(globalObject->scriptExecutionContext()) + : ActiveDOMCallback(globalObject->scriptExecutionContext()) + , m_data(new JSCallbackData(callback, globalObject)) { } JSTestCallback::~JSTestCallback() { - if (m_scriptExecutionContext->isContextThread()) + ScriptExecutionContext* context = scriptExecutionContext(); + // When the context is destroyed, all tasks with a reference to a callback + // should be deleted. So if the context is 0, we are on the context thread. + if (!context || context->isContextThread()) delete m_data; else - m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data)); + context->postTask(DeleteCallbackDataTask::create(m_data)); #ifndef NDEBUG m_data = 0; #endif @@ -54,20 +56,16 @@ JSTestCallback::~JSTestCallback() // Functions -bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param) +bool JSTestCallback::callbackWithClass1Param(Class1* class1Param) { - ASSERT(m_data); - ASSERT(context); + if (!canInvokeCallback()) + return true; RefPtr<JSTestCallback> protect(this); JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); - if (!globalObject) - return true; - - ExecState* exec = globalObject->globalExec(); + ExecState* exec = m_data->globalObject()->globalExec(); MarkedArgumentBuffer args; args.append(toJS(exec, class1Param)); @@ -76,20 +74,16 @@ bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Cl return !raisedException; } -bool JSTestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg) +bool JSTestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg) { - ASSERT(m_data); - ASSERT(context); + if (!canInvokeCallback()) + return true; RefPtr<JSTestCallback> protect(this); JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); - if (!globalObject) - return true; - - ExecState* exec = globalObject->globalExec(); + ExecState* exec = m_data->globalObject()->globalExec(); MarkedArgumentBuffer args; args.append(toJS(exec, class2Param)); args.append(jsString(exec, strArg)); diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/WebCore/bindings/scripts/test/JS/JSTestCallback.h index 47a5e95..ae91a6c 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestCallback.h +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -23,13 +23,14 @@ #if ENABLE(DATABASE) +#include "ActiveDOMCallback.h" #include "JSCallbackData.h" #include "TestCallback.h" #include <wtf/Forward.h> namespace WebCore { -class JSTestCallback : public TestCallback { +class JSTestCallback : public TestCallback, public ActiveDOMCallback { public: static PassRefPtr<JSTestCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) { @@ -39,17 +40,15 @@ public: virtual ~JSTestCallback(); // Functions - virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param); - virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg); - COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param); - virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param); + virtual bool callbackWithClass1Param(Class1* class1Param); + virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); + virtual int customCallback(Class5* class5Param, Class6* class6Param); private: JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*); JSCallbackData* m_data; - RefPtr<DOMWrapperWorld> m_isolatedWorld; - ScriptExecutionContext* m_scriptExecutionContext; }; } // namespace WebCore diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index 9c11bde..01a860c 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -25,6 +25,7 @@ #include "HTMLNames.h" #include "IDBBindingUtilities.h" #include "IDBKey.h" +#include "JSDOMBinding.h" #include "JSEventListener.h" #include "JSTestCallback.h" #include "JSTestObj.h" @@ -794,8 +795,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecSt JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->voidMethodWithArgs(intArg, strArg, objArg); return JSValue::encode(jsUndefined()); @@ -822,8 +829,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecSta JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); JSC::JSValue result = jsNumber(exec, imp->intMethodWithArgs(intArg, strArg, objArg)); @@ -851,8 +864,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecSta JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(2)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethodWithArgs(intArg, strArg, objArg))); @@ -869,7 +888,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs if (exec->argumentCount() < 2) return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(1)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgs(strArg, objArg))); @@ -887,7 +910,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); ExceptionCode ec = 0; const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); TestObj* objArg = toTestObj(exec->argument(1)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec))); @@ -903,6 +930,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->serializedValue(serializedArg); return JSValue::encode(jsUndefined()); @@ -916,6 +945,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(ExecState* exec) JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); RefPtr<IDBKey> key = createIDBKeyFromValue(exec, exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->idbKey(key); return JSValue::encode(jsUndefined()); @@ -963,6 +994,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(Ex ExceptionCode ec = 0; ScriptCallStack callStack(exec, 1); log* intArg = tolog(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->customArgsAndException(intArg, &callStack, ec); setDOMException(exec, ec); @@ -1023,6 +1056,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(Ex if (!dynamicFrame) return JSValue::encode(jsUndefined()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->withDynamicFrameAndArg(dynamicFrame, intArg); return JSValue::encode(jsUndefined()); @@ -1039,14 +1074,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOption if (!dynamicFrame) return JSValue::encode(jsUndefined()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg); return JSValue::encode(jsUndefined()); } int optionalArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg); return JSValue::encode(jsUndefined()); @@ -1063,6 +1102,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe if (!dynamicFrame) return JSValue::encode(jsUndefined()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec)); return JSValue::encode(jsUndefined()); @@ -1079,14 +1120,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe if (!dynamicFrame) return JSValue::encode(jsUndefined()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg); return JSValue::encode(jsUndefined()); } int optionalArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec)); return JSValue::encode(jsUndefined()); @@ -1174,12 +1219,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(Exe TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int argsCount = exec->argumentCount(); - if (argsCount < 1) { + if (argsCount <= 0) { imp->methodWithOptionalArg(); return JSValue::encode(jsUndefined()); } int opt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->methodWithOptionalArg(opt); return JSValue::encode(jsUndefined()); @@ -1193,14 +1240,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int nonOpt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); return JSValue::encode(jsUndefined()); } int opt = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); return JSValue::encode(jsUndefined()); @@ -1214,15 +1265,21 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int nonOpt = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); return JSValue::encode(jsUndefined()); } int opt1 = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int opt2 = exec->argument(2).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); return JSValue::encode(jsUndefined()); @@ -1237,7 +1294,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(Exe TestObj* imp = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) { setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); + return JSValue::encode(jsUndefined()); } RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); @@ -1253,9 +1310,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgA JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int nonCallback = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); if (exec->argumentCount() <= 1 || !exec->argument(1).isObject()) { setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); + return JSValue::encode(jsUndefined()); } RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(1)), castedThis->globalObject()); @@ -1270,18 +1329,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOpti return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - - int argsCount = exec->argumentCount(); - if (argsCount < 1) { - imp->methodWithCallbackAndOptionalArg(); - return JSValue::encode(jsUndefined()); - } - - if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); + RefPtr<TestCallback> callback; + if (exec->argumentCount() > 0 && !exec->argument(0).isNull() && !exec->argument(0).isUndefined()) { + if (!exec->argument(0).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return JSValue::encode(jsUndefined()); + } + callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); } - RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); imp->methodWithCallbackAndOptionalArg(callback); return JSValue::encode(jsUndefined()); @@ -1295,7 +1350,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1( JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); TestObj* objArg = toTestObj(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); const String& strArg = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->overloadedMethod(objArg, strArg); return JSValue::encode(jsUndefined()); @@ -1309,14 +1368,18 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2( JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); TestObj* objArg = toTestObj(exec->argument(0)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); int argsCount = exec->argumentCount(); - if (argsCount < 2) { + if (argsCount <= 1) { imp->overloadedMethod(objArg); return JSValue::encode(jsUndefined()); } int intArg = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->overloadedMethod(objArg, intArg); return JSValue::encode(jsUndefined()); @@ -1330,6 +1393,8 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3( JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); const String& strArg = ustringToString(exec->argument(0).toString(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->overloadedMethod(strArg); return JSValue::encode(jsUndefined()); @@ -1343,6 +1408,8 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4( JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); int intArg = exec->argument(0).toInt32(exec); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); imp->overloadedMethod(intArg); return JSValue::encode(jsUndefined()); diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm index 71d3508..01fcf34 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -500,7 +500,7 @@ - (void)serializedValue:(NSString *)serializedArg { WebCore::JSMainThreadNullState state; - IMPL->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); + IMPL->serializedValue(WebCore::SerializedScriptValue::create(WTF::String(serializedArg))); } - (void)idbKey:(DOMIDBKey *)key diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp index eff4ebd..c286c24 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -34,8 +34,9 @@ namespace WebCore { -V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback) - : m_callback(v8::Persistent<v8::Object>::New(callback)) +V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback, ScriptExecutionContext* context) + : ActiveDOMCallback(context) + , m_callback(v8::Persistent<v8::Object>::New(callback)) , m_worldContext(UseCurrentWorld) { } @@ -47,11 +48,14 @@ V8TestCallback::~V8TestCallback() // Functions -bool V8TestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param) +bool V8TestCallback::callbackWithClass1Param(Class1* class1Param) { + if (!canInvokeCallback()) + return true; + v8::HandleScope handleScope; - v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); if (v8Context.IsEmpty()) return true; @@ -68,14 +72,17 @@ bool V8TestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Cl }; bool callbackReturnValue = false; - return !invokeCallback(m_callback, 1, argv, callbackReturnValue, context); + return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext()); } -bool V8TestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg) +bool V8TestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg) { + if (!canInvokeCallback()) + return true; + v8::HandleScope handleScope; - v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); if (v8Context.IsEmpty()) return true; @@ -98,7 +105,7 @@ bool V8TestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Cl }; bool callbackReturnValue = false; - return !invokeCallback(m_callback, 2, argv, callbackReturnValue, context); + return !invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()); } } // namespace WebCore diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.h b/WebCore/bindings/scripts/test/V8/V8TestCallback.h index aed6b22..a105d75 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestCallback.h +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.h @@ -23,6 +23,7 @@ #ifndef V8TestCallback_h #define V8TestCallback_h +#include "ActiveDOMCallback.h" #include "TestCallback.h" #include "WorldContextHandle.h" #include <v8.h> @@ -30,24 +31,27 @@ namespace WebCore { -class V8TestCallback : public TestCallback { +class ScriptExecutionContext; + +class V8TestCallback : public TestCallback, public ActiveDOMCallback { public: - static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value) + static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value, ScriptExecutionContext* context) { ASSERT(value->IsObject()); - return adoptRef(new V8TestCallback(value->ToObject())); + ASSERT(context); + return adoptRef(new V8TestCallback(value->ToObject(), context)); } virtual ~V8TestCallback(); // Functions - virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param); - virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg); - COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param); - virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param); + virtual bool callbackWithClass1Param(Class1* class1Param); + virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); + virtual int customCallback(Class5* class5Param, Class6* class6Param); private: - V8TestCallback(v8::Local<v8::Object>); + V8TestCallback(v8::Local<v8::Object>, ScriptExecutionContext*); v8::Persistent<v8::Object> m_callback; WorldContextHandle m_worldContext; diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 5584eaf..7428c93 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -29,6 +29,7 @@ #include "ScriptCallStack.h" #include "SerializedScriptValue.h" #include "V8Binding.h" +#include "V8BindingMacros.h" #include "V8BindingState.h" #include "V8DOMWrapper.h" #include "V8IsolatedContext.h" @@ -556,9 +557,9 @@ static v8::Handle<v8::Value> voidMethodWithArgsCallback(const v8::Arguments& arg { INC_STATS("DOM.TestObj.voidMethodWithArgs"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); - V8Parameter<> strArg = args[1]; - TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); imp->voidMethodWithArgs(intArg, strArg, objArg); return v8::Handle<v8::Value>(); } @@ -574,9 +575,9 @@ static v8::Handle<v8::Value> intMethodWithArgsCallback(const v8::Arguments& args { INC_STATS("DOM.TestObj.intMethodWithArgs"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); - V8Parameter<> strArg = args[1]; - TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); return v8::Integer::New(imp->intMethodWithArgs(intArg, strArg, objArg)); } @@ -591,9 +592,9 @@ static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args { INC_STATS("DOM.TestObj.objMethodWithArgs"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); - V8Parameter<> strArg = args[1]; - TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0); return toV8(imp->objMethodWithArgs(intArg, strArg, objArg)); } @@ -603,8 +604,8 @@ static v8::Handle<v8::Value> methodThatRequiresAllArgsCallback(const v8::Argumen if (args.Length() < 2) return v8::Handle<v8::Value>(); TestObj* imp = V8TestObj::toNative(args.Holder()); - V8Parameter<> strArg = args[0]; - TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0; + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0); return toV8(imp->methodThatRequiresAllArgs(strArg, objArg)); } @@ -616,8 +617,8 @@ static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8 TestObj* imp = V8TestObj::toNative(args.Holder()); ExceptionCode ec = 0; { - V8Parameter<> strArg = args[0]; - TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0; + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0); RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec); if (UNLIKELY(ec)) goto fail; @@ -644,7 +645,7 @@ static v8::Handle<v8::Value> idbKeyCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.idbKey"); TestObj* imp = V8TestObj::toNative(args.Holder()); - RefPtr<IDBKey> key = createIDBKeyFromValue(args[0]); + EXCEPTION_BLOCK(RefPtr<IDBKey>, key, createIDBKeyFromValue(args[0])); imp->idbKey(key); return v8::Handle<v8::Value>(); } @@ -674,7 +675,7 @@ static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments& OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1)); if (!callStack) return v8::Undefined(); - log* intArg = V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; + EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); imp->customArgsAndException(intArg, callStack.get(), ec); if (UNLIKELY(ec)) goto fail; @@ -722,7 +723,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndArgCallback(const v8::Arguments& { INC_STATS("DOM.TestObj.withDynamicFrameAndArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) return v8::Undefined(); @@ -734,7 +735,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Ar { INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); if (args.Length() <= 1) { Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) @@ -742,7 +743,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Ar imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg); return v8::Handle<v8::Value>(); } - int optionalArg = toInt32(args[1]); + EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1])); Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) return v8::Undefined(); @@ -754,7 +755,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndUserGestureCallback(const v8::Ar { INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) return v8::Undefined(); @@ -766,7 +767,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8 { INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); if (args.Length() <= 1) { Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) @@ -774,7 +775,7 @@ static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8 imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, processingUserGesture()); return v8::Handle<v8::Value>(); } - int optionalArg = toInt32(args[1]); + EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1])); Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); if (!enteredFrame) return v8::Undefined(); @@ -861,7 +862,7 @@ static v8::Handle<v8::Value> methodWithOptionalArgCallback(const v8::Arguments& imp->methodWithOptionalArg(); return v8::Handle<v8::Value>(); } - int opt = toInt32(args[0]); + EXCEPTION_BLOCK(int, opt, toInt32(args[0])); imp->methodWithOptionalArg(opt); return v8::Handle<v8::Value>(); } @@ -870,12 +871,12 @@ static v8::Handle<v8::Value> methodWithNonOptionalArgAndOptionalArgCallback(cons { INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int nonOpt = toInt32(args[0]); + EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0])); if (args.Length() <= 1) { imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); return v8::Handle<v8::Value>(); } - int opt = toInt32(args[1]); + EXCEPTION_BLOCK(int, opt, toInt32(args[1])); imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); return v8::Handle<v8::Value>(); } @@ -884,13 +885,13 @@ static v8::Handle<v8::Value> methodWithNonOptionalArgAndTwoOptionalArgsCallback( { INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int nonOpt = toInt32(args[0]); + EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0])); if (args.Length() <= 1) { imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); return v8::Handle<v8::Value>(); } - int opt1 = toInt32(args[1]); - int opt2 = toInt32(args[2]); + EXCEPTION_BLOCK(int, opt1, toInt32(args[1])); + EXCEPTION_BLOCK(int, opt2, toInt32(args[2])); imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); return v8::Handle<v8::Value>(); } @@ -901,7 +902,7 @@ static v8::Handle<v8::Value> methodWithCallbackArgCallback(const v8::Arguments& TestObj* imp = V8TestObj::toNative(args.Holder()); if (args.Length() <= 0 || !args[0]->IsObject()) return throwError(TYPE_MISMATCH_ERR); - RefPtr<TestCallback> callback = V8TestCallback::create(args[0]); + RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext()); imp->methodWithCallbackArg(callback); return v8::Handle<v8::Value>(); } @@ -910,10 +911,10 @@ static v8::Handle<v8::Value> methodWithNonCallbackArgAndCallbackArgCallback(cons { INC_STATS("DOM.TestObj.methodWithNonCallbackArgAndCallbackArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int nonCallback = toInt32(args[0]); + EXCEPTION_BLOCK(int, nonCallback, toInt32(args[0])); if (args.Length() <= 1 || !args[1]->IsObject()) return throwError(TYPE_MISMATCH_ERR); - RefPtr<TestCallback> callback = V8TestCallback::create(args[1]); + RefPtr<TestCallback> callback = V8TestCallback::create(args[1], getScriptExecutionContext()); imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback); return v8::Handle<v8::Value>(); } @@ -922,13 +923,12 @@ static v8::Handle<v8::Value> methodWithCallbackAndOptionalArgCallback(const v8:: { INC_STATS("DOM.TestObj.methodWithCallbackAndOptionalArg"); TestObj* imp = V8TestObj::toNative(args.Holder()); - if (args.Length() <= 0) { - imp->methodWithCallbackAndOptionalArg(); - return v8::Handle<v8::Value>(); + RefPtr<TestCallback> callback; + if (args.Length() > 0 && !args[0]->IsNull() && !args[0]->IsUndefined()) { + if (!args[0]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + callback = V8TestCallback::create(args[0], getScriptExecutionContext()); } - if (args.Length() <= 0 || !args[0]->IsObject()) - return throwError(TYPE_MISMATCH_ERR); - RefPtr<TestCallback> callback = V8TestCallback::create(args[0]); imp->methodWithCallbackAndOptionalArg(callback); return v8::Handle<v8::Value>(); } @@ -937,8 +937,8 @@ static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod1"); TestObj* imp = V8TestObj::toNative(args.Holder()); - TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; - V8Parameter<> strArg = args[1]; + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]); imp->overloadedMethod(objArg, strArg); return v8::Handle<v8::Value>(); } @@ -947,12 +947,12 @@ static v8::Handle<v8::Value> overloadedMethod2Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod2"); TestObj* imp = V8TestObj::toNative(args.Holder()); - TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; + EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); if (args.Length() <= 1) { imp->overloadedMethod(objArg); return v8::Handle<v8::Value>(); } - int intArg = toInt32(args[1]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[1])); imp->overloadedMethod(objArg, intArg); return v8::Handle<v8::Value>(); } @@ -961,7 +961,7 @@ static v8::Handle<v8::Value> overloadedMethod3Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod3"); TestObj* imp = V8TestObj::toNative(args.Holder()); - V8Parameter<> strArg = args[0]; + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]); imp->overloadedMethod(strArg); return v8::Handle<v8::Value>(); } @@ -970,7 +970,7 @@ static v8::Handle<v8::Value> overloadedMethod4Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod4"); TestObj* imp = V8TestObj::toNative(args.Holder()); - int intArg = toInt32(args[0]); + EXCEPTION_BLOCK(int, intArg, toInt32(args[0])); imp->overloadedMethod(intArg); return v8::Handle<v8::Value>(); } @@ -1088,6 +1088,8 @@ static const BatchedCallback TestObjCallbacks[] = { {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback}, {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback}, {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback}, + {"methodWithCallbackArg", TestObjInternal::methodWithCallbackArgCallback}, + {"methodWithNonCallbackArgAndCallbackArg", TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback}, {"methodWithCallbackAndOptionalArg", TestObjInternal::methodWithCallbackAndOptionalArgCallback}, {"overloadedMethod", TestObjInternal::overloadedMethodCallback}, }; @@ -1161,18 +1163,6 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persi v8::Handle<v8::FunctionTemplate> customArgsAndExceptionArgv[customArgsAndExceptionArgc] = { V8log::GetRawTemplate() }; v8::Handle<v8::Signature> customArgsAndExceptionSignature = v8::Signature::New(desc, customArgsAndExceptionArgc, customArgsAndExceptionArgv); proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature)); - - // Custom Signature 'methodWithCallbackArg' - const int methodWithCallbackArgArgc = 1; - v8::Handle<v8::FunctionTemplate> methodWithCallbackArgArgv[methodWithCallbackArgArgc] = { V8TestCallback::GetRawTemplate() }; - v8::Handle<v8::Signature> methodWithCallbackArgSignature = v8::Signature::New(desc, methodWithCallbackArgArgc, methodWithCallbackArgArgv); - proto->Set(v8::String::New("methodWithCallbackArg"), v8::FunctionTemplate::New(TestObjInternal::methodWithCallbackArgCallback, v8::Handle<v8::Value>(), methodWithCallbackArgSignature)); - - // Custom Signature 'methodWithNonCallbackArgAndCallbackArg' - const int methodWithNonCallbackArgAndCallbackArgArgc = 2; - v8::Handle<v8::FunctionTemplate> methodWithNonCallbackArgAndCallbackArgArgv[methodWithNonCallbackArgAndCallbackArgArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestCallback::GetRawTemplate() }; - v8::Handle<v8::Signature> methodWithNonCallbackArgAndCallbackArgSignature = v8::Signature::New(desc, methodWithNonCallbackArgAndCallbackArgArgc, methodWithNonCallbackArgAndCallbackArgArgv); - proto->Set(v8::String::New("methodWithNonCallbackArgAndCallbackArg"), v8::FunctionTemplate::New(TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback, v8::Handle<v8::Value>(), methodWithNonCallbackArgAndCallbackArgSignature)); batchConfigureConstants(desc, proto, TestObjConsts, sizeof(TestObjConsts) / sizeof(*TestObjConsts)); // Custom toString template |