RESOLVED FIXED 74890
Web Inspector: CodeGeneratorInspector.py: generate anonymous types.
https://bugs.webkit.org/show_bug.cgi?id=74890
Summary Web Inspector: CodeGeneratorInspector.py: generate anonymous types.
Peter Rybin
Reported 2011-12-19 15:02:12 PST
Some types are anonymous in Inspector.JSON. Provide type-safe API for them too.
Attachments
Patch (39.08 KB, patch)
2011-12-19 15:11 PST, Peter Rybin
no flags
Sample output (9.95 KB, text/plain)
2011-12-19 15:12 PST, Peter Rybin
no flags
Sample output InspectorFrontend.h (138.69 KB, text/plain)
2011-12-19 15:13 PST, Peter Rybin
no flags
Patch (40.26 KB, patch)
2011-12-21 06:43 PST, Peter Rybin
no flags
Peter Rybin
Comment 1 2011-12-19 15:11:20 PST
Peter Rybin
Comment 2 2011-12-19 15:12:06 PST
Created attachment 119924 [details] Sample output
Peter Rybin
Comment 3 2011-12-19 15:13:23 PST
Created attachment 119926 [details] Sample output InspectorFrontend.h
Pavel Feldman
Comment 4 2011-12-20 02:09:34 PST
Comment on attachment 119923 [details] Patch Looks good. What does it do?
Peter Rybin
Comment 5 2011-12-20 12:03:38 PST
(In reply to comment #4) > (From update of attachment 119923 [details]) > Looks good. What does it do? Let me describe it here a bit more. In general it generates now C++ type for anonymous object types from JSON. It takes a name from the type declaration site, usually a parameter name. This all is explained comments in generated file. Also all generated types now refer to other generated types in setter methods — but this is commented out in generated code for now. All necessary forward declarations are also added. Anonymous enums are also generated, but they are in comments too, because we didn't have solution about form the enums should have in C++ API. Internally: The change reorganizes type bindings — a polymorphous "code generator" object is factored out from binding. A helper class Writer is added to allow generating code with ajustable indentations and to support insertion points where additional code can be inserted retroactively. ForwardListener class is used for preparing necessary forward declarations. AdHocTypeContext conception is a speculative abstract class that is needed wherever anonymous type can emerge.
Yury Semikhatsky
Comment 6 2011-12-21 01:01:30 PST
(In reply to comment #5) > (In reply to comment #4) > > (From update of attachment 119923 [details] [details]) > > Looks good. What does it do? > > Let me describe it here a bit more. > > In general it generates now C++ type for anonymous object types from JSON. It takes a name from the type declaration site, usually a parameter name. This all is explained comments in generated file. Also all generated types now refer to other generated types in setter methods — but this is commented out in generated code for now. All necessary forward declarations are also added. Anonymous enums are also generated, but they are in comments too, because we didn't have solution about form the enums should have in C++ API. > > Internally: > The change reorganizes type bindings — a polymorphous "code generator" object is factored out from binding. > A helper class Writer is added to allow generating code with ajustable indentations and to support insertion points where additional code can be inserted retroactively. > ForwardListener class is used for preparing necessary forward declarations. > AdHocTypeContext conception is a speculative abstract class that is needed wherever anonymous type can emerge. This is a good message to be placed into the ChangeLog entry.
Yury Semikhatsky
Comment 7 2011-12-21 01:19:02 PST
What about typedef'ed types such as BreakpointId and ScriptId? I see them declared but never used afterwards neither in comments nor in code. What prevents you from using them as corresponding parameter types e.g. in the following lines? void scriptParsed(const String& scriptId, const String& url, int startLine, int startColumn, int endLine, int endColumn, const bool* const isContentScript) void breakpointResolved(const String& breakpointId, /*PassRefPtr<TypeBuilder::Debugger::Location>*/ PassRefPtr<InspectorObject> location);
Peter Rybin
Comment 8 2011-12-21 06:43:43 PST
Peter Rybin
Comment 9 2011-12-21 06:48:22 PST
Yury, you have a very sharp eye. Indeed this typedefs were intended for use as parameter types to make client code more consistent. The answer is that I just didn't have time to do it yet and that's in my TODO. I don't think it's a high-pri task right now. (In reply to comment #7) > What about typedef'ed types such as BreakpointId and ScriptId? I see them declared but never used afterwards neither in comments nor in code. What prevents you from using them as corresponding parameter types e.g. in the following lines? > > void scriptParsed(const String& scriptId, const String& url, int startLine, int startColumn, int endLine, int endColumn, const bool* const isContentScript) > void breakpointResolved(const String& breakpointId, /*PassRefPtr<TypeBuilder::Debugger::Location>*/ PassRefPtr<InspectorObject> location);
WebKit Review Bot
Comment 10 2011-12-22 01:22:12 PST
Comment on attachment 120175 [details] Patch Clearing flags on attachment: 120175 Committed r103503: <http://trac.webkit.org/changeset/103503>
WebKit Review Bot
Comment 11 2011-12-22 01:22:17 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.