Title: [125261] trunk/Source/WebCore
Revision
125261
Author
[email protected]
Date
2012-08-10 01:46:38 -0700 (Fri, 10 Aug 2012)

Log Message

Moving the common code from CodegeneratorJS/V8.pm to Codegenerator.pm
https://bugs.webkit.org/show_bug.cgi?id=93616

Patch by Vineet Chaudhary <[email protected]> on 2012-08-10
Reviewed by Adam Barth.

IsArrayType() IsConstructorTemplate() IsTypedArrayType() these methods
has the common implementaion for both V8 and JS and can be moved to
common place Codegenerator.pm

No new tests. There should be no behavioural changes.

* bindings/scripts/CodeGenerator.pm: Moved common code here.
(IsArrayType):
(IsConstructorTemplate):
(IsSVGTypeWithWritablePropertiesNeedingTearOff):
(IsTypedArrayType):
* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForType):
(AddClassForwardIfNeeded):
(GenerateHeader):
(GenerateParametersCheckExpression):
(GenerateImplementation):
(NativeToJSValue):
(GenerateConstructorDeclaration):
(GenerateConstructorDefinition):
(IsConstructable):
* bindings/scripts/CodeGeneratorV8.pm:
(AddIncludesForType):
(GenerateHeader):
(GetHeaderClassInclude):
(GenerateParametersCheckExpression):
(GenerateImplementation):
(GetTypeNameOfExternalTypedArray):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125260 => 125261)


--- trunk/Source/WebCore/ChangeLog	2012-08-10 08:16:25 UTC (rev 125260)
+++ trunk/Source/WebCore/ChangeLog	2012-08-10 08:46:38 UTC (rev 125261)
@@ -1,3 +1,39 @@
+2012-08-10  Vineet Chaudhary  <[email protected]>
+
+        Moving the common code from CodegeneratorJS/V8.pm to Codegenerator.pm
+        https://bugs.webkit.org/show_bug.cgi?id=93616
+
+        Reviewed by Adam Barth.
+
+        IsArrayType() IsConstructorTemplate() IsTypedArrayType() these methods
+        has the common implementaion for both V8 and JS and can be moved to
+        common place Codegenerator.pm
+
+        No new tests. There should be no behavioural changes.
+
+        * bindings/scripts/CodeGenerator.pm: Moved common code here.
+        (IsArrayType):
+        (IsConstructorTemplate):
+        (IsSVGTypeWithWritablePropertiesNeedingTearOff):
+        (IsTypedArrayType):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (AddIncludesForType):
+        (AddClassForwardIfNeeded):
+        (GenerateHeader):
+        (GenerateParametersCheckExpression):
+        (GenerateImplementation):
+        (NativeToJSValue):
+        (GenerateConstructorDeclaration):
+        (GenerateConstructorDefinition):
+        (IsConstructable):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (AddIncludesForType):
+        (GenerateHeader):
+        (GetHeaderClassInclude):
+        (GenerateParametersCheckExpression):
+        (GenerateImplementation):
+        (GetTypeNameOfExternalTypedArray):
+
 2012-08-10  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r125230 and r125238.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (125260 => 125261)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2012-08-10 08:16:25 UTC (rev 125260)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2012-08-10 08:46:38 UTC (rev 125261)
@@ -354,6 +354,23 @@
     return 0;
 }
 
+sub IsArrayType
+{
+    my $object = shift;
+    my $type = shift;
+    # FIXME: Add proper support for T[], T[]?, sequence<T>.
+    return $type =~ m/\[\]$/;
+}
+
+sub IsConstructorTemplate
+{
+    my $object = shift;
+    my $dataNode = shift;
+    my $template = shift;
+
+    return $dataNode->extendedAttributes->{"ConstructorTemplate"} && $dataNode->extendedAttributes->{"ConstructorTemplate"} eq $template;
+}
+
 sub IsNumericType
 {
     my $object = shift;
@@ -409,6 +426,17 @@
     return 0;
 }
 
