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

Issue 1508293004: Simplify Go's Mojom Type Generator (Closed)

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

Description

Simplify Go's Mojom Type Generator Removes all dependence on the identifier_store. Originally, the identifier_store appeared to be needed because types were generated recursively, and their children types also needed to be registered. In order to break cycles and avoid repeats, we would use the identifier_store. However, this is actually not needed. Each relevant type to be registered (enum/union/struct/interface) is already known beforehand by the generating Python script. Types belonging to other .mojom files are also registered explicitly. Since children types do NOT need to be registered, the identifier_store could be safely removed. This CL also shifts the generation flag from the go generator to the generator scripts. This is a better location since it allows users to control whether types are generated or not. BUG=https://github.com/domokit/mojo/issues/596 R=azani@chromium.org Committed: https://chromium.googlesource.com/external/mojo/+/a241773121e1588ad04f5d970a6ccc42ad52bc00

Patch Set 1 #

Patch Set 2 : Upload again to trigger trybot tests #

Patch Set 3 : Trigger Trybot tests again #

Total comments: 8

Patch Set 4 : Rebased and minor comment update #

Patch Set 5 : Add generate_type_info flag to mojom generators #

Total comments: 15

Patch Set 6 : Address Code Cleanups #

Patch Set 7 : Add arg instead of leaving it unparsed #

Patch Set 8 : Add store_true to the argparse #

Total comments: 7

Patch Set 9 : Use hyphens in flag, not underscores #

Unified diffs Side-by-side diffs Delta from patch set Stats (+33 lines, -57 lines) Patch
M mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl View 1 2 3 4 5 3 chunks +2 lines, -22 lines 0 comments Download
M mojo/public/tools/bindings/generators/go_templates/mojom_type_macros.tmpl View 3 chunks +0 lines, -7 lines 0 comments Download
M mojo/public/tools/bindings/generators/mojom_go_generator.py View 1 2 3 4 5 4 chunks +11 lines, -28 lines 0 comments Download
M mojo/public/tools/bindings/generators/mojom_java_generator.py View 1 2 3 4 5 6 7 1 chunk +2 lines, -0 lines 0 comments Download
M mojo/public/tools/bindings/mojom_bindings_generator_v1.py View 1 2 3 4 5 6 7 8 2 chunks +9 lines, -0 lines 0 comments Download
M mojo/public/tools/bindings/run_code_generators.py View 1 2 3 4 5 6 7 8 2 chunks +9 lines, -0 lines 0 comments Download

Messages

