ObjC RWIProtocol codegen should better handle optional members For example, Highlight Config has optional color values: "id": "HighlightConfig", "type": "object", "properties": [ { "name": "showInfo", "type": "boolean", "optional": true, "description": "Whether the node info tooltip should be shown (default: false)." }, { "name": "contentColor", "$ref": "RGBAColor", "optional": true, "description": "The content box highlight fill color (default: transparent)." }, { "name": "paddingColor", "$ref": "RGBAColor", "optional": true, "description": "The padding highlight fill color (default: transparent)." }, { "name": "borderColor", "$ref": "RGBAColor", "optional": true, "description": "The border highlight fill color (default: transparent)." }, { "name": "marginColor", "$ref": "RGBAColor", "optional": true, "description": "The margin highlight fill color (default: transparent)." } ], However we return without checking if it was null or not: - (RWIProtocolDOMRGBAColor *)contentColor { return [[RWIProtocolDOMRGBAColor alloc] initWithInspectorObject:[[super objectForKey:@"contentColor"] toInspectorObject].get()]; } Should be something like: - (RWIProtocolDOMRGBAColor *)contentColor { RWIProtocolJSONObject *object = [[super objectForKey:@"contentColor"]; if (!object) return nil; return [[RWIProtocolDOMRGBAColor alloc] initWithInspectorObject:[object toInspectorObject].get()]; }
<rdar://problem/31697002>
Created attachment 308014 [details] [PATCH] Proposed Fix
This patch modifies the inspector protocol generator. Please ensure that you have rebaselined any generator test results (i.e., by running `Tools/Scripts/run-inspector-generator-tests --reset-results`)
Attachment 308014 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py:449: multiple statements on one line (semicolon) [pep8/E702] [5] ERROR: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:215: trailing whitespace [pep8/W291] [5] Total errors found: 2 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 308014 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=308014&action=review r=me > Source/JavaScriptCore/ChangeLog:18 > + Rebaselined inspector generator tests. Thanks!
<https://trac.webkit.org/changeset/215698/webkit>