Changeset 207498 in webkit
- Timestamp:
- Oct 18, 2016 4:18:55 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207497 r207498 1 2016-10-18 Chris Dumez <cdumez@apple.com> 2 3 convertDictionary<>() no longer needs to return an Optional<> type 4 https://bugs.webkit.org/show_bug.cgi?id=163624 5 6 Reviewed by Sam Weinig. 7 8 convertDictionary<>() no longer needs to return an Optional<> type now 9 that our dictionary structures are all default constructible after 10 <https://trac.webkit.org/changeset/206974>. 11 12 * bindings/js/JSDOMConvert.h: 13 * bindings/scripts/CodeGeneratorJS.pm: 14 (GenerateDictionaryHeaderContent): 15 (GenerateDictionaryImplementationContent): 16 * bindings/scripts/test/JS/JSTestEventConstructor.cpp: 17 (WebCore::convertDictionary<TestEventConstructor::Init>): 18 * bindings/scripts/test/JS/JSTestEventConstructor.h: 19 * bindings/scripts/test/JS/JSTestObj.cpp: 20 (WebCore::convertDictionary<TestObj::Dictionary>): 21 (WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>): 22 (WebCore::convertDictionary<TestObj::DictionaryThatShouldTolerateNull>): 23 (WebCore::convertDictionary<AlternateDictionaryName>): 24 (WebCore::convertDictionary<TestObj::ParentDictionary>): 25 (WebCore::convertDictionary<TestObj::ChildDictionary>): 26 * bindings/scripts/test/JS/JSTestObj.h: 27 * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: 28 (WebCore::convertDictionary<DictionaryImplName>): 29 * bindings/scripts/test/JS/JSTestStandaloneDictionary.h: 30 1 31 2016-10-18 Chris Dumez <cdumez@apple.com> 2 32 -
trunk/Source/WebCore/bindings/js/JSDOMConvert.h
r207462 r207498 43 43 44 44 // Specialized by generated code for IDL dictionary conversion. 45 template<typename T> Optional<T>convertDictionary(JSC::ExecState&, JSC::JSValue);45 template<typename T> T convertDictionary(JSC::ExecState&, JSC::JSValue); 46 46 47 47 // Specialized by generated code for IDL enumeration conversion. -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207497 r207498 1052 1052 my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary); 1053 1053 $result .= "#if ${conditionalString}\n\n" if $conditionalString; 1054 $result .= "template<> Optional<$className>convertDictionary<$className>(JSC::ExecState&, JSC::JSValue);\n\n";1054 $result .= "template<> $className convertDictionary<$className>(JSC::ExecState&, JSC::JSValue);\n\n"; 1055 1055 $result .= "#endif\n\n" if $conditionalString; 1056 1056 return $result; … … 1089 1089 1090 1090 # https://heycam.github.io/webidl/#es-dictionary 1091 $result .= "template<> Optional<$className>convertDictionary<$className>(ExecState& state, JSValue value)\n";1091 $result .= "template<> $className convertDictionary<$className>(ExecState& state, JSValue value)\n"; 1092 1092 $result .= "{\n"; 1093 1093 $result .= " VM& vm = state.vm();\n"; … … 1098 1098 $result .= " if (UNLIKELY(!isNullOrUndefined && !object)) {\n"; 1099 1099 $result .= " throwTypeError(&state, throwScope);\n"; 1100 $result .= " return Nullopt;\n";1100 $result .= " return { };\n"; 1101 1101 $result .= " }\n"; 1102 1102 … … 1105 1105 $result .= " if (UNLIKELY(object && object->type() == RegExpObjectType)) {\n"; 1106 1106 $result .= " throwTypeError(&state, throwScope);\n"; 1107 $result .= " return Nullopt;\n";1107 $result .= " return { };\n"; 1108 1108 $result .= " }\n"; 1109 1109 … … 1146 1146 # 5.3. If value is not undefined, then: 1147 1147 $result .= " if (!${key}Value.isUndefined()) {\n"; 1148 1149 # FIXME: We should figure out a way to merge these two cases. 1150 if ($codeGenerator->IsDictionaryType($idlType->name)) { 1151 $result .= " auto ${key}Optional = convert<${IDLType}>(state, ${key}Value);\n"; 1152 $result .= " RETURN_IF_EXCEPTION(throwScope, Nullopt);\n"; 1153 $result .= " result.$key = ${key}Optional.value();\n"; 1154 } else { 1155 $result .= " result.$key = convert<${IDLType}>(state, ${key}Value);\n"; 1156 $result .= " RETURN_IF_EXCEPTION(throwScope, Nullopt);\n"; 1157 } 1148 $result .= " result.$key = convert<${IDLType}>(state, ${key}Value);\n"; 1149 $result .= " RETURN_IF_EXCEPTION(throwScope, { });\n"; 1158 1150 1159 1151 # Value is undefined. … … 1166 1158 $result .= " } else {\n"; 1167 1159 $result .= " throwTypeError(&state, throwScope);\n"; 1168 $result .= " return Nullopt;\n";1160 $result .= " return { };\n"; 1169 1161 $result .= " }\n"; 1170 1162 } else { … … 1174 1166 } 1175 1167 1176 $result .= " return WTFMove(result);\n";1168 $result .= " return result;\n"; 1177 1169 $result .= "}\n\n"; 1178 1170 $result .= "#endif\n\n" if $conditionalString; -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp
r207238 r207498 34 34 namespace WebCore { 35 35 36 template<> Optional<TestEventConstructor::Init>convertDictionary<TestEventConstructor::Init>(ExecState& state, JSValue value)36 template<> TestEventConstructor::Init convertDictionary<TestEventConstructor::Init>(ExecState& state, JSValue value) 37 37 { 38 38 VM& vm = state.vm(); … … 42 42 if (UNLIKELY(!isNullOrUndefined && !object)) { 43 43 throwTypeError(&state, throwScope); 44 return Nullopt;44 return { }; 45 45 } 46 46 if (UNLIKELY(object && object->type() == RegExpObjectType)) { 47 47 throwTypeError(&state, throwScope); 48 return Nullopt;48 return { }; 49 49 } 50 50 TestEventConstructor::Init result; … … 52 52 if (!bubblesValue.isUndefined()) { 53 53 result.bubbles = convert<IDLBoolean>(state, bubblesValue); 54 RETURN_IF_EXCEPTION(throwScope, Nullopt);54 RETURN_IF_EXCEPTION(throwScope, { }); 55 55 } else 56 56 result.bubbles = false; … … 58 58 if (!cancelableValue.isUndefined()) { 59 59 result.cancelable = convert<IDLBoolean>(state, cancelableValue); 60 RETURN_IF_EXCEPTION(throwScope, Nullopt);60 RETURN_IF_EXCEPTION(throwScope, { }); 61 61 } else 62 62 result.cancelable = false; … … 64 64 if (!composedValue.isUndefined()) { 65 65 result.composed = convert<IDLBoolean>(state, composedValue); 66 RETURN_IF_EXCEPTION(throwScope, Nullopt);66 RETURN_IF_EXCEPTION(throwScope, { }); 67 67 } else 68 68 result.composed = false; … … 70 70 if (!attr2Value.isUndefined()) { 71 71 result.attr2 = convert<IDLDOMString>(state, attr2Value); 72 RETURN_IF_EXCEPTION(throwScope, Nullopt);72 RETURN_IF_EXCEPTION(throwScope, { }); 73 73 } else 74 74 result.attr2 = ""; … … 76 76 if (!attr3Value.isUndefined()) { 77 77 result.attr3 = convert<IDLDOMString>(state, attr3Value); 78 RETURN_IF_EXCEPTION(throwScope, Nullopt);78 RETURN_IF_EXCEPTION(throwScope, { }); 79 79 } else 80 80 result.attr3 = ""; 81 return WTFMove(result);81 return result; 82 82 } 83 83 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.h
r207238 r207498 72 72 using WrapperClass = JSTestEventConstructor; 73 73 }; 74 template<> Optional<TestEventConstructor::Init>convertDictionary<TestEventConstructor::Init>(JSC::ExecState&, JSC::JSValue);74 template<> TestEventConstructor::Init convertDictionary<TestEventConstructor::Init>(JSC::ExecState&, JSC::JSValue); 75 75 76 76 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r207462 r207498 460 460 } 461 461 462 template<> Optional<TestObj::Dictionary>convertDictionary<TestObj::Dictionary>(ExecState& state, JSValue value)462 template<> TestObj::Dictionary convertDictionary<TestObj::Dictionary>(ExecState& state, JSValue value) 463 463 { 464 464 VM& vm = state.vm(); … … 468 468 if (UNLIKELY(!isNullOrUndefined && !object)) { 469 469 throwTypeError(&state, throwScope); 470 return Nullopt;470 return { }; 471 471 } 472 472 if (UNLIKELY(object && object->type() == RegExpObjectType)) { 473 473 throwTypeError(&state, throwScope); 474 return Nullopt;474 return { }; 475 475 } 476 476 TestObj::Dictionary result; … … 478 478 if (!anyTypedefValueValue.isUndefined()) { 479 479 result.anyTypedefValue = convert<IDLAny>(state, anyTypedefValueValue); 480 RETURN_IF_EXCEPTION(throwScope, Nullopt);480 RETURN_IF_EXCEPTION(throwScope, { }); 481 481 } else 482 482 result.anyTypedefValue = jsUndefined(); … … 484 484 if (!anyValueValue.isUndefined()) { 485 485 result.anyValue = convert<IDLAny>(state, anyValueValue); 486 RETURN_IF_EXCEPTION(throwScope, Nullopt);486 RETURN_IF_EXCEPTION(throwScope, { }); 487 487 } else 488 488 result.anyValue = jsUndefined(); … … 490 490 if (!anyValueWithNullDefaultValue.isUndefined()) { 491 491 result.anyValueWithNullDefault = convert<IDLAny>(state, anyValueWithNullDefaultValue); 492 RETURN_IF_EXCEPTION(throwScope, Nullopt);492 RETURN_IF_EXCEPTION(throwScope, { }); 493 493 } else 494 494 result.anyValueWithNullDefault = jsNull(); … … 496 496 if (!booleanWithDefaultValue.isUndefined()) { 497 497 result.booleanWithDefault = convert<IDLBoolean>(state, booleanWithDefaultValue); 498 RETURN_IF_EXCEPTION(throwScope, Nullopt);498 RETURN_IF_EXCEPTION(throwScope, { }); 499 499 } else 500 500 result.booleanWithDefault = false; … … 502 502 if (!booleanWithoutDefaultValue.isUndefined()) { 503 503 result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue); 504 RETURN_IF_EXCEPTION(throwScope, Nullopt);504 RETURN_IF_EXCEPTION(throwScope, { }); 505 505 } 506 506 JSValue bufferSourceValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "bufferSourceValue")); 507 507 if (!bufferSourceValueValue.isUndefined()) { 508 508 result.bufferSourceValue = convert<IDLBufferSource>(state, bufferSourceValueValue); 509 RETURN_IF_EXCEPTION(throwScope, Nullopt);509 RETURN_IF_EXCEPTION(throwScope, { }); 510 510 } 511 511 JSValue dictionaryMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "dictionaryMember")); 512 512 if (!dictionaryMemberValue.isUndefined()) { 513 auto dictionaryMemberOptional = convert<IDLDictionary<TestObj::DictionaryThatShouldTolerateNull>>(state, dictionaryMemberValue); 514 RETURN_IF_EXCEPTION(throwScope, Nullopt); 515 result.dictionaryMember = dictionaryMemberOptional.value(); 513 result.dictionaryMember = convert<IDLDictionary<TestObj::DictionaryThatShouldTolerateNull>>(state, dictionaryMemberValue); 514 RETURN_IF_EXCEPTION(throwScope, { }); 516 515 } 517 516 JSValue enumerationValueWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValueWithDefault")); 518 517 if (!enumerationValueWithDefaultValue.isUndefined()) { 519 518 result.enumerationValueWithDefault = convert<IDLEnumeration<TestObj::EnumType>>(state, enumerationValueWithDefaultValue); 520 RETURN_IF_EXCEPTION(throwScope, Nullopt);519 RETURN_IF_EXCEPTION(throwScope, { }); 521 520 } else 522 521 result.enumerationValueWithDefault = TestObj::EnumType::EnumValue1; … … 524 523 if (!enumerationValueWithEmptyStringDefaultValue.isUndefined()) { 525 524 result.enumerationValueWithEmptyStringDefault = convert<IDLEnumeration<TestObj::EnumType>>(state, enumerationValueWithEmptyStringDefaultValue); 526 RETURN_IF_EXCEPTION(throwScope, Nullopt);525 RETURN_IF_EXCEPTION(throwScope, { }); 527 526 } else 528 527 result.enumerationValueWithEmptyStringDefault = TestObj::EnumType::EmptyString; … … 530 529 if (!enumerationValueWithoutDefaultValue.isUndefined()) { 531 530 result.enumerationValueWithoutDefault = convert<IDLEnumeration<TestObj::EnumType>>(state, enumerationValueWithoutDefaultValue); 532 RETURN_IF_EXCEPTION(throwScope, Nullopt);531 RETURN_IF_EXCEPTION(throwScope, { }); 533 532 } 534 533 JSValue integerValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "integer")); 535 534 if (!integerValue.isUndefined()) { 536 535 result.integer = convert<IDLLong>(state, integerValue); 537 RETURN_IF_EXCEPTION(throwScope, Nullopt);536 RETURN_IF_EXCEPTION(throwScope, { }); 538 537 } 539 538 JSValue integerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "integerWithDefault")); 540 539 if (!integerWithDefaultValue.isUndefined()) { 541 540 result.integerWithDefault = convert<IDLLong>(state, integerWithDefaultValue); 542 RETURN_IF_EXCEPTION(throwScope, Nullopt);541 RETURN_IF_EXCEPTION(throwScope, { }); 543 542 } else 544 543 result.integerWithDefault = 0; … … 546 545 if (!largeIntegerValue.isUndefined()) { 547 546 result.largeInteger = convert<IDLLongLong>(state, largeIntegerValue); 548 RETURN_IF_EXCEPTION(throwScope, Nullopt);547 RETURN_IF_EXCEPTION(throwScope, { }); 549 548 } 550 549 JSValue largeIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "largeIntegerWithDefault")); 551 550 if (!largeIntegerWithDefaultValue.isUndefined()) { 552 551 result.largeIntegerWithDefault = convert<IDLLongLong>(state, largeIntegerWithDefaultValue); 553 RETURN_IF_EXCEPTION(throwScope, Nullopt);552 RETURN_IF_EXCEPTION(throwScope, { }); 554 553 } else 555 554 result.largeIntegerWithDefault = 0; … … 557 556 if (!nullableIntegerWithDefaultValue.isUndefined()) { 558 557 result.nullableIntegerWithDefault = convert<IDLNullable<IDLLong>>(state, nullableIntegerWithDefaultValue); 559 RETURN_IF_EXCEPTION(throwScope, Nullopt);558 RETURN_IF_EXCEPTION(throwScope, { }); 560 559 } else 561 560 result.nullableIntegerWithDefault = Nullopt; … … 563 562 if (!nullableNodeValue.isUndefined()) { 564 563 result.nullableNode = convert<IDLNullable<IDLInterface<Node>>>(state, nullableNodeValue); 565 RETURN_IF_EXCEPTION(throwScope, Nullopt);564 RETURN_IF_EXCEPTION(throwScope, { }); 566 565 } else 567 566 result.nullableNode = nullptr; … … 569 568 if (!nullableStringWithDefaultValue.isUndefined()) { 570 569 result.nullableStringWithDefault = convert<IDLNullable<IDLDOMString>>(state, nullableStringWithDefaultValue); 571 RETURN_IF_EXCEPTION(throwScope, Nullopt);570 RETURN_IF_EXCEPTION(throwScope, { }); 572 571 } else 573 572 result.nullableStringWithDefault = String(); … … 575 574 if (!nullableUnionMemberValue.isUndefined()) { 576 575 result.nullableUnionMember = convert<IDLNullable<IDLUnion<IDLLong, IDLInterface<Node>>>>(state, nullableUnionMemberValue); 577 RETURN_IF_EXCEPTION(throwScope, Nullopt);576 RETURN_IF_EXCEPTION(throwScope, { }); 578 577 } else 579 578 result.nullableUnionMember = Nullopt; … … 581 580 if (!restrictedDoubleValue.isUndefined()) { 582 581 result.restrictedDouble = convert<IDLDouble>(state, restrictedDoubleValue); 583 RETURN_IF_EXCEPTION(throwScope, Nullopt);582 RETURN_IF_EXCEPTION(throwScope, { }); 584 583 } 585 584 JSValue restrictedDoubleWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedDoubleWithDefault")); 586 585 if (!restrictedDoubleWithDefaultValue.isUndefined()) { 587 586 result.restrictedDoubleWithDefault = convert<IDLDouble>(state, restrictedDoubleWithDefaultValue); 588 RETURN_IF_EXCEPTION(throwScope, Nullopt);587 RETURN_IF_EXCEPTION(throwScope, { }); 589 588 } else 590 589 result.restrictedDoubleWithDefault = 0; … … 592 591 if (!restrictedFloatValue.isUndefined()) { 593 592 result.restrictedFloat = convert<IDLFloat>(state, restrictedFloatValue); 594 RETURN_IF_EXCEPTION(throwScope, Nullopt);593 RETURN_IF_EXCEPTION(throwScope, { }); 595 594 } 596 595 JSValue restrictedFloatWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedFloatWithDefault")); 597 596 if (!restrictedFloatWithDefaultValue.isUndefined()) { 598 597 result.restrictedFloatWithDefault = convert<IDLFloat>(state, restrictedFloatWithDefaultValue); 599 RETURN_IF_EXCEPTION(throwScope, Nullopt);598 RETURN_IF_EXCEPTION(throwScope, { }); 600 599 } else 601 600 result.restrictedFloatWithDefault = 0; … … 603 602 if (!sequenceOfStringsValue.isUndefined()) { 604 603 result.sequenceOfStrings = convert<IDLSequence<IDLDOMString>>(state, sequenceOfStringsValue); 605 RETURN_IF_EXCEPTION(throwScope, Nullopt);604 RETURN_IF_EXCEPTION(throwScope, { }); 606 605 } 607 606 JSValue smallIntegerClampedValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallIntegerClamped")); 608 607 if (!smallIntegerClampedValue.isUndefined()) { 609 608 result.smallIntegerClamped = convert<IDLByte>(state, smallIntegerClampedValue); 610 RETURN_IF_EXCEPTION(throwScope, Nullopt);609 RETURN_IF_EXCEPTION(throwScope, { }); 611 610 } 612 611 JSValue smallIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallIntegerWithDefault")); 613 612 if (!smallIntegerWithDefaultValue.isUndefined()) { 614 613 result.smallIntegerWithDefault = convert<IDLByte>(state, smallIntegerWithDefaultValue); 615 RETURN_IF_EXCEPTION(throwScope, Nullopt);614 RETURN_IF_EXCEPTION(throwScope, { }); 616 615 } 617 616 JSValue smallUnsignedIntegerEnforcedRangeValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerEnforcedRange")); 618 617 if (!smallUnsignedIntegerEnforcedRangeValue.isUndefined()) { 619 618 result.smallUnsignedIntegerEnforcedRange = convert<IDLOctet>(state, smallUnsignedIntegerEnforcedRangeValue); 620 RETURN_IF_EXCEPTION(throwScope, Nullopt);619 RETURN_IF_EXCEPTION(throwScope, { }); 621 620 } 622 621 JSValue smallUnsignedIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerWithDefault")); 623 622 if (!smallUnsignedIntegerWithDefaultValue.isUndefined()) { 624 623 result.smallUnsignedIntegerWithDefault = convert<IDLOctet>(state, smallUnsignedIntegerWithDefaultValue); 625 RETURN_IF_EXCEPTION(throwScope, Nullopt);624 RETURN_IF_EXCEPTION(throwScope, { }); 626 625 } else 627 626 result.smallUnsignedIntegerWithDefault = 0; … … 629 628 if (!stringWithDefaultValue.isUndefined()) { 630 629 result.stringWithDefault = convert<IDLDOMString>(state, stringWithDefaultValue); 631 RETURN_IF_EXCEPTION(throwScope, Nullopt);630 RETURN_IF_EXCEPTION(throwScope, { }); 632 631 } else 633 632 result.stringWithDefault = "defaultString"; … … 635 634 if (!stringWithoutDefaultValue.isUndefined()) { 636 635 result.stringWithoutDefault = convert<IDLDOMString>(state, stringWithoutDefaultValue); 637 RETURN_IF_EXCEPTION(throwScope, Nullopt);636 RETURN_IF_EXCEPTION(throwScope, { }); 638 637 } 639 638 JSValue unionMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unionMember")); 640 639 if (!unionMemberValue.isUndefined()) { 641 640 result.unionMember = convert<IDLUnion<IDLLong, IDLInterface<Node>>>(state, unionMemberValue); 642 RETURN_IF_EXCEPTION(throwScope, Nullopt);641 RETURN_IF_EXCEPTION(throwScope, { }); 643 642 } 644 643 JSValue unrestrictedDoubleValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedDouble")); 645 644 if (!unrestrictedDoubleValue.isUndefined()) { 646 645 result.unrestrictedDouble = convert<IDLUnrestrictedDouble>(state, unrestrictedDoubleValue); 647 RETURN_IF_EXCEPTION(throwScope, Nullopt);646 RETURN_IF_EXCEPTION(throwScope, { }); 648 647 } 649 648 JSValue unrestrictedDoubleWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedDoubleWithDefault")); 650 649 if (!unrestrictedDoubleWithDefaultValue.isUndefined()) { 651 650 result.unrestrictedDoubleWithDefault = convert<IDLUnrestrictedDouble>(state, unrestrictedDoubleWithDefaultValue); 652 RETURN_IF_EXCEPTION(throwScope, Nullopt);651 RETURN_IF_EXCEPTION(throwScope, { }); 653 652 } else 654 653 result.unrestrictedDoubleWithDefault = 0; … … 656 655 if (!unrestrictedFloatValue.isUndefined()) { 657 656 result.unrestrictedFloat = convert<IDLUnrestrictedFloat>(state, unrestrictedFloatValue); 658 RETURN_IF_EXCEPTION(throwScope, Nullopt);657 RETURN_IF_EXCEPTION(throwScope, { }); 659 658 } 660 659 JSValue unrestrictedFloatWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedFloatWithDefault")); 661 660 if (!unrestrictedFloatWithDefaultValue.isUndefined()) { 662 661 result.unrestrictedFloatWithDefault = convert<IDLUnrestrictedFloat>(state, unrestrictedFloatWithDefaultValue); 663 RETURN_IF_EXCEPTION(throwScope, Nullopt);662 RETURN_IF_EXCEPTION(throwScope, { }); 664 663 } else 665 664 result.unrestrictedFloatWithDefault = 0; … … 667 666 if (!unsignedIntegerValue.isUndefined()) { 668 667 result.unsignedInteger = convert<IDLUnsignedLong>(state, unsignedIntegerValue); 669 RETURN_IF_EXCEPTION(throwScope, Nullopt);668 RETURN_IF_EXCEPTION(throwScope, { }); 670 669 } 671 670 JSValue unsignedIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unsignedIntegerWithDefault")); 672 671 if (!unsignedIntegerWithDefaultValue.isUndefined()) { 673 672 result.unsignedIntegerWithDefault = convert<IDLUnsignedLong>(state, unsignedIntegerWithDefaultValue); 674 RETURN_IF_EXCEPTION(throwScope, Nullopt);673 RETURN_IF_EXCEPTION(throwScope, { }); 675 674 } else 676 675 result.unsignedIntegerWithDefault = 0; … … 678 677 if (!unsignedLargeIntegerValue.isUndefined()) { 679 678 result.unsignedLargeInteger = convert<IDLUnsignedLongLong>(state, unsignedLargeIntegerValue); 680 RETURN_IF_EXCEPTION(throwScope, Nullopt);679 RETURN_IF_EXCEPTION(throwScope, { }); 681 680 } 682 681 JSValue unsignedLargeIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unsignedLargeIntegerWithDefault")); 683 682 if (!unsignedLargeIntegerWithDefaultValue.isUndefined()) { 684 683 result.unsignedLargeIntegerWithDefault = convert<IDLUnsignedLongLong>(state, unsignedLargeIntegerWithDefaultValue); 685 RETURN_IF_EXCEPTION(throwScope, Nullopt);684 RETURN_IF_EXCEPTION(throwScope, { }); 686 685 } else 687 686 result.unsignedLargeIntegerWithDefault = 0; 688 return WTFMove(result);689 } 690 691 template<> Optional<TestObj::DictionaryThatShouldNotTolerateNull>convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(ExecState& state, JSValue value)687 return result; 688 } 689 690 template<> TestObj::DictionaryThatShouldNotTolerateNull convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(ExecState& state, JSValue value) 692 691 { 693 692 VM& vm = state.vm(); … … 697 696 if (UNLIKELY(!isNullOrUndefined && !object)) { 698 697 throwTypeError(&state, throwScope); 699 return Nullopt;698 return { }; 700 699 } 701 700 if (UNLIKELY(object && object->type() == RegExpObjectType)) { 702 701 throwTypeError(&state, throwScope); 703 return Nullopt;702 return { }; 704 703 } 705 704 TestObj::DictionaryThatShouldNotTolerateNull result; … … 707 706 if (!booleanWithoutDefaultValue.isUndefined()) { 708 707 result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue); 709 RETURN_IF_EXCEPTION(throwScope, Nullopt);708 RETURN_IF_EXCEPTION(throwScope, { }); 710 709 } 711 710 JSValue nonNullableNodeValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "nonNullableNode")); 712 711 if (!nonNullableNodeValue.isUndefined()) { 713 712 result.nonNullableNode = convert<IDLInterface<Node>>(state, nonNullableNodeValue); 714 RETURN_IF_EXCEPTION(throwScope, Nullopt);713 RETURN_IF_EXCEPTION(throwScope, { }); 715 714 } else { 716 715 throwTypeError(&state, throwScope); 717 return Nullopt;716 return { }; 718 717 } 719 718 JSValue requiredDictionaryMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "requiredDictionaryMember")); 720 719 if (!requiredDictionaryMemberValue.isUndefined()) { 721 auto requiredDictionaryMemberOptional = convert<IDLDictionary<TestObj::Dictionary>>(state, requiredDictionaryMemberValue); 722 RETURN_IF_EXCEPTION(throwScope, Nullopt); 723 result.requiredDictionaryMember = requiredDictionaryMemberOptional.value(); 720 result.requiredDictionaryMember = convert<IDLDictionary<TestObj::Dictionary>>(state, requiredDictionaryMemberValue); 721 RETURN_IF_EXCEPTION(throwScope, { }); 724 722 } else { 725 723 throwTypeError(&state, throwScope); 726 return Nullopt;724 return { }; 727 725 } 728 726 JSValue requiredEnumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "requiredEnumerationValue")); 729 727 if (!requiredEnumerationValueValue.isUndefined()) { 730 728 result.requiredEnumerationValue = convert<IDLEnumeration<TestObj::EnumType>>(state, requiredEnumerationValueValue); 731 RETURN_IF_EXCEPTION(throwScope, Nullopt);729 RETURN_IF_EXCEPTION(throwScope, { }); 732 730 } else { 733 731 throwTypeError(&state, throwScope); 734 return Nullopt;735 } 736 return WTFMove(result);737 } 738 739 template<> Optional<TestObj::DictionaryThatShouldTolerateNull>convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(ExecState& state, JSValue value)732 return { }; 733 } 734 return result; 735 } 736 737 template<> TestObj::DictionaryThatShouldTolerateNull convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(ExecState& state, JSValue value) 740 738 { 741 739 VM& vm = state.vm(); … … 745 743 if (UNLIKELY(!isNullOrUndefined && !object)) { 746 744 throwTypeError(&state, throwScope); 747 return Nullopt;745 return { }; 748 746 } 749 747 if (UNLIKELY(object && object->type() == RegExpObjectType)) { 750 748 throwTypeError(&state, throwScope); 751 return Nullopt;749 return { }; 752 750 } 753 751 TestObj::DictionaryThatShouldTolerateNull result; … … 755 753 if (!booleanWithoutDefaultValue.isUndefined()) { 756 754 result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue); 757 RETURN_IF_EXCEPTION(throwScope, Nullopt);755 RETURN_IF_EXCEPTION(throwScope, { }); 758 756 } 759 757 JSValue enumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValue")); 760 758 if (!enumerationValueValue.isUndefined()) { 761 759 result.enumerationValue = convert<IDLEnumeration<TestObj::EnumType>>(state, enumerationValueValue); 762 RETURN_IF_EXCEPTION(throwScope, Nullopt);763 } 764 return WTFMove(result);765 } 766 767 template<> Optional<AlternateDictionaryName>convertDictionary<AlternateDictionaryName>(ExecState& state, JSValue value)760 RETURN_IF_EXCEPTION(throwScope, { }); 761 } 762 return result; 763 } 764 765 template<> AlternateDictionaryName convertDictionary<AlternateDictionaryName>(ExecState& state, JSValue value) 768 766 { 769 767 VM& vm = state.vm(); … … 773 771 if (UNLIKELY(!isNullOrUndefined && !object)) { 774 772 throwTypeError(&state, throwScope); 775 return Nullopt;773 return { }; 776 774 } 777 775 if (UNLIKELY(object && object->type() == RegExpObjectType)) { 778 776 throwTypeError(&state, throwScope); 779 return Nullopt;777 return { }; 780 778 } 781 779 AlternateDictionaryName result; … … 783 781 if (!booleanWithoutDefaultValue.isUndefined()) { 784 782 result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue); 785 RETURN_IF_EXCEPTION(throwScope, Nullopt);783 RETURN_IF_EXCEPTION(throwScope, { }); 786 784 } 787 785 JSValue enumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValue")); 788 786 if (!enumerationValueValue.isUndefined()) { 789 787 result.enumerationValue = convert<IDLEnumeration<TestObj::EnumType>>(state, enumerationValueValue); 790 RETURN_IF_EXCEPTION(throwScope, Nullopt);791 } 792 return WTFMove(result);793 } 794 795 template<> Optional<TestObj::ParentDictionary>convertDictionary<TestObj::ParentDictionary>(ExecState& state, JSValue value)788 RETURN_IF_EXCEPTION(throwScope, { }); 789 } 790 return result; 791 } 792 793 template<> TestObj::ParentDictionary convertDictionary<TestObj::ParentDictionary>(ExecState& state, JSValue value) 796 794 { 797 795 VM& vm = state.vm(); … … 801 799 if (UNLIKELY(!isNullOrUndefined && !object)) { 802 800 throwTypeError(&state, throwScope); 803 return Nullopt;801 return { }; 804 802 } 805 803 if (UNLIKELY(object && object->type() == RegExpObjectType)) { 806 804 throwTypeError(&state, throwScope); 807 return Nullopt;805 return { }; 808 806 } 809 807 TestObj::ParentDictionary result; … … 811 809 if (!parentMember1Value.isUndefined()) { 812 810 result.parentMember1 = convert<IDLBoolean>(state, parentMember1Value); 813 RETURN_IF_EXCEPTION(throwScope, Nullopt);811 RETURN_IF_EXCEPTION(throwScope, { }); 814 812 } 815 813 JSValue parentMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "parentMember2")); 816 814 if (!parentMember2Value.isUndefined()) { 817 815 result.parentMember2 = convert<IDLBoolean>(state, parentMember2Value); 818 RETURN_IF_EXCEPTION(throwScope, Nullopt);819 } 820 return WTFMove(result);821 } 822 823 template<> Optional<TestObj::ChildDictionary>convertDictionary<TestObj::ChildDictionary>(ExecState& state, JSValue value)816 RETURN_IF_EXCEPTION(throwScope, { }); 817 } 818 return result; 819 } 820 821 template<> TestObj::ChildDictionary convertDictionary<TestObj::ChildDictionary>(ExecState& state, JSValue value) 824 822 { 825 823 VM& vm = state.vm(); … … 829 827 if (UNLIKELY(!isNullOrUndefined && !object)) { 830 828 throwTypeError(&state, throwScope); 831 return Nullopt;829 return { }; 832 830 } 833 831 if (UNLIKELY(object && object->type() == RegExpObjectType)) { 834 832 throwTypeError(&state, throwScope); 835 return Nullopt;833 return { }; 836 834 } 837 835 TestObj::ChildDictionary result; … … 839 837 if (!parentMember1Value.isUndefined()) { 840 838 result.parentMember1 = convert<IDLBoolean>(state, parentMember1Value); 841 RETURN_IF_EXCEPTION(throwScope, Nullopt);839 RETURN_IF_EXCEPTION(throwScope, { }); 842 840 } 843 841 JSValue parentMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "parentMember2")); 844 842 if (!parentMember2Value.isUndefined()) { 845 843 result.parentMember2 = convert<IDLBoolean>(state, parentMember2Value); 846 RETURN_IF_EXCEPTION(throwScope, Nullopt);844 RETURN_IF_EXCEPTION(throwScope, { }); 847 845 } 848 846 JSValue childMember1Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "childMember1")); 849 847 if (!childMember1Value.isUndefined()) { 850 848 result.childMember1 = convert<IDLBoolean>(state, childMember1Value); 851 RETURN_IF_EXCEPTION(throwScope, Nullopt);849 RETURN_IF_EXCEPTION(throwScope, { }); 852 850 } 853 851 JSValue childMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "childMember2")); 854 852 if (!childMember2Value.isUndefined()) { 855 853 result.childMember2 = convert<IDLBoolean>(state, childMember2Value); 856 RETURN_IF_EXCEPTION(throwScope, Nullopt);857 } 858 return WTFMove(result);854 RETURN_IF_EXCEPTION(throwScope, { }); 855 } 856 return result; 859 857 } 860 858 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
r207192 r207498 208 208 template<> const char* expectedEnumerationValues<TestObj::Confidence>(); 209 209 210 template<> Optional<TestObj::Dictionary>convertDictionary<TestObj::Dictionary>(JSC::ExecState&, JSC::JSValue);211 212 template<> Optional<TestObj::DictionaryThatShouldNotTolerateNull>convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(JSC::ExecState&, JSC::JSValue);213 214 template<> Optional<TestObj::DictionaryThatShouldTolerateNull>convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(JSC::ExecState&, JSC::JSValue);215 216 template<> Optional<AlternateDictionaryName>convertDictionary<AlternateDictionaryName>(JSC::ExecState&, JSC::JSValue);217 218 template<> Optional<TestObj::ParentDictionary>convertDictionary<TestObj::ParentDictionary>(JSC::ExecState&, JSC::JSValue);219 220 template<> Optional<TestObj::ChildDictionary>convertDictionary<TestObj::ChildDictionary>(JSC::ExecState&, JSC::JSValue);210 template<> TestObj::Dictionary convertDictionary<TestObj::Dictionary>(JSC::ExecState&, JSC::JSValue); 211 212 template<> TestObj::DictionaryThatShouldNotTolerateNull convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(JSC::ExecState&, JSC::JSValue); 213 214 template<> TestObj::DictionaryThatShouldTolerateNull convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(JSC::ExecState&, JSC::JSValue); 215 216 template<> AlternateDictionaryName convertDictionary<AlternateDictionaryName>(JSC::ExecState&, JSC::JSValue); 217 218 template<> TestObj::ParentDictionary convertDictionary<TestObj::ParentDictionary>(JSC::ExecState&, JSC::JSValue); 219 220 template<> TestObj::ChildDictionary convertDictionary<TestObj::ChildDictionary>(JSC::ExecState&, JSC::JSValue); 221 221 222 222 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp
r207243 r207498 27 27 namespace WebCore { 28 28 29 template<> Optional<DictionaryImplName>convertDictionary<DictionaryImplName>(ExecState& state, JSValue value)29 template<> DictionaryImplName convertDictionary<DictionaryImplName>(ExecState& state, JSValue value) 30 30 { 31 31 VM& vm = state.vm(); … … 35 35 if (UNLIKELY(!isNullOrUndefined && !object)) { 36 36 throwTypeError(&state, throwScope); 37 return Nullopt;37 return { }; 38 38 } 39 39 if (UNLIKELY(object && object->type() == RegExpObjectType)) { 40 40 throwTypeError(&state, throwScope); 41 return Nullopt;41 return { }; 42 42 } 43 43 DictionaryImplName result; … … 45 45 if (!boolMemberValue.isUndefined()) { 46 46 result.boolMember = convert<IDLBoolean>(state, boolMemberValue); 47 RETURN_IF_EXCEPTION(throwScope, Nullopt);47 RETURN_IF_EXCEPTION(throwScope, { }); 48 48 } 49 49 JSValue stringMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "stringMember")); 50 50 if (!stringMemberValue.isUndefined()) { 51 51 result.stringMember = convert<IDLDOMString>(state, stringMemberValue); 52 RETURN_IF_EXCEPTION(throwScope, Nullopt);52 RETURN_IF_EXCEPTION(throwScope, { }); 53 53 } 54 return WTFMove(result);54 return result; 55 55 } 56 56 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.h
r207243 r207498 26 26 namespace WebCore { 27 27 28 template<> Optional<DictionaryImplName>convertDictionary<DictionaryImplName>(JSC::ExecState&, JSC::JSValue);28 template<> DictionaryImplName convertDictionary<DictionaryImplName>(JSC::ExecState&, JSC::JSValue); 29 29 30 30 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.