Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (110231 => 110232)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-03-09 00:41:22 UTC (rev 110231)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-03-09 00:46:38 UTC (rev 110232)
@@ -891,7 +891,7 @@
my $conditionalString = GenerateConditionalString($function->signature);
push(@headerContent, "#if ${conditionalString}\n") if $conditionalString;
my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementedAs"} || $codeGenerator->WK_lcfirst($function->signature->name);
- push(@headerContent, " JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n");
+ push(@headerContent, " " . ($function->isStatic ? "static " : "") . "JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n");
push(@headerContent, "#endif\n") if $conditionalString;
}
}
@@ -2077,63 +2077,79 @@
$implIncludes{"<runtime/Error.h>"} = 1;
- if ($interfaceName eq "DOMWindow") {
- push(@implContent, " $className* castedThis = toJSDOMWindow(exec->hostThisValue().toThisObject(exec));\n");
- push(@implContent, " if (!castedThis)\n");
- push(@implContent, " return throwVMTypeError(exec);\n");
- } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
- push(@implContent, " $className* castedThis = to${className}(exec->hostThisValue().toThisObject(exec));\n");
- push(@implContent, " if (!castedThis)\n");
- push(@implContent, " return throwVMTypeError(exec);\n");
- } elsif (!$function->isStatic) {
- push(@implContent, " JSValue thisValue = exec->hostThisValue();\n");
- push(@implContent, " if (!thisValue.inherits(&${className}::s_info))\n");
- push(@implContent, " return throwVMTypeError(exec);\n");
- push(@implContent, " $className* castedThis = static_cast<$className*>(asObject(thisValue));\n");
- }
+ if ($function->isStatic) {
+ if ($isCustom) {
+ GenerateArgumentsCountCheck(\@implContent, $function, $dataNode);
+ push(@implContent, " return JSValue::encode(${className}::" . $functionImplementationName . "(exec));\n");
+ } else {
+ GenerateArgumentsCountCheck(\@implContent, $function, $dataNode);
- push(@implContent, " ASSERT_GC_OBJECT_INHERITS(castedThis, &${className}::s_info);\n") unless ($function->isStatic);
+ if (@{$function->raisesExceptions}) {
+ push(@implContent, " ExceptionCode ec = 0;\n");
+ }
- if ($dataNode->extendedAttributes->{"CheckSecurity"} and
- !$function->signature->extendedAttributes->{"DoNotCheckSecurity"} and
- !$function->isStatic) {
- push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n");
- push(@implContent, " return JSValue::encode(jsUndefined());\n");
- }
-
- if ($isCustom) {
- push(@implContent, " return JSValue::encode(castedThis->" . $functionImplementationName . "(exec));\n") unless ($function->isStatic);
+ my $numParameters = @{$function->parameters};
+ my ($functionString, $dummy) = GenerateParametersCheck(\@implContent, $function, $dataNode, $numParameters, $implClassName, $functionImplementationName, $svgPropertyType, $svgPropertyOrListPropertyType, $svgListPropertyType);
+ GenerateImplementationFunctionCall($function, $functionString, " ", $svgPropertyType, $implClassName);
+ }
} else {
- push(@implContent, " $implType* impl = static_cast<$implType*>(castedThis->impl());\n") unless ($function->isStatic);
- if ($svgPropertyType and !$function->isStatic) {
- push(@implContent, " if (impl->role() == AnimValRole) {\n");
- push(@implContent, " setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n");
- push(@implContent, " return JSValue::encode(jsUndefined());\n");
- push(@implContent, " }\n");
- push(@implContent, " $svgPropertyType& podImpl = impl->propertyReference();\n");
- $implIncludes{"ExceptionCode.h"} = 1;
+ if ($interfaceName eq "DOMWindow") {
+ push(@implContent, " $className* castedThis = toJSDOMWindow(exec->hostThisValue().toThisObject(exec));\n");
+ push(@implContent, " if (!castedThis)\n");
+ push(@implContent, " return throwVMTypeError(exec);\n");
+ } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
+ push(@implContent, " $className* castedThis = to${className}(exec->hostThisValue().toThisObject(exec));\n");
+ push(@implContent, " if (!castedThis)\n");
+ push(@implContent, " return throwVMTypeError(exec);\n");
+ } else {
+ push(@implContent, " JSValue thisValue = exec->hostThisValue();\n");
+ push(@implContent, " if (!thisValue.inherits(&${className}::s_info))\n");
+ push(@implContent, " return throwVMTypeError(exec);\n");
+ push(@implContent, " $className* castedThis = static_cast<$className*>(asObject(thisValue));\n");
}
- GenerateArgumentsCountCheck(\@implContent, $function, $dataNode);
+ push(@implContent, " ASSERT_GC_OBJECT_INHERITS(castedThis, &${className}::s_info);\n");
- if (@{$function->raisesExceptions}) {
- push(@implContent, " ExceptionCode ec = 0;\n");
- }
-
- if ($function->signature->extendedAttributes->{"CheckSecurityForNode"} and !$function->isStatic) {
- push(@implContent, " if (!shouldAllowAccessToNode(exec, impl->" . $function->signature->name . "(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
+ if ($dataNode->extendedAttributes->{"CheckSecurity"} and
+ !$function->signature->extendedAttributes->{"DoNotCheckSecurity"}) {
+ push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n");
push(@implContent, " return JSValue::encode(jsUndefined());\n");
- $implIncludes{"JSDOMBinding.h"} = 1;
}
- if ($function->signature->name eq "addEventListener") {
- push(@implContent, GenerateEventListenerCall($className, "add"));
- } elsif ($function->signature->name eq "removeEventListener") {
- push(@implContent, GenerateEventListenerCall($className, "remove"));
+ if ($isCustom) {
+ push(@implContent, " return JSValue::encode(castedThis->" . $functionImplementationName . "(exec));\n");
} else {
- my $numParameters = @{$function->parameters};
- my ($functionString, $dummy) = GenerateParametersCheck(\@implContent, $function, $dataNode, $numParameters, $implClassName, $functionImplementationName, $svgPropertyType, $svgPropertyOrListPropertyType, $svgListPropertyType);
- GenerateImplementationFunctionCall($function, $functionString, " ", $svgPropertyType, $implClassName);
+ push(@implContent, " $implType* impl = static_cast<$implType*>(castedThis->impl());\n");
+ if ($svgPropertyType) {
+ push(@implContent, " if (impl->role() == AnimValRole) {\n");
+ push(@implContent, " setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n");
+ push(@implContent, " return JSValue::encode(jsUndefined());\n");
+ push(@implContent, " }\n");
+ push(@implContent, " $svgPropertyType& podImpl = impl->propertyReference();\n");
+ $implIncludes{"ExceptionCode.h"} = 1;
+ }
+
+ GenerateArgumentsCountCheck(\@implContent, $function, $dataNode);
+
+ if (@{$function->raisesExceptions}) {
+ push(@implContent, " ExceptionCode ec = 0;\n");
+ }
+
+ if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) {
+ push(@implContent, " if (!shouldAllowAccessToNode(exec, impl->" . $function->signature->name . "(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
+ push(@implContent, " return JSValue::encode(jsUndefined());\n");
+ $implIncludes{"JSDOMBinding.h"} = 1;
+ }
+
+ if ($function->signature->name eq "addEventListener") {
+ push(@implContent, GenerateEventListenerCall($className, "add"));
+ } elsif ($function->signature->name eq "removeEventListener") {
+ push(@implContent, GenerateEventListenerCall($className, "remove"));
+ } else {
+ my $numParameters = @{$function->parameters};
+ my ($functionString, $dummy) = GenerateParametersCheck(\@implContent, $function, $dataNode, $numParameters, $implClassName, $functionImplementationName, $svgPropertyType, $svgPropertyOrListPropertyType, $svgListPropertyType);
+ GenerateImplementationFunctionCall($function, $functionString, " ", $svgPropertyType, $implClassName);
+ }
}
}
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (110231 => 110232)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-03-09 00:41:22 UTC (rev 110231)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-03-09 00:46:38 UTC (rev 110232)
@@ -163,6 +163,7 @@
{ "CONST_JAVASCRIPT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_JAVASCRIPT), (intptr_t)0, 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 },
#if ENABLE(Condition1)
{ "overloadedMethod1", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionOverloadedMethod1), (intptr_t)1, NoIntrinsic },
#endif
@@ -2082,6 +2083,13 @@
return JSValue::encode(result);
}
+EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod2(ExecState* exec)
+{
+ if (exec->argumentCount() < 1)
+ return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
+ return JSValue::encode(JSTestObj::classMethod2(exec));
+}
+
#if ENABLE(Condition1)
static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod11(ExecState* exec)
{
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (110231 => 110232)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-03-09 00:41:22 UTC (rev 110231)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-03-09 00:46:38 UTC (rev 110232)
@@ -2011,6 +2011,7 @@
proto->Set(v8::String::New("methodThatRequiresAllArgsAndThrows"), v8::FunctionTemplate::New(TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsAndThrowsSignature));
desc->Set(v8::String::New("classMethod"), v8::FunctionTemplate::New(TestObjInternal::classMethodCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
desc->Set(v8::String::New("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjInternal::classMethodWithOptionalCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
+ desc->Set(v8::String::New("classMethod2"), v8::FunctionTemplate::New(V8TestObj::classMethod2Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
#if ENABLE(Condition1)
desc->Set(v8::String::New("overloadedMethod1"), v8::FunctionTemplate::New(TestObjInternal::overloadedMethod1Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>()));
#endif // ENABLE(Condition1)