Conditional support in bindings code generator for overloaded functions
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Oct 2013 17:45:42 +0000 (17:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Oct 2013 17:45:42 +0000 (17:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122443

Patch by Philippe Normand <pnormand@igalia.com> on 2013-10-07
Reviewed by Darin Adler.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateOverloadedFunction): Generate conditional for overloaded
function, if it's present in the idl.
(GenerateImplementation): Close the last overloaded function
conditional before generating the distpatch function.
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjConstructorFunctionOverloadedMethod1):
Rebaseline overloaded function tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157048 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

index b2032e280d0e8cffe2691245220a99d0855976a1..eecf9f48de42ef1a5322b1a071b7f4cf73b6d966 100644 (file)
@@ -1,3 +1,19 @@
+2013-10-07  Philippe Normand  <pnormand@igalia.com>
+
+        Conditional support in bindings code generator for overloaded functions
+        https://bugs.webkit.org/show_bug.cgi?id=122443
+
+        Reviewed by Darin Adler.
+
+        * bindings/scripts/CodeGeneratorJS.pm: 
+        (GenerateOverloadedFunction): Generate conditional for overloaded
+        function, if it's present in the idl.
+        (GenerateImplementation): Close the last overloaded function
+        conditional before generating the distpatch function.
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjConstructorFunctionOverloadedMethod1):
+        Rebaseline overloaded function tests.
+
 2013-10-07  Tim Horton  <timothy_horton@apple.com>
 
         -webkit-cross-fade paints SVGs at full opacity during cross-fade
index 67ad9bdb21aee840206f8326ac426551f386858b..1d2200346ddec9b189b84a4650f785c1d008db0f 100644 (file)
@@ -1286,8 +1286,13 @@ END
             $fetchedArguments{$parameterIndex} = 1;
         }
 
+        my $conditionalString = $codeGenerator->GenerateConditionalString($overload->signature);
+        push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
+
         push(@implContent, "    if ($parametersCheck)\n");
         push(@implContent, "        return ${functionName}$overload->{overloadIndex}(exec);\n");
+        push(@implContent, "#endif\n\n") if $conditionalString;
+
     }
     if ($leastNumMandatoryParams >= 1) {
         push(@implContent, "    if (argsCount < $leastNumMandatoryParams)\n");
@@ -2432,13 +2437,13 @@ sub GenerateImplementation
             }
 
             push(@implContent, "}\n\n");
+            push(@implContent, "#endif\n\n") if $conditional;
 
             if (!$isCustom && $isOverloaded && $function->{overloadIndex} == @{$function->{overloads}}) {
                 # Generate a function dispatching call to the rest of the overloads.
                 GenerateOverloadedFunction($function, $interface, $interfaceName);
             }
 
-            push(@implContent, "#endif\n\n") if $conditional;
         }
     }
 
index 479aa5d4365ded103f8e244080db00366d584edc..bda11809fde173e0b175e0a0a08d3e3ab380cbb2 100644 (file)
@@ -2818,21 +2818,27 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod
     return JSValue::encode(jsUndefined());
 }
 
+#endif
+
 EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(ExecState* exec)
 {
     size_t argsCount = exec->argumentCount();
+#if ENABLE(Condition1)
     if (argsCount == 1)
         return jsTestObjConstructorFunctionOverloadedMethod11(exec);
+#endif
+
     JSValue arg0(exec->argument(0));
+#if ENABLE(Condition1)
     if ((argsCount == 1 && (arg0.isUndefinedOrNull() || arg0.isString() || arg0.isObject())))
         return jsTestObjConstructorFunctionOverloadedMethod12(exec);
+#endif
+
     if (argsCount < 1)
         return throwVMError(exec, createNotEnoughArgumentsError(exec));
     return throwVMTypeError(exec);
 }
 
-#endif
-
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithClamp(ExecState* exec)
 {
     JSValue thisValue = exec->hostThisValue();