Bug 69295

Summary: Web Inspector: reimplement protocol backend/frontend source generator
Product: WebKit Reporter: Peter Rybin <peter.rybin>
Component: Web Inspector (Deprecated)Assignee: Ilya Tikhonovsky <loislo>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, bweinstein, gustavo, joepeck, keishi, loislo, peter.rybin, pfeldman, pmuellr, rik, thakis, timothy, webkit.review.bot, xan.lopez, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 70486    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Peter Rybin
Reported 2011-10-03 14:56:44 PDT
Inspector includes generated C++ and JavaScript source. Currently generator is written in Python/Perl and uses intermediate IDL format. Get rid of IDL intermediate and rewrite generator fully in Python. This is need to prepare protocol validator development.
Attachments
Patch (55.71 KB, patch)
2011-10-03 14:59 PDT, Peter Rybin
no flags
Patch (109.02 KB, patch)
2011-10-04 15:24 PDT, Peter Rybin
no flags
Patch (117.10 KB, patch)
2011-10-05 11:11 PDT, Peter Rybin
no flags
Patch (116.88 KB, patch)
2011-10-05 15:13 PDT, Peter Rybin
no flags
Patch (118.80 KB, patch)
2011-10-06 12:06 PDT, Peter Rybin
no flags
Patch (119.02 KB, patch)
2011-10-06 14:21 PDT, Peter Rybin
no flags
Patch (119.17 KB, patch)
2011-10-06 15:14 PDT, Peter Rybin
no flags
Patch (120.02 KB, patch)
2011-10-07 09:53 PDT, Peter Rybin
no flags
Patch (120.04 KB, patch)
2011-10-11 09:22 PDT, Peter Rybin
no flags
Patch (118.96 KB, patch)
2011-10-17 09:40 PDT, Peter Rybin
no flags
Patch (118.88 KB, patch)
2011-10-17 10:07 PDT, Peter Rybin
no flags
Patch (119.01 KB, patch)
2011-10-19 12:52 PDT, Peter Rybin
no flags
Patch (119.06 KB, patch)
2011-10-20 13:01 PDT, Ilya Tikhonovsky
no flags
Peter Rybin
Comment 1 2011-10-03 14:59:14 PDT
Ilya Tikhonovsky
Comment 2 2011-10-03 23:36:31 PDT
Comment on attachment 109534 [details] Patch It can't be applied to the ToT could you please rebaseline it.
Peter Rybin
Comment 3 2011-10-04 15:24:43 PDT
Peter Rybin
Comment 4 2011-10-04 15:25:44 PDT
Patch is uploaded this time to try on buildbots
Early Warning System Bot
Comment 5 2011-10-04 16:12:12 PDT
Gyuyoung Kim
Comment 6 2011-10-04 16:14:01 PDT
Gustavo Noronha (kov)
Comment 7 2011-10-04 22:20:47 PDT
Pavel Feldman
Comment 8 2011-10-05 00:07:56 PDT
Comment on attachment 109704 [details] Patch EWS reports multiple errors (qt, gtk, efl). Make sure your make files are ok.
Peter Rybin
Comment 9 2011-10-05 11:11:13 PDT
Gyuyoung Kim
Comment 10 2011-10-05 11:15:52 PDT
Early Warning System Bot
Comment 11 2011-10-05 11:19:31 PDT
Ilya Tikhonovsky
Comment 12 2011-10-05 12:33:44 PDT
InspectorProtocolVersion.h was generated into WebCore folder instead of WebKit folder. Also it was added to the list of files for compilation. gcc -c -pipe -O2 -o obj/release/InspectorProtocolVersion.o ../../WebCore/generated/InspectorProtocolVersion.h
Peter Rybin
Comment 13 2011-10-05 15:13:26 PDT
Early Warning System Bot
Comment 14 2011-10-05 16:15:42 PDT
Gyuyoung Kim
Comment 15 2011-10-05 16:30:33 PDT
Peter Rybin
Comment 16 2011-10-06 12:06:02 PDT
Gyuyoung Kim
Comment 17 2011-10-06 12:12:03 PDT
Peter Rybin
Comment 18 2011-10-06 14:21:49 PDT
Gyuyoung Kim
Comment 19 2011-10-06 14:46:25 PDT
Peter Rybin
Comment 20 2011-10-06 15:14:09 PDT
Ilya Tikhonovsky
Comment 21 2011-10-07 00:08:46 PDT
Comment on attachment 110041 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=110041&action=review > Source/WebCore/ChangeLog:10655 > +2011-10-03 Peter Rybin <peter.rybin@gmail.com> > + > + Web Inspector: reimplement protocol backend/frontend source generator > + https://bugs.webkit.org/show_bug.cgi?id=69295 > + > + Reviewed by NOBODY (OOPS!). > + > + No new tests. (OOPS!) > + > + * WebCore.gyp/WebCore.gyp: > + * inspector/CodeGeneratorInspector.pm: > + (finish): > + * inspector/CodeGeneratorInspector.py: Added. > + second change log entry. > Source/WebCore/CodeGenerators.pri:679 > +inspectorJSON.output = $${WC_GENERATED_SOURCES_DIR}/InspectorFrontend.cpp $${WC_GENERATED_SOURCES_DIR}/InspectorBackendDispatcher.cpp please add headers too > Source/WebCore/WebCore.gyp/WebCore.gyp:369 > + 'message': 'Generating Inspector protocol sources from Inspector.idl', from Inspector.json > Source/WebCore/inspector/CodeGeneratorInspector.py:446 > +if (!protocolErrors->length()) > + $agentField->$methodName(&error$agentCallParams); wrong indent in the generated file. > Source/WebCore/inspector/CodeGeneratorInspector.py:449 > +${responseCook}sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "$domainName.$methodName"), protocolErrors, error); wrong indent in the generated file. It'd be nice to extract String::format("Some arguments of method '%s' can't be processed", "some method name") call to an inline function. > Source/WebCore/inspector/CodeGeneratorInspector.py:457 > +$code if (m_inspectorFrontendChannel) improvement: I'd like to convert this if statement to guard. > Source/WebCore/inspector/CodeGeneratorInspector.py:462 > + frontend_h = string.Template("""// Copyright (c) 2010 The Chromium Authors. All rights reserved. Copyright (c) 2011 > Source/WebCore/inspector/CodeGeneratorInspector.py:482 > + unnecessary empty line > Source/WebCore/inspector/CodeGeneratorInspector.py:485 > +$domainClassList > +private: unnecessary empty line was inserted between last class and private statement > Source/WebCore/inspector/CodeGeneratorInspector.py:493 > + backend_h = string.Template("""// Copyright (c) 2010 The Chromium Authors. All rights reserved. license 2011 > Source/WebCore/inspector/CodeGeneratorInspector.py:539 > + unnecessary empty line > Source/WebCore/inspector/CodeGeneratorInspector.py:540 > +$enumConstants $methodNamesEnumContent ? > Source/WebCore/inspector/CodeGeneratorInspector.py:541 > +}; wrong indent > Source/WebCore/inspector/CodeGeneratorInspector.py:565 > + backend_cpp = string.Template("""// Copyright (c) 2010 The Chromium Authors. All rights reserved. Copyright (c) 2011 > Source/WebCore/inspector/CodeGeneratorInspector.py:589 > + unnecessary empty string > Source/WebCore/inspector/CodeGeneratorInspector.py:601 > +$messageHandlers wrong indent in the generated file. > Source/WebCore/inspector/CodeGeneratorInspector.py:666 > + if (m_inspectorFrontendChannel) improvement: I'd like to convert this if statement to guard. > Source/WebCore/inspector/CodeGeneratorInspector.py:701 > + if (m_inspectorFrontendChannel) improvement: I'd like to convert this if statement to guard. > Source/WebCore/inspector/CodeGeneratorInspector.py:840 > +PassRefPtr<InspectorObject> InspectorBackendDispatcher::getObject(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors) > +{ > + ASSERT(protocolErrors); > + > + if (valueFound) > + *valueFound = false; > + > + RefPtr<InspectorObject> value = InspectorObject::create(); > + > + if (!object) { > + if (!valueFound) { > + // Required parameter in missing params container. > + protocolErrors->pushString(String::format("'params' object must contain required parameter '%s' with type 'Object'.", name.utf8().data())); > + } > + return value; > + } > + > + InspectorObject::const_iterator end = object->end(); > + InspectorObject::const_iterator valueIterator = object->find(name); > + > + if (valueIterator == end) { > + if (!valueFound) > + protocolErrors->pushString(String::format("Parameter '%s' with type 'Object' was not found.", name.utf8().data())); > + return value; > + } > + > + if (!valueIterator->second->asObject(&value)) > + protocolErrors->pushString(String::format("Parameter '%s' has wrong type. It must be 'Object'.", name.utf8().data())); > + else > + if (valueFound) > + *valueFound = true; > + return value; > +} > + The old version is generating the getters > Source/WebCore/inspector/CodeGeneratorInspector.py:874 > +bool InspectorBackendDispatcher::getCommandName(const String& message, String* result) empty line required > Source/WebCore/inspector/CodeGeneratorInspector.py:914 > + > + unnecessary empty lines > Source/WebCore/inspector/CodeGeneratorInspector.py:928 > + backend_js = string.Template("""// Copyright (c) 2010 The Chromium Authors. All rights reserved. license 2011 > Source/WebCore/inspector/CodeGeneratorInspector.py:940 > +$delegates$eventArgs$domainDispatchers } wrong indent in the generated code > Source/WebCore/inspector/CodeGeneratorInspector.py:1398 > + enumConstants=join(Generator.method_name_enum_list, "\n"), bad name
Peter Rybin
Comment 22 2011-10-07 09:38:34 PDT
Hi Ilya, Thank you for review! In this change I'm trying to provide a generator that is character-compatible with the old version. Old extra or missing lines are kept as legacy. I think we should leave all improvements to the next CL not to do 2 things at once. > > Source/WebCore/ChangeLog:10655 > > +2011-10-03 Peter Rybin <peter.rybin@gmail.com> > > + > > + Web Inspector: reimplement protocol backend/frontend source generator > > + https://bugs.webkit.org/show_bug.cgi?id=69295 > > + > > + Reviewed by NOBODY (OOPS!). > > + > > + No new tests. (OOPS!) > > + > > + * WebCore.gyp/WebCore.gyp: > > + * inspector/CodeGeneratorInspector.pm: > > + (finish): > > + * inspector/CodeGeneratorInspector.py: Added. > > + > > second change log entry. Done > > Source/WebCore/CodeGenerators.pri:679 > > +inspectorJSON.output = $${WC_GENERATED_SOURCES_DIR}/InspectorFrontend.cpp $${WC_GENERATED_SOURCES_DIR}/InspectorBackendDispatcher.cpp > please add headers too Are you sure it's the right thing to do? Look at the removed target below, it doesn't list header files. > > Source/WebCore/WebCore.gyp/WebCore.gyp:369 > > + 'message': 'Generating Inspector protocol sources from Inspector.idl', > from Inspector.json Done > > Source/WebCore/inspector/CodeGeneratorInspector.py:449 > > +${responseCook}sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "$domainName.$methodName"), protocolErrors, error); > It'd be nice to extract String::format("Some arguments of method '%s' can't be processed", "some method name") call to an inline function. There's no need for formatting it on runtime. We should format it right in generator instead. > > Source/WebCore/inspector/CodeGeneratorInspector.py:540 > > +$enumConstants > $methodNamesEnumContent ? Done > > Source/WebCore/inspector/CodeGeneratorInspector.py:601 > > +$messageHandlers > wrong indent in the generated file. This is a multi-line placeholder. Indents are inside argument. > > Source/WebCore/inspector/CodeGeneratorInspector.py:840 > > +PassRefPtr<InspectorObject> InspectorBackendDispatcher::getObject(InspectorObject* object, const String& name, bool* valueFound, InspectorArray* protocolErrors) > > +{ > The old version is generating the getters I missed this. Let me handle it in the next change. I would consider leaving it as it is or programming using C++ template technology (to keep the minimum amount of generated code). > > Source/WebCore/inspector/CodeGeneratorInspector.py:1398 > > + enumConstants=join(Generator.method_name_enum_list, "\n"), > bad name Done
Peter Rybin
Comment 23 2011-10-07 09:53:57 PDT
Ilya Tikhonovsky
Comment 24 2011-10-07 12:08:41 PDT
> > > Source/WebCore/inspector/CodeGeneratorInspector.py:449 > > > +${responseCook}sendResponse(callId, result, String::format("Some arguments of method '%s' can't be processed", "$domainName.$methodName"), protocolErrors, error); > > It'd be nice to extract String::format("Some arguments of method '%s' can't be processed", "some method name") call to an inline function. > > There's no need for formatting it on runtime. We should format it right in generator instead. > In this case the size of binary will be bigger. > > > Source/WebCore/inspector/CodeGeneratorInspector.py:601 > > > +$messageHandlers > > wrong indent in the generated file. > > This is a multi-line placeholder. Indents are inside argument. I saw the wrong indent in the generated file.
Peter Rybin
Comment 25 2011-10-11 09:22:32 PDT
Pavel Feldman
Comment 26 2011-10-16 10:54:37 PDT
Comment on attachment 110523 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=110523&action=review Minor formal comments, otherwise code looks good. > Source/WebCore/ChangeLog:3 > + Web Inspector: reimplement protocol backend/frontend source generator You should be more explicit wrt rationale of the change. I.e. port source generator from perl to python, explain why. > Source/WebCore/ChangeLog:3178 > +2011-10-04 Peter Rybin <peter.rybin@gmail.com> You should nuke this > Source/WebCore/ChangeLog:13819 > +2011-10-03 Peter Rybin <peter.rybin@gmail.com> ditto > Source/WebCore/WebCore.gyp/WebCore.gyp:363 > + '../inspector/CodeGeneratorInspector.py', prefer <@(_inputs) > Source/WebCore/inspector/CodeGeneratorInspector.py:493 > + backend_h = string.Template("""// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2011
Peter Rybin
Comment 27 2011-10-17 09:36:54 PDT
(In reply to comment #26) > > Source/WebCore/ChangeLog:3 > > + Web Inspector: reimplement protocol backend/frontend source generator > You should be more explicit wrt rationale of the change. I.e. port source generator from perl to python, explain why. Done > > Source/WebCore/ChangeLog:3178 > > +2011-10-04 Peter Rybin <peter.rybin@gmail.com> > You should nuke this Done > > Source/WebCore/ChangeLog:13819 > > +2011-10-03 Peter Rybin <peter.rybin@gmail.com> > > ditto Doneto > > Source/WebCore/WebCore.gyp/WebCore.gyp:363 > > + '../inspector/CodeGeneratorInspector.py', > > prefer <@(_inputs) Done > > Source/WebCore/inspector/CodeGeneratorInspector.py:493 > > + backend_h = string.Template("""// Copyright (c) 2010 The Chromium Authors. All rights reserved. > 2011 Let's not modify output during this change. This change is the true port.
Peter Rybin
Comment 28 2011-10-17 09:40:33 PDT
WebKit Review Bot
Comment 29 2011-10-17 09:44:20 PDT
Attachment 111276 [details] did not pass style-queue: Failed to run "['Tools/Scripts/update-webkit', '--chromium']" exit_code: 2 Updating OpenSource Current branch master is up to date. Updating chromium port dependencies using gclient... Error: Can't switch the checkout to http://v8.googlecode.com/svn/branches/3.6@9637; UUID don't match and there is local changes in /mnt/git/webkit-style-queue/Source/WebKit/chromium/v8. Delete the directory and try again. Re-trying 'depot_tools/gclient sync' Error: Can't switch the checkout to http://v8.googlecode.com/svn/branches/3.6@9637; UUID don't match and there is local changes in /mnt/git/webkit-style-queue/Source/WebKit/chromium/v8. Delete the directory and try again. Re-trying 'depot_tools/gclient sync' Error: Can't switch the checkout to http://v8.googlecode.com/svn/branches/3.6@9637; UUID don't match and there is local changes in /mnt/git/webkit-style-queue/Source/WebKit/chromium/v8. Delete the directory and try again. Error: 'depot_tools/gclient sync' failed 3 tries and returned 256 at Tools/Scripts/update-webkit-chromium line 107. Re-trying 'depot_tools/gclient sync' No such file or directory at Tools/Scripts/update-webkit line 104. If any of these errors are false positives, please file a bug against check-webkit-style.
Peter Rybin
Comment 30 2011-10-17 10:07:38 PDT
WebKit Review Bot
Comment 31 2011-10-17 10:10:58 PDT
Attachment 111279 [details] did not pass style-queue: Failed to run "['Tools/Scripts/update-webkit', '--chromium']" exit_code: 2 Updating OpenSource From git://git.webkit.org/WebKit 38bca30..7d79b00 master -> origin/master M Source/WebCore/ChangeLog M Source/WebCore/accessibility/AccessibilitySlider.h M Source/WebCore/accessibility/AccessibilityScrollView.h M Source/WebCore/accessibility/AccessibilityTableHeaderContainer.cpp M Source/WebCore/accessibility/AccessibilityTableColumn.cpp M Source/WebCore/accessibility/AccessibilityRenderObject.h M Source/WebCore/accessibility/AccessibilityObject.h M Source/WebCore/accessibility/AccessibilitySlider.cpp M Source/WebCore/accessibility/AccessibilityScrollView.cpp M Source/WebCore/accessibility/AccessibilityRenderObject.cpp M Source/WebCore/accessibility/AccessibilityObject.cpp M Source/WebCore/accessibility/AccessibilityTableHeaderContainer.h M Source/WebCore/accessibility/AccessibilityTableColumn.h r97629 = db16dcbed1aa59c3f8b9618e43d75410fa38e632 (refs/remotes/trunk) M LayoutTests/platform/qt-wk2/Skipped M LayoutTests/ChangeLog r97630 = 7d79b00ad79af37d995a3601775a897ea3539050 (refs/remotes/trunk) First, rewinding head to replay your work on top of it... Fast-forwarded master to refs/remotes/trunk. Updating chromium port dependencies using gclient... Error: Can't switch the checkout to http://v8.googlecode.com/svn/branches/3.6@9637; UUID don't match and there is local changes in /mnt/git/webkit-style-queue/Source/WebKit/chromium/v8. Delete the directory and try again. Re-trying 'depot_tools/gclient sync' Error: Can't switch the checkout to http://v8.googlecode.com/svn/branches/3.6@9637; UUID don't match and there is local changes in /mnt/git/webkit-style-queue/Source/WebKit/chromium/v8. Delete the directory and try again. Re-trying 'depot_tools/gclient sync' Error: Can't switch the checkout to http://v8.googlecode.com/svn/branches/3.6@9637; UUID don't match and there is local changes in /mnt/git/webkit-style-queue/Source/WebKit/chromium/v8. Delete the directory and try again. Error: 'depot_tools/gclient sync' failed 3 tries and returned 256 at Tools/Scripts/update-webkit-chromium line 107. Re-trying 'depot_tools/gclient sync' No such file or directory at Tools/Scripts/update-webkit line 104. If any of these errors are false positives, please file a bug against check-webkit-style.
Ilya Tikhonovsky
Comment 32 2011-10-18 23:20:00 PDT
Comment on attachment 111279 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=111279&action=review > Source/WebCore/inspector/CodeGeneratorInspector.py:265 > + def getCParamType(cls, param_type, optional): > + if (param_type == ParamType.EVENT): > + if optional: > + return cls._ref_c_type > + else: > + return cls._plain_c_type > + else: > + return cls._plain_c_type I'm a bit confused by the mix of styles in this script. I'd like to see the names of methods, member variables, etc formatted according to WebKit style guide.
Peter Rybin
Comment 33 2011-10-19 12:52:07 PDT
Peter Rybin
Comment 34 2011-10-19 12:56:33 PDT
(In reply to comment #32) > (From update of attachment 111279 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=111279&action=review > > > Source/WebCore/inspector/CodeGeneratorInspector.py:265 > > + def getCParamType(cls, param_type, optional): > > + if (param_type == ParamType.EVENT): > > + if optional: > > + return cls._ref_c_type > > + else: > > + return cls._plain_c_type > > + else: > > + return cls._plain_c_type > > I'm a bit confused by the mix of styles in this script. > I'd like to see the names of methods, member variables, etc formatted according to WebKit style guide. Done
Ilya Tikhonovsky
Comment 35 2011-10-19 14:01:06 PDT
Comment on attachment 111660 [details] Patch I asked Peter to keep the generator code to be consistent with WebKit style guide. http://www.webkit.org/coding/coding-style.html But Peter found that WebKit community has a separate guide for Python and informally supports PEP8. "Informally, we try to follow PEP8. Eventually we may make this official." from http://trac.webkit.org/wiki/PythonGuidelines lgtm
Ilya Tikhonovsky
Comment 36 2011-10-20 02:49:31 PDT
Comment on attachment 111660 [details] Patch Clearing flags on attachment: 111660 Committed r97954: <http://trac.webkit.org/changeset/97954>
Ilya Tikhonovsky
Comment 37 2011-10-20 02:49:45 PDT
All reviewed patches have been landed. Closing bug.
Ilya Tikhonovsky
Comment 38 2011-10-20 13:01:42 PDT
Ilya Tikhonovsky
Comment 39 2011-10-20 22:59:47 PDT
Pavel Feldman
Comment 40 2011-10-21 12:18:06 PDT
Comment on attachment 111828 [details] Patch Clearing r? from the patch that has landed.
Nico Weber
Comment 41 2012-07-20 09:53:46 PDT
The build output when building chromium now looks like this: hummer:src thakis$ time ninja -C out/Release/ chrome ninja: Entering directory `out/Release/' [595/10791] ACTION Generating Inspector protocol sources from Inspector.json writing ../../../../../out/Release/gen/webkit/InspectorBackendDispatcher.h writing ../../../../../out/Release/gen/webcore/InspectorBackendDispatcher.cpp writing ../../../../../out/Release/gen/webkit/InspectorFrontend.h writing ../../../../../out/Release/gen/webcore/InspectorFrontend.cpp writing ../../../../../out/Release/gen/webkit/InspectorTypeBuilder.h writing ../../../../../out/Release/gen/webcore/InspectorBackendCommands.js [5508/10791] CXX obj/third_party/WebKit/Source/WebCore/html/webcore_html.HTMLStyleElement.o Can you remove the print spew from this new generator please?
Peter Rybin
Comment 42 2012-07-20 09:59:49 PDT
(In reply to comment #41) > The build output when building chromium now looks like this: > > hummer:src thakis$ time ninja -C out/Release/ chrome > ninja: Entering directory `out/Release/' > [595/10791] ACTION Generating Inspector protocol sources from Inspector.json > writing ../../../../../out/Release/gen/webkit/InspectorBackendDispatcher.h > writing ../../../../../out/Release/gen/webcore/InspectorBackendDispatcher.cpp > writing ../../../../../out/Release/gen/webkit/InspectorFrontend.h > writing ../../../../../out/Release/gen/webcore/InspectorFrontend.cpp > writing ../../../../../out/Release/gen/webkit/InspectorTypeBuilder.h > writing ../../../../../out/Release/gen/webcore/InspectorBackendCommands.js > [5508/10791] CXX obj/third_party/WebKit/Source/WebCore/html/webcore_html.HTMLStyleElement.o > > > Can you remove the print spew from this new generator please? Sorry about this. https://bugs.webkit.org/show_bug.cgi?id=91758
Note You need to log in before you can comment on or make changes to this bug.