Changeset 212462 in webkit


Ignore:
Timestamp:
Feb 16, 2017 1:31:17 PM (7 years ago)
Author:
BJ Burg
Message:

[Cocoa] Web Inspector: Inspector::fromProtocolString<T> should return std::optional<T>
https://bugs.webkit.org/show_bug.cgi?id=168018
<rdar://problem/30468779>

Reviewed by Joseph Pecoraro.

These methods parse untrusted string inputs, so they should return an optional instead
of asserting or crashing when the input is not usable.

Update various pieces of generated code to handle the error case gracefully.

  • inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:

(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
The local variable holding the ObjC-friendly converted value should take a std::optional
when converting an enum from a string into an NS_ENUM value. If the enum command parameter
is not optional, then send a response with a command failure message and return.

The optional enum parameter case is not handled correctly, but no existing code requires it.

  • inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py:

(ObjCProtocolTypeConversionsHeaderGenerator._generate_enum_from_protocol_string):
Fix signature and remove default case ASSERT_NOT_REACHED.

  • inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py:

(ObjCProtocolTypeConversionsImplementationGenerator._generate_type_factory_method_implementation):
Since this code assumes all inputs to be valid and throws an exception otherwise, we
try to convert the enum and throw an exception if it's nullopt. If it's valid, write to outValue.

  • inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:

(ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload):
The local variable holding the ObjC-friendly converted value should take a std::optional
when converting an enum from a string into an NS_ENUM value. If the enum command parameter
is not optional, then throw an exception if the value is nullopt. Otherwise, allow it to be empty.

  • inspector/scripts/codegen/objc_generator.py:

(ObjCGenerator.protocol_to_objc_expression_for_member):
Unconditionally unwrap the optional. This expression is only used inside the typechecked
ObjC protocol objects. In this case we are guaranteed to have already initialized the enum with a valid
value, but must store it as a string inside a wrapped InspectorObject. The getter needs to
re-convert the stored string into an NS_ENUM value.

  • inspector/scripts/codegen/objc_generator_templates.py:

Update type template for fromProtocolString<T>().

  • inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result:
  • inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result:
  • inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result:
  • inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result:
  • inspector/scripts/tests/generic/expected/domain-availability.json-result:
  • inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result:
  • inspector/scripts/tests/generic/expected/enum-values.json-result:
  • inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result:
  • inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result:
  • inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result:
  • inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result:
  • inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result:
  • inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result:
  • inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result:
  • inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result:
  • inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
  • inspector/scripts/tests/generic/expected/worker-supported-domains.json-result:
  • inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result:
  • inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result:

Rebaseline tests.

Location:
trunk/Source/JavaScriptCore
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r212458 r212462  
     12017-02-15  Brian Burg  <bburg@apple.com>
     2
     3        [Cocoa] Web Inspector: Inspector::fromProtocolString<T> should return std::optional<T>
     4        https://bugs.webkit.org/show_bug.cgi?id=168018
     5        <rdar://problem/30468779>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        These methods parse untrusted string inputs, so they should return an optional instead
     10        of asserting or crashing when the input is not usable.
     11
     12        Update various pieces of generated code to handle the error case gracefully.
     13
     14        * inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
     15        (ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
     16        (ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
     17        The local variable holding the ObjC-friendly converted value should take a std::optional
     18        when converting an enum from a string into an NS_ENUM value. If the enum command parameter
     19        is not optional, then send a response with a command failure message and return.
     20
     21        The optional enum parameter case is not handled correctly, but no existing code requires it.
     22
     23        * inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py:
     24        (ObjCProtocolTypeConversionsHeaderGenerator._generate_enum_from_protocol_string):
     25        Fix signature and remove default case ASSERT_NOT_REACHED.
     26
     27        * inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py:
     28        (ObjCProtocolTypeConversionsImplementationGenerator._generate_type_factory_method_implementation):
     29        Since this code assumes all inputs to be valid and throws an exception otherwise, we
     30        try to convert the enum and throw an exception if it's nullopt. If it's valid, write to outValue.
     31
     32        * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:
     33        (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload):
     34        The local variable holding the ObjC-friendly converted value should take a std::optional
     35        when converting an enum from a string into an NS_ENUM value. If the enum command parameter
     36        is not optional, then throw an exception if the value is nullopt. Otherwise, allow it to be empty.
     37
     38        * inspector/scripts/codegen/objc_generator.py:
     39        (ObjCGenerator.protocol_to_objc_expression_for_member):
     40        Unconditionally unwrap the optional. This expression is only used inside the typechecked
     41        ObjC protocol objects. In this case we are guaranteed to have already initialized the enum with a valid
     42        value, but must store it as a string inside a wrapped InspectorObject. The getter needs to
     43        re-convert the stored string into an NS_ENUM value.
     44
     45        * inspector/scripts/codegen/objc_generator_templates.py:
     46        Update type template for fromProtocolString<T>().
     47
     48        * inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result:
     49        * inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result:
     50        * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result:
     51        * inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result:
     52        * inspector/scripts/tests/generic/expected/domain-availability.json-result:
     53        * inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result:
     54        * inspector/scripts/tests/generic/expected/enum-values.json-result:
     55        * inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result:
     56        * inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result:
     57        * inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result:
     58        * inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result:
     59        * inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result:
     60        * inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result:
     61        * inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result:
     62        * inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result:
     63        * inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
     64        * inspector/scripts/tests/generic/expected/worker-supported-domains.json-result:
     65        * inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result:
     66        * inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result:
     67        Rebaseline tests.
     68
    1692017-02-16  Keith Miller  <keith_miller@apple.com>
    270
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py

    r210309 r212462  
    169169            objc_in_param_name = 'o_%s' % in_param_name
    170170            objc_type = self.objc_type_for_param(domain, command.command_name, parameter, False)
     171            if isinstance(parameter.type, EnumType):
     172                objc_type = 'std::optional<%s>' % objc_type
    171173            param_expression = in_param_expression(in_param_name, parameter)
    172174            import_expression = self.objc_protocol_import_expression_for_parameter(param_expression, domain, command.command_name, parameter)
    173175            if not parameter.is_optional:
    174176                lines.append('    %s = %s;' % (join_type_and_name(objc_type, objc_in_param_name), import_expression))
     177
     178                if isinstance(parameter.type, EnumType):
     179                    lines.append('    if (!%s) {' % objc_in_param_name)
     180                    lines.append('        backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter \'%%s\' of method \'%%s\' cannot be processed", "%s", "%s.%s"));' % (parameter.parameter_name, domain.domain_name, command.command_name))
     181                    lines.append('        return;')
     182                    lines.append('    }')
     183
    175184            else:
    176185                lines.append('    %s;' % join_type_and_name(objc_type, objc_in_param_name))
     
    188197        for parameter in command.call_parameters:
    189198            in_param_name = 'in_%s' % parameter.parameter_name
    190             objc_in_param_name = 'o_%s' % in_param_name
     199            objc_in_param_expression = 'o_%s' % in_param_name
    191200            if not parameter.is_optional:
    192                 pairs.append('%s:%s' % (parameter.parameter_name, objc_in_param_name))
     201                # FIXME: we don't handle optional enum values in commands here because it isn't used anywhere yet.
     202                # We'd need to change the delegate's signature to take std::optional for optional enum values.
     203                if isinstance(parameter.type, EnumType):
     204                    objc_in_param_expression = '%s.value()' % objc_in_param_expression
     205
     206                pairs.append('%s:%s' % (parameter.parameter_name, objc_in_param_expression))
    193207            else:
    194                 optional_expression = '(%s ? &%s : nil)' % (in_param_name, objc_in_param_name)
     208                optional_expression = '(%s ? &%s : nil)' % (in_param_name, objc_in_param_expression)
    195209                pairs.append('%s:%s' % (parameter.parameter_name, optional_expression))
    196210        return '    [m_delegate %s%s];' % (command.command_name, ' '.join(pairs))
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py

    r212116 r212462  
    156156        lines = []
    157157        lines.append('template<>')
    158         lines.append('inline %s fromProtocolString(const String& value)' % objc_enum_name)
     158        lines.append('inline std::optional<%s> fromProtocolString(const String& value)' % objc_enum_name)
    159159        lines.append('{')
    160160        for enum_value in enum_values:
    161161            lines.append('    if (value == "%s")' % enum_value)
    162162            lines.append('        return %s%s;' % (objc_enum_name, Generator.stylized_name_for_enum_value(enum_value)))
    163         lines.append('    ASSERT_NOT_REACHED();')
    164         lines.append('    return %s%s;' % (objc_enum_name, Generator.stylized_name_for_enum_value(enum_values[0])))
     163        lines.append('    return std::nullopt;')
    165164        lines.append('}')
    166165        return '\n'.join(lines)
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py

    r210309 r212462  
    126126        if isinstance(resolved_type, EnumType):
    127127            lines.append('    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);')
    128             lines.append('    *outValue = @(Inspector::fromProtocolString<%s>(payload));' % self.objc_name_for_type(resolved_type))
     128            lines.append('    std::optional<%(type)s> result = Inspector::fromProtocolString<%(type)s>(payload);' % {'type': self.objc_name_for_type(resolved_type)})
     129            lines.append('    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"%s");' % declaration.type.raw_name())
     130            lines.append('    *outValue = @(result.value());')
    129131        elif isinstance(resolved_type, (ArrayType, PrimitiveType)):
    130132            lines.append('    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [%s class]);' % objc_class)
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py

    r212157 r212462  
    3131
    3232from generator import Generator, ucfirst
    33 from models import ObjectType, Frameworks
     33from models import ObjectType, EnumType, Frameworks
    3434from objc_generator import ObjCGenerator
    3535from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
     
    130130        for member in declaration.type_members:
    131131            member_name = member.member_name
    132             conversion_expression = self.payload_to_objc_expression_for_member(declaration, member)
    133132
    134133            if not member.is_optional:
    135134                lines.append('    THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"%s"], @"%s");' % (member_name, member_name))
    136135
     136            objc_type = self.objc_type_for_member(declaration, member)
    137137            var_name = ObjCGenerator.identifier_to_objc_identifier(member_name)
    138             lines.append('    self.%s = %s;' % (var_name, conversion_expression))
     138            conversion_expression = self.payload_to_objc_expression_for_member(declaration, member)
     139            if isinstance(member.type, EnumType):
     140                lines.append('    std::optional<%s> %s = %s;' % (objc_type, var_name, conversion_expression))
     141                if not member.is_optional:
     142                    lines.append('    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(%s, @"%s");' % (var_name, member_name))
     143                    lines.append('    self.%s = %s.value();' % (var_name, var_name))
     144                else:
     145                    lines.append('    if (%s)' % var_name)
     146                    lines.append('        self.%s = %s.value();' % (var_name, var_name))
     147            else:
     148                lines.append('    self.%s = %s;' % (var_name, conversion_expression))
     149
    139150            lines.append('')
    140151
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py

    r210309 r212462  
    443443            if isinstance(member.type, EnumType):
    444444                if member.type.is_anonymous:
    445                     return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_anonymous_enum_member(declaration, member), sub_expression)
    446                 return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_non_anonymous_enum(member.type), sub_expression)
     445                    return 'fromProtocolString<%s>(%s).value()' % (self.objc_enum_name_for_anonymous_enum_member(declaration, member), sub_expression)
     446                return 'fromProtocolString<%s>(%s).value()' % (self.objc_enum_name_for_non_anonymous_enum(member.type), sub_expression)
    447447            return sub_expression
    448448        if category is ObjCTypeCategory.Object:
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator_templates.py

    r210852 r212462  
    5656    TypeConversionsHeaderStandard = (
    5757    """template<typename ObjCEnumType>
    58 ObjCEnumType fromProtocolString(const String& value);""")
     58std::optional<ObjCEnumType> fromProtocolString(const String& value);""")
    5959
    6060    BackendDispatcherHeaderPrelude = (
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result

    r212116 r212462  
    10071007
    10081008template<typename ObjCEnumType>
    1009 ObjCEnumType fromProtocolString(const String& value);
     1009std::optional<ObjCEnumType> fromProtocolString(const String& value);
    10101010
    10111011inline String toProtocolString(TestProtocolPlatform value)
     
    10241024
    10251025template<>
    1026 inline TestProtocolPlatform fromProtocolString(const String& value)
     1026inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    10271027{
    10281028    if (value == "all")
     
    10341034    if (value == "macos")
    10351035        return TestProtocolPlatformMacOS;
    1036     ASSERT_NOT_REACHED();
    1037     return TestProtocolPlatformAll;
     1036    return std::nullopt;
    10381037}
    10391038
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result

    r212116 r212462  
    14261426
    14271427template<typename ObjCEnumType>
    1428 ObjCEnumType fromProtocolString(const String& value);
     1428std::optional<ObjCEnumType> fromProtocolString(const String& value);
    14291429
    14301430inline String toProtocolString(TestProtocolPlatform value)
     
    14431443
    14441444template<>
    1445 inline TestProtocolPlatform fromProtocolString(const String& value)
     1445inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    14461446{
    14471447    if (value == "all")
     
    14531453    if (value == "macos")
    14541454        return TestProtocolPlatformMacOS;
    1455     ASSERT_NOT_REACHED();
    1456     return TestProtocolPlatformAll;
     1455    return std::nullopt;
    14571456}
    14581457
     
    14711470
    14721471template<>
    1473 inline TestProtocolDatabasePrimaryColors fromProtocolString(const String& value)
     1472inline std::optional<TestProtocolDatabasePrimaryColors> fromProtocolString(const String& value)
    14741473{
    14751474    if (value == "red")
     
    14791478    if (value == "blue")
    14801479        return TestProtocolDatabasePrimaryColorsBlue;
    1481     ASSERT_NOT_REACHED();
    1482     return TestProtocolDatabasePrimaryColorsRed;
     1480    return std::nullopt;
    14831481}
    14841482
     
    14981496
    14991497template<>
    1500 inline TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor fromProtocolString(const String& value)
     1498inline std::optional<TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor> fromProtocolString(const String& value)
    15011499{
    15021500    if (value == "cyan")
     
    15081506    if (value == "black")
    15091507        return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorBlack;
    1510     ASSERT_NOT_REACHED();
    1511     return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan;
     1508    return std::nullopt;
    15121509}
    15131510
     
    15271524
    15281525template<>
    1529 inline TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor fromProtocolString(const String& value)
     1526inline std::optional<TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor> fromProtocolString(const String& value)
    15301527{
    15311528    if (value == "cyan")
     
    15371534    if (value == "black")
    15381535        return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorBlack;
    1539     ASSERT_NOT_REACHED();
    1540     return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan;
     1536    return std::nullopt;
    15411537}
    15421538
     
    15561552
    15571553template<>
    1558 inline TestProtocolDatabaseExecuteSQLSyncPrintColor fromProtocolString(const String& value)
     1554inline std::optional<TestProtocolDatabaseExecuteSQLSyncPrintColor> fromProtocolString(const String& value)
    15591555{
    15601556    if (value == "cyan")
     
    15661562    if (value == "black")
    15671563        return TestProtocolDatabaseExecuteSQLSyncPrintColorBlack;
    1568     ASSERT_NOT_REACHED();
    1569     return TestProtocolDatabaseExecuteSQLSyncPrintColorCyan;
     1564    return std::nullopt;
    15701565}
    15711566
     
    15851580
    15861581template<>
    1587 inline TestProtocolDatabaseExecuteSQLAsyncPrintColor fromProtocolString(const String& value)
     1582inline std::optional<TestProtocolDatabaseExecuteSQLAsyncPrintColor> fromProtocolString(const String& value)
    15881583{
    15891584    if (value == "cyan")
     
    15951590    if (value == "black")
    15961591        return TestProtocolDatabaseExecuteSQLAsyncPrintColorBlack;
    1597     ASSERT_NOT_REACHED();
    1598     return TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan;
     1592    return std::nullopt;
    15991593}
    16001594
     
    16621656{
    16631657    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
    1664     *outValue = @(Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload));
     1658    std::optional<TestProtocolDatabasePrimaryColors> result = Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload);
     1659    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"PrimaryColors");
     1660    *outValue = @(result.value());
    16651661}
    16661662
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result

    r212116 r212462  
    873873    if (in_sqlError)
    874874        o_in_sqlError = [[[TestProtocolDatabaseError alloc] initWithInspectorObject:in_sqlError] autorelease];
    875     TestProtocolDatabasePrimaryColors o_in_screenColor;
     875    std::optional<TestProtocolDatabasePrimaryColors> o_in_screenColor;
    876876    if (in_screenColor)
    877877        o_in_screenColor = fromProtocolString<TestProtocolDatabasePrimaryColors>(*in_screenColor);
     
    879879    if (in_alternateColors)
    880880        o_in_alternateColors = objcStringArray(in_alternateColors);
    881     TestProtocolDatabaseExecuteAllOptionalParametersPrintColor o_in_printColor;
     881    std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> o_in_printColor;
    882882    if (in_printColor)
    883883        o_in_printColor = fromProtocolString<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor>(*in_printColor);
     
    921921    int o_in_databaseId = in_databaseId;
    922922    TestProtocolDatabaseError *o_in_sqlError = [[[TestProtocolDatabaseError alloc] initWithInspectorObject:&in_sqlError] autorelease];
    923     TestProtocolDatabasePrimaryColors o_in_screenColor = fromProtocolString<TestProtocolDatabasePrimaryColors>(in_screenColor);
     923    std::optional<TestProtocolDatabasePrimaryColors> o_in_screenColor = fromProtocolString<TestProtocolDatabasePrimaryColors>(in_screenColor);
     924    if (!o_in_screenColor) {
     925        backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' of method '%s' cannot be processed", "screenColor", "Database.executeNoOptionalParameters"));
     926        return;
     927    }
    924928    NSArray/*<NSString>*/ *o_in_alternateColors = objcStringArray(&in_alternateColors);
    925     TestProtocolDatabaseExecuteNoOptionalParametersPrintColor o_in_printColor = fromProtocolString<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor>(in_printColor);
    926 
    927     [m_delegate executeNoOptionalParametersWithErrorCallback:errorCallback successCallback:successCallback columnNames:o_in_columnNames notes:o_in_notes timestamp:o_in_timestamp values:o_in_values payload:o_in_payload databaseId:o_in_databaseId sqlError:o_in_sqlError screenColor:o_in_screenColor alternateColors:o_in_alternateColors printColor:o_in_printColor];
     929    std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> o_in_printColor = fromProtocolString<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor>(in_printColor);
     930    if (!o_in_printColor) {
     931        backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' of method '%s' cannot be processed", "printColor", "Database.executeNoOptionalParameters"));
     932        return;
     933    }
     934
     935    [m_delegate executeNoOptionalParametersWithErrorCallback:errorCallback successCallback:successCallback columnNames:o_in_columnNames notes:o_in_notes timestamp:o_in_timestamp values:o_in_values payload:o_in_payload databaseId:o_in_databaseId sqlError:o_in_sqlError screenColor:o_in_screenColor.value() alternateColors:o_in_alternateColors printColor:o_in_printColor.value()];
    928936}
    929937
     
    12811289
    12821290template<typename ObjCEnumType>
    1283 ObjCEnumType fromProtocolString(const String& value);
     1291std::optional<ObjCEnumType> fromProtocolString(const String& value);
    12841292
    12851293inline String toProtocolString(TestProtocolPlatform value)
     
    12981306
    12991307template<>
    1300 inline TestProtocolPlatform fromProtocolString(const String& value)
     1308inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    13011309{
    13021310    if (value == "all")
     
    13081316    if (value == "macos")
    13091317        return TestProtocolPlatformMacOS;
    1310     ASSERT_NOT_REACHED();
    1311     return TestProtocolPlatformAll;
     1318    return std::nullopt;
    13121319}
    13131320
     
    13261333
    13271334template<>
    1328 inline TestProtocolDatabasePrimaryColors fromProtocolString(const String& value)
     1335inline std::optional<TestProtocolDatabasePrimaryColors> fromProtocolString(const String& value)
    13291336{
    13301337    if (value == "red")
     
    13341341    if (value == "blue")
    13351342        return TestProtocolDatabasePrimaryColorsBlue;
    1336     ASSERT_NOT_REACHED();
    1337     return TestProtocolDatabasePrimaryColorsRed;
     1343    return std::nullopt;
    13381344}
    13391345
     
    13531359
    13541360template<>
    1355 inline TestProtocolDatabaseExecuteAllOptionalParametersPrintColor fromProtocolString(const String& value)
     1361inline std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> fromProtocolString(const String& value)
    13561362{
    13571363    if (value == "cyan")
     
    13631369    if (value == "black")
    13641370        return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack;
    1365     ASSERT_NOT_REACHED();
    1366     return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan;
     1371    return std::nullopt;
    13671372}
    13681373
     
    13821387
    13831388template<>
    1384 inline TestProtocolDatabaseExecuteAllOptionalParametersPrintColor fromProtocolString(const String& value)
     1389inline std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> fromProtocolString(const String& value)
    13851390{
    13861391    if (value == "cyan")
     
    13921397    if (value == "black")
    13931398        return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack;
    1394     ASSERT_NOT_REACHED();
    1395     return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan;
     1399    return std::nullopt;
    13961400}
    13971401
     
    14111415
    14121416template<>
    1413 inline TestProtocolDatabaseExecuteNoOptionalParametersPrintColor fromProtocolString(const String& value)
     1417inline std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> fromProtocolString(const String& value)
    14141418{
    14151419    if (value == "cyan")
     
    14211425    if (value == "black")
    14221426        return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack;
    1423     ASSERT_NOT_REACHED();
    1424     return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan;
     1427    return std::nullopt;
    14251428}
    14261429
     
    14401443
    14411444template<>
    1442 inline TestProtocolDatabaseExecuteNoOptionalParametersPrintColor fromProtocolString(const String& value)
     1445inline std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> fromProtocolString(const String& value)
    14431446{
    14441447    if (value == "cyan")
     
    14501453    if (value == "black")
    14511454        return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack;
    1452     ASSERT_NOT_REACHED();
    1453     return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan;
     1455    return std::nullopt;
    14541456}
    14551457
     
    15171519{
    15181520    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
    1519     *outValue = @(Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload));
     1521    std::optional<TestProtocolDatabasePrimaryColors> result = Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload);
     1522    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"PrimaryColors");
     1523    *outValue = @(result.value());
    15201524}
    15211525
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result

    r212116 r212462  
    743743
    744744template<typename ObjCEnumType>
    745 ObjCEnumType fromProtocolString(const String& value);
     745std::optional<ObjCEnumType> fromProtocolString(const String& value);
    746746
    747747inline String toProtocolString(TestProtocolPlatform value)
     
    760760
    761761template<>
    762 inline TestProtocolPlatform fromProtocolString(const String& value)
     762inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    763763{
    764764    if (value == "all")
     
    770770    if (value == "macos")
    771771        return TestProtocolPlatformMacOS;
    772     ASSERT_NOT_REACHED();
    773     return TestProtocolPlatformAll;
     772    return std::nullopt;
    774773}
    775774
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domain-availability.json-result

    r212116 r212462  
    997997
    998998template<typename ObjCEnumType>
    999 ObjCEnumType fromProtocolString(const String& value);
     999std::optional<ObjCEnumType> fromProtocolString(const String& value);
    10001000
    10011001inline String toProtocolString(TestProtocolPlatform value)
     
    10141014
    10151015template<>
    1016 inline TestProtocolPlatform fromProtocolString(const String& value)
     1016inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    10171017{
    10181018    if (value == "all")
     
    10241024    if (value == "macos")
    10251025        return TestProtocolPlatformMacOS;
    1026     ASSERT_NOT_REACHED();
    1027     return TestProtocolPlatformAll;
     1026    return std::nullopt;
    10281027}
    10291028
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result

    r212116 r212462  
    12601260
    12611261template<typename ObjCEnumType>
    1262 ObjCEnumType fromProtocolString(const String& value);
     1262std::optional<ObjCEnumType> fromProtocolString(const String& value);
    12631263
    12641264inline String toProtocolString(TestProtocolPlatform value)
     
    12771277
    12781278template<>
    1279 inline TestProtocolPlatform fromProtocolString(const String& value)
     1279inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    12801280{
    12811281    if (value == "all")
     
    12871287    if (value == "macos")
    12881288        return TestProtocolPlatformMacOS;
    1289     ASSERT_NOT_REACHED();
    1290     return TestProtocolPlatformAll;
     1289    return std::nullopt;
    12911290}
    12921291
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result

    r212116 r212462  
    10401040
    10411041template<typename ObjCEnumType>
    1042 ObjCEnumType fromProtocolString(const String& value);
     1042std::optional<ObjCEnumType> fromProtocolString(const String& value);
    10431043
    10441044inline String toProtocolString(TestProtocolPlatform value)
     
    10571057
    10581058template<>
    1059 inline TestProtocolPlatform fromProtocolString(const String& value)
     1059inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    10601060{
    10611061    if (value == "all")
     
    10671067    if (value == "macos")
    10681068        return TestProtocolPlatformMacOS;
    1069     ASSERT_NOT_REACHED();
    1070     return TestProtocolPlatformAll;
     1069    return std::nullopt;
    10711070}
    10721071
     
    10871086
    10881087template<>
    1089 inline TestProtocolTypeDomainEnum fromProtocolString(const String& value)
     1088inline std::optional<TestProtocolTypeDomainEnum> fromProtocolString(const String& value)
    10901089{
    10911090    if (value == "shared")
     
    10971096    if (value == "blue")
    10981097        return TestProtocolTypeDomainEnumBlue;
    1099     ASSERT_NOT_REACHED();
    1100     return TestProtocolTypeDomainEnumShared;
     1098    return std::nullopt;
    11011099}
    11021100
     
    11551153{
    11561154    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
    1157     *outValue = @(Inspector::fromProtocolString<TestProtocolTypeDomainEnum>(payload));
     1155    std::optional<TestProtocolTypeDomainEnum> result = Inspector::fromProtocolString<TestProtocolTypeDomainEnum>(payload);
     1156    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"TypeDomainEnum");
     1157    *outValue = @(result.value());
    11581158}
    11591159
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result

    r212116 r212462  
    993993
    994994template<typename ObjCEnumType>
    995 ObjCEnumType fromProtocolString(const String& value);
     995std::optional<ObjCEnumType> fromProtocolString(const String& value);
    996996
    997997inline String toProtocolString(TestProtocolPlatform value)
     
    10101010
    10111011template<>
    1012 inline TestProtocolPlatform fromProtocolString(const String& value)
     1012inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    10131013{
    10141014    if (value == "all")
     
    10201020    if (value == "macos")
    10211021        return TestProtocolPlatformMacOS;
    1022     ASSERT_NOT_REACHED();
    1023     return TestProtocolPlatformAll;
     1022    return std::nullopt;
    10241023}
    10251024
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result

    r212116 r212462  
    10341034
    10351035template<typename ObjCEnumType>
    1036 ObjCEnumType fromProtocolString(const String& value);
     1036std::optional<ObjCEnumType> fromProtocolString(const String& value);
    10371037
    10381038inline String toProtocolString(TestProtocolPlatform value)
     
    10511051
    10521052template<>
    1053 inline TestProtocolPlatform fromProtocolString(const String& value)
     1053inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    10541054{
    10551055    if (value == "all")
     
    10611061    if (value == "macos")
    10621062        return TestProtocolPlatformMacOS;
    1063     ASSERT_NOT_REACHED();
    1064     return TestProtocolPlatformAll;
     1063    return std::nullopt;
    10651064}
    10661065
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result

    r212116 r212462  
    753753
    754754template<typename ObjCEnumType>
    755 ObjCEnumType fromProtocolString(const String& value);
     755std::optional<ObjCEnumType> fromProtocolString(const String& value);
    756756
    757757inline String toProtocolString(TestProtocolPlatform value)
     
    770770
    771771template<>
    772 inline TestProtocolPlatform fromProtocolString(const String& value)
     772inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    773773{
    774774    if (value == "all")
     
    780780    if (value == "macos")
    781781        return TestProtocolPlatformMacOS;
    782     ASSERT_NOT_REACHED();
    783     return TestProtocolPlatformAll;
     782    return std::nullopt;
    784783}
    785784
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result

    r212116 r212462  
    890890
    891891template<typename ObjCEnumType>
    892 ObjCEnumType fromProtocolString(const String& value);
     892std::optional<ObjCEnumType> fromProtocolString(const String& value);
    893893
    894894inline String toProtocolString(TestProtocolPlatform value)
     
    907907
    908908template<>
    909 inline TestProtocolPlatform fromProtocolString(const String& value)
     909inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    910910{
    911911    if (value == "all")
     
    917917    if (value == "macos")
    918918        return TestProtocolPlatformMacOS;
    919     ASSERT_NOT_REACHED();
    920     return TestProtocolPlatformAll;
     919    return std::nullopt;
    921920}
    922921
     
    935934
    936935template<>
    937 inline TestProtocolRuntimeKeyPathType fromProtocolString(const String& value)
     936inline std::optional<TestProtocolRuntimeKeyPathType> fromProtocolString(const String& value)
    938937{
    939938    if (value == "null")
     
    943942    if (value == "array")
    944943        return TestProtocolRuntimeKeyPathTypeArray;
    945     ASSERT_NOT_REACHED();
    946     return TestProtocolRuntimeKeyPathTypeNull;
     944    return std::nullopt;
    947945}
    948946
     
    10581056
    10591057    THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"type"], @"type");
    1060     self.type = fromProtocolString<TestProtocolRuntimeKeyPathType>(payload[@"type"]);
     1058    std::optional<TestProtocolRuntimeKeyPathType> type = fromProtocolString<TestProtocolRuntimeKeyPathType>(payload[@"type"]);
     1059    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(type, @"type");
     1060    self.type = type.value();
    10611061
    10621062    self.string = payload[@"string"];
     
    10911091- (TestProtocolRuntimeKeyPathType)type
    10921092{
    1093     return fromProtocolString<TestProtocolRuntimeKeyPathType>([super stringForKey:@"type"]);
     1093    return fromProtocolString<TestProtocolRuntimeKeyPathType>([super stringForKey:@"type"]).value();
    10941094}
    10951095
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result

    r212116 r212462  
    748748
    749749template<typename ObjCEnumType>
    750 ObjCEnumType fromProtocolString(const String& value);
     750std::optional<ObjCEnumType> fromProtocolString(const String& value);
    751751
    752752inline String toProtocolString(TestProtocolPlatform value)
     
    765765
    766766template<>
    767 inline TestProtocolPlatform fromProtocolString(const String& value)
     767inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    768768{
    769769    if (value == "all")
     
    775775    if (value == "macos")
    776776        return TestProtocolPlatformMacOS;
    777     ASSERT_NOT_REACHED();
    778     return TestProtocolPlatformAll;
     777    return std::nullopt;
    779778}
    780779
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result

    r212116 r212462  
    831831
    832832template<typename ObjCEnumType>
    833 ObjCEnumType fromProtocolString(const String& value);
     833std::optional<ObjCEnumType> fromProtocolString(const String& value);
    834834
    835835inline String toProtocolString(TestProtocolPlatform value)
     
    848848
    849849template<>
    850 inline TestProtocolPlatform fromProtocolString(const String& value)
     850inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    851851{
    852852    if (value == "all")
     
    858858    if (value == "macos")
    859859        return TestProtocolPlatformMacOS;
    860     ASSERT_NOT_REACHED();
    861     return TestProtocolPlatformAll;
     860    return std::nullopt;
    862861}
    863862
     
    876875
    877876template<>
    878 inline TestProtocolDebuggerReason fromProtocolString(const String& value)
     877inline std::optional<TestProtocolDebuggerReason> fromProtocolString(const String& value)
    879878{
    880879    if (value == "Died")
     
    884883    if (value == "Hungry")
    885884        return TestProtocolDebuggerReasonHungry;
    886     ASSERT_NOT_REACHED();
    887     return TestProtocolDebuggerReasonDied;
     885    return std::nullopt;
    888886}
    889887
     
    961959{
    962960    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
    963     *outValue = @(Inspector::fromProtocolString<TestProtocolDebuggerReason>(payload));
     961    std::optional<TestProtocolDebuggerReason> result = Inspector::fromProtocolString<TestProtocolDebuggerReason>(payload);
     962    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"Reason");
     963    *outValue = @(result.value());
    964964}
    965965
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result

    r212116 r212462  
    859859
    860860template<typename ObjCEnumType>
    861 ObjCEnumType fromProtocolString(const String& value);
     861std::optional<ObjCEnumType> fromProtocolString(const String& value);
    862862
    863863inline String toProtocolString(TestProtocolPlatform value)
     
    876876
    877877template<>
    878 inline TestProtocolPlatform fromProtocolString(const String& value)
     878inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    879879{
    880880    if (value == "all")
     
    886886    if (value == "macos")
    887887        return TestProtocolPlatformMacOS;
    888     ASSERT_NOT_REACHED();
    889     return TestProtocolPlatformAll;
     888    return std::nullopt;
    890889}
    891890
     
    906905
    907906template<>
    908 inline TestProtocolRuntimeFarmAnimals fromProtocolString(const String& value)
     907inline std::optional<TestProtocolRuntimeFarmAnimals> fromProtocolString(const String& value)
    909908{
    910909    if (value == "Pigs")
     
    916915    if (value == "Hens")
    917916        return TestProtocolRuntimeFarmAnimalsHens;
    918     ASSERT_NOT_REACHED();
    919     return TestProtocolRuntimeFarmAnimalsPigs;
     917    return std::nullopt;
    920918}
    921919
     
    935933
    936934template<>
    937 inline TestProtocolRuntimeTwoLeggedAnimals fromProtocolString(const String& value)
     935inline std::optional<TestProtocolRuntimeTwoLeggedAnimals> fromProtocolString(const String& value)
    938936{
    939937    if (value == "Ducks")
     
    945943    if (value == "Flamingos")
    946944        return TestProtocolRuntimeTwoLeggedAnimalsFlamingos;
    947     ASSERT_NOT_REACHED();
    948     return TestProtocolRuntimeTwoLeggedAnimalsDucks;
     945    return std::nullopt;
    949946}
    950947
     
    10041001{
    10051002    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
    1006     *outValue = @(Inspector::fromProtocolString<TestProtocolRuntimeFarmAnimals>(payload));
     1003    std::optional<TestProtocolRuntimeFarmAnimals> result = Inspector::fromProtocolString<TestProtocolRuntimeFarmAnimals>(payload);
     1004    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"FarmAnimals");
     1005    *outValue = @(result.value());
    10071006}
    10081007
     
    10101009{
    10111010    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
    1012     *outValue = @(Inspector::fromProtocolString<TestProtocolRuntimeTwoLeggedAnimals>(payload));
     1011    std::optional<TestProtocolRuntimeTwoLeggedAnimals> result = Inspector::fromProtocolString<TestProtocolRuntimeTwoLeggedAnimals>(payload);
     1012    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"TwoLeggedAnimals");
     1013    *outValue = @(result.value());
    10131014}
    10141015
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result

    r212116 r212462  
    12841284
    12851285template<typename ObjCEnumType>
    1286 ObjCEnumType fromProtocolString(const String& value);
     1286std::optional<ObjCEnumType> fromProtocolString(const String& value);
    12871287
    12881288inline String toProtocolString(TestProtocolPlatform value)
     
    13011301
    13021302template<>
    1303 inline TestProtocolPlatform fromProtocolString(const String& value)
     1303inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    13041304{
    13051305    if (value == "all")
     
    13111311    if (value == "macos")
    13121312        return TestProtocolPlatformMacOS;
    1313     ASSERT_NOT_REACHED();
    1314     return TestProtocolPlatformAll;
     1313    return std::nullopt;
    13151314}
    13161315
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result

    r212157 r212462  
    12131213
    12141214template<typename ObjCEnumType>
    1215 ObjCEnumType fromProtocolString(const String& value);
     1215std::optional<ObjCEnumType> fromProtocolString(const String& value);
    12161216
    12171217inline String toProtocolString(TestProtocolPlatform value)
     
    12301230
    12311231template<>
    1232 inline TestProtocolPlatform fromProtocolString(const String& value)
     1232inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    12331233{
    12341234    if (value == "all")
     
    12401240    if (value == "macos")
    12411241        return TestProtocolPlatformMacOS;
    1242     ASSERT_NOT_REACHED();
    1243     return TestProtocolPlatformAll;
     1242    return std::nullopt;
    12441243}
    12451244
     
    12601259
    12611260template<>
    1262 inline TestProtocolTestUncastedAnimals fromProtocolString(const String& value)
     1261inline std::optional<TestProtocolTestUncastedAnimals> fromProtocolString(const String& value)
    12631262{
    12641263    if (value == "Pigs")
     
    12701269    if (value == "Hens")
    12711270        return TestProtocolTestUncastedAnimalsHens;
    1272     ASSERT_NOT_REACHED();
    1273     return TestProtocolTestUncastedAnimalsPigs;
     1271    return std::nullopt;
    12741272}
    12751273
     
    12891287
    12901288template<>
    1291 inline TestProtocolTestCastedAnimals fromProtocolString(const String& value)
     1289inline std::optional<TestProtocolTestCastedAnimals> fromProtocolString(const String& value)
    12921290{
    12931291    if (value == "Ducks")
     
    12991297    if (value == "Flamingos")
    13001298        return TestProtocolTestCastedAnimalsFlamingos;
    1301     ASSERT_NOT_REACHED();
    1302     return TestProtocolTestCastedAnimalsDucks;
     1299    return std::nullopt;
    13031300}
    13041301
     
    13811378{
    13821379    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
    1383     *outValue = @(Inspector::fromProtocolString<TestProtocolTestUncastedAnimals>(payload));
     1380    std::optional<TestProtocolTestUncastedAnimals> result = Inspector::fromProtocolString<TestProtocolTestUncastedAnimals>(payload);
     1381    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"UncastedAnimals");
     1382    *outValue = @(result.value());
    13841383}
    13851384
     
    13871386{
    13881387    THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
    1389     *outValue = @(Inspector::fromProtocolString<TestProtocolTestCastedAnimals>(payload));
     1388    std::optional<TestProtocolTestCastedAnimals> result = Inspector::fromProtocolString<TestProtocolTestCastedAnimals>(payload);
     1389    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"CastedAnimals");
     1390    *outValue = @(result.value());
    13901391}
    13911392
     
    14621463
    14631464    THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"animals"], @"animals");
    1464     self.animals = fromProtocolString<TestProtocolTestCastedAnimals>(payload[@"animals"]);
     1465    std::optional<TestProtocolTestCastedAnimals> animals = fromProtocolString<TestProtocolTestCastedAnimals>(payload[@"animals"]);
     1466    THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(animals, @"animals");
     1467    self.animals = animals.value();
    14651468
    14661469    THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"id"], @"id");
     
    15241527- (TestProtocolTestCastedAnimals)animals
    15251528{
    1526     return fromProtocolString<TestProtocolTestCastedAnimals>([super stringForKey:@"animals"]);
     1529    return fromProtocolString<TestProtocolTestCastedAnimals>([super stringForKey:@"animals"]).value();
    15271530}
    15281531
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result

    r212116 r212462  
    998998
    999999template<typename ObjCEnumType>
    1000 ObjCEnumType fromProtocolString(const String& value);
     1000std::optional<ObjCEnumType> fromProtocolString(const String& value);
    10011001
    10021002inline String toProtocolString(TestProtocolPlatform value)
     
    10151015
    10161016template<>
    1017 inline TestProtocolPlatform fromProtocolString(const String& value)
     1017inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    10181018{
    10191019    if (value == "all")
     
    10251025    if (value == "macos")
    10261026        return TestProtocolPlatformMacOS;
    1027     ASSERT_NOT_REACHED();
    1028     return TestProtocolPlatformAll;
     1027    return std::nullopt;
    10291028}
    10301029
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result

    r212116 r212462  
    743743
    744744template<typename ObjCEnumType>
    745 ObjCEnumType fromProtocolString(const String& value);
     745std::optional<ObjCEnumType> fromProtocolString(const String& value);
    746746
    747747inline String toProtocolString(TestProtocolPlatform value)
     
    760760
    761761template<>
    762 inline TestProtocolPlatform fromProtocolString(const String& value)
     762inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    763763{
    764764    if (value == "all")
     
    770770    if (value == "macos")
    771771        return TestProtocolPlatformMacOS;
    772     ASSERT_NOT_REACHED();
    773     return TestProtocolPlatformAll;
     772    return std::nullopt;
    774773}
    775774
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result

    r212116 r212462  
    10071007
    10081008template<typename ObjCEnumType>
    1009 ObjCEnumType fromProtocolString(const String& value);
     1009std::optional<ObjCEnumType> fromProtocolString(const String& value);
    10101010
    10111011inline String toProtocolString(TestProtocolPlatform value)
     
    10241024
    10251025template<>
    1026 inline TestProtocolPlatform fromProtocolString(const String& value)
     1026inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
    10271027{
    10281028    if (value == "all")
     
    10341034    if (value == "macos")
    10351035        return TestProtocolPlatformMacOS;
    1036     ASSERT_NOT_REACHED();
    1037     return TestProtocolPlatformAll;
     1036    return std::nullopt;
    10381037}
    10391038
Note: See TracChangeset for help on using the changeset viewer.