Total messages: 21 (4 generated)
azani
thanks for the cl. https://codereview.chromium.org/1508293004/diff/40001/mojo/public/tools/bindings/generators/mojom_go_generator.py File mojo/public/tools/bindings/generators/mojom_go_generator.py (right): https://codereview.chromium.org/1508293004/diff/40001/mojo/public/tools/bindings/generators/mojom_go_generator.py#newcode314 mojo/public/tools/bindings/generators/mojom_go_generator.py:314: # Note: InterfaceRequestKind's should use ...
5 years ago (2015-12-10 23:16:19 UTC) #3
alexfandrianto
Thanks. I'm actually not quite sure what to do about the flag name. Currently, each ...
5 years ago (2015-12-11 01:26:57 UTC) #4
rudominer
Can you please add a comment to the CL description explaining why you thought use ...
5 years ago (2015-12-14 21:29:57 UTC) #5
azani
Hey Alex, Sorry this took so long. I thought I had responded to your CL ...
5 years ago (2015-12-14 22:20:01 UTC) #6
alexfandrianto
https://codereview.chromium.org/1508293004/diff/40001/mojo/public/tools/bindings/generators/mojom_go_generator.py File mojo/public/tools/bindings/generators/mojom_go_generator.py (right): https://codereview.chromium.org/1508293004/diff/40001/mojo/public/tools/bindings/generators/mojom_go_generator.py#newcode389 mojo/public/tools/bindings/generators/mojom_go_generator.py:389: if "--go_gen_types" in args: On 2015/12/14 22:20:01, azani wrote: ...
5 years ago (2015-12-15 20:53:40 UTC) #7
alexfandrianto
On 2015/12/15 20:53:40, alexfandrianto wrote: > https://codereview.chromium.org/1508293004/diff/40001/mojo/public/tools/bindings/generators/mojom_go_generator.py > File mojo/public/tools/bindings/generators/mojom_go_generator.py (right): > > https://codereview.chromium.org/1508293004/diff/40001/mojo/public/tools/bindings/generators/mojom_go_generator.py#newcode389 > ...
5 years ago (2015-12-17 19:31:00 UTC) #9
azani
Thanks again. Sorry I didn't get to this sooner. https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl File mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl (right): https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl#newcode29 mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl:29: ...
5 years ago (2015-12-18 18:12:58 UTC) #10
alexfandrianto
Thanks for the review. https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl File mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl (right): https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl#newcode29 mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl:29: {# No need to register ...
5 years ago (2015-12-18 19:08:32 UTC) #11
azani
https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/mojom_go_generator.py File mojo/public/tools/bindings/generators/mojom_go_generator.py (right): https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/mojom_go_generator.py#newcode322 mojo/public/tools/bindings/generators/mojom_go_generator.py:322: # This is for a type that should not ...
5 years ago (2015-12-18 23:19:11 UTC) #12
alexfandrianto
On 2015/12/18 23:19:11, azani wrote: > https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/mojom_go_generator.py > File mojo/public/tools/bindings/generators/mojom_go_generator.py (right): > > https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/mojom_go_generator.py#newcode322 > ...
5 years ago (2015-12-18 23:20:56 UTC) #13
alexfandrianto
https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/mojom_java_generator.py File mojo/public/tools/bindings/generators/mojom_java_generator.py (right): https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/mojom_java_generator.py#newcode500 mojo/public/tools/bindings/generators/mojom_java_generator.py:500: (args, _) = parser.parse_known_args(unparsed_args) On 2015/12/18 23:19:11, azani wrote: ...
5 years ago (2015-12-18 23:24:10 UTC) #14
alexfandrianto
On 2015/12/18 23:24:10, alexfandrianto wrote: > https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/mojom_java_generator.py > File mojo/public/tools/bindings/generators/mojom_java_generator.py (right): > > https://codereview.chromium.org/1508293004/diff/80001/mojo/public/tools/bindings/generators/mojom_java_generator.py#newcode500 > ...
5 years ago (2015-12-21 21:47:54 UTC) #15
azani
Sorry, I forgot to send my drafts a couple hours ago. https://codereview.chromium.org/1508293004/diff/140001/mojo/public/tools/bindings/mojom_bindings_generator_v1.py File mojo/public/tools/bindings/mojom_bindings_generator_v1.py (right): ...
5 years ago (2015-12-21 22:28:37 UTC) #16
alexfandrianto
https://codereview.chromium.org/1508293004/diff/140001/mojo/public/tools/bindings/mojom_bindings_generator_v1.py File mojo/public/tools/bindings/mojom_bindings_generator_v1.py (right): https://codereview.chromium.org/1508293004/diff/140001/mojo/public/tools/bindings/mojom_bindings_generator_v1.py#newcode209 mojo/public/tools/bindings/mojom_bindings_generator_v1.py:209: parser.add_argument("--generate_type_info", dest="generate_type_info", On 2015/12/21 22:28:37, azani wrote: > Same ...
5 years ago (2015-12-21 23:50:11 UTC) #17
azani
lgtm https://codereview.chromium.org/1508293004/diff/140001/mojo/public/tools/bindings/run_code_generators.py File mojo/public/tools/bindings/run_code_generators.py (right): https://codereview.chromium.org/1508293004/diff/140001/mojo/public/tools/bindings/run_code_generators.py#newcode48 mojo/public/tools/bindings/run_code_generators.py:48: parser.set_defaults(generate_type_info=True) On 2015/12/21 23:50:11, alexfandrianto wrote: > On ...
4 years, 11 months ago (2016-01-04 22:20:44 UTC) #18
alexfandrianto
Committed patchset #9 (id:160001) manually as a241773121e1588ad04f5d970a6ccc42ad52bc00 (presubmit successful).
4 years, 11 months ago (2016-01-06 20:13:29 UTC) #20
alexfandrianto
4 years, 11 months ago (2016-01-06 20:23:11 UTC) #21
Message was sent while issue was closed.
On 2016/01/04 22:20:44, azani wrote:
> lgtm
> 
>
https://codereview.chromium.org/1508293004/diff/140001/mojo/public/tools/bind...
> File mojo/public/tools/bindings/run_code_generators.py (right):
> 
>
https://codereview.chromium.org/1508293004/diff/140001/mojo/public/tools/bind...
> mojo/public/tools/bindings/run_code_generators.py:48:
> parser.set_defaults(generate_type_info=True)
> On 2015/12/21 23:50:11, alexfandrianto wrote:
> > On 2015/12/21 22:28:37, azani wrote:
> > > Just use the default param to add_argument. Also, don't we want to default
> to
> > > False?
> > 
> > The default is true so that the test(s) will compile.
> > 
> > action="store_true" and "store_false" already have the opposite as defaults.
I
> > like this way more since it's clearer what it will end up being. Further, it
> is
> > also clearer how to change it in the future.
> 
> I understand your point regarding tests, but if we set it to true by default,
> this means type info will be generated for everybody. As long as this is just
> something that happens with go bindings, that's not a big deal because you're
> the primary users. But the Dart bindings are in use by a lot of people and
they
> shouldn't have to do anything to avoid generating extraneous code. So I'm ok
> with this for now, but we need to switch the default to False before your dart
> bindings change is landed.

Thanks.

This is definitely a point that we will need to reconcile. Depending on our
priorities, it may actually not be that bad to allow the extra code to be
generated in Dart.

For the next CL, I will try to get numbers on how the code size is affected by
type generation. If the increase in size is not acceptable, we will have to work
something out. Since a Dart test for Mojom types will have to run too, it's not
as simple as having the default be false for Dart. We will need to come up with
a better solution.

If the solution we come up with is nontrivial, then it can still be better to
temporarily ( a few weeks?) accept an increase in code size since a code size
increase is not very harmful to Dart users.

Powered by Google App Engine
This is Rietveld 408576698