+sub IsTypedArrayType
+{
+    my $object = shift;
+    my $type = shift;
+    return 1 if (($type eq "ArrayBuffer") or ($type eq "ArrayBufferView"));
+    return 1 if (($type eq "Uint8Array") or ($type eq "Uint8ClampedArray") or ($type eq "Uint16Array") or ($type eq "Uint32Array"));
+    return 1 if (($type eq "Int8Array") or ($type eq "Int16Array") or ($type eq "Int32Array"));
+    return 1 if (($type eq "Float32Array") or ($type eq "Float64Array"));
+    return 0;
+}
+
 sub GetSVGTypeNeedingTearOff
 {
     my $object = shift;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (125260 => 125261)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-08-10 08:16:25 UTC (rev 125260)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-08-10 08:46:38 UTC (rev 125261)
@@ -264,7 +264,7 @@
         $includesRef->{"SerializedScriptValue.h"} = 1;
     } elsif ($isCallback) {
         $includesRef->{"JS${type}.h"} = 1;
-    } elsif (IsTypedArrayType($type)) {
+    } elsif ($codeGenerator->IsTypedArrayType($type)) {
         $includesRef->{"<wtf/${type}.h>"} = 1;
     } elsif ($codeGenerator->GetSequenceType($type)) {
     } else {
@@ -315,16 +315,6 @@
     return 0;
 }
 
