Changeset 205048 in webkit


Ignore:
Timestamp:
Aug 26, 2016 2:34:21 PM (8 years ago)
Author:
Chris Dumez
Message:

REGRESSION(r204028): Fix unused-but-set-variable warning in generated JSNavigator.cpp
https://bugs.webkit.org/show_bug.cgi?id=161252

Reviewed by Ryosuke Niwa.

Improve support for [Conditional] with overloaded operations in the IDL.

No new tests, updated bindings tests.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):
(GeneratePropertiesHashTable):
(getConditionalForFunctionConsideringOverloads):
(GenerateOverloadedFunctionOrConstructor):
(GenerateImplementation):

  • bindings/scripts/test/JS/JSTestGlobalObject.cpp:

(WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation): Deleted.

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjPrototypeFunctionConditionalOverload1):
(WebCore::jsTestObjPrototypeFunctionConditionalOverload2):
(WebCore::jsTestObjPrototypeFunctionConditionalOverload):
(WebCore::jsTestObjPrototypeFunctionEnabledAtRuntimeOperation): Deleted.
(WebCore::jsTestObjConstructorFunctionOverloadedMethod1): Deleted.

  • bindings/scripts/test/TestObj.idl:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205044 r205048  
     12016-08-26  Chris Dumez  <cdumez@apple.com>
     2
     3        REGRESSION(r204028): Fix unused-but-set-variable warning in generated JSNavigator.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=161252
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Improve support for [Conditional] with overloaded operations in the IDL.
     9
     10        No new tests, updated bindings tests.
     11
     12        * bindings/scripts/CodeGeneratorJS.pm:
     13        (GenerateHeader):
     14        (GeneratePropertiesHashTable):
     15        (getConditionalForFunctionConsideringOverloads):
     16        (GenerateOverloadedFunctionOrConstructor):
     17        (GenerateImplementation):
     18        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
     19        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation): Deleted.
     20        * bindings/scripts/test/JS/JSTestObj.cpp:
     21        (WebCore::jsTestObjPrototypeFunctionConditionalOverload1):
     22        (WebCore::jsTestObjPrototypeFunctionConditionalOverload2):
     23        (WebCore::jsTestObjPrototypeFunctionConditionalOverload):
     24        (WebCore::jsTestObjPrototypeFunctionEnabledAtRuntimeOperation): Deleted.
     25        (WebCore::jsTestObjConstructorFunctionOverloadedMethod1): Deleted.
     26        * bindings/scripts/test/TestObj.idl:
     27
    1282016-08-26  Beth Dakin  <bdakin@apple.com>
    229
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r205008 r205048  
    15381538            }
    15391539
    1540             my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature);
     1540            my $conditionalAttribute = getConditionalForFunctionConsideringOverloads($function);
     1541            my $conditionalString = $conditionalAttribute ? $codeGenerator->GenerateConditionalStringFromAttributeValue($conditionalAttribute) : undef;
    15411542            push(@headerContent, "#if ${conditionalString}\n") if $conditionalString;
    15421543            my $functionName = GetFunctionName($interface, $className, $function);
     
    16751676        push(@$hashSpecials, ComputeFunctionSpecial($interface, $function));
    16761677
    1677         my $conditional = $function->signature->extendedAttributes->{"Conditional"};
     1678        my $conditional = getConditionalForFunctionConsideringOverloads($function);
    16781679        if ($conditional) {
    16791680            $conditionals->{$name} = $conditional;
     
    18271828        return @{$tuple}[0] if $matches->(StripNullable($type), $optionality, $isNullable);
    18281829    }
     1830}
     1831
     1832sub getConditionalForFunctionConsideringOverloads
     1833{
     1834    my $function = shift;
     1835
     1836    return $function->signature->extendedAttributes->{"Conditional"} unless $function->{overloads};
     1837
     1838    my %conditions;
     1839    foreach my $overload (@{$function->{overloads}}) {
     1840        if ($overload->signature->extendedAttributes->{"Conditional"}) {
     1841            $conditions{$overload->signature->extendedAttributes->{"Conditional"}} = 1;
     1842        }
     1843    }
     1844    return undef unless keys %conditions;
     1845    return join("|", keys %conditions);
    18291846}
    18301847
     
    19141931    my $maxArgCount = LengthOfLongestFunctionParameterList($function->{overloads});
    19151932
     1933    my $conditionalAttribute = getConditionalForFunctionConsideringOverloads($function);
     1934    my $conditionalString = $conditionalAttribute ? $codeGenerator->GenerateConditionalStringFromAttributeValue($conditionalAttribute) : undef;
     1935    push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
    19161936    if ($isConstructor) {
    19171937        push(@implContent, "template<> EncodedJSValue JSC_HOST_CALL ${className}Constructor::construct(ExecState* state)\n");
     
    19992019        push(@implContent, "    return throwVMTypeError(state);\n")
    20002020    }
    2001     push(@implContent, "}\n\n");
     2021    push(@implContent, "}\n");
     2022    push(@implContent, "#endif\n") if $conditionalString;
     2023    push(@implContent, "\n");
    20022024}
    20032025
     
    22922314            }
    22932315
    2294             my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature);
     2316            my $conditionalAttribute = getConditionalForFunctionConsideringOverloads($function);
     2317            my $conditionalString = $conditionalAttribute ? $codeGenerator->GenerateConditionalStringFromAttributeValue($conditionalAttribute) : undef;
    22952318            push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
    22962319            my $functionName = GetFunctionName($interface, $className, $function);
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp

    r204028 r205048  
    396396#endif
    397397
     398#if ENABLE(TEST_FEATURE)
    398399EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(ExecState* state)
    399400{
     
    411412    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
    412413}
     414#endif
    413415
    414416#if ENABLE(TEST_FEATURE)
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r205008 r205048  
    785785JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunctionWithException(JSC::ExecState*);
    786786JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNeedsCustomElementReactionStack(JSC::ExecState*);
     787#if ENABLE(CONDITION1) || ENABLE(CONDITION2)
     788JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalOverload(JSC::ExecState*);
     789#endif
    787790JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAttachShadowRoot(JSC::ExecState*);
    788791JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToString(JSC::ExecState*);
     
    13801383    { "testPromiseOverloadedFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseOverloadedFunction), (intptr_t) (1) } },
    13811384    { "methodWithNeedsCustomElementReactionStack", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNeedsCustomElementReactionStack), (intptr_t) (0) } },
     1385#if ENABLE(CONDITION1) || ENABLE(CONDITION2)
     1386    { "conditionalOverload", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConditionalOverload), (intptr_t) (1) } },
     1387#else
     1388    { 0, 0, NoIntrinsic, { 0, 0 } },
     1389#endif
    13821390    { "attachShadowRoot", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAttachShadowRoot), (intptr_t) (1) } },
    13831391    { "toString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionToString), (intptr_t) (0) } },
     
    42054213#endif
    42064214
     4215#if ENABLE(TEST_FEATURE)
    42074216EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionEnabledAtRuntimeOperation(ExecState* state)
    42084217{
     
    42204229    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
    42214230}
     4231#endif
    42224232
    42234233EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* state)
     
    59795989#endif
    59805990
     5991#if ENABLE(Condition1)
    59815992EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(ExecState* state)
    59825993{
     
    59946005    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
    59956006}
     6007#endif
    59966008
    59976009EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithClamp(ExecState* state)
     
    65226534}
    65236535
     6536#if ENABLE(CONDITION1)
     6537static inline EncodedJSValue jsTestObjPrototypeFunctionConditionalOverload1(ExecState* state)
     6538{
     6539    JSValue thisValue = state->thisValue();
     6540    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     6541    if (UNLIKELY(!castedThis))
     6542        return throwThisTypeError(*state, "TestObject", "conditionalOverload");
     6543    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     6544    auto& impl = castedThis->wrapped();
     6545    if (UNLIKELY(state->argumentCount() < 1))
     6546        return throwVMError(state, createNotEnoughArgumentsError(state));
     6547    auto str = state->argument(0).toWTFString(state);
     6548    if (UNLIKELY(state->hadException()))
     6549        return JSValue::encode(jsUndefined());
     6550    impl.conditionalOverload(WTFMove(str));
     6551    return JSValue::encode(jsUndefined());
     6552}
     6553
     6554#endif
     6555
     6556#if ENABLE(CONDITION2)
     6557static inline EncodedJSValue jsTestObjPrototypeFunctionConditionalOverload2(ExecState* state)
     6558{
     6559    JSValue thisValue = state->thisValue();
     6560    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     6561    if (UNLIKELY(!castedThis))
     6562        return throwThisTypeError(*state, "TestObject", "conditionalOverload");
     6563    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     6564    auto& impl = castedThis->wrapped();
     6565    if (UNLIKELY(state->argumentCount() < 1))
     6566        return throwVMError(state, createNotEnoughArgumentsError(state));
     6567    auto a = convert<int32_t>(*state, state->argument(0), NormalConversion);
     6568    if (UNLIKELY(state->hadException()))
     6569        return JSValue::encode(jsUndefined());
     6570    impl.conditionalOverload(WTFMove(a));
     6571    return JSValue::encode(jsUndefined());
     6572}
     6573
     6574#endif
     6575
     6576#if ENABLE(CONDITION1) || ENABLE(CONDITION2)
     6577EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalOverload(ExecState* state)
     6578{
     6579    size_t argsCount = std::min<size_t>(1, state->argumentCount());
     6580    if (argsCount == 1) {
     6581        JSValue distinguishingArg = state->uncheckedArgument(0);
     6582#if ENABLE(CONDITION2)
     6583        if (distinguishingArg.isNumber())
     6584            return jsTestObjPrototypeFunctionConditionalOverload2(state);
     6585#endif
     6586#if ENABLE(CONDITION1)
     6587        return jsTestObjPrototypeFunctionConditionalOverload1(state);
     6588#endif
     6589    }
     6590    return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state);
     6591}
     6592#endif
     6593
    65246594EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAttachShadowRoot(ExecState* state)
    65256595{
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r204978 r205048  
    396396#if defined(TESTING_JS)
    397397    [CEReactions] void methodWithNeedsCustomElementReactionStack();
     398#endif
     399
     400#if defined(TESTING_JS)
     401    // Overloading with conditionals.
     402    [Conditional=CONDITION1] void conditionalOverload(DOMString str);
     403    [Conditional=CONDITION2] void conditionalOverload(long a);
    398404#endif
    399405
Note: See TracChangeset for help on using the changeset viewer.