Changeset 207498 in webkit


Ignore:
Timestamp:
Oct 18, 2016 4:18:55 PM (8 years ago)
Author:
Chris Dumez
Message:

convertDictionary<>() no longer needs to return an Optional<> type
https://bugs.webkit.org/show_bug.cgi?id=163624

Reviewed by Sam Weinig.

convertDictionary<>() no longer needs to return an Optional<> type now
that our dictionary structures are all default constructible after
<https://trac.webkit.org/changeset/206974>.

  • bindings/js/JSDOMConvert.h:
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateDictionaryHeaderContent):
(GenerateDictionaryImplementationContent):

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

(WebCore::convertDictionary<TestEventConstructor::Init>):

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

(WebCore::convertDictionary<TestObj::Dictionary>):
(WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>):
(WebCore::convertDictionary<TestObj::DictionaryThatShouldTolerateNull>):
(WebCore::convertDictionary<AlternateDictionaryName>):
(WebCore::convertDictionary<TestObj::ParentDictionary>):
(WebCore::convertDictionary<TestObj::ChildDictionary>):

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

(WebCore::convertDictionary<DictionaryImplName>):

  • bindings/scripts/test/JS/JSTestStandaloneDictionary.h:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207497 r207498  
     12016-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
    1312016-10-18  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebCore/bindings/js/JSDOMConvert.h

    r207462 r207498  
    4343
    4444// Specialized by generated code for IDL dictionary conversion.
    45 template<typename T> Optional<T> convertDictionary(JSC::ExecState&, JSC::JSValue);
     45template<typename T> T convertDictionary(JSC::ExecState&, JSC::JSValue);
    4646
    4747// Specialized by generated code for IDL enumeration conversion.
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r207497 r207498  
    10521052    my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
    10531053    $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";
    10551055    $result .= "#endif\n\n" if $conditionalString;
    10561056    return $result;
     
    10891089
    10901090    # 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";
    10921092    $result .= "{\n";
    10931093    $result .= "    VM& vm = state.vm();\n";
     
    10981098    $result .= "    if (UNLIKELY(!isNullOrUndefined && !object)) {\n";
    10991099    $result .= "        throwTypeError(&state, throwScope);\n";
    1100     $result .= "        return Nullopt;\n";
     1100    $result .= "        return { };\n";
    11011101    $result .= "    }\n";
    11021102
     
    11051105    $result .= "    if (UNLIKELY(object && object->type() == RegExpObjectType)) {\n";
    11061106    $result .= "        throwTypeError(&state, throwScope);\n";
    1107     $result .= "        return Nullopt;\n";
     1107    $result .= "        return { };\n";
    11081108    $result .= "    }\n";
    11091109
     
    11461146            # 5.3. If value is not undefined, then:
    11471147            $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";
    11581150
    11591151            # Value is undefined.
     
    11661158                $result .= "    } else {\n";
    11671159                $result .= "        throwTypeError(&state, throwScope);\n";
    1168                 $result .= "        return Nullopt;\n";
     1160                $result .= "        return { };\n";
    11691161                $result .= "    }\n";
    11701162            } else {
     
    11741166    }
    11751167
    1176     $result .= "    return WTFMove(result);\n";
     1168    $result .= "    return result;\n";
    11771169    $result .= "}\n\n";
    11781170    $result .= "#endif\n\n" if $conditionalString;
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp

    r207238 r207498  
    3434namespace WebCore {
    3535
    36 template<> Optional<TestEventConstructor::Init> convertDictionary<TestEventConstructor::Init>(ExecState& state, JSValue value)
     36template<> TestEventConstructor::Init convertDictionary<TestEventConstructor::Init>(ExecState& state, JSValue value)
    3737{
    3838    VM& vm = state.vm();
     
    4242    if (UNLIKELY(!isNullOrUndefined && !object)) {
    4343        throwTypeError(&state, throwScope);
    44         return Nullopt;
     44        return { };
    4545    }
    4646    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
    4747        throwTypeError(&state, throwScope);
    48         return Nullopt;
     48        return { };
    4949    }
    5050    TestEventConstructor::Init result;
     
    5252    if (!bubblesValue.isUndefined()) {
    5353        result.bubbles = convert<IDLBoolean>(state, bubblesValue);
    54         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     54        RETURN_IF_EXCEPTION(throwScope, { });
    5555    } else
    5656        result.bubbles = false;
     
    5858    if (!cancelableValue.isUndefined()) {
    5959        result.cancelable = convert<IDLBoolean>(state, cancelableValue);
    60         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     60        RETURN_IF_EXCEPTION(throwScope, { });
    6161    } else
    6262        result.cancelable = false;
     
    6464    if (!composedValue.isUndefined()) {
    6565        result.composed = convert<IDLBoolean>(state, composedValue);
    66         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     66        RETURN_IF_EXCEPTION(throwScope, { });
    6767    } else
    6868        result.composed = false;
     
    7070    if (!attr2Value.isUndefined()) {
    7171        result.attr2 = convert<IDLDOMString>(state, attr2Value);
    72         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     72        RETURN_IF_EXCEPTION(throwScope, { });
    7373    } else
    7474        result.attr2 = "";
     
    7676    if (!attr3Value.isUndefined()) {
    7777        result.attr3 = convert<IDLDOMString>(state, attr3Value);
    78         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     78        RETURN_IF_EXCEPTION(throwScope, { });
    7979    } else
    8080        result.attr3 = "";
    81     return WTFMove(result);
     81    return result;
    8282}
    8383
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.h

    r207238 r207498  
    7272    using WrapperClass = JSTestEventConstructor;
    7373};
    74 template<> Optional<TestEventConstructor::Init> convertDictionary<TestEventConstructor::Init>(JSC::ExecState&, JSC::JSValue);
     74template<> TestEventConstructor::Init convertDictionary<TestEventConstructor::Init>(JSC::ExecState&, JSC::JSValue);
    7575
    7676
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r207462 r207498  
    460460}
    461461
    462 template<> Optional<TestObj::Dictionary> convertDictionary<TestObj::Dictionary>(ExecState& state, JSValue value)
     462template<> TestObj::Dictionary convertDictionary<TestObj::Dictionary>(ExecState& state, JSValue value)
    463463{
    464464    VM& vm = state.vm();
     
    468468    if (UNLIKELY(!isNullOrUndefined && !object)) {
    469469        throwTypeError(&state, throwScope);
    470         return Nullopt;
     470        return { };
    471471    }
    472472    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
    473473        throwTypeError(&state, throwScope);
    474         return Nullopt;
     474        return { };
    475475    }
    476476    TestObj::Dictionary result;
     
    478478    if (!anyTypedefValueValue.isUndefined()) {
    479479        result.anyTypedefValue = convert<IDLAny>(state, anyTypedefValueValue);
    480         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     480        RETURN_IF_EXCEPTION(throwScope, { });
    481481    } else
    482482        result.anyTypedefValue = jsUndefined();
     
    484484    if (!anyValueValue.isUndefined()) {
    485485        result.anyValue = convert<IDLAny>(state, anyValueValue);
    486         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     486        RETURN_IF_EXCEPTION(throwScope, { });
    487487    } else
    488488        result.anyValue = jsUndefined();
     
    490490    if (!anyValueWithNullDefaultValue.isUndefined()) {
    491491        result.anyValueWithNullDefault = convert<IDLAny>(state, anyValueWithNullDefaultValue);
    492         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     492        RETURN_IF_EXCEPTION(throwScope, { });
    493493    } else
    494494        result.anyValueWithNullDefault = jsNull();
     
    496496    if (!booleanWithDefaultValue.isUndefined()) {
    497497        result.booleanWithDefault = convert<IDLBoolean>(state, booleanWithDefaultValue);
    498         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     498        RETURN_IF_EXCEPTION(throwScope, { });
    499499    } else
    500500        result.booleanWithDefault = false;
     
    502502    if (!booleanWithoutDefaultValue.isUndefined()) {
    503503        result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue);
    504         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     504        RETURN_IF_EXCEPTION(throwScope, { });
    505505    }
    506506    JSValue bufferSourceValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "bufferSourceValue"));
    507507    if (!bufferSourceValueValue.isUndefined()) {
    508508        result.bufferSourceValue = convert<IDLBufferSource>(state, bufferSourceValueValue);
    509         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     509        RETURN_IF_EXCEPTION(throwScope, { });
    510510    }
    511511    JSValue dictionaryMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "dictionaryMember"));
    512512    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, { });
    516515    }
    517516    JSValue enumerationValueWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValueWithDefault"));
    518517    if (!enumerationValueWithDefaultValue.isUndefined()) {
    519518        result.enumerationValueWithDefault = convert<IDLEnumeration<TestObj::EnumType>>(state, enumerationValueWithDefaultValue);
    520         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     519        RETURN_IF_EXCEPTION(throwScope, { });
    521520    } else
    522521        result.enumerationValueWithDefault = TestObj::EnumType::EnumValue1;
     
    524523    if (!enumerationValueWithEmptyStringDefaultValue.isUndefined()) {
    525524        result.enumerationValueWithEmptyStringDefault = convert<IDLEnumeration<TestObj::EnumType>>(state, enumerationValueWithEmptyStringDefaultValue);
    526         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     525        RETURN_IF_EXCEPTION(throwScope, { });
    527526    } else
    528527        result.enumerationValueWithEmptyStringDefault = TestObj::EnumType::EmptyString;
     
    530529    if (!enumerationValueWithoutDefaultValue.isUndefined()) {
    531530        result.enumerationValueWithoutDefault = convert<IDLEnumeration<TestObj::EnumType>>(state, enumerationValueWithoutDefaultValue);
    532         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     531        RETURN_IF_EXCEPTION(throwScope, { });
    533532    }
    534533    JSValue integerValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "integer"));
    535534    if (!integerValue.isUndefined()) {
    536535        result.integer = convert<IDLLong>(state, integerValue);
    537         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     536        RETURN_IF_EXCEPTION(throwScope, { });
    538537    }
    539538    JSValue integerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "integerWithDefault"));
    540539    if (!integerWithDefaultValue.isUndefined()) {
    541540        result.integerWithDefault = convert<IDLLong>(state, integerWithDefaultValue);
    542         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     541        RETURN_IF_EXCEPTION(throwScope, { });
    543542    } else
    544543        result.integerWithDefault = 0;
     
    546545    if (!largeIntegerValue.isUndefined()) {
    547546        result.largeInteger = convert<IDLLongLong>(state, largeIntegerValue);
    548         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     547        RETURN_IF_EXCEPTION(throwScope, { });
    549548    }
    550549    JSValue largeIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "largeIntegerWithDefault"));
    551550    if (!largeIntegerWithDefaultValue.isUndefined()) {
    552551        result.largeIntegerWithDefault = convert<IDLLongLong>(state, largeIntegerWithDefaultValue);
    553         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     552        RETURN_IF_EXCEPTION(throwScope, { });
    554553    } else
    555554        result.largeIntegerWithDefault = 0;
     
    557556    if (!nullableIntegerWithDefaultValue.isUndefined()) {
    558557        result.nullableIntegerWithDefault = convert<IDLNullable<IDLLong>>(state, nullableIntegerWithDefaultValue);
    559         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     558        RETURN_IF_EXCEPTION(throwScope, { });
    560559    } else
    561560        result.nullableIntegerWithDefault = Nullopt;
     
    563562    if (!nullableNodeValue.isUndefined()) {
    564563        result.nullableNode = convert<IDLNullable<IDLInterface<Node>>>(state, nullableNodeValue);
    565         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     564        RETURN_IF_EXCEPTION(throwScope, { });
    566565    } else
    567566        result.nullableNode = nullptr;
     
    569568    if (!nullableStringWithDefaultValue.isUndefined()) {
    570569        result.nullableStringWithDefault = convert<IDLNullable<IDLDOMString>>(state, nullableStringWithDefaultValue);
    571         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     570        RETURN_IF_EXCEPTION(throwScope, { });
    572571    } else
    573572        result.nullableStringWithDefault = String();
     
    575574    if (!nullableUnionMemberValue.isUndefined()) {
    576575        result.nullableUnionMember = convert<IDLNullable<IDLUnion<IDLLong, IDLInterface<Node>>>>(state, nullableUnionMemberValue);
    577         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     576        RETURN_IF_EXCEPTION(throwScope, { });
    578577    } else
    579578        result.nullableUnionMember = Nullopt;
     
    581580    if (!restrictedDoubleValue.isUndefined()) {
    582581        result.restrictedDouble = convert<IDLDouble>(state, restrictedDoubleValue);
    583         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     582        RETURN_IF_EXCEPTION(throwScope, { });
    584583    }
    585584    JSValue restrictedDoubleWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedDoubleWithDefault"));
    586585    if (!restrictedDoubleWithDefaultValue.isUndefined()) {
    587586        result.restrictedDoubleWithDefault = convert<IDLDouble>(state, restrictedDoubleWithDefaultValue);
    588         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     587        RETURN_IF_EXCEPTION(throwScope, { });
    589588    } else
    590589        result.restrictedDoubleWithDefault = 0;
     
    592591    if (!restrictedFloatValue.isUndefined()) {
    593592        result.restrictedFloat = convert<IDLFloat>(state, restrictedFloatValue);
    594         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     593        RETURN_IF_EXCEPTION(throwScope, { });
    595594    }
    596595    JSValue restrictedFloatWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedFloatWithDefault"));
    597596    if (!restrictedFloatWithDefaultValue.isUndefined()) {
    598597        result.restrictedFloatWithDefault = convert<IDLFloat>(state, restrictedFloatWithDefaultValue);
    599         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     598        RETURN_IF_EXCEPTION(throwScope, { });
    600599    } else
    601600        result.restrictedFloatWithDefault = 0;
     
    603602    if (!sequenceOfStringsValue.isUndefined()) {
    604603        result.sequenceOfStrings = convert<IDLSequence<IDLDOMString>>(state, sequenceOfStringsValue);
    605         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     604        RETURN_IF_EXCEPTION(throwScope, { });
    606605    }
    607606    JSValue smallIntegerClampedValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallIntegerClamped"));
    608607    if (!smallIntegerClampedValue.isUndefined()) {
    609608        result.smallIntegerClamped = convert<IDLByte>(state, smallIntegerClampedValue);
    610         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     609        RETURN_IF_EXCEPTION(throwScope, { });
    611610    }
    612611    JSValue smallIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallIntegerWithDefault"));
    613612    if (!smallIntegerWithDefaultValue.isUndefined()) {
    614613        result.smallIntegerWithDefault = convert<IDLByte>(state, smallIntegerWithDefaultValue);
    615         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     614        RETURN_IF_EXCEPTION(throwScope, { });
    616615    }
    617616    JSValue smallUnsignedIntegerEnforcedRangeValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerEnforcedRange"));
    618617    if (!smallUnsignedIntegerEnforcedRangeValue.isUndefined()) {
    619618        result.smallUnsignedIntegerEnforcedRange = convert<IDLOctet>(state, smallUnsignedIntegerEnforcedRangeValue);
    620         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     619        RETURN_IF_EXCEPTION(throwScope, { });
    621620    }
    622621    JSValue smallUnsignedIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerWithDefault"));
    623622    if (!smallUnsignedIntegerWithDefaultValue.isUndefined()) {
    624623        result.smallUnsignedIntegerWithDefault = convert<IDLOctet>(state, smallUnsignedIntegerWithDefaultValue);
    625         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     624        RETURN_IF_EXCEPTION(throwScope, { });
    626625    } else
    627626        result.smallUnsignedIntegerWithDefault = 0;
     
    629628    if (!stringWithDefaultValue.isUndefined()) {
    630629        result.stringWithDefault = convert<IDLDOMString>(state, stringWithDefaultValue);
    631         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     630        RETURN_IF_EXCEPTION(throwScope, { });
    632631    } else
    633632        result.stringWithDefault = "defaultString";
     
    635634    if (!stringWithoutDefaultValue.isUndefined()) {
    636635        result.stringWithoutDefault = convert<IDLDOMString>(state, stringWithoutDefaultValue);
    637         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     636        RETURN_IF_EXCEPTION(throwScope, { });
    638637    }
    639638    JSValue unionMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unionMember"));
    640639    if (!unionMemberValue.isUndefined()) {
    641640        result.unionMember = convert<IDLUnion<IDLLong, IDLInterface<Node>>>(state, unionMemberValue);
    642         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     641        RETURN_IF_EXCEPTION(throwScope, { });
    643642    }
    644643    JSValue unrestrictedDoubleValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedDouble"));
    645644    if (!unrestrictedDoubleValue.isUndefined()) {
    646645        result.unrestrictedDouble = convert<IDLUnrestrictedDouble>(state, unrestrictedDoubleValue);
    647         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     646        RETURN_IF_EXCEPTION(throwScope, { });
    648647    }
    649648    JSValue unrestrictedDoubleWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedDoubleWithDefault"));
    650649    if (!unrestrictedDoubleWithDefaultValue.isUndefined()) {
    651650        result.unrestrictedDoubleWithDefault = convert<IDLUnrestrictedDouble>(state, unrestrictedDoubleWithDefaultValue);
    652         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     651        RETURN_IF_EXCEPTION(throwScope, { });
    653652    } else
    654653        result.unrestrictedDoubleWithDefault = 0;
     
    656655    if (!unrestrictedFloatValue.isUndefined()) {
    657656        result.unrestrictedFloat = convert<IDLUnrestrictedFloat>(state, unrestrictedFloatValue);
    658         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     657        RETURN_IF_EXCEPTION(throwScope, { });
    659658    }
    660659    JSValue unrestrictedFloatWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedFloatWithDefault"));
    661660    if (!unrestrictedFloatWithDefaultValue.isUndefined()) {
    662661        result.unrestrictedFloatWithDefault = convert<IDLUnrestrictedFloat>(state, unrestrictedFloatWithDefaultValue);
    663         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     662        RETURN_IF_EXCEPTION(throwScope, { });
    664663    } else
    665664        result.unrestrictedFloatWithDefault = 0;
     
    667666    if (!unsignedIntegerValue.isUndefined()) {
    668667        result.unsignedInteger = convert<IDLUnsignedLong>(state, unsignedIntegerValue);
    669         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     668        RETURN_IF_EXCEPTION(throwScope, { });
    670669    }
    671670    JSValue unsignedIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unsignedIntegerWithDefault"));
    672671    if (!unsignedIntegerWithDefaultValue.isUndefined()) {
    673672        result.unsignedIntegerWithDefault = convert<IDLUnsignedLong>(state, unsignedIntegerWithDefaultValue);
    674         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     673        RETURN_IF_EXCEPTION(throwScope, { });
    675674    } else
    676675        result.unsignedIntegerWithDefault = 0;
     
    678677    if (!unsignedLargeIntegerValue.isUndefined()) {
    679678        result.unsignedLargeInteger = convert<IDLUnsignedLongLong>(state, unsignedLargeIntegerValue);
    680         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     679        RETURN_IF_EXCEPTION(throwScope, { });
    681680    }
    682681    JSValue unsignedLargeIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unsignedLargeIntegerWithDefault"));
    683682    if (!unsignedLargeIntegerWithDefaultValue.isUndefined()) {
    684683        result.unsignedLargeIntegerWithDefault = convert<IDLUnsignedLongLong>(state, unsignedLargeIntegerWithDefaultValue);
    685         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     684        RETURN_IF_EXCEPTION(throwScope, { });
    686685    } else
    687686        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
     690template<> TestObj::DictionaryThatShouldNotTolerateNull convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(ExecState& state, JSValue value)
    692691{
    693692    VM& vm = state.vm();
     
    697696    if (UNLIKELY(!isNullOrUndefined && !object)) {
    698697        throwTypeError(&state, throwScope);
    699         return Nullopt;
     698        return { };
    700699    }
    701700    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
    702701        throwTypeError(&state, throwScope);
    703         return Nullopt;
     702        return { };
    704703    }
    705704    TestObj::DictionaryThatShouldNotTolerateNull result;
     
    707706    if (!booleanWithoutDefaultValue.isUndefined()) {
    708707        result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue);
    709         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     708        RETURN_IF_EXCEPTION(throwScope, { });
    710709    }
    711710    JSValue nonNullableNodeValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "nonNullableNode"));
    712711    if (!nonNullableNodeValue.isUndefined()) {
    713712        result.nonNullableNode = convert<IDLInterface<Node>>(state, nonNullableNodeValue);
    714         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     713        RETURN_IF_EXCEPTION(throwScope, { });
    715714    } else {
    716715        throwTypeError(&state, throwScope);
    717         return Nullopt;
     716        return { };
    718717    }
    719718    JSValue requiredDictionaryMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "requiredDictionaryMember"));
    720719    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, { });
    724722    } else {
    725723        throwTypeError(&state, throwScope);
    726         return Nullopt;
     724        return { };
    727725    }
    728726    JSValue requiredEnumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "requiredEnumerationValue"));
    729727    if (!requiredEnumerationValueValue.isUndefined()) {
    730728        result.requiredEnumerationValue = convert<IDLEnumeration<TestObj::EnumType>>(state, requiredEnumerationValueValue);
    731         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     729        RETURN_IF_EXCEPTION(throwScope, { });
    732730    } else {
    733731        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
     737template<> TestObj::DictionaryThatShouldTolerateNull convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(ExecState& state, JSValue value)
    740738{
    741739    VM& vm = state.vm();
     
    745743    if (UNLIKELY(!isNullOrUndefined && !object)) {
    746744        throwTypeError(&state, throwScope);
    747         return Nullopt;
     745        return { };
    748746    }
    749747    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
    750748        throwTypeError(&state, throwScope);
    751         return Nullopt;
     749        return { };
    752750    }
    753751    TestObj::DictionaryThatShouldTolerateNull result;
     
    755753    if (!booleanWithoutDefaultValue.isUndefined()) {
    756754        result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue);
    757         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     755        RETURN_IF_EXCEPTION(throwScope, { });
    758756    }
    759757    JSValue enumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValue"));
    760758    if (!enumerationValueValue.isUndefined()) {
    761759        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
     765template<> AlternateDictionaryName convertDictionary<AlternateDictionaryName>(ExecState& state, JSValue value)
    768766{
    769767    VM& vm = state.vm();
     
    773771    if (UNLIKELY(!isNullOrUndefined && !object)) {
    774772        throwTypeError(&state, throwScope);
    775         return Nullopt;
     773        return { };
    776774    }
    777775    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
    778776        throwTypeError(&state, throwScope);
    779         return Nullopt;
     777        return { };
    780778    }
    781779    AlternateDictionaryName result;
     
    783781    if (!booleanWithoutDefaultValue.isUndefined()) {
    784782        result.booleanWithoutDefault = convert<IDLBoolean>(state, booleanWithoutDefaultValue);
    785         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     783        RETURN_IF_EXCEPTION(throwScope, { });
    786784    }
    787785    JSValue enumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValue"));
    788786    if (!enumerationValueValue.isUndefined()) {
    789787        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
     793template<> TestObj::ParentDictionary convertDictionary<TestObj::ParentDictionary>(ExecState& state, JSValue value)
    796794{
    797795    VM& vm = state.vm();
     
    801799    if (UNLIKELY(!isNullOrUndefined && !object)) {
    802800        throwTypeError(&state, throwScope);
    803         return Nullopt;
     801        return { };
    804802    }
    805803    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
    806804        throwTypeError(&state, throwScope);
    807         return Nullopt;
     805        return { };
    808806    }
    809807    TestObj::ParentDictionary result;
     
    811809    if (!parentMember1Value.isUndefined()) {
    812810        result.parentMember1 = convert<IDLBoolean>(state, parentMember1Value);
    813         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     811        RETURN_IF_EXCEPTION(throwScope, { });
    814812    }
    815813    JSValue parentMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "parentMember2"));
    816814    if (!parentMember2Value.isUndefined()) {
    817815        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
     821template<> TestObj::ChildDictionary convertDictionary<TestObj::ChildDictionary>(ExecState& state, JSValue value)
    824822{
    825823    VM& vm = state.vm();
     
    829827    if (UNLIKELY(!isNullOrUndefined && !object)) {
    830828        throwTypeError(&state, throwScope);
    831         return Nullopt;
     829        return { };
    832830    }
    833831    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
    834832        throwTypeError(&state, throwScope);
    835         return Nullopt;
     833        return { };
    836834    }
    837835    TestObj::ChildDictionary result;
     
    839837    if (!parentMember1Value.isUndefined()) {
    840838        result.parentMember1 = convert<IDLBoolean>(state, parentMember1Value);
    841         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     839        RETURN_IF_EXCEPTION(throwScope, { });
    842840    }
    843841    JSValue parentMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "parentMember2"));
    844842    if (!parentMember2Value.isUndefined()) {
    845843        result.parentMember2 = convert<IDLBoolean>(state, parentMember2Value);
    846         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     844        RETURN_IF_EXCEPTION(throwScope, { });
    847845    }
    848846    JSValue childMember1Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "childMember1"));
    849847    if (!childMember1Value.isUndefined()) {
    850848        result.childMember1 = convert<IDLBoolean>(state, childMember1Value);
    851         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     849        RETURN_IF_EXCEPTION(throwScope, { });
    852850    }
    853851    JSValue childMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "childMember2"));
    854852    if (!childMember2Value.isUndefined()) {
    855853        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;
    859857}
    860858
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h

    r207192 r207498  
    208208template<> const char* expectedEnumerationValues<TestObj::Confidence>();
    209209
    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);
     210template<> TestObj::Dictionary convertDictionary<TestObj::Dictionary>(JSC::ExecState&, JSC::JSValue);
     211
     212template<> TestObj::DictionaryThatShouldNotTolerateNull convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(JSC::ExecState&, JSC::JSValue);
     213
     214template<> TestObj::DictionaryThatShouldTolerateNull convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(JSC::ExecState&, JSC::JSValue);
     215
     216template<> AlternateDictionaryName convertDictionary<AlternateDictionaryName>(JSC::ExecState&, JSC::JSValue);
     217
     218template<> TestObj::ParentDictionary convertDictionary<TestObj::ParentDictionary>(JSC::ExecState&, JSC::JSValue);
     219
     220template<> TestObj::ChildDictionary convertDictionary<TestObj::ChildDictionary>(JSC::ExecState&, JSC::JSValue);
    221221
    222222
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp

    r207243 r207498  
    2727namespace WebCore {
    2828
    29 template<> Optional<DictionaryImplName> convertDictionary<DictionaryImplName>(ExecState& state, JSValue value)
     29template<> DictionaryImplName convertDictionary<DictionaryImplName>(ExecState& state, JSValue value)
    3030{
    3131    VM& vm = state.vm();
     
    3535    if (UNLIKELY(!isNullOrUndefined && !object)) {
    3636        throwTypeError(&state, throwScope);
    37         return Nullopt;
     37        return { };
    3838    }
    3939    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
    4040        throwTypeError(&state, throwScope);
    41         return Nullopt;
     41        return { };
    4242    }
    4343    DictionaryImplName result;
     
    4545    if (!boolMemberValue.isUndefined()) {
    4646        result.boolMember = convert<IDLBoolean>(state, boolMemberValue);
    47         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     47        RETURN_IF_EXCEPTION(throwScope, { });
    4848    }
    4949    JSValue stringMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "stringMember"));
    5050    if (!stringMemberValue.isUndefined()) {
    5151        result.stringMember = convert<IDLDOMString>(state, stringMemberValue);
    52         RETURN_IF_EXCEPTION(throwScope, Nullopt);
     52        RETURN_IF_EXCEPTION(throwScope, { });
    5353    }
    54     return WTFMove(result);
     54    return result;
    5555}
    5656
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.h

    r207243 r207498  
    2626namespace WebCore {
    2727
    28 template<> Optional<DictionaryImplName> convertDictionary<DictionaryImplName>(JSC::ExecState&, JSC::JSValue);
     28template<> DictionaryImplName convertDictionary<DictionaryImplName>(JSC::ExecState&, JSC::JSValue);
    2929
    3030} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.