-sub IsTypedArrayType
-{
-    my $type = shift;
-    return 1 if (($type eq "ArrayBuffer") or ($type eq "ArrayBufferView"));
-    return 1 if (($type eq "Uint8Array") or ($type eq "Uint8ClampedArray") or ($type eq "Uint16Array") or ($type eq "Uint32Array"));
-    return 1 if (($type eq "Int8Array") or ($type eq "Int16Array") or ($type eq "Int32Array"));
-    return 1 if (($type eq "Float32Array") or ($type eq "Float64Array"));
-    return 0;
-}
-
 sub AddTypedefForScriptProfileType
 {
     my $type = shift;
@@ -338,7 +328,7 @@
     my $implClassName = shift;
 
     # SVGAnimatedLength/Number/etc. are typedefs to SVGAnimatedTemplate, so don't use class forwards for them!
-    unless ($codeGenerator->IsSVGAnimatedType($implClassName) or IsScriptProfileType($implClassName) or IsTypedArrayType($implClassName)) {
+    unless ($codeGenerator->IsSVGAnimatedType($implClassName) or IsScriptProfileType($implClassName) or $codeGenerator->IsTypedArrayType($implClassName)) {
         push(@headerContent, "class $implClassName;\n\n");
     # ScriptProfile and ScriptProfileNode are typedefs to JSC::Profile and JSC::ProfileNode.
     } elsif (IsScriptProfileType($implClassName)) {
@@ -705,7 +695,7 @@
     }
 
     if ($hasParent && $dataNode->extendedAttributes->{"JSGenerateToNativeObject"}) {
-        if (IsTypedArrayType($implClassName)) {
+        if ($codeGenerator->IsTypedArrayType($implClassName)) {
             $headerIncludes{"<wtf/$implClassName.h>"} = 1;
         } else {
             $headerIncludes{"$implClassName.h"} = 1;
@@ -739,7 +729,7 @@
     }
 
     AddClassForwardIfNeeded("JSDOMWindowShell") if $interfaceName eq "DOMWindow";
-    AddClassForwardIfNeeded("JSDictionary") if IsConstructorTemplate($dataNode, "Event");
+    AddClassForwardIfNeeded("JSDictionary") if $codeGenerator->IsConstructorTemplate($dataNode, "Event");
 
     # Class declaration
     push(@headerContent, "class $className : public $parentClassName {\n");
@@ -949,7 +939,7 @@
         push(@headerContent, "    }\n");
     }
 
-    if (IsTypedArrayType($implType) and ($implType ne "ArrayBufferView") and ($implType ne "ArrayBuffer")) {
+    if ($codeGenerator->IsTypedArrayType($implType) and ($implType ne "ArrayBufferView") and ($implType ne "ArrayBuffer")) {
         push(@headerContent, "    static const JSC::TypedArrayType TypedArrayStorageType = JSC::");
         push(@headerContent, "TypedArrayInt8") if $implType eq "Int8Array";
         push(@headerContent, "TypedArrayInt16") if $implType eq "Int16Array";
@@ -1274,7 +1264,7 @@
             # For Callbacks only checks if the value is null or object.
             push(@andExpression, "(${value}.isNull() || ${value}.isFunction())");
             $usedArguments{$parameterIndex} = 1;
-        } elsif (IsArrayType($type) || $codeGenerator->GetSequenceType($type)) {
+        } elsif ($codeGenerator->IsArrayType($type) || $codeGenerator->GetSequenceType($type)) {
             # FIXME: Add proper support for T[], T[]?, sequence<T>
             if ($parameter->isNullable) {
                 push(@andExpression, "(${value}.isNull() || (${value}.isObject() && isJSArray(${value})))");
@@ -1665,7 +1655,7 @@
         push(@implContent, "void ${className}::finishCreation(JSGlobalData& globalData)\n");
         push(@implContent, "{\n");
         push(@implContent, "    Base::finishCreation(globalData);\n");
-        if (IsTypedArrayType($implType) and ($implType ne "ArrayBufferView") and ($implType ne "ArrayBuffer")) {
+        if ($codeGenerator->IsTypedArrayType($implType) and ($implType ne "ArrayBufferView") and ($implType ne "ArrayBuffer")) {
             push(@implContent, "    TypedArrayDescriptor descriptor(&${className}::s_info, OBJECT_OFFSETOF(${className}, m_storage), OBJECT_OFFSETOF(${className}, m_storageLength));\n");
             push(@implContent, "    globalData.registerTypedArrayDescriptor(impl(), descriptor);\n");
             push(@implContent, "    m_storage = impl()->data();\n");
@@ -3010,13 +3000,6 @@
     return exists $nativeType{$type};
 }
 
-sub IsArrayType
-{
-    my $type = shift;
-    # FIXME: Add proper support for T[], T[]?, sequence<T>.
-    return $type =~ m/\[\]$/;
-}
-
 sub JSValueToNative
 {
     my $signature = shift;
@@ -3201,7 +3184,7 @@
     } else {
         # Default, include header with same name.
         AddToImplIncludes("JS$type.h", $conditional);
-        if (IsTypedArrayType($type)) {
+        if ($codeGenerator->IsTypedArrayType($type)) {
             AddToImplIncludes("<wtf/$type.h>", $conditional) if not $codeGenerator->SkipIncludeHeader($type);
         } else {
             AddToImplIncludes("$type.h", $conditional) if not $codeGenerator->SkipIncludeHeader($type);
@@ -3553,7 +3536,7 @@
     }
     push(@$outputArray, "};\n\n");
 
-    if (IsConstructorTemplate($dataNode, "Event")) {
+    if ($codeGenerator->IsConstructorTemplate($dataNode, "Event")) {
         push(@$outputArray, "bool fill${interfaceName}Init(${interfaceName}Init&, JSDictionary&);\n\n");
     }
 
@@ -3602,7 +3585,7 @@
     my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor";
     my $numberOfConstructorParameters = $dataNode->extendedAttributes->{"ConstructorParameters"};
     if (!defined $numberOfConstructorParameters) {
-        if (IsConstructorTemplate($dataNode, "Event")) {
+        if ($codeGenerator->IsConstructorTemplate($dataNode, "Event")) {
             $numberOfConstructorParameters = 2;
         } elsif ($dataNode->extendedAttributes->{"Constructor"}) {
             $numberOfConstructorParameters = @{$dataNode->constructor->parameters};
@@ -3664,7 +3647,7 @@
     }
 
     if (IsConstructable($dataNode)) {
-        if (IsConstructorTemplate($dataNode, "Event")) {
+        if ($codeGenerator->IsConstructorTemplate($dataNode, "Event")) {
             $implIncludes{"JSDictionary.h"} = 1;
             $implIncludes{"<runtime/Error.h>"} = 1;
 
@@ -3728,7 +3711,7 @@
 }
 
 END
-        } elsif (IsConstructorTemplate($dataNode, "TypedArray")) {
+        } elsif ($codeGenerator->IsConstructorTemplate($dataNode, "TypedArray")) {
             $implIncludes{"JSArrayBufferViewHelper.h"} = 1;
             my $viewType = $dataNode->extendedAttributes->{"TypedArray"};
             push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n");
@@ -3831,12 +3814,4 @@
     return $dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"JSCustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"NamedConstructor"} || $dataNode->extendedAttributes->{"ConstructorTemplate"};
 }
 
-sub IsConstructorTemplate
-{
-    my $dataNode = shift;
-    my $template = shift;
-
-    return $dataNode->extendedAttributes->{"ConstructorTemplate"} && $dataNode->extendedAttributes->{"ConstructorTemplate"} eq $template;
-}
-
 1;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (125260 => 125261)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-10 08:16:25 UTC (rev 125260)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-10 08:46:38 UTC (rev 125261)
@@ -141,7 +141,7 @@
 
     # When we're finished with the one-file-per-class
     # reorganization, we won't need these special cases.
-    if (IsTypedArrayType($type)) {
+    if ($codeGenerator->IsTypedArrayType($type)) {
         AddToImplIncludes("wtf/${type}.h");
     }
     if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->IsStringType($type) and !$codeGenerator->SkipIncludeHeader($type) and $type ne "Date") {
@@ -337,7 +337,7 @@
 
     push(@headerContent, "\n");
     push(@headerContent, "class FloatRect;\n") if $svgPropertyType && $svgPropertyType eq "FloatRect";
-    push(@headerContent, "class Dictionary;\n") if IsConstructorTemplate($dataNode, "Event");
+    push(@headerContent, "class Dictionary;\n") if $codeGenerator->IsConstructorTemplate($dataNode, "Event");
 
     my $nativeType = GetNativeTypeForConversions($dataNode, $interfaceName);
     if ($dataNode->extendedAttributes->{"NamedConstructor"}) {
@@ -543,7 +543,7 @@
 }
 END
 
-    if (IsConstructorTemplate($dataNode, "Event")) {
+    if ($codeGenerator->IsConstructorTemplate($dataNode, "Event")) {
         push(@headerContent, "\nbool fill${implClassName}Init(${implClassName}Init&, const Dictionary&);\n");
     }
 
@@ -584,7 +584,7 @@
     if ($className =~ /SVGPathSeg/) {
         $className =~ s/Abs|Rel//;
     }
-    return "wtf/${className}.h" if IsTypedArrayType($className);
+    return "wtf/${className}.h" if $codeGenerator->IsTypedArrayType($className);
     return "" if ($codeGenerator->SkipIncludeHeader($className));
     return "${className}.h";
 }
@@ -728,14 +728,6 @@
     return $dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"Constructor"} || $dataNode->extendedAttributes->{"ConstructorTemplate"};
 }
 
-sub IsConstructorTemplate
-{
-    my $dataNode = shift;
-    my $template = shift;
-
-    return $dataNode->extendedAttributes->{"ConstructorTemplate"} && $dataNode->extendedAttributes->{"ConstructorTemplate"} eq $template;
-}
-
 sub GenerateDomainSafeFunctionGetter
 {
     my $function = shift;
@@ -1390,7 +1382,7 @@
         } elsif ($parameter->extendedAttributes->{"Callback"}) {
             # For Callbacks only checks if the value is null or object.
             push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())");
-        } elsif (IsArrayType($type) || $codeGenerator->GetSequenceType($type)) {
+        } elsif ($codeGenerator->IsArrayType($type) || $codeGenerator->GetSequenceType($type)) {
             # FIXME: Add proper support for T[], T[]?, sequence<T>.
             if ($parameter->isNullable) {
                 push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())");
@@ -2515,17 +2507,6 @@
     }
 }
 
-sub IsTypedArrayType
-{
-    my $type = shift;
-    return 1 if (($type eq "ArrayBuffer") or ($type eq "ArrayBufferView"));
-    return 1 if (($type eq "Uint8Array") or ($type eq "Uint8ClampedArray") or ($type eq "Uint16Array") or ($type eq "Uint32Array"));
-    return 1 if (($type eq "Int8Array") or ($type eq "Int16Array") or ($type eq "Int32Array"));
-    return 1 if (($type eq "Float32Array") or ($type eq "Float64Array"));
-    return 0;
-}
-
-
 sub GenerateImplementation
 {
     my $object = shift;
@@ -2798,9 +2779,9 @@
         GenerateNamedConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
     } elsif ($dataNode->extendedAttributes->{"Constructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
         GenerateConstructorCallback($dataNode->constructor, $dataNode, $interfaceName);
-    } elsif (IsConstructorTemplate($dataNode, "Event")) {
+    } elsif ($codeGenerator->IsConstructorTemplate($dataNode, "Event")) {
         GenerateEventConstructorCallback($dataNode, $interfaceName);
-    } elsif (IsConstructorTemplate($dataNode, "TypedArray")) {
+    } elsif ($codeGenerator->IsConstructorTemplate($dataNode, "TypedArray")) {
         GenerateTypedArrayConstructorCallback($dataNode, $interfaceName);
     }
 
@@ -4007,13 +3988,6 @@
     die "TypedArray of unknown type is found";
 }
 
-sub IsArrayType
-{
-    my $type = $codeGenerator->StripModule(shift);
-    # FIXME: Add proper support for T[], T[]?, sequence<T>.
-    return $type =~ m/\[\]$/;
-}
-
 sub IsDOMNodeType
 {
     my $type = shift;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to