Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (198076 => 198077)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-13 03:48:56 UTC (rev 198077)
@@ -1,3 +1,46 @@
+2016-03-12 Brian Burg <[email protected]>
+
+ When generating Objective-C protocol types, getters for objects need to synthesize a new object instance
+ https://bugs.webkit.org/show_bug.cgi?id=155389
+ <rdar://problem/25125821>
+
+ Reviewed by Timothy Hatcher.
+
+ Currently, in object property getters for Objective-C protocol types, we use
+ a C-style cast of the member's RWIProtocolJSONObject * to the type of the property.
+ However, at runtime the class of `self` is going to be RWIProtocolJSONObject *,
+ not MemberType *, so any subsequent calls to MemberType properties on the return value
+ will fail as the selectors will not be recognized.
+
+ Instead of doing a C-style pointer cast, we need to create a new MemberType object
+ that's backed by the InspectorObject retrieved from the parent object by key.
+ This requires a new initWithJSONObject initializer for each object protocol type.
+
+ * inspector/scripts/codegen/generate_objc_header.py:
+ (ObjCHeaderGenerator._generate_type_interface): Add new declaration.
+
+ * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:
+ (ObjCProtocolTypesImplementationGenerator.generate_type_implementation):
+ (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_json_object): Added.
+ Forward through to the super class initializer who assigns the underlying InspectorObject.
+
+ (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_required_members):
+ Drive-by cleanup to use the more compact [super init] form.
+
+ * inspector/scripts/codegen/objc_generator.py:
+ (ObjCGenerator.protocol_to_objc_expression_for_member):
+ For property getters of objects, use initWithJSONObject: rather than a C-style cast.
+
+ Rebaseline relevant test results.
+
+ * inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
+ * inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
+ * inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
+ * inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
+ * inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
+ * inspector/scripts/tests/expected/type-declaration-object-type.json-result:
+ * inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
+
2016-03-12 Konstantin Tokarev <[email protected]>
Removed variable names from default constructor declarations.
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_header.py (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_header.py 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_header.py 2016-03-13 03:48:56 UTC (rev 198077)
@@ -160,9 +160,10 @@
lines.append('__attribute__((visibility ("default")))')
lines.append('@interface %s : %sJSONObject' % (objc_name, ObjCGenerator.OBJC_STATIC_PREFIX))
- # The initializer that takes a payload is only needed by the frontend.
+ # The initializers that take a payload or inspector object are only needed by the frontend.
if self.get_generator_setting('generate_frontend', False):
lines.append('- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;')
+ lines.append('- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;')
required_members = filter(lambda member: not member.is_optional, declaration.type_members)
optional_members = filter(lambda member: member.is_optional, declaration.type_members)
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py 2016-03-13 03:48:56 UTC (rev 198077)
@@ -94,6 +94,7 @@
if self.get_generator_setting('generate_frontend', False):
lines.append('')
lines.append(self._generate_init_method_for_payload(domain, declaration))
+ lines.append(self._generate_init_method_for_json_object(domain, declaration))
required_members = filter(lambda member: not member.is_optional, declaration.type_members)
if required_members:
lines.append('')
@@ -107,6 +108,17 @@
lines.append('@end')
return '\n'.join(lines)
+ def _generate_init_method_for_json_object(self, domain, declaration):
+ lines = []
+ lines.append('- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject')
+ lines.append('{')
+ lines.append(' if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))')
+ lines.append(' return nil;')
+ lines.append('')
+ lines.append(' return self;')
+ lines.append('}')
+ return '\n'.join(lines)
+
def _generate_init_method_for_payload(self, domain, declaration):
lines = []
lines.append('- (instancetype)initWithPayload:(nonnull NSDictionary<NSString *, id> *)payload')
@@ -137,8 +149,7 @@
lines = []
lines.append('- (instancetype)initWith%s;' % ' '.join(pairs))
lines.append('{')
- lines.append(' self = [super init];')
- lines.append(' if (!self)')
+ lines.append(' if (!(self = [super init]))')
lines.append(' return nil;')
lines.append('')
Modified: trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator.py (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator.py 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/codegen/objc_generator.py 2016-03-13 03:48:56 UTC (rev 198077)
@@ -443,8 +443,8 @@
return 'fromProtocolString<%s>(%s)' % (self.objc_enum_name_for_non_anonymous_enum(member.type), sub_expression)
return sub_expression
if category is ObjCTypeCategory.Object:
- objc_type = self.objc_type_for_member(declaration, member)
- return '(%s)%s' % (objc_type, sub_expression)
+ objc_class = self.objc_class_for_type(member.type)
+ return '[[%s alloc] initWithInspectorObject:[%s toInspectorObject].get()]' % (objc_class, sub_expression)
if category is ObjCTypeCategory.Array:
protocol_type = ObjCGenerator.protocol_type_for_type(member.type.element_type)
objc_class = self.objc_class_for_type(member.type.element_type)
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/expected/commands-with-async-attribute.json-result (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/expected/commands-with-async-attribute.json-result 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/expected/commands-with-async-attribute.json-result 2016-03-13 03:48:56 UTC (rev 198077)
@@ -1306,6 +1306,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolDatabaseError : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
/* required */ @property (nonatomic, copy) NSString *message;
/* required */ @property (nonatomic, assign) int code;
@@ -1687,11 +1688,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message");
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result 2016-03-13 03:48:56 UTC (rev 198077)
@@ -1163,6 +1163,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolDatabaseError : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
/* required */ @property (nonatomic, copy) NSString *message;
/* required */ @property (nonatomic, assign) int code;
@@ -1542,11 +1543,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message");
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/expected/events-with-optional-parameters.json-result (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/expected/events-with-optional-parameters.json-result 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/expected/events-with-optional-parameters.json-result 2016-03-13 03:48:56 UTC (rev 198077)
@@ -919,6 +919,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolDatabaseError : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
/* required */ @property (nonatomic, copy) NSString *message;
/* required */ @property (nonatomic, assign) int code;
@@ -1160,11 +1161,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message");
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result 2016-03-13 03:48:56 UTC (rev 198077)
@@ -966,6 +966,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolNetwork2NetworkError : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
/* required */ @property (nonatomic, copy) NSString *message;
/* required */ @property (nonatomic, assign) int code;
@@ -1194,11 +1195,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message");
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result 2016-03-13 03:48:56 UTC (rev 198077)
@@ -773,6 +773,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolRuntimeKeyPath : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithType:(TestProtocolRuntimeKeyPathType)type;
/* required */ @property (nonatomic, assign) TestProtocolRuntimeKeyPathType type;
/* optional */ @property (nonatomic, copy) NSString *string;
@@ -1013,11 +1014,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithType:(TestProtocolRuntimeKeyPathType)type;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
self.type = type;
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-declaration-object-type.json-result (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-declaration-object-type.json-result 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-declaration-object-type.json-result 2016-03-13 03:48:56 UTC (rev 198077)
@@ -1166,6 +1166,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolDatabaseError : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
/* required */ @property (nonatomic, copy) NSString *message;
/* required */ @property (nonatomic, assign) int code;
@@ -1174,6 +1175,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolDatabaseOptionalParameterBundle : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
/* optional */ @property (nonatomic, copy) NSArray/*<NSString>*/ *columnNames;
/* optional */ @property (nonatomic, copy) NSString *notes;
/* optional */ @property (nonatomic, assign) double timestamp;
@@ -1186,6 +1188,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolDatabaseParameterBundle : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error errorList:(NSArray/*<TestProtocolDatabaseError>*/ *)errorList;
/* required */ @property (nonatomic, copy) NSArray/*<NSString>*/ *columnNames;
/* required */ @property (nonatomic, copy) NSString *notes;
@@ -1199,6 +1202,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolDatabaseObjectWithPropertyNameConflicts : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithInteger:(NSString *)integer array:(NSString *)array string:(NSString *)string value:(NSString *)value object:(NSString *)object;
/* required */ @property (nonatomic, copy) NSString *integer;
/* required */ @property (nonatomic, copy) NSString *array;
@@ -1210,11 +1214,13 @@
__attribute__((visibility ("default")))
@interface TestProtocolDatabaseDummyObject : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
@end
__attribute__((visibility ("default")))
@interface TestProtocolTestParameterBundle : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error;
/* required */ @property (nonatomic, copy) NSArray/*<NSString>*/ *columnNames;
/* required */ @property (nonatomic, copy) NSString *notes;
@@ -1478,11 +1484,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithMessage:(NSString *)message code:(int)code;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(message, @"message");
@@ -1538,7 +1550,14 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (void)setColumnNames:(NSArray/*<NSString>*/ *)columnNames
{
[super setInspectorArray:inspectorStringArray(columnNames) forKey:@"columnNames"];
@@ -1576,7 +1595,7 @@
- (RWIProtocolJSONObject *)values
{
- return (RWIProtocolJSONObject *)[super objectForKey:@"values"];
+ return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()];
}
- (void)setPayload:(RWIProtocolJSONObject *)payload
@@ -1586,7 +1605,7 @@
- (RWIProtocolJSONObject *)payload
{
- return (RWIProtocolJSONObject *)[super objectForKey:@"payload"];
+ return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()];
}
- (void)setError:(TestProtocolDatabaseError *)error
@@ -1596,7 +1615,7 @@
- (TestProtocolDatabaseError *)error
{
- return (TestProtocolDatabaseError *)[super objectForKey:@"error"];
+ return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()];
}
- (void)setErrorList:(NSArray/*<TestProtocolDatabaseError>*/ *)errorList
@@ -1642,11 +1661,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error errorList:(NSArray/*<TestProtocolDatabaseError>*/ *)errorList;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(columnNames, @"columnNames");
@@ -1705,7 +1730,7 @@
- (RWIProtocolJSONObject *)values
{
- return (RWIProtocolJSONObject *)[super objectForKey:@"values"];
+ return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()];
}
- (void)setPayload:(RWIProtocolJSONObject *)payload
@@ -1715,7 +1740,7 @@
- (RWIProtocolJSONObject *)payload
{
- return (RWIProtocolJSONObject *)[super objectForKey:@"payload"];
+ return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()];
}
- (void)setError:(TestProtocolDatabaseError *)error
@@ -1725,7 +1750,7 @@
- (TestProtocolDatabaseError *)error
{
- return (TestProtocolDatabaseError *)[super objectForKey:@"error"];
+ return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()];
}
- (void)setErrorList:(NSArray/*<TestProtocolDatabaseError>*/ *)errorList
@@ -1765,11 +1790,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithInteger:(NSString *)integer array:(NSString *)array string:(NSString *)string value:(NSString *)value object:(NSString *)object;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(integer, @"integer");
@@ -1848,7 +1879,14 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
@end
@@ -1879,11 +1917,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithColumnNames:(NSArray/*<NSString>*/ *)columnNames notes:(NSString *)notes timestamp:(double)timestamp values:(RWIProtocolJSONObject *)values payload:(RWIProtocolJSONObject *)payload error:(TestProtocolDatabaseError *)error;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(columnNames, @"columnNames");
@@ -1939,7 +1983,7 @@
- (RWIProtocolJSONObject *)values
{
- return (RWIProtocolJSONObject *)[super objectForKey:@"values"];
+ return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"values"] toInspectorObject].get()];
}
- (void)setPayload:(RWIProtocolJSONObject *)payload
@@ -1949,7 +1993,7 @@
- (RWIProtocolJSONObject *)payload
{
- return (RWIProtocolJSONObject *)[super objectForKey:@"payload"];
+ return [[RWIProtocolJSONObject alloc] initWithInspectorObject:[[super objectForKey:@"payload"] toInspectorObject].get()];
}
- (void)setError:(TestProtocolDatabaseError *)error
@@ -1959,7 +2003,7 @@
- (TestProtocolDatabaseError *)error
{
- return (TestProtocolDatabaseError *)[super objectForKey:@"error"];
+ return [[TestProtocolDatabaseError alloc] initWithInspectorObject:[[super objectForKey:@"error"] toInspectorObject].get()];
}
@end
Modified: trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result (198076 => 198077)
--- trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result 2016-03-13 02:39:43 UTC (rev 198076)
+++ trunk/Source/_javascript_Core/inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result 2016-03-13 03:48:56 UTC (rev 198077)
@@ -1061,6 +1061,7 @@
__attribute__((visibility ("default")))
@interface TestProtocolTestTypeNeedingCast : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
- (instancetype)initWithString:(NSString *)string number:(int)number animals:(TestProtocolTestCastedAnimals)animals identifier:(int)identifier tree:(TestProtocolTestRecursiveObject1 *)tree;
/* required */ @property (nonatomic, copy) NSString *string;
/* required */ @property (nonatomic, assign) int number;
@@ -1072,12 +1073,14 @@
__attribute__((visibility ("default")))
@interface TestProtocolTestRecursiveObject1 : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
/* optional */ @property (nonatomic, retain) TestProtocolTestRecursiveObject2 *obj;
@end
__attribute__((visibility ("default")))
@interface TestProtocolTestRecursiveObject2 : RWIProtocolJSONObject
- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject;
/* optional */ @property (nonatomic, retain) TestProtocolTestRecursiveObject1 *obj;
@end
@@ -1398,11 +1401,17 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (instancetype)initWithString:(NSString *)string number:(int)number animals:(TestProtocolTestCastedAnimals)animals identifier:(int)identifier tree:(TestProtocolTestRecursiveObject1 *)tree;
{
- self = [super init];
- if (!self)
+ if (!(self = [super init]))
return nil;
THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(string, @"string");
@@ -1464,7 +1473,7 @@
- (TestProtocolTestRecursiveObject1 *)tree
{
- return (TestProtocolTestRecursiveObject1 *)[super objectForKey:@"tree"];
+ return [[TestProtocolTestRecursiveObject1 alloc] initWithInspectorObject:[[super objectForKey:@"tree"] toInspectorObject].get()];
}
@end
@@ -1480,7 +1489,14 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (void)setObj:(TestProtocolTestRecursiveObject2 *)obj
{
[super setObject:obj forKey:@"obj"];
@@ -1488,7 +1504,7 @@
- (TestProtocolTestRecursiveObject2 *)obj
{
- return (TestProtocolTestRecursiveObject2 *)[super objectForKey:@"obj"];
+ return [[TestProtocolTestRecursiveObject2 alloc] initWithInspectorObject:[[super objectForKey:@"obj"] toInspectorObject].get()];
}
@end
@@ -1504,7 +1520,14 @@
return self;
}
+- (instancetype)initWithJSONObject:(RWIProtocolJSONObject *)jsonObject
+{
+ if (!(self = [super initWithInspectorObject:[jsonObject toInspectorObject].get()]))
+ return nil;
+ return self;
+}
+
- (void)setObj:(TestProtocolTestRecursiveObject1 *)obj
{
[super setObject:obj forKey:@"obj"];
@@ -1512,7 +1535,7 @@
- (TestProtocolTestRecursiveObject1 *)obj
{
- return (TestProtocolTestRecursiveObject1 *)[super objectForKey:@"obj"];
+ return [[TestProtocolTestRecursiveObject1 alloc] initWithInspectorObject:[[super objectForKey:@"obj"] toInspectorObject].get()];
}
@end