Changeset 205048 in webkit
- Timestamp:
- Aug 26, 2016 2:34:21 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205044 r205048 1 2016-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 1 28 2016-08-26 Beth Dakin <bdakin@apple.com> 2 29 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r205008 r205048 1538 1538 } 1539 1539 1540 my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); 1540 my $conditionalAttribute = getConditionalForFunctionConsideringOverloads($function); 1541 my $conditionalString = $conditionalAttribute ? $codeGenerator->GenerateConditionalStringFromAttributeValue($conditionalAttribute) : undef; 1541 1542 push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; 1542 1543 my $functionName = GetFunctionName($interface, $className, $function); … … 1675 1676 push(@$hashSpecials, ComputeFunctionSpecial($interface, $function)); 1676 1677 1677 my $conditional = $function->signature->extendedAttributes->{"Conditional"};1678 my $conditional = getConditionalForFunctionConsideringOverloads($function); 1678 1679 if ($conditional) { 1679 1680 $conditionals->{$name} = $conditional; … … 1827 1828 return @{$tuple}[0] if $matches->(StripNullable($type), $optionality, $isNullable); 1828 1829 } 1830 } 1831 1832 sub 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); 1829 1846 } 1830 1847 … … 1914 1931 my $maxArgCount = LengthOfLongestFunctionParameterList($function->{overloads}); 1915 1932 1933 my $conditionalAttribute = getConditionalForFunctionConsideringOverloads($function); 1934 my $conditionalString = $conditionalAttribute ? $codeGenerator->GenerateConditionalStringFromAttributeValue($conditionalAttribute) : undef; 1935 push(@implContent, "#if ${conditionalString}\n") if $conditionalString; 1916 1936 if ($isConstructor) { 1917 1937 push(@implContent, "template<> EncodedJSValue JSC_HOST_CALL ${className}Constructor::construct(ExecState* state)\n"); … … 1999 2019 push(@implContent, " return throwVMTypeError(state);\n") 2000 2020 } 2001 push(@implContent, "}\n\n"); 2021 push(@implContent, "}\n"); 2022 push(@implContent, "#endif\n") if $conditionalString; 2023 push(@implContent, "\n"); 2002 2024 } 2003 2025 … … 2292 2314 } 2293 2315 2294 my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); 2316 my $conditionalAttribute = getConditionalForFunctionConsideringOverloads($function); 2317 my $conditionalString = $conditionalAttribute ? $codeGenerator->GenerateConditionalStringFromAttributeValue($conditionalAttribute) : undef; 2295 2318 push(@implContent, "#if ${conditionalString}\n") if $conditionalString; 2296 2319 my $functionName = GetFunctionName($interface, $className, $function); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
r204028 r205048 396 396 #endif 397 397 398 #if ENABLE(TEST_FEATURE) 398 399 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(ExecState* state) 399 400 { … … 411 412 return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state); 412 413 } 414 #endif 413 415 414 416 #if ENABLE(TEST_FEATURE) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r205008 r205048 785 785 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunctionWithException(JSC::ExecState*); 786 786 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNeedsCustomElementReactionStack(JSC::ExecState*); 787 #if ENABLE(CONDITION1) || ENABLE(CONDITION2) 788 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalOverload(JSC::ExecState*); 789 #endif 787 790 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAttachShadowRoot(JSC::ExecState*); 788 791 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToString(JSC::ExecState*); … … 1380 1383 { "testPromiseOverloadedFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseOverloadedFunction), (intptr_t) (1) } }, 1381 1384 { "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 1382 1390 { "attachShadowRoot", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAttachShadowRoot), (intptr_t) (1) } }, 1383 1391 { "toString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionToString), (intptr_t) (0) } }, … … 4205 4213 #endif 4206 4214 4215 #if ENABLE(TEST_FEATURE) 4207 4216 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionEnabledAtRuntimeOperation(ExecState* state) 4208 4217 { … … 4220 4229 return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state); 4221 4230 } 4231 #endif 4222 4232 4223 4233 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* state) … … 5979 5989 #endif 5980 5990 5991 #if ENABLE(Condition1) 5981 5992 EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(ExecState* state) 5982 5993 { … … 5994 6005 return argsCount < 1 ? throwVMError(state, createNotEnoughArgumentsError(state)) : throwVMTypeError(state); 5995 6006 } 6007 #endif 5996 6008 5997 6009 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithClamp(ExecState* state) … … 6522 6534 } 6523 6535 6536 #if ENABLE(CONDITION1) 6537 static 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) 6557 static 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) 6577 EncodedJSValue 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 6524 6594 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAttachShadowRoot(ExecState* state) 6525 6595 { -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r204978 r205048 396 396 #if defined(TESTING_JS) 397 397 [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); 398 404 #endif 399 405
Note: See TracChangeset
for help on using the changeset viewer.