| Summary: | Web Inspector: code generator should introduce typedefs for protocol types that are arrays | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Brian Burg <burg> | ||||
| Component: | Web Inspector | Assignee: | Brian Burg <burg> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | commit-queue, graouts, joepeck, jonowells, mattbaker, nvasilyev, timothy, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Attachments: |
|
||||||
Created attachment 244799 [details]
Patch
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`) 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. 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. Committed r178606: <http://trac.webkit.org/changeset/178606> |
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.