Changeset 206090 in webkit


Ignore:
Timestamp:
Sep 19, 2016 2:00:38 AM (8 years ago)
Author:
nael.ouedraogo@crf.canon.fr
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):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206076 r206090  
     12016-09-19  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
     2
     3        JSDOMBindings' toArguments() should return a more descriptive object
     4        https://bugs.webkit.org/show_bug.cgi?id=161793
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Replace std::pair with new VariadicHelperResult class with more
     9        readable members names.
     10
     11        No additional tests required.
     12
     13        * bindings/js/JSDOMBinding.h:
     14        (WebCore::VariadicHelper::Result::Result):
     15        * bindings/scripts/CodeGeneratorJS.pm:
     16        (GenerateParametersCheck):
     17        * bindings/scripts/test/JS/JSTestObj.cpp:
     18        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod12):
     19        (WebCore::jsTestObjPrototypeFunctionVariadicStringMethod):
     20        (WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod):
     21        (WebCore::jsTestObjPrototypeFunctionVariadicNodeMethod):
     22
    1232016-09-18  Alex Christensen  <achristensen@webkit.org>
    224
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r205953 r206090  
    357357    using Item = typename VariadicHelperBase<JSClass, DOMClass>::Item;
    358358    using Container = Vector<Item>;
    359     using Result = typename std::pair<size_t, Optional<Container>>;
     359
     360    struct Result {
     361        Result(size_t argumentIndex, Optional<Container>&& arguments)
     362            : argumentIndex(argumentIndex)
     363            , arguments(WTFMove(arguments))
     364        {
     365        }
     366        size_t argumentIndex;
     367        Optional<Container> arguments;
     368    };
    360369};
    361370
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r206011 r206090  
    40114011            }
    40124012            else {
    4013                 push(@$outputArray, "    if (!$name.second)\n");
    4014                 push(@$outputArray, "        return throwArgumentTypeError(*state, throwScope, $name.first, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n");
    4015             }
    4016             $value = "WTFMove(*$name.second)";
     4013                push(@$outputArray, "    if (!$name.arguments)\n");
     4014                push(@$outputArray, "        return throwArgumentTypeError(*state, throwScope, $name.argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n");
     4015            }
     4016            $value = "WTFMove($name.arguments.value())";
    40174017
    40184018        } elsif ($codeGenerator->IsEnumType($type)) {
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r206011 r206090  
    65526552    auto& impl = castedThis->wrapped();
    65536553    auto blobArgs = toArguments<VariadicHelper<JSBlob, Blob>>(*state, 0);
    6554     if (!blobArgs.second)
    6555         return throwArgumentTypeError(*state, throwScope, blobArgs.first, "blobArgs", "TestObject", "overloadedMethod", "Blob");
    6556     impl.overloadedMethod(WTFMove(*blobArgs.second));
     6554    if (!blobArgs.arguments)
     6555        return throwArgumentTypeError(*state, throwScope, blobArgs.argumentIndex, "blobArgs", "TestObject", "overloadedMethod", "Blob");
     6556    impl.overloadedMethod(WTFMove(blobArgs.arguments.value()));
    65576557    return JSValue::encode(jsUndefined());
    65586558}
     
    70877087    if (UNLIKELY(throwScope.exception()))
    70887088        return JSValue::encode(jsUndefined());
    7089     impl.variadicStringMethod(WTFMove(head), WTFMove(*tail.second));
     7089    impl.variadicStringMethod(WTFMove(head), WTFMove(tail.arguments.value()));
    70907090    return JSValue::encode(jsUndefined());
    70917091}
     
    71107110    if (UNLIKELY(throwScope.exception()))
    71117111        return JSValue::encode(jsUndefined());
    7112     impl.variadicDoubleMethod(WTFMove(head), WTFMove(*tail.second));
     7112    impl.variadicDoubleMethod(WTFMove(head), WTFMove(tail.arguments.value()));
    71137113    return JSValue::encode(jsUndefined());
    71147114}
     
    71317131        return throwArgumentTypeError(*state, throwScope, 0, "head", "TestObject", "variadicNodeMethod", "Node");
    71327132    auto tail = toArguments<VariadicHelper<JSNode, Node>>(*state, 1);
    7133     if (!tail.second)
    7134         return throwArgumentTypeError(*state, throwScope, tail.first, "tail", "TestObject", "variadicNodeMethod", "Node");
    7135     impl.variadicNodeMethod(*head, WTFMove(*tail.second));
     7133    if (!tail.arguments)
     7134        return throwArgumentTypeError(*state, throwScope, tail.argumentIndex, "tail", "TestObject", "variadicNodeMethod", "Node");
     7135    impl.variadicNodeMethod(*head, WTFMove(tail.arguments.value()));
    71367136    return JSValue::encode(jsUndefined());
    71377137}
Note: See TracChangeset for help on using the changeset viewer.