Diff
Modified: trunk/Source/WebCore/ChangeLog (144100 => 144101)
--- trunk/Source/WebCore/ChangeLog 2013-02-26 21:38:10 UTC (rev 144100)
+++ trunk/Source/WebCore/ChangeLog 2013-02-26 21:40:08 UTC (rev 144101)
@@ -1,3 +1,29 @@
+2013-02-26 CHAUDHARY VINEET <rgf...@motorola.com>
+
+ [JSC] static methods with Callback should not have this pointer
+ https://bugs.webkit.org/show_bug.cgi?id=110846
+
+ Reviewed by Kentaro Hara.
+
+ Fixing the JSC Codegenerator not to use 'this' pointer in static methods.
+
+ No new tests.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateParametersCheck):
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::jsTestObjConstructorFunctionStaticMethodWithCallbackAndOptionalArg):
+ (WebCore::jsTestObjConstructorFunctionStaticMethodWithCallbackArg):
+ * bindings/scripts/test/JS/JSTestObj.h:
+ * bindings/scripts/test/TestObj.idl:
+ * bindings/scripts/test/V8/V8TestObj.cpp:
+ (WebCore::TestObjV8Internal::staticMethodWithCallbackAndOptionalArgMethod):
+ (TestObjV8Internal):
+ (WebCore::TestObjV8Internal::staticMethodWithCallbackAndOptionalArgMethodCallback):
+ (WebCore::TestObjV8Internal::staticMethodWithCallbackArgMethod):
+ (WebCore::TestObjV8Internal::staticMethodWithCallbackArgMethodCallback):
+ (WebCore::ConfigureV8TestObjTemplate):
+
2013-02-20 Alpha Lam <hc...@chromium.org>
GIFImageReader to read from source data directly
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (144100 => 144101)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-02-26 21:38:10 UTC (rev 144100)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-02-26 21:40:08 UTC (rev 144101)
@@ -2703,12 +2703,20 @@
push(@$outputArray, " if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isUndefinedOrNull()) {\n");
push(@$outputArray, " if (!exec->argument($argsIndex).isFunction())\n");
push(@$outputArray, " return throwVMTypeError(exec);\n");
- push(@$outputArray, " $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");
+ if ($function->isStatic) {
+ push(@$outputArray, " $name = createFunctionOnlyCallback<${callbackClassName}>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument($argsIndex));\n");
+ } else {
+ push(@$outputArray, " $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");
+ }
push(@$outputArray, " }\n");
} else {
push(@$outputArray, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isFunction())\n");
push(@$outputArray, " return throwVMTypeError(exec);\n");
- push(@$outputArray, " RefPtr<$argType> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");
+ if ($function->isStatic) {
+ push(@$outputArray, " RefPtr<$argType> $name = createFunctionOnlyCallback<${callbackClassName}>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument($argsIndex));\n");
+ } else {
+ push(@$outputArray, " RefPtr<$argType> $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n");
+ }
}
} elsif ($parameter->extendedAttributes->{"Clamp"}) {
my $nativeValue = "${name}NativeValue";
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (144100 => 144101)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2013-02-26 21:38:10 UTC (rev 144100)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2013-02-26 21:40:08 UTC (rev 144101)
@@ -173,6 +173,8 @@
{ "staticReadOnlyLongAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticReadOnlyLongAttr), (intptr_t)0, NoIntrinsic },
{ "staticStringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticStringAttr), (intptr_t)setJSTestObjConstructorStaticStringAttr, NoIntrinsic },
{ "TestSubObj", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorTestSubObj), (intptr_t)0, NoIntrinsic },
+ { "staticMethodWithCallbackAndOptionalArg", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionStaticMethodWithCallbackAndOptionalArg), (intptr_t)1, NoIntrinsic },
+ { "staticMethodWithCallbackArg", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionStaticMethodWithCallbackArg), (intptr_t)1, NoIntrinsic },
{ "classMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethod), (intptr_t)0, NoIntrinsic },
{ "classMethodWithOptional", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethodWithOptional), (intptr_t)1, NoIntrinsic },
{ "classMethod2", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethod2), (intptr_t)1, NoIntrinsic },
@@ -182,7 +184,7 @@
{ 0, 0, 0, 0, NoIntrinsic }
};
-static const HashTable JSTestObjConstructorTable = { 37, 31, JSTestObjConstructorTableValues, 0 };
+static const HashTable JSTestObjConstructorTable = { 38, 31, JSTestObjConstructorTableValues, 0 };
#if ENABLE(Condition1)
COMPILE_ASSERT(0 == TestObj::CONDITIONAL_CONST, TestObjEnumCONDITIONAL_CONSTIsWrongUseDoNotCheckConstants);
@@ -2035,6 +2037,29 @@
return JSValue::encode(jsUndefined());
}
+EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionStaticMethodWithCallbackAndOptionalArg(ExecState* exec)
+{
+ RefPtr<TestCallback> callback;
+ if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull()) {
+ if (!exec->argument(0).isFunction())
+ return throwVMTypeError(exec);
+ callback = createFunctionOnlyCallback<JSTestCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(0));
+ }
+ TestObj::staticMethodWithCallbackAndOptionalArg(callback);
+ return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionStaticMethodWithCallbackArg(ExecState* exec)
+{
+ if (exec->argumentCount() < 1)
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction())
+ return throwVMTypeError(exec);
+ RefPtr<TestCallback> callback = createFunctionOnlyCallback<JSTestCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(0));
+ TestObj::staticMethodWithCallbackArg(callback);
+ return JSValue::encode(jsUndefined());
+}
+
#if ENABLE(Condition1)
EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalMethod1(ExecState* exec)
{
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (144100 => 144101)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h 2013-02-26 21:38:10 UTC (rev 144100)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h 2013-02-26 21:40:08 UTC (rev 144101)
@@ -187,6 +187,8 @@
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionStaticMethodWithCallbackAndOptionalArg(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionStaticMethodWithCallbackArg(JSC::ExecState*);
#if ENABLE(Condition1)
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalMethod1(JSC::ExecState*);
#endif
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (144100 => 144101)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2013-02-26 21:38:10 UTC (rev 144100)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2013-02-26 21:40:08 UTC (rev 144101)
@@ -145,6 +145,9 @@
void methodWithCallbackArg(in [Callback] TestCallback callback);
void methodWithNonCallbackArgAndCallbackArg(in long nonCallback, in [Callback] TestCallback callback);
void methodWithCallbackAndOptionalArg(in [Callback, Optional] TestCallback callback);
+ // static methods with 'Callback' extended attribute
+ static void staticMethodWithCallbackAndOptionalArg(in [Callback, Optional] TestCallback callback);
+ static void staticMethodWithCallbackArg(in [Callback] TestCallback callback);
#endif
// 'Conditional' extended attribute
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (144100 => 144101)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2013-02-26 21:38:10 UTC (rev 144100)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2013-02-26 21:40:08 UTC (rev 144101)
@@ -2139,6 +2139,39 @@
return TestObjV8Internal::methodWithCallbackAndOptionalArgMethod(args);
}
+static v8::Handle<v8::Value> staticMethodWithCallbackAndOptionalArgMethod(const v8::Arguments& args)
+{
+ RefPtr<TestCallback> callback;
+ if (args.Length() > 0 && !args[0]->IsNull() && !args[0]->IsUndefined()) {
+ if (!args[0]->IsFunction())
+ return throwTypeError(0, args.GetIsolate());
+ callback = V8TestCallback::create(args[0], getScriptExecutionContext());
+ }
+ TestObj::staticMethodWithCallbackAndOptionalArg(callback);
+ return v8Undefined();
+}
+
+static v8::Handle<v8::Value> staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Arguments& args)
+{
+ return TestObjV8Internal::staticMethodWithCallbackAndOptionalArgMethod(args);
+}
+
+static v8::Handle<v8::Value> staticMethodWithCallbackArgMethod(const v8::Arguments& args)
+{
+ if (args.Length() < 1)
+ return throwNotEnoughArgumentsError(args.GetIsolate());
+ if (args.Length() <= 0 || !args[0]->IsFunction())
+ return throwTypeError(0, args.GetIsolate());
+ RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext());
+ TestObj::staticMethodWithCallbackArg(callback);
+ return v8Undefined();
+}
+
+static v8::Handle<v8::Value> staticMethodWithCallbackArgMethodCallback(const v8::Arguments& args)
+{
+ return TestObjV8Internal::staticMethodWithCallbackArgMethod(args);
+}
+
#if ENABLE(Condition1)
static v8::Handle<v8::Value> conditionalMethod1Method(const v8::Arguments& args)
@@ -3051,6 +3084,8 @@
v8::Handle<v8::FunctionTemplate> methodThatRequiresAllArgsAndThrowsArgv[methodThatRequiresAllArgsAndThrowsArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate(isolate) };
v8::Handle<v8::Signature> methodThatRequiresAllArgsAndThrowsSignature = v8::Signature::New(desc, methodThatRequiresAllArgsAndThrowsArgc, methodThatRequiresAllArgsAndThrowsArgv);
proto->Set(v8::String::NewSymbol("methodThatRequiresAllArgsAndThrows"), v8::FunctionTemplate::New(TestObjV8Internal::methodThatRequiresAllArgsAndThrowsMethodCallback, v8Undefined(), methodThatRequiresAllArgsAndThrowsSignature));
+ desc->Set(v8::String::NewSymbol("staticMethodWithCallbackAndOptionalArg"), v8::FunctionTemplate::New(TestObjV8Internal::staticMethodWithCallbackAndOptionalArgMethodCallback, v8Undefined(), v8::Local<v8::Signature>()));
+ desc->Set(v8::String::NewSymbol("staticMethodWithCallbackArg"), v8::FunctionTemplate::New(TestObjV8Internal::staticMethodWithCallbackArgMethodCallback, v8Undefined(), v8::Local<v8::Signature>()));
desc->Set(v8::String::NewSymbol("classMethod"), v8::FunctionTemplate::New(TestObjV8Internal::classMethodMethodCallback, v8Undefined(), v8::Local<v8::Signature>()));
desc->Set(v8::String::NewSymbol("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjV8Internal::classMethodWithOptionalMethodCallback, v8Undefined(), v8::Local<v8::Signature>()));
desc->Set(v8::String::NewSymbol("classMethod2"), v8::FunctionTemplate::New(TestObjV8Internal::classMethod2MethodCallback, v8Undefined(), v8::Local<v8::Signature>()));