Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Issue 917333003: Mojo C++ bindings templates: use the same templates for user-defined structs and method params. (Closed)

Created:
5 years, 10 months ago by yzshen1
Modified:
5 years, 10 months ago
Reviewers:
viettrungluu
CC:
mojo-reviews_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, darin (slow to review), ben+mojo_chromium.org
Base URL:
https://github.com/domokit/mojo.git@master
Target Ref:
refs/heads/master
Project:
mojo
Visibility:
Public.

Description

Mojo C++ bindings templates: use the same templates for user-defined structs and method params. This CL removes params_defintion.tmpl and avoids several macros. BUG=None TEST=None R=viettrungluu@chromium.org Committed: https://chromium.googlesource.com/external/mojo/+/36e2c9b9a02d1bd81ce79c1b1ecd34ce0cb6f835

Patch Set 1 #

Patch Set 2 : #

Total comments: 11

Patch Set 3 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+189 lines, -253 lines) Patch
M mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl View 1 chunk +4 lines, -2 lines 0 comments Download
D mojo/public/tools/bindings/generators/cpp_templates/params_definition.tmpl View 1 chunk +0 lines, -33 lines 0 comments Download
M mojo/public/tools/bindings/generators/cpp_templates/struct_declaration.tmpl View 1 2 2 chunks +30 lines, -4 lines 0 comments Download
M mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl View 1 2 chunks +154 lines, -8 lines 0 comments Download
M mojo/public/tools/bindings/generators/cpp_templates/struct_macros.tmpl View 1 chunk +1 line, -205 lines 0 comments Download
M mojo/public/tools/bindings/mojom.gni View 1 chunk +0 lines, -1 line 0 comments Download

Messages

Total messages: 8 (2 generated)
yzshen1
Please take a look. This is the first step. I will do more cleanups.
5 years, 10 months ago (2015-02-12 23:52:40 UTC) #2
viettrungluu
LGTM (with various comments, not to be addressed in this CL). https://codereview.chromium.org/917333003/diff/20001/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl File mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl (right): ...
5 years, 10 months ago (2015-02-13 00:51:34 UTC) #3
yzshen1
https://codereview.chromium.org/917333003/diff/20001/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl File mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl (right): https://codereview.chromium.org/917333003/diff/20001/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl#newcode6 mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl:6: {#- Validates the specified struct field, which is supposed ...
5 years, 10 months ago (2015-02-17 22:17:08 UTC) #5
yzshen1
Committed patchset #3 (id:40001) manually as 36e2c9b9a02d1bd81ce79c1b1ecd34ce0cb6f835 (presubmit successful).
5 years, 10 months ago (2015-02-17 22:18:18 UTC) #6
viettrungluu
https://codereview.chromium.org/917333003/diff/20001/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl File mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl (right): https://codereview.chromium.org/917333003/diff/20001/mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl#newcode6 mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl:6: {#- Validates the specified struct field, which is supposed ...
5 years, 10 months ago (2015-02-17 22:32:50 UTC) #7
yzshen1
5 years, 10 months ago (2015-02-17 22:42:31 UTC) #8
Message was sent while issue was closed.
On 2015/02/17 22:32:50, viettrungluu wrote:
>
https://codereview.chromium.org/917333003/diff/20001/mojo/public/tools/bindin...
> File
mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl
> (right):
> 
>
https://codereview.chromium.org/917333003/diff/20001/mojo/public/tools/bindin...
> mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl:6:
> {#- Validates the specified struct field, which is supposed to be an object
> On 2015/02/17 22:17:08, yzshen1 wrote:
> > On 2015/02/13 00:51:34, viettrungluu wrote:
> > > At least it's all in one file now, which already makes things easier.
> > > 
> > > Not to be addressed in this CL:
> > > 
> > > I wonder if it's possible to restructure this as a function (or multiple
> > > functions) in some way (possibly with various strings and function
pointers
> as
> > > arguments).
> > > 
> > > I'm at least slightly concerned about the binary size impact of blind
> > expansions
> > > like this. (There's a space versus time tradeoff, but on the other hand
> bigger
> > > code is often slower due to cache issues.)
> > > 
> > > (In the grand scheme of things, the impact of improving on things like
this
> is
> > > pretty small. On the other hand, generated bindings code has a
well-deserved
> > > reputation for being big and bloated.[*])
> > > 
> > > [*] And I'm not even talking about our generated code!
> > 
> > I am thinking about converting the code into C++ template to make it a
little
> > more readable. (Well, maybe even less readable for people that are not
> familiar
> > with C++ template...) But not sure how much that will help with reducing
> binary
> > size. (I don't know much about how modern compilers optimize templates.)
> 
> A C++ template is one definite possibility, though templates can come with
> binary size issues (as well as compilation time issues, if they're in
headers).
> 
> Another possibility is to use classical polymorphism, etc. (This might
sometimes
> win on binary size, with the cost being some indirection/vtable thunks.)
> 
> You might want to use some combination of the two (in addition to pure
generated
> code), as appropriate. (Both have the advantage that you can read the code and
> test it, without involving the bindings generator.)

Thanks for the suggestion. I will think more about it and hopefully come up with
a CL. :)

Powered by Google App Engine
This is Rietveld 408576698