RESOLVED FIXED Bug 140557
Web Inspector: code generator should introduce typedefs for protocol types that are arrays
https://bugs.webkit.org/show_bug.cgi?id=140557
Summary Web Inspector: code generator should introduce typedefs for protocol types th...
Brian Burg
Reported 2015-01-16 12:36:34 PST
Example: say I want the following situation: { "domain": "OverlayTypes", "description": "Exposes types to be used by the inspector overlay.", "types": [ { "id": "Point", "type": "object", "properties": [ { "name": "x", "type": "number" }, { "name": "y", "type": "number" } ] }, { "id": "Quad", "description": "A quad is a collection of 4 points, often representing a transformed rectangle. When initialized from a rect, the points are in clockwise order from top left.", "type": "array", "items": { "type": "Point" } } ] } Currently, there is no generated type name for Inspector::Protocol::OverlayTypes::Quad. Instead, you have to do Inspector::Protocol::Array<Inspector::Protocol::OverlayTypes::Point>. This is longwinded and makes the code hard to follow.
Attachments
Patch (100.12 KB, patch)
2015-01-16 13:21 PST, Brian Burg
joepeck: review+
Radar WebKit Bug Importer
Comment 1 2015-01-16 12:36:56 PST
Brian Burg
Comment 2 2015-01-16 13:21:09 PST
WebKit Commit Bot
Comment 3 2015-01-16 13:24:16 PST
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`)
Joseph Pecoraro
Comment 4 2015-01-16 14:17:50 PST
Comment on attachment 244799 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=244799&action=review Nice. r=me > Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py:154 > + if len(declaration.description) > 0: > + typedef_lines.append('/* %s */' % declaration.description) I see this is copied from the primitive typedef, is it useful in either case? I'll be honest, I don't think I ever noticed these comments before. > Source/JavaScriptCore/inspector/scripts/tests/expected/type-declaration-array-type.json-result:368 > +typedef Inspector::Protocol::Array<int> LuckyNumbers; > + > +typedef Inspector::Protocol::Array<String> BabyNames; > + > +typedef Inspector::Protocol::Array<Inspector::Protocol::Runtime::ObjectId> NewObjects; > + > +typedef Inspector::Protocol::Array<Inspector::Protocol::Debugger::BreakpointId> OldObjects; > + > +typedef Inspector::Protocol::Array<Inspector::Protocol::Debugger::Reason> StopReasons; Hmm, why are there newlines between these? They are all defined in the same domain.
Brian Burg
Comment 5 2015-01-16 14:19:40 PST
Comment on attachment 244799 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=244799&action=review >> Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py:154 >> + typedef_lines.append('/* %s */' % declaration.description) > > I see this is copied from the primitive typedef, is it useful in either case? I'll be honest, I don't think I ever noticed these comments before. It is a vestige from the old generator. I think the idea is that you will see a description if you use "go to definition" in an IDE. >> Source/JavaScriptCore/inspector/scripts/tests/expected/type-declaration-array-type.json-result:368 >> +typedef Inspector::Protocol::Array<Inspector::Protocol::Debugger::Reason> StopReasons; > > Hmm, why are there newlines between these? They are all defined in the same domain. I'll fix that.
Brian Burg
Comment 6 2015-01-16 15:17:44 PST
Note You need to log in before you can comment on or make changes to this bug.