diff options
Diffstat (limited to 'WebCore/bindings/scripts')
-rw-r--r-- | WebCore/bindings/scripts/CodeGenerator.pm | 61 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorGObject.pm | 3 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorJS.pm | 37 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorObjC.pm | 136 | ||||
-rw-r--r-- | WebCore/bindings/scripts/CodeGeneratorV8.pm | 83 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/JS/JSTestObj.cpp | 8 | ||||
-rw-r--r-- | WebCore/bindings/scripts/test/V8/V8TestObj.cpp | 8 |
7 files changed, 218 insertions, 118 deletions
diff --git a/WebCore/bindings/scripts/CodeGenerator.pm b/WebCore/bindings/scripts/CodeGenerator.pm index c4f87f0..d439c19 100644 --- a/WebCore/bindings/scripts/CodeGenerator.pm +++ b/WebCore/bindings/scripts/CodeGenerator.pm @@ -50,8 +50,8 @@ my %numericTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1, my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1); -my %podTypeHash = ("SVGNumber" => 1, "SVGTransform" => 1); -my %podTypesWithWritablePropertiesHash = ("SVGMatrix" => 1, "SVGPoint" => 1, "SVGPreserveAspectRatio" => 1); +my %podTypeHash = ("SVGTransform" => 1); +my %podTypesWithWritablePropertiesHash = ("SVGMatrix" => 1); my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1); my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1, "SVGPaintType" => 1); @@ -59,7 +59,9 @@ my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1, "SVGPaintType" my %svgNewStyleAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1, "SVGAnimatedEnumeration" => 1, "SVGAnimatedInteger" => 1, "SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1, - "SVGAnimatedRect" => 1); + "SVGAnimatedNumber" => 1, "SVGAnimatedNumberList" => 1, + "SVGAnimatedPreserveAspectRatio" => 1, "SVGAnimatedRect" => 1, + "SVGAnimatedString" => 1); my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1, "SVGAnimatedEnumeration" => 1, "SVGAnimatedInteger" => 1, @@ -75,11 +77,21 @@ my %svgAttributesInHTMLHash = ("class" => 1, "id" => 1, "onabort" => 1, "onclick "onmouseup" => 1, "onresize" => 1, "onscroll" => 1, "onunload" => 1); -my %svgNativeType = ( +my %svgTypeNeedingTearOff = ( "SVGAngle" => "SVGPropertyTearOff<SVGAngle>", "SVGLength" => "SVGPropertyTearOff<SVGLength>", "SVGLengthList" => "SVGListPropertyTearOff<SVGLengthList>", - "SVGRect" => "SVGPropertyTearOff<FloatRect>" + "SVGNumber" => "SVGPropertyTearOff<float>", + "SVGNumberList" => "SVGListPropertyTearOff<SVGNumberList>", + "SVGPoint" => "SVGPropertyTearOff<FloatPoint>", + "SVGPointList" => "SVGListPropertyTearOff<SVGPointList>", + "SVGPreserveAspectRatio" => "SVGPropertyTearOff<SVGPreserveAspectRatio>", + "SVGRect" => "SVGPropertyTearOff<FloatRect>", + "SVGStringList" => "SVGStaticListPropertyTearOff<SVGStringList>" +); + +my %svgTypeWithWritablePropertiesNeedingTearOff = ( + "SVGPoint" => 1 ); # Cache of IDL file pathnames. @@ -367,7 +379,16 @@ sub IsSVGTypeNeedingTearOff my $object = shift; my $type = shift; - return 1 if exists $svgNativeType{$type}; + return 1 if exists $svgTypeNeedingTearOff{$type}; + return 0; +} + +sub IsSVGTypeWithWritablePropertiesNeedingTearOff +{ + my $object = shift; + my $type = shift; + + return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type}; return 0; } @@ -376,7 +397,7 @@ sub GetSVGTypeNeedingTearOff my $object = shift; my $type = shift; - return $svgNativeType{$type} if exists $svgNativeType{$type}; + return $svgTypeNeedingTearOff{$type} if exists $svgTypeNeedingTearOff{$type}; return undef; } @@ -385,16 +406,19 @@ sub GetSVGWrappedTypeNeedingTearOff my $object = shift; my $type = shift; - my $svgNativeType = $object->GetSVGTypeNeedingTearOff($type); - return $svgNativeType if not $svgNativeType; + my $svgTypeNeedingTearOff = $object->GetSVGTypeNeedingTearOff($type); + return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff; - if ($svgNativeType =~ /SVGPropertyTearOff/) { - $svgNativeType =~ s/SVGPropertyTearOff<//; - } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) { - $svgNativeType =~ s/SVGListPropertyTearOff<//; + if ($svgTypeNeedingTearOff =~ /SVGPropertyTearOff/) { + $svgTypeNeedingTearOff =~ s/SVGPropertyTearOff<//; + } elsif ($svgTypeNeedingTearOff =~ /SVGListPropertyTearOff/) { + $svgTypeNeedingTearOff =~ s/SVGListPropertyTearOff<//; + } elsif ($svgTypeNeedingTearOff =~ /SVGStaticListPropertyTearOff/) { + $svgTypeNeedingTearOff =~ s/SVGStaticListPropertyTearOff<//; } - $svgNativeType =~ s/>//; - return $svgNativeType; + + $svgTypeNeedingTearOff =~ s/>//; + return $svgTypeNeedingTearOff; } # FIXME: This method will go away once all SVG animated properties are converted to the new scheme. @@ -476,13 +500,18 @@ sub AttributeNameForGetterAndSetter my ($generator, $attribute) = @_; my $attributeName = $attribute->signature->name; + my $attributeType = $generator->StripModule($attribute->signature->type); # Avoid clash with C++ keyword. $attributeName = "_operator" if $attributeName eq "operator"; + # SVGAElement defines a non-virtual "String& target() const" method which clashes with "virtual String target() const" in Element. + # To solve this issue the SVGAElement method was renamed to "svgTarget", take care of that when calling this method. + $attributeName = "svgTarget" if $attributeName eq "target" and $attributeType eq "SVGAnimatedString"; + # SVG animated types need to use a special attribute name. # The rest of the special casing for SVG animated types is handled in the language-specific code generators. - $attributeName .= "Animated" if $generator->IsSVGAnimatedType($generator->StripModule($attribute->signature->type)); + $attributeName .= "Animated" if $generator->IsSVGAnimatedType($attributeType); return $attributeName; } diff --git a/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/WebCore/bindings/scripts/CodeGeneratorGObject.pm index dd9e3c7..6c450ad 100644 --- a/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -501,8 +501,7 @@ EOF my ${listenerName} = $name . "Listener"; my $txtInstallEventListener = << "EOF"; - RefPtr<WebCore::GObjectEventListener> ${listenerName} = WebCore::GObjectEventListener::create(reinterpret_cast<GObject*>(object), "${gobjectSignalName}"); - coreObject->addEventListener("${name}", ${listenerName}, false); + WebCore::GObjectEventListener::addEventListener(object, coreObject, "${name}", "${gobjectSignalName}"); EOF push(@txtInstallEventListeners, $txtInstallEventListener); diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 9244bc6..b18e57e 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -1983,8 +1983,12 @@ sub GenerateImplementation my $hasOptionalArguments = 0; if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { - push(@implContent, " ScriptCallStack callStack(exec, $numParameters);\n"); + push(@implContent, " OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, $numParameters));\n"); + push(@implContent, " size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1;\n"); + push(@implContent, " OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize));\n"); + $implIncludes{"ScriptArguments.h"} = 1; $implIncludes{"ScriptCallStack.h"} = 1; + $implIncludes{"ScriptCallStackFactory.h"} = 1; } my $callWith = $function->signature->extendedAttributes->{"CallWith"}; @@ -2389,8 +2393,8 @@ sub GenerateImplementationFunctionCall() if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { $functionString .= ", " if $paramIndex; - ++$paramIndex; - $functionString .= "&callStack"; + $paramIndex += 2; + $functionString .= "scriptArguments.release(), callStack.release()"; } if (@{$function->raisesExceptions}) { @@ -2455,11 +2459,7 @@ my %nativeType = ( "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", "IDBKey" => "RefPtr<IDBKey>", "SVGMatrix" => "AffineTransform", - "SVGNumber" => "float", "SVGPaintType" => "SVGPaint::SVGPaintType", - "SVGPreserveAspectRatio" => "SVGPreserveAspectRatio", - "SVGPoint" => "FloatPoint", - "SVGRect" => "FloatRect", "SVGTransform" => "SVGTransform", "boolean" => "bool", "double" => "double", @@ -2504,7 +2504,7 @@ sub GetSVGPropertyTypes $svgPropertyType = $svgWrappedNativeType; $headerIncludes{"$svgWrappedNativeType.h"} = 1; $headerIncludes{"SVGAnimatedPropertyTearOff.h"} = 1; - } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) { + } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { $svgListPropertyType = $svgWrappedNativeType; $headerIncludes{"$svgWrappedNativeType.h"} = 1; $headerIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; @@ -2528,7 +2528,7 @@ sub JSValueToNative return "$value.toBoolean(exec)" if $type eq "boolean"; return "$value.toNumber(exec)" if $type eq "double"; - return "$value.toFloat(exec)" if $type eq "float" or $type eq "SVGNumber"; + return "$value.toFloat(exec)" if $type eq "float"; return "$value.toInt32(exec)" if $type eq "long"; return "$value.toUInt32(exec)" if $type eq "unsigned long" or $type eq "unsigned short"; return "static_cast<$type>($value.toInteger(exec))" if $type eq "long long" or $type eq "unsigned long long"; @@ -2558,8 +2558,6 @@ sub JSValueToNative return "createIDBKeyFromValue(exec, $value)"; } - $implIncludes{"FloatPoint.h"} = 1 if $type eq "SVGPoint"; - $implIncludes{"FloatRect.h"} = 1 if $type eq "SVGRect"; $implIncludes{"HTMLOptionElement.h"} = 1 if $type eq "HTMLOptionElement"; $implIncludes{"JSCustomVoidCallback.h"} = 1 if $type eq "VoidCallback"; $implIncludes{"Event.h"} = 1 if $type eq "Event"; @@ -2681,7 +2679,22 @@ sub NativeToJSValue # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked. $value = "static_cast<" . GetNativeType($type) . ">($value)"; } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $implClassName =~ /List$/) { - $value = $codeGenerator->GetSVGTypeNeedingTearOff($type) . "::create($value)"; + my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($type); + if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($type) and $inFunctionCall eq 0 and not defined $signature->extendedAttributes->{"Immutable"}) { + $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassName, /; + $implIncludes{"SVGStaticPropertyTearOff.h"} = 1; + + my $getter = $value; + $getter =~ s/imp->//; + $getter =~ s/\(\)//; + my $updater = "update" . $codeGenerator->WK_ucfirst($getter); + $value = "${tearOffType}::create(imp, $value, &${implClassName}::$updater)"; + } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { + my $extraImp = "GetOwnerElementForType<$implClassName, IsDerivedFromSVGElement<$implClassName>::value>::ownerElement(imp), "; + $value = "${tearOffType}::create($extraImp$value)"; + } elsif (not $tearOffType =~ /SVGPointList/) { + $value = "${tearOffType}::create($value)"; + } } return "toJS(exec, $globalObject, WTF::getPtr($value))"; diff --git a/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 8351c87..69e24a9 100644 --- a/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -1,4 +1,4 @@ -# +# # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> # Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> @@ -59,8 +59,7 @@ my @depsContent = (); my %protocolTypeHash = ("XPathNSResolver" => 1, "EventListener" => 1, "EventTarget" => 1, "NodeFilter" => 1, "SVGLocatable" => 1, "SVGTransformable" => 1, "SVGStylable" => 1, "SVGFilterPrimitiveStandardAttributes" => 1, "SVGTests" => 1, "SVGLangSpace" => 1, "SVGExternalResourcesRequired" => 1, "SVGURIReference" => 1, - "SVGZoomAndPan" => 1, "SVGFitToViewBox" => 1, "SVGAnimatedPathData" => 1, "SVGAnimatedPoints" => 1, - "ElementTimeControl" => 1); + "SVGZoomAndPan" => 1, "SVGFitToViewBox" => 1, "SVGAnimatedPathData" => 1, "ElementTimeControl" => 1); my %nativeObjCTypeHash = ("URL" => 1, "Color" => 1); # FIXME: this should be replaced with a function that recurses up the tree @@ -71,7 +70,7 @@ my %baseTypeHash = ("Object" => 1, "Node" => 1, "NodeList" => 1, "NamedNodeMap" "NodeIterator" => 1, "TreeWalker" => 1, "AbstractView" => 1, "Blob" => 1, "SVGAngle" => 1, "SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1, "SVGAnimatedEnumeration" => 1, "SVGAnimatedInteger" => 1, "SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1, - "SVGAnimatedNumber" => 1, "SVGAnimatedNumberList" => 1, "SVGAnimatedPoints" => 1, + "SVGAnimatedNumber" => 1, "SVGAnimatedNumberList" => 1, "SVGAnimatedPreserveAspectRatio" => 1, "SVGAnimatedRect" => 1, "SVGAnimatedString" => 1, "SVGAnimatedTransformList" => 1, "SVGLength" => 1, "SVGLengthList" => 1, "SVGMatrix" => 1, "SVGNumber" => 1, "SVGNumberList" => 1, "SVGPathSeg" => 1, "SVGPathSegList" => 1, "SVGPoint" => 1, @@ -600,12 +599,6 @@ sub AddIncludesForType return; } - if ($type eq "SVGPoint") { - $implIncludes{"FloatPoint.h"} = 1; - $implIncludes{"DOMSVGPointInternal.h"} = 1; - return; - } - if ($type eq "SVGMatrix") { $implIncludes{"AffineTransform.h"} = 1; $implIncludes{"DOMSVGMatrixInternal.h"} = 1; @@ -613,11 +606,6 @@ sub AddIncludesForType return; } - if ($type eq "SVGNumber") { - $implIncludes{"DOMSVGNumberInternal.h"} = 1; - return; - } - if ($type =~ /(\w+)(Abs|Rel)$/) { $implIncludes{"$1.h"} = 1; $implIncludes{"DOM${type}Internal.h"} = 1; @@ -656,6 +644,16 @@ sub AddIncludesForType $implIncludes{"DOM${type}Internal.h"} = 1; } +sub GetSVGTypeWithNamespace +{ + my $type = shift; + my $typeWithNamespace = "WebCore::" . $codeGenerator->GetSVGTypeNeedingTearOff($type); + + # Special case for DOMSVGNumber + $typeWithNamespace =~ s/</\<WebCore::/ unless $type eq "SVGNumber"; + return $typeWithNamespace; +} + sub GetSVGPropertyTypes { my $implType = shift; @@ -671,13 +669,18 @@ sub GetSVGPropertyTypes # Append space to avoid compilation errors when using PassRefPtr<$svgNativeType> $svgNativeType = "WebCore::$svgNativeType "; - $svgNativeType =~ s/</\<WebCore::/; + $svgNativeType =~ s/</\<WebCore::/ if not $svgNativeType =~ /float/; my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implType); if ($svgNativeType =~ /SVGPropertyTearOff/) { - $svgPropertyType = "WebCore::$svgWrappedNativeType"; - $svgPropertyType =~ s/</\<WebCore::/; - } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) { + if ($svgWrappedNativeType eq "float") { + # Special case for DOMSVGNumber + $svgPropertyType = $svgWrappedNativeType; + } else { + $svgPropertyType = "WebCore::$svgWrappedNativeType"; + $svgPropertyType =~ s/</\<WebCore::/; + } + } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { $svgListPropertyType = "WebCore::$svgWrappedNativeType"; $svgListPropertyType =~ s/</\<WebCore::/; } @@ -1127,7 +1130,12 @@ sub GenerateImplementation $implIncludes{"$1.h"} = 1; } else { if (!$podType) { - $implIncludes{"$implClassName.h"} = 1 if not $codeGenerator->AvoidInclusionOfType($implClassName); + if (!$codeGenerator->AvoidInclusionOfType($implClassName)) { + $implIncludes{"$implClassName.h"} = 1 ; + } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($implClassName)) { + my $includeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); + $implIncludes{"${includeType}.h"} = 1; + } } else { $implIncludes{"$podType.h"} = 1 unless $podType eq "float"; } @@ -1236,13 +1244,7 @@ sub GenerateImplementation # TODO: Handle special case for DOMSVGLength. We do need Custom code support for this. if ($svgPropertyType eq "WebCore::SVGLength" and $attributeName eq "value") { - $getterContentHead = "value(0 /* FIXME */"; - } - } else { - # Special case for DOMSVGNumber - if ($podType and $podType eq "float") { - $getterContentHead = "*IMPL"; - $getterContentTail = ""; + $getterContentHead = "value(IMPL->contextElement(), "; } } @@ -1287,10 +1289,15 @@ sub GenerateImplementation $getterContentHead = "kit($getterContentHead"; $getterContentTail .= ")"; } elsif ($svgPropertyType) { - $getterContentHead = "IMPL->propertyReference().$getterContentHead"; + # Special case for DOMSVGNumber + if ($svgPropertyType eq "float") { + # Intentional leave out closing brace, it's already contained in getterContentTail + $getterContentHead = "IMPL->propertyReference("; + } else { + $getterContentHead = "IMPL->propertyReference().$getterContentHead"; + } } elsif ($codeGenerator->IsSVGNewStyleAnimatedType($implClassName) and $codeGenerator->IsSVGTypeNeedingTearOff($idlType)) { - my $idlTypeWithNamespace = "WebCore::" . $codeGenerator->GetSVGTypeNeedingTearOff($idlType); - $idlTypeWithNamespace =~ s/</\<WebCore::/; + my $idlTypeWithNamespace = GetSVGTypeWithNamespace($idlType); $getterContentHead = "kit(static_cast<$idlTypeWithNamespace*>($getterContentHead)"; $getterContentTail .= ")"; } elsif (IsProtocolType($idlType) and $idlType ne "EventTarget") { @@ -1303,12 +1310,30 @@ sub GenerateImplementation $getterContentHead = "$getterContentHead"; $getterContentTail .= "->toString()"; } elsif (ConversionNeeded($attribute->signature->type)) { - if ($codeGenerator->IsSVGTypeNeedingTearOff($attribute->signature->type) and not $implClassName =~ /List$/) { - my $idlType = $attribute->signature->type; - my $idlTypeWithNamespace = "WebCore::" . $codeGenerator->GetSVGTypeNeedingTearOff($idlType); - $idlTypeWithNamespace =~ s/</\<WebCore::/; - $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($getterContentHead"; - $getterContentTail .= ")))"; + my $type = $attribute->signature->type; + if ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $implClassName =~ /List$/) { + my $idlTypeWithNamespace = GetSVGTypeWithNamespace($type); + if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($type) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { + $idlTypeWithNamespace =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassNameWithNamespace, /; + $implIncludes{"SVGStaticPropertyTearOff.h"} = 1; + + my $getter = $getterContentHead; + $getter =~ s/IMPL->//; + $getter =~ s/\(//; + my $updater = "update" . $codeGenerator->WK_ucfirst($getter); + $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create(IMPL, $getterContentHead$getterContentTail, &${implClassNameWithNamespace}::$updater"; + $getterContentTail .= "))"; + } elsif ($idlTypeWithNamespace =~ /SVGStaticListPropertyTearOff/) { + my $extraImp = "WebCore::GetOwnerElementForType<$implClassNameWithNamespace, WebCore::IsDerivedFromSVGElement<$implClassNameWithNamespace>::value>::ownerElement(IMPL), "; + $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($extraImp$getterContentHead"; + $getterContentTail .= ")))"; + } elsif ($idlTypeWithNamespace =~ /SVGPointList/) { + $getterContentHead = "kit(WTF::getPtr($getterContentHead"; + $getterContentTail .= "))"; + } else { + $getterContentHead = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($getterContentHead"; + $getterContentTail .= ")))"; + } } else { $getterContentHead = "kit(WTF::getPtr($getterContentHead"; $getterContentTail .= "))"; @@ -1381,24 +1406,31 @@ sub GenerateImplementation push(@implContent, " $svgPropertyType& podImpl = IMPL->propertyReference();\n"); my $ec = $hasSetterException ? ", ec" : ""; push(@implContent, " $exceptionInit\n") if $hasSetterException; - push(@implContent, " podImpl.$coreSetterName($arg$ec);\n"); + + # Special case for DOMSVGNumber + if ($svgPropertyType eq "float") { + push(@implContent, " podImpl = $arg;\n"); + } else { + # FIXME: Special case for DOMSVGLength. We do need Custom code support for this. + if ($svgPropertyType eq "WebCore::SVGLength" and $attributeName eq "value") { + push(@implContent, " podImpl.$coreSetterName($arg, IMPL->contextElement()$ec);\n"); + } else { + push(@implContent, " podImpl.$coreSetterName($arg$ec);\n"); + } + } + if ($hasSetterException) { push(@implContent, " if (!ec)\n"); push(@implContent, " IMPL->commitChange();\n"); push(@implContent, " $exceptionRaiseOnError\n"); } else { - push(@implContent, " IMPL->commitChange();\n"); + push(@implContent, " IMPL->commitChange();\n"); } } elsif ($svgListPropertyType) { $getterContentHead = "$getterExpressionPrefix"; push(@implContent, " IMPL->$coreSetterName($arg);\n"); } elsif ($podType) { - # Special case for DOMSVGNumber - if ($podType eq "float") { - push(@implContent, " *IMPL = $arg;\n"); - } else { - push(@implContent, " IMPL->$coreSetterName($arg);\n"); - } + push(@implContent, " IMPL->$coreSetterName($arg);\n"); } else { my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); my $ec = $hasSetterException ? ", ec" : ""; @@ -1519,8 +1551,8 @@ sub GenerateImplementation my $svgMatrixInverse = ($podType and $podType eq "AffineTransform" and $functionName eq "inverse"); my $svgLengthConvertToSpecifiedUnits = ($svgPropertyType and $svgPropertyType eq "WebCore::SVGLength" and $functionName eq "convertToSpecifiedUnits"); + push(@parameterNames, "IMPL->contextElement()") if $svgLengthConvertToSpecifiedUnits; push(@parameterNames, "ec") if $raisesExceptions and !($svgMatrixRotateFromVector || $svgMatrixInverse); - push(@parameterNames, "0 /* FIXME */") if $svgLengthConvertToSpecifiedUnits; # Handle arguments that are 'SVGProperty' based (SVGAngle/SVGLength). We need to convert from SVGPropertyTearOff<Type>* to Type, # to be able to call the desired WebCore function. If the conversion fails, we can't extract Type and need to raise an exception. @@ -1533,8 +1565,7 @@ sub GenerateImplementation next if not $codeGenerator->IsSVGTypeNeedingTearOff($idlType) or $implClassName =~ /List$/; my $implGetter = GetObjCTypeGetter($paramName, $idlType); - my $idlTypeWithNamespace = "WebCore::" . $codeGenerator->GetSVGTypeNeedingTearOff($idlType); - $idlTypeWithNamespace =~ s/</\<WebCore::/; + my $idlTypeWithNamespace = GetSVGTypeWithNamespace($idlType); push(@functionContent, " $idlTypeWithNamespace* ${paramName}Core = $implGetter;\n"); push(@functionContent, " if (!${paramName}Core) {\n"); @@ -1555,7 +1586,7 @@ sub GenerateImplementation if ($svgPropertyType) { push(@functionContent, " $svgPropertyType& podImpl = IMPL->propertyReference();\n"); - $content = "podImpl.$content;\n IMPL->commitChange()"; + $content = "podImpl.$content"; } else { $content = $caller . "->$content"; } @@ -1579,9 +1610,14 @@ sub GenerateImplementation if ($raisesExceptions) { push(@functionContent, " $exceptionInit\n"); push(@functionContent, " $content;\n"); + if ($svgPropertyType) { + push(@functionContent, " if (!ec)\n"); + push(@functionContent, " IMPL->commitChange();\n"); + } push(@functionContent, " $exceptionRaiseOnError\n"); } else { push(@functionContent, " $content;\n"); + push(@functionContent, " IMPL->commitChange()\n") if $svgPropertyType; } } elsif (defined $needsCustom{"NodeToReturn"}) { # Special case the insertBefore, replaceChild, removeChild @@ -1603,9 +1639,7 @@ sub GenerateImplementation } else { if (ConversionNeeded($function->signature->type)) { if ($codeGenerator->IsSVGTypeNeedingTearOff($function->signature->type) and not $implClassName =~ /List$/) { - my $idlType = $function->signature->type; - my $idlTypeWithNamespace = "WebCore::" . $codeGenerator->GetSVGTypeNeedingTearOff($idlType); - $idlTypeWithNamespace =~ s/</\<WebCore::/; + my $idlTypeWithNamespace = GetSVGTypeWithNamespace($function->signature->type); $content = "kit(WTF::getPtr(${idlTypeWithNamespace}::create($content)))"; } elsif ($codeGenerator->IsPodType($function->signature->type)) { $content = "kit($content)"; diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index cfb8a6d..2a76692 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -130,22 +130,13 @@ sub GenerateModule $module = $dataNode->module; } -sub AvoidInclusionOfType -{ - my $type = shift; - - # Special case: SVGRect.h / SVGPoint.h / SVGNumber.h / SVGMatrix.h do not exist. - return 1 if $type eq "SVGRect" or $type eq "SVGPoint" or $type eq "SVGNumber" or $type eq "SVGMatrix"; - return 0; -} - sub AddIncludesForType { my $type = $codeGenerator->StripModule(shift); # When we're finished with the one-file-per-class # reorganization, we won't need these special cases. - if (!$codeGenerator->IsPrimitiveType($type) and !AvoidInclusionOfType($type) and $type ne "Date") { + if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->AvoidInclusionOfType($type) and $type ne "Date") { # default, include the same named file $implIncludes{GetV8HeaderName(${type})} = 1; @@ -231,12 +222,13 @@ sub GetSVGPropertyTypes my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implType); if ($svgNativeType =~ /SVGPropertyTearOff/) { $svgPropertyType = $svgWrappedNativeType; - $implIncludes{"SVGAnimatedPropertyTearOff.h"} = 1, - } elsif ($svgNativeType =~ /SVGListPropertyTearOff/) { + $implIncludes{"SVGAnimatedPropertyTearOff.h"} = 1; + } elsif ($svgNativeType =~ /SVGListPropertyTearOff/ or $svgNativeType =~ /SVGStaticListPropertyTearOff/) { $svgListPropertyType = $svgWrappedNativeType; - $implIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1, + $implIncludes{"SVGAnimatedListPropertyTearOff.h"} = 1; } + $svgPropertyType = "SVGPoint" if $svgPropertyType eq "FloatPoint"; return ($svgPropertyType, $svgListPropertyType, $svgNativeType); } @@ -280,7 +272,17 @@ sub GenerateHeader push(@headerContent, "\nnamespace WebCore {\n"); push(@headerContent, "\ntemplate<typename PODType> class V8SVGPODTypeWrapper;\n") if $podType; push(@headerContent, "\ntemplate<typename PropertyType> class SVGPropertyTearOff;\n") if $svgPropertyType; +<<<<<<< HEAD push(@headerContent, "\ntemplate<typename PropertyType> class SVGListPropertyTearOff;\n") if $svgListPropertyType; +======= + if ($svgListPropertyType) { + if ($svgListPropertyType =~ /SVGStaticListPropertyTearOff/) { + push(@headerContent, "\ntemplate<typename PropertyType> class SVGStaticListPropertyTearOff;\n"); + } else { + push(@headerContent, "\ntemplate<typename PropertyType> class SVGListPropertyTearOff;\n"); + } + } +>>>>>>> webkit.org at r71558 push(@headerContent, "\nclass FloatRect;\n") if $svgPropertyType && $svgPropertyType eq "FloatRect"; push(@headerContent, "\nclass $className {\n"); @@ -479,7 +481,7 @@ sub GetHeaderClassInclude if ($className =~ /SVGPathSeg/) { $className =~ s/Abs|Rel//; } - return "" if (AvoidInclusionOfType($className)); + return "" if ($codeGenerator->AvoidInclusionOfType($className)); return "DeprecatedSVGAnimatedTemplate.h" if $codeGenerator->IsSVGAnimatedType($className) and !$codeGenerator->IsSVGNewStyleAnimatedType($className); return "${className}.h"; } @@ -728,7 +730,7 @@ sub GenerateNormalAttrGetter $attrIsPodType = 0; } - my $getterStringUsesImp = $implClassName ne "float"; + my $getterStringUsesImp = $implClassName ne "SVGNumber"; my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implClassName); # Getter @@ -761,8 +763,12 @@ END push(@implContentDecls, <<END); $svgNativeType* wrapper = V8${implClassName}::toNative(info.Holder()); $svgWrappedNativeType& impInstance = wrapper->propertyReference(); +END + if ($getterStringUsesImp) { + push(@implContentDecls, <<END); $svgWrappedNativeType* imp = &impInstance; END + } } } elsif ($attrExt->{"v8OnProto"} || $attrExt->{"V8DisallowShadowing"}) { if ($interfaceName eq "DOMWindow") { @@ -928,8 +934,29 @@ END } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($attrType) and not $implClassName =~ /List$/) { $implIncludes{"V8$attrType.h"} = 1; $implIncludes{"SVGPropertyTearOff.h"} = 1; +<<<<<<< HEAD my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); push(@implContentDecls, " return toV8(WTF::getPtr(${svgNativeType}::create($result)));\n"); +======= + my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); + if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($attrType) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { + $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassName, /; + $implIncludes{"SVGStaticPropertyTearOff.h"} = 1; + + my $getter = $result; + $getter =~ s/imp->//; + $getter =~ s/\(\)//; + my $updater = "update" . $codeGenerator->WK_ucfirst($getter); + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(imp, $result, &${implClassName}::$updater)));\n"); + } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { + my $extraImp = "GetOwnerElementForType<$implClassName, IsDerivedFromSVGElement<$implClassName>::value>::ownerElement(imp), "; + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create($extraImp$result)));\n"); + } elsif ($tearOffType =~ /SVGPointList/) { + push(@implContentDecls, " return toV8(WTF::getPtr($result));\n"); + } else { + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create($result)));\n"); + } +>>>>>>> webkit.org at r71558 } elsif ($attrIsPodType) { $implIncludes{"V8${attrType}.h"} = 1; push(@implContentDecls, " return toV8(wrapper.release().get());\n"); @@ -1071,7 +1098,7 @@ END push(@implContentDecls, " ExceptionCode ec = 0;\n"); } - if ($implClassName eq "float") { + if ($implClassName eq "SVGNumber") { push(@implContentDecls, " *imp = $result;\n"); } else { if ($attribute->signature->type eq "EventListener") { @@ -1361,11 +1388,15 @@ END if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { push(@implContentDecls, <<END); - OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, $numParameters)); + OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, $numParameters)); + size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; + OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize)); if (!callStack) return v8::Undefined(); END + $implIncludes{"ScriptArguments.h"} = 1; $implIncludes{"ScriptCallStack.h"} = 1; + $implIncludes{"ScriptCallStackFactory.h"} = 1; } if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) { push(@implContentDecls, <<END); @@ -2673,9 +2704,7 @@ sub GetNativeTypeForConversions my $dataNode = shift; my $type = shift; - $type = "FloatPoint" if $type eq "SVGPoint"; $type = "AffineTransform" if $type eq "SVGMatrix"; - $type = "float" if $type eq "SVGNumber"; $type = "V8SVGPODTypeWrapper<$type>" if $dataNode->extendedAttributes->{"PODType"}; $type = $codeGenerator->GetSVGTypeNeedingTearOff($type) if $codeGenerator->IsSVGTypeNeedingTearOff($type); return $type; @@ -2788,8 +2817,8 @@ sub GenerateFunctionCallString() if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { $functionString .= ", " if $index; - $functionString .= "callStack.get()"; - $index++; + $functionString .= "scriptArguments.release(), callStack.release()"; + $index += 2; } if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { @@ -2944,7 +2973,6 @@ sub IsRefPtrType return 0 if $type eq "unsigned"; return 0 if $type eq "unsigned long"; return 0 if $type eq "unsigned short"; - return 0 if $type eq "SVGAnimatedPoints"; return 1; } @@ -2977,11 +3005,8 @@ sub GetNativeType return "bool" if $type eq "boolean"; return "String" if $type eq "DOMString"; return "Range::CompareHow" if $type eq "CompareHow"; - return "FloatPoint" if $type eq "SVGPoint"; return "AffineTransform" if $type eq "SVGMatrix"; return "SVGTransform" if $type eq "SVGTransform"; - return "float" if $type eq "SVGNumber"; - return "SVGPreserveAspectRatio" if $type eq "SVGPreserveAspectRatio"; return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType"; return "DOMTimeStamp" if $type eq "DOMTimeStamp"; return "unsigned" if $type eq "unsigned int"; @@ -3032,8 +3057,6 @@ sub BasicTypeCanFailConversion my $type = GetTypeFromSignature($signature); return 1 if $type eq "SVGMatrix"; - return 1 if $type eq "SVGPoint"; - return 1 if $type eq "SVGPreserveAspectRatio"; return 1 if $type eq "SVGTransform"; return 0; } @@ -3063,7 +3086,6 @@ sub JSValueToNative return "$value" if $type eq "JSObject"; return "$value->BooleanValue()" if $type eq "boolean"; return "static_cast<$type>($value->NumberValue())" if $type eq "float" or $type eq "double"; - return "$value->NumberValue()" if $type eq "SVGNumber"; return "toInt32($value${maybeOkParam})" if $type eq "long"; return "toUInt32($value${maybeOkParam})" if $type eq "unsigned long" or $type eq "unsigned short"; @@ -3097,10 +3119,6 @@ sub JSValueToNative $implIncludes{"FloatRect.h"} = 1; } - if ($type eq "SVGPoint") { - $implIncludes{"FloatPoint.h"} = 1; - } - # Default, assume autogenerated type conversion routines if ($type eq "EventTarget") { $implIncludes{"V8Node.h"} = 1; @@ -3492,7 +3510,6 @@ sub IsSVGListTypeNeedingSpecialHandling { my $className = shift; - return 1 if $className eq "SVGPointList"; return 1 if $className eq "SVGTransformList"; return 0; diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index 5236267..7e06068 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -31,7 +31,9 @@ #include "JSTestObj.h" #include "JSlog.h" #include "KURL.h" +#include "ScriptArguments.h" #include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" #include "SerializedScriptValue.h" #include "TestObj.h" #include <runtime/Error.h> @@ -994,12 +996,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(Ex JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; - ScriptCallStack callStack(exec, 1); + OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1)); + size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; + OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize)); log* intArg = tolog(exec->argument(0)); if (exec->hadException()) return JSValue::encode(jsUndefined()); - imp->customArgsAndException(intArg, &callStack, ec); + imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec); setDOMException(exec, ec); return JSValue::encode(jsUndefined()); } diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 4be1177..4c921bb 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -26,7 +26,9 @@ #include "IDBBindingUtilities.h" #include "IDBKey.h" #include "RuntimeEnabledFeatures.h" +#include "ScriptArguments.h" #include "ScriptCallStack.h" +#include "ScriptCallStackFactory.h" #include "SerializedScriptValue.h" #include "V8Binding.h" #include "V8BindingMacros.h" @@ -715,11 +717,13 @@ static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments& TestObj* imp = V8TestObj::toNative(args.Holder()); ExceptionCode ec = 0; { - OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1)); + OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1)); + size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; + OwnPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize)); if (!callStack) return v8::Undefined(); EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); - imp->customArgsAndException(intArg, callStack.get(), ec); + imp->customArgsAndException(intArg, scriptArguments.release(), callStack.release(), ec); if (UNLIKELY(ec)) goto fail; return v8::Handle<v8::Value>(); |