Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (212461 => 212462)
--- trunk/Source/_javascript_Core/ChangeLog 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1,3 +1,71 @@
+2017-02-15 Brian Burg <[email protected]>
+
+ [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.
+
2017-02-16 Keith Miller <[email protected]>
ASSERTION FAILED: vm.heap.mutatorState() == MutatorState::Running || vm.apiLock().ownerThread() != std::this_thread::get_id()
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py 2017-02-16 21:31:17 UTC (rev 212462)
@@ -168,10 +168,19 @@
in_param_name = 'in_%s' % parameter.parameter_name
objc_in_param_name = 'o_%s' % in_param_name
objc_type = self.objc_type_for_param(domain, command.command_name, parameter, False)
+ if isinstance(parameter.type, EnumType):
+ objc_type = 'std::optional<%s>' % objc_type
param_expression = in_param_expression(in_param_name, parameter)
import_expression = self.objc_protocol_import_expression_for_parameter(param_expression, domain, command.command_name, parameter)
if not parameter.is_optional:
lines.append(' %s = %s;' % (join_type_and_name(objc_type, objc_in_param_name), import_expression))
+
+ if isinstance(parameter.type, EnumType):
+ lines.append(' if (!%s) {' % objc_in_param_name)
+ 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))
+ lines.append(' return;')
+ lines.append(' }')
+
else:
lines.append(' %s;' % join_type_and_name(objc_type, objc_in_param_name))
lines.append(' if (%s)' % in_param_name)
@@ -187,10 +196,15 @@
pairs.append('successCallback:successCallback')
for parameter in command.call_parameters:
in_param_name = 'in_%s' % parameter.parameter_name
- objc_in_param_name = 'o_%s' % in_param_name
+ objc_in_param_expression = 'o_%s' % in_param_name
if not parameter.is_optional:
- pairs.append('%s:%s' % (parameter.parameter_name, objc_in_param_name))
+ # FIXME: we don't handle optional enum values in commands here because it isn't used anywhere yet.
+ # We'd need to change the delegate's signature to take std::optional for optional enum values.
+ if isinstance(parameter.type, EnumType):
+ objc_in_param_expression = '%s.value()' % objc_in_param_expression
+
+ pairs.append('%s:%s' % (parameter.parameter_name, objc_in_param_expression))
else:
- optional_expression = '(%s ? &%s : nil)' % (in_param_name, objc_in_param_name)
+ optional_expression = '(%s ? &%s : nil)' % (in_param_name, objc_in_param_expression)
pairs.append('%s:%s' % (parameter.parameter_name, optional_expression))
return ' [m_delegate %s%s];' % (command.command_name, ' '.join(pairs))
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py 2017-02-16 21:31:17 UTC (rev 212462)
@@ -155,12 +155,11 @@
def _generate_enum_from_protocol_string(self, objc_enum_name, enum_values):
lines = []
lines.append('template<>')
- lines.append('inline %s fromProtocolString(const String& value)' % objc_enum_name)
+ lines.append('inline std::optional<%s> fromProtocolString(const String& value)' % objc_enum_name)
lines.append('{')
for enum_value in enum_values:
lines.append(' if (value == "%s")' % enum_value)
lines.append(' return %s%s;' % (objc_enum_name, Generator.stylized_name_for_enum_value(enum_value)))
- lines.append(' ASSERT_NOT_REACHED();')
- lines.append(' return %s%s;' % (objc_enum_name, Generator.stylized_name_for_enum_value(enum_values[0])))
+ lines.append(' return std::nullopt;')
lines.append('}')
return '\n'.join(lines)
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py 2017-02-16 21:31:17 UTC (rev 212462)
@@ -125,7 +125,9 @@
lines.append('{')
if isinstance(resolved_type, EnumType):
lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);')
- lines.append(' *outValue = @(Inspector::fromProtocolString<%s>(payload));' % self.objc_name_for_type(resolved_type))
+ lines.append(' std::optional<%(type)s> result = Inspector::fromProtocolString<%(type)s>(payload);' % {'type': self.objc_name_for_type(resolved_type)})
+ lines.append(' THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"%s");' % declaration.type.raw_name())
+ lines.append(' *outValue = @(result.value());')
elif isinstance(resolved_type, (ArrayType, PrimitiveType)):
lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE(payload, [%s class]);' % objc_class)
lines.append(' *outValue = (%s *)payload;' % objc_class)
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py 2017-02-16 21:31:17 UTC (rev 212462)
@@ -30,7 +30,7 @@
from string import Template
from generator import Generator, ucfirst
-from models import ObjectType, Frameworks
+from models import ObjectType, EnumType, Frameworks
from objc_generator import ObjCGenerator
from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
@@ -129,13 +129,24 @@
for member in declaration.type_members:
member_name = member.member_name
- conversion_expression = self.payload_to_objc_expression_for_member(declaration, member)
if not member.is_optional:
lines.append(' THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"%s"], @"%s");' % (member_name, member_name))
+ objc_type = self.objc_type_for_member(declaration, member)
var_name = ObjCGenerator.identifier_to_objc_identifier(member_name)
- lines.append(' self.%s = %s;' % (var_name, conversion_expression))
+ conversion_expression = self.payload_to_objc_expression_for_member(declaration, member)
+ if isinstance(member.type, EnumType):
+ lines.append(' std::optional<%s> %s = %s;' % (objc_type, var_name, conversion_expression))
+ if not member.is_optional:
+ lines.append(' THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(%s, @"%s");' % (var_name, member_name))
+ lines.append(' self.%s = %s.value();' % (var_name, var_name))
+ else:
+ lines.append(' if (%s)' % var_name)
+ lines.append(' self.%s = %s.value();' % (var_name, var_name))
+ else:
+ lines.append(' self.%s = %s;' % (var_name, conversion_expression))
+
lines.append('')
lines.append(' return self;')
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator.py (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator.py 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator.py 2017-02-16 21:31:17 UTC (rev 212462)
@@ -442,8 +442,8 @@
if category in [ObjCTypeCategory.Simple, ObjCTypeCategory.String]:
if isinstance(member.type, EnumType):
if member.type.is_anonymous:
- return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_anonymous_enum_member(declaration, member), sub_expression)
- return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_non_anonymous_enum(member.type), sub_expression)
+ return 'fromProtocolString<%s>(%s).value()' % (self.objc_enum_name_for_anonymous_enum_member(declaration, member), sub_expression)
+ return 'fromProtocolString<%s>(%s).value()' % (self.objc_enum_name_for_non_anonymous_enum(member.type), sub_expression)
return sub_expression
if category is ObjCTypeCategory.Object:
objc_class = self.objc_class_for_type(member.type)
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator_templates.py (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator_templates.py 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator_templates.py 2017-02-16 21:31:17 UTC (rev 212462)
@@ -55,7 +55,7 @@
TypeConversionsHeaderStandard = (
"""template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);""")
+std::optional<ObjCEnumType> fromProtocolString(const String& value);""")
BackendDispatcherHeaderPrelude = (
"""${includes}
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1006,7 +1006,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1023,7 +1023,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1033,8 +1033,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1425,7 +1425,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1442,7 +1442,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1452,8 +1452,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
@@ -1470,7 +1469,7 @@
}
template<>
-inline TestProtocolDatabasePrimaryColors fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabasePrimaryColors> fromProtocolString(const String& value)
{
if (value == "red")
return TestProtocolDatabasePrimaryColorsRed;
@@ -1478,8 +1477,7 @@
return TestProtocolDatabasePrimaryColorsGreen;
if (value == "blue")
return TestProtocolDatabasePrimaryColorsBlue;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabasePrimaryColorsRed;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor value)
@@ -1497,7 +1495,7 @@
}
template<>
-inline TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColor> fromProtocolString(const String& value)
{
if (value == "cyan")
return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan;
@@ -1507,8 +1505,7 @@
return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorYellow;
if (value == "black")
return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorBlack;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabaseExecuteSQLSyncOptionalReturnValuesPrintColorCyan;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor value)
@@ -1526,7 +1523,7 @@
}
template<>
-inline TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColor> fromProtocolString(const String& value)
{
if (value == "cyan")
return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan;
@@ -1536,8 +1533,7 @@
return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorYellow;
if (value == "black")
return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorBlack;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabaseExecuteSQLAsyncOptionalReturnValuesPrintColorCyan;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolDatabaseExecuteSQLSyncPrintColor value)
@@ -1555,7 +1551,7 @@
}
template<>
-inline TestProtocolDatabaseExecuteSQLSyncPrintColor fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabaseExecuteSQLSyncPrintColor> fromProtocolString(const String& value)
{
if (value == "cyan")
return TestProtocolDatabaseExecuteSQLSyncPrintColorCyan;
@@ -1565,8 +1561,7 @@
return TestProtocolDatabaseExecuteSQLSyncPrintColorYellow;
if (value == "black")
return TestProtocolDatabaseExecuteSQLSyncPrintColorBlack;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabaseExecuteSQLSyncPrintColorCyan;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolDatabaseExecuteSQLAsyncPrintColor value)
@@ -1584,7 +1579,7 @@
}
template<>
-inline TestProtocolDatabaseExecuteSQLAsyncPrintColor fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabaseExecuteSQLAsyncPrintColor> fromProtocolString(const String& value)
{
if (value == "cyan")
return TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan;
@@ -1594,8 +1589,7 @@
return TestProtocolDatabaseExecuteSQLAsyncPrintColorYellow;
if (value == "black")
return TestProtocolDatabaseExecuteSQLAsyncPrintColorBlack;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabaseExecuteSQLAsyncPrintColorCyan;
+ return std::nullopt;
}
} // namespace Inspector
@@ -1661,7 +1655,9 @@
+ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload
{
THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
- *outValue = @(Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload));
+ std::optional<TestProtocolDatabasePrimaryColors> result = Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"PrimaryColors");
+ *outValue = @(result.value());
}
+ (void)_parseColorList:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -872,13 +872,13 @@
TestProtocolDatabaseError *o_in_sqlError;
if (in_sqlError)
o_in_sqlError = [[[TestProtocolDatabaseError alloc] initWithInspectorObject:in_sqlError] autorelease];
- TestProtocolDatabasePrimaryColors o_in_screenColor;
+ std::optional<TestProtocolDatabasePrimaryColors> o_in_screenColor;
if (in_screenColor)
o_in_screenColor = fromProtocolString<TestProtocolDatabasePrimaryColors>(*in_screenColor);
NSArray/*<NSString>*/ *o_in_alternateColors;
if (in_alternateColors)
o_in_alternateColors = objcStringArray(in_alternateColors);
- TestProtocolDatabaseExecuteAllOptionalParametersPrintColor o_in_printColor;
+ std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> o_in_printColor;
if (in_printColor)
o_in_printColor = fromProtocolString<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor>(*in_printColor);
@@ -920,11 +920,19 @@
RWIProtocolJSONObject *o_in_payload = [[[RWIProtocolJSONObject alloc] initWithInspectorObject:&in_payload] autorelease];
int o_in_databaseId = in_databaseId;
TestProtocolDatabaseError *o_in_sqlError = [[[TestProtocolDatabaseError alloc] initWithInspectorObject:&in_sqlError] autorelease];
- TestProtocolDatabasePrimaryColors o_in_screenColor = fromProtocolString<TestProtocolDatabasePrimaryColors>(in_screenColor);
+ std::optional<TestProtocolDatabasePrimaryColors> o_in_screenColor = fromProtocolString<TestProtocolDatabasePrimaryColors>(in_screenColor);
+ if (!o_in_screenColor) {
+ backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' of method '%s' cannot be processed", "screenColor", "Database.executeNoOptionalParameters"));
+ return;
+ }
NSArray/*<NSString>*/ *o_in_alternateColors = objcStringArray(&in_alternateColors);
- TestProtocolDatabaseExecuteNoOptionalParametersPrintColor o_in_printColor = fromProtocolString<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor>(in_printColor);
+ std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> o_in_printColor = fromProtocolString<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor>(in_printColor);
+ if (!o_in_printColor) {
+ backendDispatcher()->reportProtocolError(BackendDispatcher::InvalidParams, String::format("Parameter '%s' of method '%s' cannot be processed", "printColor", "Database.executeNoOptionalParameters"));
+ return;
+ }
- [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];
+ [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()];
}
@@ -1280,7 +1288,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1297,7 +1305,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1307,8 +1315,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
@@ -1325,7 +1332,7 @@
}
template<>
-inline TestProtocolDatabasePrimaryColors fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabasePrimaryColors> fromProtocolString(const String& value)
{
if (value == "red")
return TestProtocolDatabasePrimaryColorsRed;
@@ -1333,8 +1340,7 @@
return TestProtocolDatabasePrimaryColorsGreen;
if (value == "blue")
return TestProtocolDatabasePrimaryColorsBlue;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabasePrimaryColorsRed;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolDatabaseExecuteAllOptionalParametersPrintColor value)
@@ -1352,7 +1358,7 @@
}
template<>
-inline TestProtocolDatabaseExecuteAllOptionalParametersPrintColor fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> fromProtocolString(const String& value)
{
if (value == "cyan")
return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan;
@@ -1362,8 +1368,7 @@
return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow;
if (value == "black")
return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolDatabaseExecuteAllOptionalParametersPrintColor value)
@@ -1381,7 +1386,7 @@
}
template<>
-inline TestProtocolDatabaseExecuteAllOptionalParametersPrintColor fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabaseExecuteAllOptionalParametersPrintColor> fromProtocolString(const String& value)
{
if (value == "cyan")
return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan;
@@ -1391,8 +1396,7 @@
return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorYellow;
if (value == "black")
return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorBlack;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabaseExecuteAllOptionalParametersPrintColorCyan;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolDatabaseExecuteNoOptionalParametersPrintColor value)
@@ -1410,7 +1414,7 @@
}
template<>
-inline TestProtocolDatabaseExecuteNoOptionalParametersPrintColor fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> fromProtocolString(const String& value)
{
if (value == "cyan")
return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan;
@@ -1420,8 +1424,7 @@
return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow;
if (value == "black")
return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolDatabaseExecuteNoOptionalParametersPrintColor value)
@@ -1439,7 +1442,7 @@
}
template<>
-inline TestProtocolDatabaseExecuteNoOptionalParametersPrintColor fromProtocolString(const String& value)
+inline std::optional<TestProtocolDatabaseExecuteNoOptionalParametersPrintColor> fromProtocolString(const String& value)
{
if (value == "cyan")
return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan;
@@ -1449,8 +1452,7 @@
return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorYellow;
if (value == "black")
return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorBlack;
- ASSERT_NOT_REACHED();
- return TestProtocolDatabaseExecuteNoOptionalParametersPrintColorCyan;
+ return std::nullopt;
}
} // namespace Inspector
@@ -1516,7 +1518,9 @@
+ (void)_parsePrimaryColors:(NSNumber **)outValue fromPayload:(id)payload
{
THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
- *outValue = @(Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload));
+ std::optional<TestProtocolDatabasePrimaryColors> result = Inspector::fromProtocolString<TestProtocolDatabasePrimaryColors>(payload);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"PrimaryColors");
+ *outValue = @(result.value());
}
+ (void)_parseColorList:(NSArray/*<NSString>*/ **)outValue fromPayload:(id)payload
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/definitions-with-mac-platform.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -742,7 +742,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -759,7 +759,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -769,8 +769,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
} // namespace Inspector
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/domain-availability.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/domain-availability.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/domain-availability.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -996,7 +996,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1013,7 +1013,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1023,8 +1023,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
} // namespace Inspector
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1259,7 +1259,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1276,7 +1276,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1286,8 +1286,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/enum-values.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/enum-values.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/enum-values.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1039,7 +1039,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1056,7 +1056,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1066,8 +1066,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
@@ -1086,7 +1085,7 @@
}
template<>
-inline TestProtocolTypeDomainEnum fromProtocolString(const String& value)
+inline std::optional<TestProtocolTypeDomainEnum> fromProtocolString(const String& value)
{
if (value == "shared")
return TestProtocolTypeDomainEnumShared;
@@ -1096,8 +1095,7 @@
return TestProtocolTypeDomainEnumGreen;
if (value == "blue")
return TestProtocolTypeDomainEnumBlue;
- ASSERT_NOT_REACHED();
- return TestProtocolTypeDomainEnumShared;
+ return std::nullopt;
}
} // namespace Inspector
@@ -1154,7 +1152,9 @@
+ (void)_parseTypeDomainEnum:(NSNumber **)outValue fromPayload:(id)payload
{
THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
- *outValue = @(Inspector::fromProtocolString<TestProtocolTypeDomainEnum>(payload));
+ std::optional<TestProtocolTypeDomainEnum> result = Inspector::fromProtocolString<TestProtocolTypeDomainEnum>(payload);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"TypeDomainEnum");
+ *outValue = @(result.value());
}
@end
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/events-with-optional-parameters.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -992,7 +992,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1009,7 +1009,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1019,8 +1019,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1033,7 +1033,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1050,7 +1050,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1060,8 +1060,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/same-type-id-different-domain.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -752,7 +752,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -769,7 +769,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -779,8 +779,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/shadowed-optional-type-setters.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -889,7 +889,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -906,7 +906,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -916,8 +916,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
@@ -934,7 +933,7 @@
}
template<>
-inline TestProtocolRuntimeKeyPathType fromProtocolString(const String& value)
+inline std::optional<TestProtocolRuntimeKeyPathType> fromProtocolString(const String& value)
{
if (value == "null")
return TestProtocolRuntimeKeyPathTypeNull;
@@ -942,8 +941,7 @@
return TestProtocolRuntimeKeyPathTypeString;
if (value == "array")
return TestProtocolRuntimeKeyPathTypeArray;
- ASSERT_NOT_REACHED();
- return TestProtocolRuntimeKeyPathTypeNull;
+ return std::nullopt;
}
} // namespace Inspector
@@ -1057,7 +1055,9 @@
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"type"], @"type");
- self.type = fromProtocolString<TestProtocolRuntimeKeyPathType>(payload[@"type"]);
+ std::optional<TestProtocolRuntimeKeyPathType> type = fromProtocolString<TestProtocolRuntimeKeyPathType>(payload[@"type"]);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(type, @"type");
+ self.type = type.value();
self.string = payload[@"string"];
@@ -1090,7 +1090,7 @@
- (TestProtocolRuntimeKeyPathType)type
{
- return fromProtocolString<TestProtocolRuntimeKeyPathType>([super stringForKey:@"type"]);
+ return fromProtocolString<TestProtocolRuntimeKeyPathType>([super stringForKey:@"type"]).value();
}
- (void)setString:(NSString *)string
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-aliased-primitive-type.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -747,7 +747,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -764,7 +764,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -774,8 +774,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -830,7 +830,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -847,7 +847,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -857,8 +857,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
@@ -875,7 +874,7 @@
}
template<>
-inline TestProtocolDebuggerReason fromProtocolString(const String& value)
+inline std::optional<TestProtocolDebuggerReason> fromProtocolString(const String& value)
{
if (value == "Died")
return TestProtocolDebuggerReasonDied;
@@ -883,8 +882,7 @@
return TestProtocolDebuggerReasonFainted;
if (value == "Hungry")
return TestProtocolDebuggerReasonHungry;
- ASSERT_NOT_REACHED();
- return TestProtocolDebuggerReasonDied;
+ return std::nullopt;
}
@@ -960,7 +958,9 @@
+ (void)_parseReason:(NSNumber **)outValue fromPayload:(id)payload
{
THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
- *outValue = @(Inspector::fromProtocolString<TestProtocolDebuggerReason>(payload));
+ std::optional<TestProtocolDebuggerReason> result = Inspector::fromProtocolString<TestProtocolDebuggerReason>(payload);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"Reason");
+ *outValue = @(result.value());
}
@end
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -858,7 +858,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -875,7 +875,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -885,8 +885,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
@@ -905,7 +904,7 @@
}
template<>
-inline TestProtocolRuntimeFarmAnimals fromProtocolString(const String& value)
+inline std::optional<TestProtocolRuntimeFarmAnimals> fromProtocolString(const String& value)
{
if (value == "Pigs")
return TestProtocolRuntimeFarmAnimalsPigs;
@@ -915,8 +914,7 @@
return TestProtocolRuntimeFarmAnimalsCats;
if (value == "Hens")
return TestProtocolRuntimeFarmAnimalsHens;
- ASSERT_NOT_REACHED();
- return TestProtocolRuntimeFarmAnimalsPigs;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolRuntimeTwoLeggedAnimals value)
@@ -934,7 +932,7 @@
}
template<>
-inline TestProtocolRuntimeTwoLeggedAnimals fromProtocolString(const String& value)
+inline std::optional<TestProtocolRuntimeTwoLeggedAnimals> fromProtocolString(const String& value)
{
if (value == "Ducks")
return TestProtocolRuntimeTwoLeggedAnimalsDucks;
@@ -944,8 +942,7 @@
return TestProtocolRuntimeTwoLeggedAnimalsCrows;
if (value == "Flamingos")
return TestProtocolRuntimeTwoLeggedAnimalsFlamingos;
- ASSERT_NOT_REACHED();
- return TestProtocolRuntimeTwoLeggedAnimalsDucks;
+ return std::nullopt;
}
} // namespace Inspector
@@ -1003,13 +1000,17 @@
+ (void)_parseFarmAnimals:(NSNumber **)outValue fromPayload:(id)payload
{
THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
- *outValue = @(Inspector::fromProtocolString<TestProtocolRuntimeFarmAnimals>(payload));
+ std::optional<TestProtocolRuntimeFarmAnimals> result = Inspector::fromProtocolString<TestProtocolRuntimeFarmAnimals>(payload);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"FarmAnimals");
+ *outValue = @(result.value());
}
+ (void)_parseTwoLeggedAnimals:(NSNumber **)outValue fromPayload:(id)payload
{
THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
- *outValue = @(Inspector::fromProtocolString<TestProtocolRuntimeTwoLeggedAnimals>(payload));
+ std::optional<TestProtocolRuntimeTwoLeggedAnimals> result = Inspector::fromProtocolString<TestProtocolRuntimeTwoLeggedAnimals>(payload);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"TwoLeggedAnimals");
+ *outValue = @(result.value());
}
@end
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1283,7 +1283,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1300,7 +1300,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1310,8 +1310,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1212,7 +1212,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1229,7 +1229,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1239,8 +1239,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
@@ -1259,7 +1258,7 @@
}
template<>
-inline TestProtocolTestUncastedAnimals fromProtocolString(const String& value)
+inline std::optional<TestProtocolTestUncastedAnimals> fromProtocolString(const String& value)
{
if (value == "Pigs")
return TestProtocolTestUncastedAnimalsPigs;
@@ -1269,8 +1268,7 @@
return TestProtocolTestUncastedAnimalsCats;
if (value == "Hens")
return TestProtocolTestUncastedAnimalsHens;
- ASSERT_NOT_REACHED();
- return TestProtocolTestUncastedAnimalsPigs;
+ return std::nullopt;
}
inline String toProtocolString(TestProtocolTestCastedAnimals value)
@@ -1288,7 +1286,7 @@
}
template<>
-inline TestProtocolTestCastedAnimals fromProtocolString(const String& value)
+inline std::optional<TestProtocolTestCastedAnimals> fromProtocolString(const String& value)
{
if (value == "Ducks")
return TestProtocolTestCastedAnimalsDucks;
@@ -1298,8 +1296,7 @@
return TestProtocolTestCastedAnimalsCrows;
if (value == "Flamingos")
return TestProtocolTestCastedAnimalsFlamingos;
- ASSERT_NOT_REACHED();
- return TestProtocolTestCastedAnimalsDucks;
+ return std::nullopt;
}
} // namespace Inspector
@@ -1380,13 +1377,17 @@
+ (void)_parseUncastedAnimals:(NSNumber **)outValue fromPayload:(id)payload
{
THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
- *outValue = @(Inspector::fromProtocolString<TestProtocolTestUncastedAnimals>(payload));
+ std::optional<TestProtocolTestUncastedAnimals> result = Inspector::fromProtocolString<TestProtocolTestUncastedAnimals>(payload);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"UncastedAnimals");
+ *outValue = @(result.value());
}
+ (void)_parseCastedAnimals:(NSNumber **)outValue fromPayload:(id)payload
{
THROW_EXCEPTION_FOR_BAD_TYPE(payload, [NSString class]);
- *outValue = @(Inspector::fromProtocolString<TestProtocolTestCastedAnimals>(payload));
+ std::optional<TestProtocolTestCastedAnimals> result = Inspector::fromProtocolString<TestProtocolTestCastedAnimals>(payload);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(result, @"CastedAnimals");
+ *outValue = @(result.value());
}
+ (void)_parseRecursiveObject1:(TestProtocolTestRecursiveObject1 **)outValue fromPayload:(id)payload
@@ -1461,7 +1462,9 @@
self.number = [payload[@"number"] integerValue];
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"animals"], @"animals");
- self.animals = fromProtocolString<TestProtocolTestCastedAnimals>(payload[@"animals"]);
+ std::optional<TestProtocolTestCastedAnimals> animals = fromProtocolString<TestProtocolTestCastedAnimals>(payload[@"animals"]);
+ THROW_EXCEPTION_FOR_BAD_ENUM_VALUE(animals, @"animals");
+ self.animals = animals.value();
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(payload[@"id"], @"id");
self.identifier = [payload[@"id"] integerValue];
@@ -1523,7 +1526,7 @@
- (TestProtocolTestCastedAnimals)animals
{
- return fromProtocolString<TestProtocolTestCastedAnimals>([super stringForKey:@"animals"]);
+ return fromProtocolString<TestProtocolTestCastedAnimals>([super stringForKey:@"animals"]).value();
}
- (void)setIdentifier:(int)identifier
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/generic/expected/worker-supported-domains.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -997,7 +997,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1014,7 +1014,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1024,8 +1024,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
} // namespace Inspector
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/ios/expected/definitions-with-mac-platform.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -742,7 +742,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -759,7 +759,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -769,8 +769,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}
} // namespace Inspector
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result (212461 => 212462)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result 2017-02-16 21:23:33 UTC (rev 212461)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result 2017-02-16 21:31:17 UTC (rev 212462)
@@ -1006,7 +1006,7 @@
namespace Inspector {
template<typename ObjCEnumType>
-ObjCEnumType fromProtocolString(const String& value);
+std::optional<ObjCEnumType> fromProtocolString(const String& value);
inline String toProtocolString(TestProtocolPlatform value)
{
@@ -1023,7 +1023,7 @@
}
template<>
-inline TestProtocolPlatform fromProtocolString(const String& value)
+inline std::optional<TestProtocolPlatform> fromProtocolString(const String& value)
{
if (value == "all")
return TestProtocolPlatformAll;
@@ -1033,8 +1033,7 @@
return TestProtocolPlatformIOS;
if (value == "macos")
return TestProtocolPlatformMacOS;
- ASSERT_NOT_REACHED();
- return TestProtocolPlatformAll;
+ return std::nullopt;
}