Diff
Modified: trunk/Source/WebCore/ChangeLog (101432 => 101433)
--- trunk/Source/WebCore/ChangeLog 2011-11-30 00:30:48 UTC (rev 101432)
+++ trunk/Source/WebCore/ChangeLog 2011-11-30 00:38:05 UTC (rev 101433)
@@ -1,3 +1,31 @@
+2011-11-29 Erik Arvidsson <a...@chromium.org>
+
+ WebIDL: Add support for static for JSC and V8
+ https://bugs.webkit.org/show_bug.cgi?id=72998
+
+ Reviewed by Adam Barth.
+
+ WebIDL uses "static" for class methods. We used to use "[ClassMethod]". This change makes us use the WebIDL syntax instead.
+
+ No new tests: Covered by existing tests.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GetFunctionName): Use isStatic instead.
+ (GenerateOverloadedFunction): Ditto.
+ (GenerateImplementation): Ditto.
+ (GenerateParametersCheck): Ditto.
+ (GenerateImplementationFunctionCall): Ditto.
+ (GenerateConstructorDefinition): Ditto.
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateFunctionCallback): Ditto.
+ (GenerateImplementation): Ditto.
+ (GenerateFunctionCallString): Ditto.
+ * bindings/scripts/IDLParser.pm:
+ (ParseInterface): Set isStatic as needed.
+ * bindings/scripts/IDLStructure.pm: Update regular _expression_ to parse "static".
+ * bindings/scripts/test/TestObj.idl: Use static instead of [ClassMethod].
+ * storage/IDBKeyRange.idl: Ditto.
+
2011-11-29 Kentaro Hara <hara...@chromium.org>
Unreviewed. Rebaselined a run-bindings-tests result.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (101432 => 101433)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2011-11-30 00:30:48 UTC (rev 101432)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2011-11-30 00:38:05 UTC (rev 101433)
@@ -651,8 +651,7 @@
sub GetFunctionName
{
my ($className, $function) = @_;
- my $isStatic = $function->signature->extendedAttributes->{"ClassMethod"};
- my $kind = $isStatic ? "Constructor" : "Prototype";
+ my $kind = $function->isStatic ? "Constructor" : "Prototype";
return $codeGenerator->WK_lcfirst($className) . $kind . "Function" . $codeGenerator->WK_ucfirst($function->signature->name);
}
@@ -1309,8 +1308,7 @@
# overload is applicable, precedence is given according to the order of
# declaration in the IDL.
- my $isStatic = $function->signature->extendedAttributes->{"ClassMethod"};
- my $kind = $isStatic ? "Constructor" : "Prototype";
+ my $kind = $function->isStatic ? "Constructor" : "Prototype";
my $functionName = "js${implClassName}${kind}Function" . $codeGenerator->WK_ucfirst($function->signature->name);
push(@implContent, "EncodedJSValue JSC_HOST_CALL ${functionName}(ExecState* exec)\n");
@@ -1405,7 +1403,7 @@
}
foreach my $function (@{$dataNode->functions}) {
- next unless ($function->signature->extendedAttributes->{"ClassMethod"});
+ next unless ($function->isStatic);
next if $function->{overloadIndex} && $function->{overloadIndex} > 1;
my $name = $function->signature->name;
push(@hashKeys, $name);
@@ -1466,7 +1464,7 @@
}
foreach my $function (@{$dataNode->functions}) {
- next if ($function->signature->extendedAttributes->{"ClassMethod"});
+ next if ($function->isStatic);
next if $function->{overloadIndex} && $function->{overloadIndex} > 1;
my $name = $function->signature->name;
push(@hashKeys, $name);
@@ -2064,8 +2062,6 @@
$implIncludes{"<runtime/Error.h>"} = 1;
- my $isStatic = $function->signature->extendedAttributes->{"ClassMethod"};
-
if ($interfaceName eq "DOMWindow") {
push(@implContent, " $className* castedThis = toJSDOMWindow(exec->hostThisValue().toThisObject(exec));\n");
push(@implContent, " if (!castedThis)\n");
@@ -2074,27 +2070,27 @@
push(@implContent, " $className* castedThis = to${className}(exec->hostThisValue().toThisObject(exec));\n");
push(@implContent, " if (!castedThis)\n");
push(@implContent, " return throwVMTypeError(exec);\n");
- } elsif (!$isStatic) {
+ } 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");
}
- push(@implContent, " ASSERT_GC_OBJECT_INHERITS(castedThis, &${className}::s_info);\n") unless ($isStatic);
+ push(@implContent, " ASSERT_GC_OBJECT_INHERITS(castedThis, &${className}::s_info);\n") unless ($function->isStatic);
if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} and
!$function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"} and
- !$isStatic) {
+ !$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 ($isStatic);
+ push(@implContent, " return JSValue::encode(castedThis->" . $functionImplementationName . "(exec));\n") unless ($function->isStatic);
} else {
- push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n") unless ($isStatic);
- if ($svgPropertyType and !$isStatic) {
+ push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n") unless ($function->isStatic);
+ if ($svgPropertyType and !$function->isStatic) {
push(@implContent, " if (imp->role() == AnimValRole) {\n");
push(@implContent, " setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n");
push(@implContent, " return JSValue::encode(jsUndefined());\n");
@@ -2109,7 +2105,7 @@
push(@implContent, " ExceptionCode ec = 0;\n");
}
- if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"} and !$isStatic) {
+ if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"} and !$function->isStatic) {
push(@implContent, " if (!checkNodeSecurity(exec, imp->getSVGDocument(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
push(@implContent, " return JSValue::encode(jsUndefined());\n");
$implIncludes{"JSDOMBinding.h"} = 1;
@@ -2359,10 +2355,9 @@
my $paramIndex = 0;
my $argsIndex = 0;
my $hasOptionalArguments = 0;
- my $isStatic = $function->signature->extendedAttributes->{"ClassMethod"};
my $functionBase = "";
- if ($isStatic) {
+ if ($function->isStatic) {
$functionBase = "${implClassName}::";
} elsif ($svgPropertyOrListPropertyType and !$svgListPropertyType) {
$functionBase = "podImp.";
@@ -2371,7 +2366,7 @@
}
my $functionString = "$functionBase$functionImplementationName(";
- if ($function->signature->extendedAttributes->{"CustomArgumentHandling"} and !$isStatic) {
+ if ($function->signature->extendedAttributes->{"CustomArgumentHandling"} and !$function->isStatic) {
push(@$outputArray, " RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n");
push(@$outputArray, " size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;\n");
push(@$outputArray, " RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));\n");
@@ -2700,13 +2695,11 @@
}
$functionString .= ")";
- my $isStatic = $function->signature->extendedAttributes->{"ClassMethod"};
-
if ($function->signature->type eq "void") {
push(@implContent, $indent . "$functionString;\n");
push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
- if ($svgPropertyType and !$isStatic) {
+ if ($svgPropertyType and !$function->isStatic) {
if (@{$function->raisesExceptions}) {
push(@implContent, $indent . "if (!ec)\n");
push(@implContent, $indent . " imp->commitChange();\n");
@@ -3362,7 +3355,7 @@
my $hasStaticFunctions = 0;
foreach my $function (@{$dataNode->functions}) {
- if ($function->signature->extendedAttributes->{"ClassMethod"}) {
+ if ($function->isStatic) {
$hasStaticFunctions = 1;
last;
}
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (101432 => 101433)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-11-30 00:30:48 UTC (rev 101432)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-11-30 00:38:05 UTC (rev 101433)
@@ -1335,7 +1335,7 @@
push(@implContentDecls, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n");
push(@implContentDecls, " $svgWrappedNativeType* imp = &impInstance;\n");
}
- } elsif (!$function->signature->extendedAttributes->{"ClassMethod"}) {
+ } elsif (!$function->isStatic) {
push(@implContentDecls, <<END);
${implClassName}* imp = V8${implClassName}::toNative(args.Holder());
END
@@ -2307,7 +2307,7 @@
if ($attrExt->{"V8OnInstance"}) {
next;
}
- if ($attrExt->{"ClassMethod"}) {
+ if ($function->isStatic) {
next;
}
if ($attrExt->{"EnabledAtRuntime"} || RequiresCustomSignature($function) || $attrExt->{"V8DoNotCheckSignature"}) {
@@ -2526,7 +2526,7 @@
if ($attrExt->{"V8OnInstance"}) {
$template = "instance";
}
- if ($attrExt->{"ClassMethod"}) {
+ if ($function->isStatic) {
$template = "desc";
}
@@ -2559,38 +2559,38 @@
// $commentInfo
${conditional}$template->SetAccessor(v8::String::New("$name"), ${interfaceName}Internal::${name}AttrGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attributes));
END
- $num_callbacks++;
- next;
- }
+ $num_callbacks++;
+ next;
+ }
- my $signature = "defaultSignature";
- if ($attrExt->{"V8DoNotCheckSignature"} || $attrExt->{"ClassMethod"}) {
- $signature = "v8::Local<v8::Signature>()";
- }
+ my $signature = "defaultSignature";
+ if ($attrExt->{"V8DoNotCheckSignature"} || $function->isStatic) {
+ $signature = "v8::Local<v8::Signature>()";
+ }
- if (RequiresCustomSignature($function)) {
- $signature = "${name}Signature";
- push(@implContent, "\n // Custom Signature '$name'\n", CreateCustomSignature($function));
- }
+ if (RequiresCustomSignature($function)) {
+ $signature = "${name}Signature";
+ push(@implContent, "\n // Custom Signature '$name'\n", CreateCustomSignature($function));
+ }
- # Normal function call is a template
- my $callback = GetFunctionTemplateCallbackName($function, $interfaceName);
+ # Normal function call is a template
+ my $callback = GetFunctionTemplateCallbackName($function, $interfaceName);
- if ($property_attributes eq "v8::DontDelete") {
- $property_attributes = "";
- } else {
- $property_attributes = ", static_cast<v8::PropertyAttribute>($property_attributes)";
- }
+ if ($property_attributes eq "v8::DontDelete") {
+ $property_attributes = "";
+ } else {
+ $property_attributes = ", static_cast<v8::PropertyAttribute>($property_attributes)";
+ }
- if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSignature" && $property_attributes eq "") {
- # Standard type of callback, already created in the batch, so skip it here.
- next;
- }
+ if ($template eq "proto" && $conditional eq "" && $signature eq "defaultSignature" && $property_attributes eq "") {
+ # Standard type of callback, already created in the batch, so skip it here.
+ next;
+ }
- push(@implContent, <<END);
+ push(@implContent, <<END);
${conditional}$template->Set(v8::String::New("$name"), v8::FunctionTemplate::New($callback, v8::Handle<v8::Value>(), ${signature})$property_attributes);
END
- $num_callbacks++;
+ $num_callbacks++;
}
die "Wrong number of callbacks generated for $interfaceName ($num_callbacks, should be $total_functions)" if $num_callbacks != $total_functions;
@@ -3122,7 +3122,7 @@
}
my $functionString = "imp->${name}(";
- if ($function->signature->extendedAttributes->{"ClassMethod"}) {
+ if ($function->isStatic) {
$functionString = "${implClassName}::${name}(";
}
Modified: trunk/Source/WebCore/bindings/scripts/IDLParser.pm (101432 => 101433)
--- trunk/Source/WebCore/bindings/scripts/IDLParser.pm 2011-11-30 00:30:48 UTC (rev 101432)
+++ trunk/Source/WebCore/bindings/scripts/IDLParser.pm 2011-11-30 00:38:05 UTC (rev 101433)
@@ -360,10 +360,11 @@
} elsif (($line !~ s/^\s*$//g) and ($line !~ /^\s*const/)) {
$line =~ /$IDLStructure::interfaceMethodSelector/ or die "Parsing error!\nSource:\n$line\n)";
- my $methodExtendedAttributes = (defined($1) ? $1 : " "); chop($methodExtendedAttributes);
- my $methodType = (defined($2) ? $2 : die("Parsing error!\nSource:\n$line\n)"));
- my $methodName = (defined($3) ? $3 : die("Parsing error!\nSource:\n$line\n)"));
- my $methodSignature = (defined($4) ? $4 : die("Parsing error!\nSource:\n$line\n)"));
+ my $isStatic = defined($1);
+ my $methodExtendedAttributes = (defined($2) ? $2 : " "); chop($methodExtendedAttributes);
+ my $methodType = (defined($3) ? $3 : die("Parsing error!\nSource:\n$line\n)"));
+ my $methodName = (defined($4) ? $4 : die("Parsing error!\nSource:\n$line\n)"));
+ my $methodSignature = (defined($5) ? $5 : die("Parsing error!\nSource:\n$line\n)"));
('' =~ /^/); # Reset variables needed for regexp matching
@@ -372,6 +373,7 @@
my $newDataNode = new domFunction();
+ $newDataNode->isStatic($isStatic);
$newDataNode->signature(new domSignature());
$newDataNode->signature->name($methodName);
$newDataNode->signature->type($methodType);
Modified: trunk/Source/WebCore/bindings/scripts/IDLStructure.pm (101432 => 101433)
--- trunk/Source/WebCore/bindings/scripts/IDLStructure.pm 2011-11-30 00:30:48 UTC (rev 101432)
+++ trunk/Source/WebCore/bindings/scripts/IDLStructure.pm 2011-11-30 00:38:05 UTC (rev 101433)
@@ -45,6 +45,7 @@
# Used to represent domClass contents (name of method, signature)
struct( domFunction => {
+ isStatic => '$',
signature => '$', # Return type/Object name/extended attributes
parameters => '@', # List of 'domSignature'
raisesExceptions => '@', # Possibly raised exceptions.
@@ -103,7 +104,7 @@
our $typeNamespaceSelector = '((?:' . $idlId . '*::)*)\s*(' . $idlDataType . '*)';
our $interfaceSelector = 'interface\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([-a-zA-Z0-9_"=\s(),;:\[\]&\|]*)';
-our $interfaceMethodSelector = '\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]]*)';
+our $interfaceMethodSelector = '\s*(static\s+)?((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]]*)';
our $interfaceParameterSelector = '(in|out)\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)';
our $interfaceAttributeSelector = '\s*(readonly attribute|attribute)\s*(' . $extendedAttributeSyntax . ' )?' . $supportedTypes . '\s*(' . $idlType . '*)';
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (101432 => 101433)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2011-11-30 00:30:48 UTC (rev 101432)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2011-11-30 00:38:05 UTC (rev 101433)
@@ -162,8 +162,8 @@
#endif
// Class methods within _javascript_ (like what's used for IDBKeyRange).
- [ClassMethod] void classMethod();
- [ClassMethod] long classMethodWithOptional(in [Optional] long arg);
+ static void classMethod();
+ static long classMethodWithOptional(in [Optional] long arg);
#if defined(TESTING_V8)
// 'EnabledAtRuntime' methods and attributes.
Modified: trunk/Source/WebCore/storage/IDBKeyRange.idl (101432 => 101433)
--- trunk/Source/WebCore/storage/IDBKeyRange.idl 2011-11-30 00:30:48 UTC (rev 101432)
+++ trunk/Source/WebCore/storage/IDBKeyRange.idl 2011-11-30 00:38:05 UTC (rev 101433)
@@ -33,14 +33,13 @@
readonly attribute boolean lowerOpen;
readonly attribute boolean upperOpen;
- // FIXME: Make ClassMethod work for JSC as well.
- [ClassMethod] IDBKeyRange only(in IDBKey value)
+ static IDBKeyRange only(in IDBKey value)
raises (IDBDatabaseException);
- [ClassMethod] IDBKeyRange lowerBound(in IDBKey bound, in [Optional] boolean open)
+ static IDBKeyRange lowerBound(in IDBKey bound, in [Optional] boolean open)
raises (IDBDatabaseException);
- [ClassMethod] IDBKeyRange upperBound(in IDBKey bound, in [Optional] boolean open)
+ static IDBKeyRange upperBound(in IDBKey bound, in [Optional] boolean open)
raises (IDBDatabaseException);
- [ClassMethod] IDBKeyRange bound(in IDBKey lower, in IDBKey upper, in [Optional] boolean lowerOpen, in [Optional] boolean upperOpen)
+ static IDBKeyRange bound(in IDBKey lower, in IDBKey upper, in [Optional] boolean lowerOpen, in [Optional] boolean upperOpen)
raises (IDBDatabaseException);
};