Title: [93809] trunk/Source/WebCore
Revision
93809
Author
[email protected]
Date
2011-08-25 12:44:06 -0700 (Thu, 25 Aug 2011)

Log Message

use strict in CodeGeneratorJS and CodeGeneratorV8
https://bugs.webkit.org/show_bug.cgi?id=66915

Reviewed by Darin Adler.

Making these files "use strict" makes changing them less
time-consuming and error-prone, and helps avoid accidentally
adding dead code (added a FIXME for one such case).

No expected change in behavior.

* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForType):
(GenerateParametersCheckExpression):
(GenerateFunctionParametersCheck):
(GenerateImplementation):
(GenerateImplementationFunctionCall):
(NativeToJSValue):
(GenerateHashValue):
* bindings/scripts/CodeGeneratorV8.pm:
(AddIncludesForType):
(GenerateHeaderNamedAndIndexedPropertyAccessors):
(GenerateNormalAttrSetter):
(GetFunctionTemplateCallbackName):
(GenerateNewFunctionTemplate):
(GenerateParametersCheckExpression):
(GenerateFunctionParametersCheck):
(GenerateImplementation):
():

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (93808 => 93809)


--- trunk/Source/WebCore/ChangeLog	2011-08-25 19:21:41 UTC (rev 93808)
+++ trunk/Source/WebCore/ChangeLog	2011-08-25 19:44:06 UTC (rev 93809)
@@ -1,3 +1,35 @@
+2011-08-25  Adam Klein  <[email protected]>
+
+        use strict in CodeGeneratorJS and CodeGeneratorV8
+        https://bugs.webkit.org/show_bug.cgi?id=66915
+
+        Reviewed by Darin Adler.
+
+        Making these files "use strict" makes changing them less
+        time-consuming and error-prone, and helps avoid accidentally
+        adding dead code (added a FIXME for one such case).
+
+        No expected change in behavior.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (AddIncludesForType):
+        (GenerateParametersCheckExpression):
+        (GenerateFunctionParametersCheck):
+        (GenerateImplementation):
+        (GenerateImplementationFunctionCall):
+        (NativeToJSValue):
+        (GenerateHashValue):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (AddIncludesForType):
+        (GenerateHeaderNamedAndIndexedPropertyAccessors):
+        (GenerateNormalAttrSetter):
+        (GetFunctionTemplateCallbackName):
+        (GenerateNewFunctionTemplate):
+        (GenerateParametersCheckExpression):
+        (GenerateFunctionParametersCheck):
+        (GenerateImplementation):
+        ():
+
 2011-08-25  Dean Jackson  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=21586

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (93808 => 93809)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-08-25 19:21:41 UTC (rev 93808)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2011-08-25 19:44:06 UTC (rev 93809)
@@ -26,6 +26,10 @@
 
 package CodeGeneratorJS;
 
+use strict;
+
+my ($codeGenerator, $IMPL, $HEADER, $DEPS);
+
 my $module = "";
 my $outputDir = "";
 my $writeDependencies = 0;
