Diff
Modified: trunk/Source/WebCore/ChangeLog (101913 => 101914)
--- trunk/Source/WebCore/ChangeLog 2011-12-03 07:06:54 UTC (rev 101913)
+++ trunk/Source/WebCore/ChangeLog 2011-12-03 07:22:10 UTC (rev 101914)
@@ -1,3 +1,48 @@
+2011-12-02 Kentaro Hara <[email protected]>
+
+ [Refactoring] Use join(", ", @arguments) to build a method argument string in CodeGenerator*.pm
+ https://bugs.webkit.org/show_bug.cgi?id=73651
+
+ Reviewed by Darin Adler.
+
+ The code in CodeGenerator*.pm to build a method argument string is really dirty
+ and error-prone. It is building an argument string incrementally judging whether
+ ", " is necessary or not, like this:
+
+ my $method = ... ? "func(" : "func(a";
+ if (...) {
+ $method .= $method =~ /\($/ ? "b" : ", b";
+ }
+ $method .= ")";
+
+ Alternatively, we can refactor the code as follows:
+
+ my $funcName = "func";
+ my @arguments;
+ push(@arguments, "a") if (...);
+ push(@arguments, "b") if (...);
+ my $method = $funcName . "(" . join(", ", @arguments) . ")";
+
+ This patch just refactors the code, and generated .h and .cpp files should be
+ exactly the same as the current .h and .cpp files.
+
+ Tests: bindings/scripts/test/*
+
+ * bindings/scripts/CodeGenerator.pm:
+ (GetterExpression):
+ (SetterExpression):
+ * bindings/scripts/CodeGeneratorCPP.pm:
+ (GenerateImplementation):
+ * bindings/scripts/CodeGeneratorGObject.pm:
+ ():
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateImplementation):
+ * bindings/scripts/CodeGeneratorObjC.pm:
+ (GenerateImplementation):
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateNormalAttrGetter):
+ (GenerateNormalAttrSetter):
+
2011-12-02 David Levin <[email protected]>
Rename WTF class from TemporarilyChange to TemporaryChange.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (101913 => 101914)
--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm 2011-12-03 07:06:54 UTC (rev 101913)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm 2011-12-03 07:22:10 UTC (rev 101914)
@@ -499,14 +499,14 @@
return "WebCore::${namespace}::${contentAttributeName}Attr";
}
-sub GetterExpressionPrefix
+sub GetterExpression
{
my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute);
if (!$contentAttributeName) {
- return $generator->WK_lcfirst($generator->AttributeNameForGetterAndSetter($attribute)) . "(";
+ return ($generator->WK_lcfirst($generator->AttributeNameForGetterAndSetter($attribute)));
}
my $functionName;
@@ -526,17 +526,17 @@
$functionName = "getAttribute";
}
- return "$functionName($contentAttributeName"
+ return ($functionName, $contentAttributeName);
}
-sub SetterExpressionPrefix
+sub SetterExpression
{
my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute);
if (!$contentAttributeName) {
- return "set" . $generator->WK_ucfirst($generator->AttributeNameForGetterAndSetter($attribute)) . "(";
+ return ("set" . $generator->WK_ucfirst($generator->AttributeNameForGetterAndSetter($attribute)));
}
my $functionName;
@@ -550,7 +550,7 @@
$functionName = "setAttribute";
}
- return "$functionName($contentAttributeName, "
+ return ($functionName, $contentAttributeName);
}
sub ShouldCheckEnums
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm (101913 => 101914)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm 2011-12-03 07:06:54 UTC (rev 101913)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm 2011-12-03 07:22:10 UTC (rev 101914)
@@ -702,37 +702,32 @@
# - GETTER
my $getterSig = "$attributeType $className\:\:$attributeName() const\n";
my $hasGetterException = @{$attribute->getterExceptions};
- my $getterContentHead;
- my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
+ my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
+ push(@arguments, "ec") if $hasGetterException;
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- $getterContentHead = "${implementedBy}::${getterExpressionPrefix}impl()";
+ unshift(@arguments, "impl()");
+ $functionName = "${implementedBy}::${functionName}";
} else {
- $getterContentHead = "impl()->${getterExpressionPrefix}";
+ $functionName = "impl()->${functionName}";
}
- my $getterContentTail = ")";
# Special cases
+ my $getterContentHead = "";
+ my $getterContentTail = "";
my @customGetterContent = ();
if ($attribute->signature->extendedAttributes->{"ConvertToString"}) {
- $getterContentHead = "WTF::String::number(" . $getterContentHead;
- $getterContentTail .= ")";
+ $getterContentHead = "WTF::String::number(";
+ $getterContentTail = ")";
} elsif ($attribute->signature->type eq "SerializedScriptValue") {
- $getterContentHead = "$getterContentHead";
- $getterContentTail .= "->toString()";
+ $getterContentTail = "->toString()";
} elsif (ConversionNeeded($attribute->signature->type)) {
- $getterContentHead = "toWebKit(WTF::getPtr($getterContentHead";
- $getterContentTail .= "))";
+ $getterContentHead = "toWebKit(WTF::getPtr(";
+ $getterContentTail = "))";
}
- my $getterContent;
- if ($hasGetterException) {
- $getterContent = $getterContentHead . ($getterContentHead =~ /\($/ ? "ec" : ", ec") . $getterContentTail;
- } else {
- $getterContent = $getterContentHead . $getterContentTail;
- }
-
+ my $getterContent = "${getterContentHead}${functionName}(" . join(", ", @arguments) . ")${getterContentTail}";
my $attributeConditionalString = GenerateConditionalString($attribute->signature);
push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString;
@@ -779,15 +774,19 @@
push(@implContent, AddEarlyReturnStatement());
push(@implContent, " $exceptionInit\n") if $hasSetterException;
- my $ec = $hasSetterException ? ", ec" : "";
- my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
+
+ my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
+ push(@arguments, $arg);
+ push(@arguments, "ec") if $hasSetterException;
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- push(@implContent, " ${implementedBy}::${setterExpressionPrefix}impl(), ${arg}${ec});\n");
+ unshift(@arguments, "impl()");
+ $functionName = "${implementedBy}::${functionName}";
} else {
- push(@implContent, " impl()->$setterExpressionPrefix$arg$ec);\n");
+ $functionName = "impl()->${functionName}";
}
+ push(@implContent, " ${functionName}(" . join(", ", @arguments) . ");\n");
push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException;
push(@implContent, "}\n\n");
}
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (101913 => 101914)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2011-12-03 07:06:54 UTC (rev 101913)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2011-12-03 07:22:10 UTC (rev 101914)
@@ -379,52 +379,46 @@
$convertFunction = "WTF::String::fromUTF8";
}
- my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
- my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
+ my ($getterFunctionName, @getterArguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
+ my ($setterFunctionName, @setterArguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
- my $getterContentHead;
- my $setterContentHead;
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- $getterContentHead = "${implementedBy}::${getterExpressionPrefix}coreSelf";
- $setterContentHead = "${implementedBy}::${setterExpressionPrefix}coreSelf, ${convertFunction}(g_value_get_$gtype(value))";
+ push(@setterArguments, "${convertFunction}(g_value_get_$gtype(value))");
+ unshift(@getterArguments, "coreSelf");
+ unshift(@setterArguments, "coreSelf");
+ $getterFunctionName = "${implementedBy}::$getterFunctionName";
+ $setterFunctionName = "${implementedBy}::$setterFunctionName";
} else {
- $getterContentHead = "coreSelf->$getterExpressionPrefix";
- $setterContentHead = "coreSelf->$setterExpressionPrefix${convertFunction}(g_value_get_$gtype(value))";
+ push(@setterArguments, "${convertFunction}(g_value_get_$gtype(value))");
+ $getterFunctionName = "coreSelf->$getterFunctionName";
+ $setterFunctionName = "coreSelf->$setterFunctionName";
}
+ push(@getterArguments, "ec") if @{$attribute->getterExceptions};
+ push(@setterArguments, "ec") if @{$attribute->setterExceptions};
if (grep {$_ eq $attribute} @writeableProperties) {
push(@txtSetProps, "#if ${conditionalString}\n") if $conditionalString;
push(@txtSetProps, " case ${propEnum}:\n {\n");
push(@txtSetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
- push(@txtSetProps, " ${setterContentHead}");
- push(@txtSetProps, ", ec") if @{$attribute->setterExceptions};
- push(@txtSetProps, ");\n");
+ push(@txtSetProps, " ${setterFunctionName}(" . join(", ", @setterArguments) . ");\n");
push(@txtSetProps, " break;\n }\n");
push(@txtSetProps, "#endif /* ${conditionalString} */\n") if $conditionalString;
}
push(@txtGetProps, "#if ${conditionalString}\n") if $conditionalString;
push(@txtGetProps, " case ${propEnum}:\n {\n");
+ push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->getterExceptions};
- my $exception = "";
- if (@{$attribute->getterExceptions}) {
- $exception = "ec";
- push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n");
- }
-
my $postConvertFunction = "";
my $done = 0;
if ($gtype eq "string") {
- push(@txtGetProps, " g_value_take_string(value, convertToUTF8String(${getterContentHead}" . ($getterContentHead !~ /\($/ && $exception ? ", $exception" : "$exception") . ")));\n");
+ push(@txtGetProps, " g_value_take_string(value, convertToUTF8String(${getterFunctionName}(" . join(", ", @getterArguments) . ")));\n");
$done = 1;
} elsif ($gtype eq "object") {
- $txtGetProp = << "EOF";
- RefPtr<WebCore::${propType}> ptr = coreSelf->${getPropNameFunction}(${exception});
- g_value_set_object(value, WebKit::kit(ptr.get()));
-EOF
- push(@txtGetProps, $txtGetProp);
+ push(@txtGetProps, " RefPtr<WebCore::${propType}> ptr = coreSelf->${getPropNameFunction}(" . (@{$attribute->getterExceptions} ? "ec" : "") . ");\n");
+ push(@txtGetProps, " g_value_set_object(value, WebKit::kit(ptr.get()));\n");
$done = 1;
}
@@ -438,9 +432,9 @@
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}${implementedBy}::${getterExpressionPrefix}coreSelf, ${exception})${postConvertFunction});\n");
+ push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}${getterFunctionName}(" . join(", ", @getterArguments) . ")${postConvertFunction});\n");
} else {
- push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}coreSelf->${getterExpressionPrefix}${exception})${postConvertFunction});\n");
+ push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}${getterFunctionName}(" . join(", ", @getterArguments) . ")${postConvertFunction});\n");
}
}
@@ -742,7 +736,7 @@
my $functionSig = "${className}* self";
- my $callImplParams = "";
+ my @callImplParams;
# skip some custom functions for now
my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"} ||
@@ -770,11 +764,7 @@
if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) {
$paramName = "converted_" . $paramName;
}
- if ($callImplParams) {
- $callImplParams .= ", $paramName";
- } else {
- $callImplParams = "$paramName";
- }
+ push(@callImplParams, $paramName);
}
# Not quite sure what to do with this yet, but we need to take into
@@ -782,8 +772,7 @@
# actual implementation.
if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
$functionSig .= ", gboolean isUserGesture";
- $callImplParams .= ", " if $callImplParams;
- $callImplParams .= "false";
+ push(@callImplParams, "false");
}
if ($returnType ne "void" && $returnValueIsGDOMType && $functionSigType ne "DOMObject") {
@@ -911,19 +900,15 @@
$assign = "${returnType} res = ";
}
}
- my $exceptions = "";
+
if (@{$function->raisesExceptions}) {
- push(@cBody, " WebCore::ExceptionCode ec = 0;\n");
- if (${callImplParams} ne "") {
- $exceptions = ", ec";
- } else {
- $exceptions = "ec";
- }
+ push(@cBody, " WebCore::ExceptionCode ec = 0;\n") ;
+ push(@callImplParams, "ec");
}
if ($functionHasCustomReturn) {
+ push(@cBody, " bool ok = item->${functionSigName}(" . join(", ", @callImplParams) . ");\n");
my $customNodeAppendChild = << "EOF";
- bool ok = item->${functionSigName}(${callImplParams}${exceptions});
if (ok)
{
${returnType} res = WebKit::kit($returnParamName);
@@ -946,43 +931,50 @@
} elsif ($functionSigType eq "DOMString") {
my $getterContentHead;
if ($prefix) {
- my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $function);
+ my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $function);
+ push(@arguments, @callImplParams);
if ($function->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- my $item = !$callImplParams && !$exceptions ? "item" : "item, ";
- $getterContentHead = "${assign}convertToUTF8String(${implementedBy}::$getterExpressionPrefix$item${exceptions}));\n";
+ unshift(@arguments, "item");
+ $functionName = "${implementedBy}::${functionName}";
} else {
- $getterContentHead = "${assign}convertToUTF8String(item->$getterExpressionPrefix${exceptions}));\n";
+ $functionName = "item->${functionName}";
}
+ $getterContentHead = "${assign}convertToUTF8String(${functionName}(" . join(", ", @arguments) . "));\n";
} else {
- $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n";
+ $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(" . join(", ", @callImplParams) . "));\n";
}
push(@cBody, " ${getterContentHead}");
} else {
my $contentHead;
if ($prefix eq "get_") {
- my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $function);
+ my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $function);
+ push(@arguments, @callImplParams);
if ($function->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- my $item = !$callImplParams && !$exceptions ? "item" : "item, ";
- $contentHead = "${assign}${assignPre}${implementedBy}::$getterExpressionPrefix$item${callImplParams}${exceptions}${assignPost});\n";
+ unshift(@arguments, "item");
+ $functionName = "${implementedBy}::${functionName}";
} else {
- $contentHead = "${assign}${assignPre}item->$getterExpressionPrefix${callImplParams}${exceptions}${assignPost});\n";
+ $functionName = "item->${functionName}";
}
+ $contentHead = "${assign}${assignPre}${functionName}(" . join(", ", @arguments) . "${assignPost});\n";
} elsif ($prefix eq "set_") {
- my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $function);
+ my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $function);
+ push(@arguments, @callImplParams);
if ($function->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $function->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- my $item = !$callImplParams && !$exceptions ? "item" : "item, ";
- $contentHead = "${assign}${assignPre}${implementedBy}::$setterExpressionPrefix$item${callImplParams}${exceptions}${assignPost});\n";
+ unshift(@arguments, "item");
+ $functionName = "${implementedBy}::${functionName}";
+ $contentHead = "${assign}${assignPre}${functionName}(" . join(", ", @arguments) . "${assignPost});\n";
} else {
- $contentHead = "${assign}${assignPre}item->$setterExpressionPrefix${callImplParams}${exceptions}${assignPost});\n";
+ $functionName = "item->${functionName}";
+ $contentHead = "${assign}${assignPre}${functionName}(" . join(", ", @arguments) . "${assignPost});\n";
}
} else {
- $contentHead = "${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n";
+ $contentHead = "${assign}${assignPre}item->${functionSigName}(" . join(", ", @callImplParams) . "${assignPost});\n";
}
push(@cBody, " ${contentHead}");
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (101913 => 101914)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2011-12-03 07:06:54 UTC (rev 101913)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2011-12-03 07:22:10 UTC (rev 101914)
@@ -1769,17 +1769,17 @@
push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "imp.$implGetterFunctionName()", "castedThis") . ";\n");
}
} else {
- my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
- my $getterExpression;
+ my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- $getterExpression = "${implementedBy}::${getterExpressionPrefix}imp)";
+ $functionName = "${implementedBy}::${functionName}";
+ unshift(@arguments, "imp");
} else {
- $getterExpression = "imp->" . $getterExpressionPrefix . ")";
+ $functionName = "imp->${functionName}";
}
- my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $getterExpression, "castedThis");
+ my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, "${functionName}(" . join(", ", @arguments) . ")", "castedThis");
push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n");
if ($codeGenerator->IsSVGAnimatedType($type)) {
push(@implContent, " RefPtr<$type> obj = $jsType;\n");
@@ -1991,16 +1991,18 @@
}
}
} else {
- my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
+ my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
+ push(@arguments, $nativeValue);
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- push(@implContent, " ${implementedBy}::${setterExpressionPrefix}imp, $nativeValue");
+ unshift(@arguments, "imp");
+ $functionName = "${implementedBy}::${functionName}";
} else {
- push(@implContent, " imp->$setterExpressionPrefix$nativeValue");
+ $functionName = "imp->${functionName}";
}
- push(@implContent, ", ec") if @{$attribute->setterExceptions};
- push(@implContent, ");\n");
+ push(@arguments, "ec") if @{$attribute->setterExceptions};
+ push(@implContent, " ${functionName}(" . join(", ", @arguments) . ");\n");
push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
}
}
@@ -2011,10 +2013,10 @@
}
}
}
-
+
if ($dataNode->extendedAttributes->{"ReplaceableConstructor"}) {
my $constructorFunctionName = "setJS" . $interfaceName . "Constructor";
-
+
push(@implContent, "void ${constructorFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n");
push(@implContent, "{\n");
if ($dataNode->extendedAttributes->{"CheckDomainSecurity"}) {
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm (101913 => 101914)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm 2011-12-03 07:06:54 UTC (rev 101913)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm 2011-12-03 07:22:10 UTC (rev 101914)
@@ -1200,7 +1200,8 @@
# - GETTER
my $getterSig = "- ($attributeType)$attributeInterfaceName\n";
- my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
+ my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
+ my $getterExpressionPrefix = "$functionName(" . join(", ", @arguments);
# FIXME: Special case attribute ownerDocument to call document. This makes it return the
# document when called on the document itself. Legacy behavior, see <https://bugs.webkit.org/show_bug.cgi?id=10889>.
@@ -1442,16 +1443,19 @@
$getterContentHead = "$getterExpressionPrefix";
push(@implContent, " IMPL->$coreSetterName($arg);\n");
} else {
- my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
- my $ec = $hasSetterException ? ", ec" : "";
+ my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
+ push(@arguments, $arg);
+ push(@arguments, "ec") if $hasSetterException;
push(@implContent, " $exceptionInit\n") if $hasSetterException;
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
$implIncludes{"${implementedBy}.h"} = 1;
- push(@implContent, " ${implementedBy}::${setterExpressionPrefix}IMPL, ${arg}${ec});\n");
+ unshift(@arguments, "IMPL");
+ $functionName = "${implementedBy}::${functionName}";
} else {
- push(@implContent, " IMPL->$setterExpressionPrefix$arg$ec);\n");
+ $functionName = "IMPL->${functionName}";
}
+ push(@implContent, " ${functionName}(" . join(", ", @arguments) . ");\n");
push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException;
}
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (101913 => 101914)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-12-03 07:06:54 UTC (rev 101913)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2011-12-03 07:22:10 UTC (rev 101914)
@@ -873,20 +873,19 @@
}
my $returnType = GetTypeFromSignature($attribute->signature);
-
my $getterString;
if ($getterStringUsesImp) {
- my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
+ my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
+ push(@arguments, "ec") if $useExceptions;
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
AddToImplIncludes("${implementedBy}.h");
- $getterString = "${implementedBy}::${getterExpressionPrefix}imp";
- $getterString .= ", ec" if $useExceptions;
+ unshift(@arguments, "imp");
+ $functionName = "${implementedBy}::${functionName}";
} else {
- $getterString = "imp->$getterExpressionPrefix";
- $getterString .= "ec" if $useExceptions;
+ $functionName = "imp->${functionName}";
}
- $getterString .= ")";
+ $getterString = "${functionName}(" . join(", ", @arguments) . ")";
} else {
$getterString = "impInstance";
}
@@ -1124,18 +1123,22 @@
} else {
push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)");
}
+ push(@implContentDecls, ", ec") if $useExceptions;
+ push(@implContentDecls, ");\n");
} else {
- my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute);
+ my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
+ push(@arguments, $result);
+ push(@arguments, "ec") if $useExceptions;
if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
AddToImplIncludes("${implementedBy}.h");
- push(@implContentDecls, " ${implementedBy}::${setterExpressionPrefix}imp, $result");
+ unshift(@arguments, "imp");
+ $functionName = "${implementedBy}::${functionName}";
} else {
- push(@implContentDecls, " imp->$setterExpressionPrefix$result");
+ $functionName = "imp->${functionName}";
}
+ push(@implContentDecls, " ${functionName}(" . join(", ", @arguments) . ");\n");
}
- push(@implContentDecls, ", ec") if $useExceptions;
- push(@implContentDecls, ");\n");
}
if ($useExceptions) {