Title: [206090] trunk/Source/WebCore
Revision
206090
Author
nael.ouedra...@crf.canon.fr
Date
2016-09-19 02:00:38 -0700 (Mon, 19 Sep 2016)

Log Message

JSDOMBindings' toArguments() should return a more descriptive object
https://bugs.webkit.org/show_bug.cgi?id=161793

Reviewed by Youenn Fablet.

Replace std::pair with new VariadicHelperResult class with more
readable members names.

No additional tests required.

* bindings/js/JSDOMBinding.h:
(WebCore::VariadicHelper::Result::Result):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheck):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod12):
(WebCore::jsTestObjPrototypeFunctionVariadicStringMethod):
(WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod):
(WebCore::jsTestObjPrototypeFunctionVariadicNodeMethod):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206089 => 206090)


--- trunk/Source/WebCore/ChangeLog	2016-09-19 07:23:53 UTC (rev 206089)
+++ trunk/Source/WebCore/ChangeLog	2016-09-19 09:00:38 UTC (rev 206090)
@@ -1,3 +1,25 @@
+2016-09-19  Nael Ouedraogo  <nael.ouedra...@crf.canon.fr>
+
+        JSDOMBindings' toArguments() should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=161793
+
+        Reviewed by Youenn Fablet.
+
+        Replace std::pair with new VariadicHelperResult class with more
+        readable members names.
+
+        No additional tests required.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::VariadicHelper::Result::Result):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateParametersCheck):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod12):
+        (WebCore::jsTestObjPrototypeFunctionVariadicStringMethod):
+        (WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod):
+        (WebCore::jsTestObjPrototypeFunctionVariadicNodeMethod):
+
 2016-09-18  Alex Christensen  <achristen...@webkit.org>
 
         Remove unnecessary String allocations in URLParser

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (206089 => 206090)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-09-19 07:23:53 UTC (rev 206089)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-09-19 09:00:38 UTC (rev 206090)
@@ -356,7 +356,16 @@
 struct VariadicHelper : public VariadicHelperBase<JSClass, DOMClass> {
     using Item = typename VariadicHelperBase<JSClass, DOMClass>::Item;
     using Container = Vector<Item>;
-    using Result = typename std::pair<size_t, Optional<Container>>;
+
+    struct Result {
+        Result(size_t argumentIndex, Optional<Container>&& arguments)
+            : argumentIndex(argumentIndex)
+            , arguments(WTFMove(arguments))
+        {
+        }
+        size_t argumentIndex;
+        Optional<Container> arguments;
+    };
 };
 
 template<typename VariadicHelper> typename VariadicHelper::Result toArguments(JSC::ExecState&, size_t startIndex = 0);

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (206089 => 206090)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-09-19 07:23:53 UTC (rev 206089)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-09-19 09:00:38 UTC (rev 206090)
@@ -4010,10 +4010,10 @@
                 push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
             }
             else {
-                push(@$outputArray, "    if (!$name.second)\n");
-                push(@$outputArray, "        return throwArgumentTypeError(*state, throwScope, $name.first, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n");
+                push(@$outputArray, "    if (!$name.arguments)\n");
+                push(@$outputArray, "        return throwArgumentTypeError(*state, throwScope, $name.argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n");
             }
-            $value = "WTFMove(*$name.second)";
+            $value = "WTFMove($name.arguments.value())";
 
         } elsif ($codeGenerator->IsEnumType($type)) {
             my $className = GetEnumerationClassName($interface, $type);

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (206089 => 206090)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-09-19 07:23:53 UTC (rev 206089)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-09-19 09:00:38 UTC (rev 206090)
@@ -6551,9 +6551,9 @@
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->wrapped();
     auto blobArgs = toArguments<VariadicHelper<JSBlob, Blob>>(*state, 0);
-    if (!blobArgs.second)
-        return throwArgumentTypeError(*state, throwScope, blobArgs.first, "blobArgs", "TestObject", "overloadedMethod", "Blob");
-    impl.overloadedMethod(WTFMove(*blobArgs.second));
+    if (!blobArgs.arguments)
+        return throwArgumentTypeError(*state, throwScope, blobArgs.argumentIndex, "blobArgs", "TestObject", "overloadedMethod", "Blob");
+    impl.overloadedMethod(WTFMove(blobArgs.arguments.value()));
     return JSValue::encode(jsUndefined());
 }
 
@@ -7086,7 +7086,7 @@
     auto tail = toArguments<VariadicHelper<JSC::JSValue, String>>(*state, 1);
     if (UNLIKELY(throwScope.exception()))
         return JSValue::encode(jsUndefined());
-    impl.variadicStringMethod(WTFMove(head), WTFMove(*tail.second));
+    impl.variadicStringMethod(WTFMove(head), WTFMove(tail.arguments.value()));
     return JSValue::encode(jsUndefined());
 }
 
@@ -7109,7 +7109,7 @@
     auto tail = toArguments<VariadicHelper<JSC::JSValue, double>>(*state, 1);
     if (UNLIKELY(throwScope.exception()))
         return JSValue::encode(jsUndefined());
-    impl.variadicDoubleMethod(WTFMove(head), WTFMove(*tail.second));
+    impl.variadicDoubleMethod(WTFMove(head), WTFMove(tail.arguments.value()));
     return JSValue::encode(jsUndefined());
 }
 
@@ -7130,9 +7130,9 @@
     if (UNLIKELY(!head))
         return throwArgumentTypeError(*state, throwScope, 0, "head", "TestObject", "variadicNodeMethod", "Node");
     auto tail = toArguments<VariadicHelper<JSNode, Node>>(*state, 1);
-    if (!tail.second)
-        return throwArgumentTypeError(*state, throwScope, tail.first, "tail", "TestObject", "variadicNodeMethod", "Node");
-    impl.variadicNodeMethod(*head, WTFMove(*tail.second));
+    if (!tail.arguments)
+        return throwArgumentTypeError(*state, throwScope, tail.argumentIndex, "tail", "TestObject", "variadicNodeMethod", "Node");
+    impl.variadicNodeMethod(*head, WTFMove(tail.arguments.value()));
     return JSValue::encode(jsUndefined());
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to