@@ -281,7 +285,7 @@
     if ($codeGenerator->IsPrimitiveType($type) or $codeGenerator->AvoidInclusionOfType($type)
         or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array") {
     } elsif ($type =~ /SVGPathSeg/) {
-        $joinedName = $type;
+        my $joinedName = $type;
         $joinedName =~ s/Abs|Rel//;
         $includesRef->{"${joinedName}.h"} = 1;
     } elsif ($type eq "XPathNSResolver") {
@@ -1182,7 +1186,7 @@
     push(@andExpression, "argsCount == $numParameters");
     my $parameterIndex = 0;
     my %usedArguments = ();
-    foreach $parameter (@{$function->parameters}) {
+    foreach my $parameter (@{$function->parameters}) {
         last if $parameterIndex >= $numParameters;
         my $value = "arg$parameterIndex";
         my $type = $codeGenerator->StripModule($parameter->type);
@@ -1217,7 +1221,7 @@
     my $numParameters = 0;
     my @neededArguments = ();
 
-    foreach $parameter (@{$function->parameters}) {
+    foreach my $parameter (@{$function->parameters}) {
         if ($parameter->extendedAttributes->{"Optional"}) {
             my ($_expression_, @usedArguments) = GenerateParametersCheckExpression($numParameters, $function);
             push(@orExpression, $_expression_);
@@ -1312,13 +1316,13 @@
 
     # - Add all constants
     if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) {
-        $hashSize = $numConstants;
-        $hashName = $className . "ConstructorTable";
+        my $hashSize = $numConstants;
+        my $hashName = $className . "ConstructorTable";
 
-        @hashKeys = ();
-        @hashValue1 = ();
-        @hashValue2 = ();
-        @hashSpecials = ();
+        my @hashKeys = ();
+        my @hashValue1 = ();
+        my @hashValue2 = ();
+        my @hashSpecials = ();
 
         # FIXME: we should not need a function for every constant.
         foreach my $constant (@{$dataNode->constants}) {
@@ -1342,13 +1346,13 @@
     }
 
     # - Add functions and constants to a hashtable definition
-    $hashSize = $numFunctions + $numConstants;
-    $hashName = $className . "PrototypeTable";
+    my $hashSize = $numFunctions + $numConstants;
+    my $hashName = $className . "PrototypeTable";
 
-    @hashKeys = ();
-    @hashValue1 = ();
-    @hashValue2 = ();
-    @hashSpecials = ();
+    my @hashKeys = ();
+    my @hashValue1 = ();
+    my @hashValue2 = ();
+    my @hashSpecials = ();
 
     # FIXME: we should not need a function for every constant.
     foreach my $constant (@{$dataNode->constants}) {
@@ -1801,6 +1805,7 @@
                             }
                             push(@implContent, "    // Shadowing a built-in constructor\n");
                             if ($interfaceName eq "DOMWindow" && $className eq "JSblah") {
+                                # FIXME: This branch never executes and should be removed.
                                 push(@implContent, "    static_cast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n");
                             } else {
                                 push(@implContent, "    static_cast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n");
@@ -1892,7 +1897,7 @@
                 if ($interfaceName eq "DOMWindow") {
                     push(@implContent, "    static_cast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n");
                 } else {
-                    push(@implContent, "    static_cast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n");
+                    die "No way to handle interface with ReplaceableConstructor extended attribute: $interfaceName";
                 }
                 push(@implContent, "}\n\n");
             }        
@@ -2519,7 +2524,7 @@
         push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, $functionString, "castedThis") . ";\n");
         push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
 
-        $callWith = $function->signature->extendedAttributes->{"CallWith"};
+        my $callWith = $function->signature->extendedAttributes->{"CallWith"};
         if ($callWith and $callWith eq "ScriptState") {
             push(@implContent, $indent . "if (exec->hadException())\n");
             push(@implContent, $indent . "    return JSValue::encode(jsUndefined());\n");
@@ -2736,7 +2741,7 @@
         }
     } elsif ($type =~ /SVGPathSeg/) {
         $implIncludes{"JS$type.h"} = 1;
-        $joinedName = $type;
+        my $joinedName = $type;
         $joinedName =~ s/Abs|Rel//;
         $implIncludes{"$joinedName.h"} = 1;
     } elsif ($type eq "SerializedScriptValue" or $type eq "any") {
@@ -2916,7 +2921,7 @@
 {
     my $object = shift;
 
-    @chars = split(/ */, $_[0]);
+    my @chars = split(/ */, $_[0]);
 
     # This hash is designed to work on 16-bit chunks at a time. But since the normal case
     # (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (93808 => 93809)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-08-25 19:21:41 UTC (rev 93808)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-08-25 19:44:06 UTC (rev 93809)
@@ -26,8 +26,12 @@
 
 package CodeGeneratorV8;
 
+use strict;
+
 use Digest::MD5;
 
+my ($codeGenerator, $IMPL, $HEADER);
+
 my $module = "";
 my $outputDir = "";
 my $outputHeadersDir = "";
@@ -35,6 +39,7 @@
 my @headerContent = ();
 my @implContentHeader = ();
 my @implFixedHeader = ();
+my @implHeaderContent = ();
 my @implContent = ();
 my @implContentDecls = ();
 my %implIncludes = ();
@@ -133,7 +138,7 @@
         $implIncludes{GetV8HeaderName(${type})} = 1;
 
         if ($type =~ /SVGPathSeg/) {
-            $joinedName = $type;
+            my $joinedName = $type;
             $joinedName =~ s/Abs|Rel//;
             $implIncludes{"${joinedName}.h"} = 1;
         }
@@ -534,8 +539,8 @@
         $hasCustomNamedGetter = 1;
     }
     if ($interfaceName eq "DOMWindow") {
-        $hasCustomDeleterr = 0;
-        $hasEnumerator = 0;
+        $hasCustomDeleters = 0;
+        $hasCustomEnumerator = 0;
     }
     if ($interfaceName eq "HTMLAppletElement" || $interfaceName eq "HTMLEmbedElement" || $interfaceName eq "HTMLObjectElement") {
         $hasCustomNamedGetter = 1;
@@ -925,6 +930,7 @@
 
     $implIncludes{"V8BindingMacros.h"} = 1;
 
+    my $attrName = $attribute->signature->name;
     my $attrExt = $attribute->signature->extendedAttributes;
 
     my $conditionalString = GenerateConditionalString($attribute->signature);
@@ -1077,8 +1083,8 @@
 
 sub GetFunctionTemplateCallbackName
 {
-    $function = shift;
-    $interfaceName = shift;
+    my $function = shift;
+    my $interfaceName = shift;
 
     my $name = $function->signature->name;
 
@@ -1096,9 +1102,9 @@
 
 sub GenerateNewFunctionTemplate
 {
-    $function = shift;
-    $interfaceName = shift;
-    $signature = shift;
+    my $function = shift;
+    my $interfaceName = shift;
+    my $signature = shift;
 
     my $callback = GetFunctionTemplateCallbackName($function, $interfaceName);
     return "v8::FunctionTemplate::New($callback, v8::Handle<v8::Value>(), $signature)";
@@ -1142,7 +1148,7 @@
     my @andExpression = ();
     push(@andExpression, "args.Length() == $numParameters");
     my $parameterIndex = 0;
-    foreach $parameter (@{$function->parameters}) {
+    foreach my $parameter (@{$function->parameters}) {
         last if $parameterIndex >= $numParameters;
         my $value = "args[$parameterIndex]";
         my $type = GetTypeFromSignature($parameter);
@@ -1173,7 +1179,7 @@
 
     my @orExpression = ();
     my $numParameters = 0;
-    foreach $parameter (@{$function->parameters}) {
+    foreach my $parameter (@{$function->parameters}) {
         if ($parameter->extendedAttributes->{"Optional"}) {
             push(@orExpression, GenerateParametersCheckExpression($numParameters, $function));
         }
@@ -1790,10 +1796,9 @@
     my $hasConstructors = 0;
     my $serializedAttribute;
     # Generate property accessors for attributes.
-    for ($index = 0; $index < @{$dataNode->attributes}; $index++) {
-        $attribute = @{$dataNode->attributes}[$index];
-        $attrName = $attribute->signature->name;
-        $attrType = $attribute->signature->type;
+    for (my $index = 0; $index < @{$dataNode->attributes}; $index++) {
+        my $attribute = @{$dataNode->attributes}[$index];
+        my $attrType = $attribute->signature->type;
 
         # Generate special code for the constructor attributes.
         if ($attrType =~ /Constructor$/) {
@@ -1908,8 +1913,8 @@
     }
 
     # Setup table of standard callback functions
-    $num_callbacks = 0;
-    $has_callbacks = 0;
+    my $num_callbacks = 0;
+    my $has_callbacks = 0;
     foreach my $function (@{$dataNode->functions}) {
         # Only one table entry is needed for overloaded methods:
         next if $function->{overloadIndex} > 1;
@@ -2078,7 +2083,7 @@
     GenerateImplementationMasqueradesAsUndefined($dataNode);
 
     # Define our functions with Set() or SetAccessor()
-    $total_functions = 0;
+    my $total_functions = 0;
     foreach my $function (@{$dataNode->functions}) {
         # Only one accessor is needed for overloaded methods:
         next if $function->{overloadIndex} > 1;
@@ -2108,7 +2113,7 @@
         my $conditional = "";
         if ($attrExt->{"EnabledAtRuntime"}) {
             # Only call Set()/SetAccessor() if this method should be enabled
-            $enable_function = GetRuntimeEnableFunctionName($function->signature);
+            my $enable_function = GetRuntimeEnableFunctionName($function->signature);
             $conditional = "if (${enable_function}())\n        ";
         }
 
@@ -2616,8 +2621,8 @@
 
 sub HasCustomToV8Implementation {
     # FIXME: This subroutine is lame. Probably should be an .idl attribute (CustomToV8)?
-    $dataNode = shift;
-    $interfaceName = shift;
+    my $dataNode = shift;
+    my $interfaceName = shift;
 
     # We generate a custom converter (but JSC doesn't) for the following:
     return 1 if $interfaceName eq "CSSStyleSheet";
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to