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

Issue 1421193003: New Mojom Parser: Serialization. (Closed)

Created:
5 years, 1 month ago by rudominer
Modified:
5 years, 1 month ago
Reviewers:
mattr, 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
Base URL:
https://github.com/domokit/mojo.git@master
Target Ref:
refs/heads/master
Project:
mojo
Visibility:
Public.

Description

New Mojom Parser: Serialization. R=azani@chromium.org, mattr@google.com BUG=#461 This is the final major piece of the mojom parser--the logic to serialize the MojomDescriptor to a Mojo message. Note that currently the use of Mojo serialization requires using cgo and linking against native librarires. This also means that serialization_test.go cannot be run as a pure go test the way the other tests are run but rather must be run using the "go_test_binary" target. This target will build a test binary in <out_dir>/obj/mojom/mojom_parser/serialization_test which needs to be executed separately. Here is a summary of the files changed: - mojo/go/rules.gni: I updated the "go_test_binary" target to be closer to the "go_binary" target - get_test_list.py: I added a new category of test for serialization_test since on the one hand it cannot be run as part of the Pure Go unit tests and on the other hand it would be confusing and misleading to run it under the heading Go system tests. - mojom/mojom_parser/generated: This directory contains generated Go code that we are checking in. It is the Go bindings for mojom_types.mojom and mojom_files.mojom. - serialization.go: This is the actual serialization logic. - serialization_test.go: A test of the serialization logic. Committed: https://chromium.googlesource.com/external/mojo/+/3708f59648870ffd4ab7f062e75f9d7ac7375449

Patch Set 1 #

Patch Set 2 : Rebasing #

Patch Set 3 : Working on serialization_test.go (This file not ready for review.) #

Patch Set 4 : Introduce function newString(). More serialization_test work. #

Patch Set 5 : New strategy for testing structure identity: Use modified fmt package. #

Patch Set 6 : Use revered fqn for type keys. Make line numbers optional. #

Total comments: 2

Patch Set 7 : "mojom parser serialization tests" => "mojom parser tests" #

Patch Set 8 : Adds README to the |generated| directory. #

Patch Set 9 : Fix typos. #

Total comments: 11

Patch Set 10 : Responding to code reveiw. #

Patch Set 11 : Refactors TestSingleFileSerialization. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+7233 lines, -14 lines) Patch
M mojo/go/rules.gni View 4 chunks +20 lines, -5 lines 0 comments Download
M mojo/tools/get_test_list.py View 1 2 3 4 5 6 7 8 9 1 chunk +5 lines, -0 lines 0 comments Download
M mojom/BUILD.gn View 1 1 chunk +12 lines, -3 lines 0 comments Download
M mojom/mojom_parser/BUILD.gn View 1 2 3 4 5 2 chunks +28 lines, -0 lines 0 comments Download
A mojom/mojom_parser/generated/README.md View 1 2 3 4 5 6 7 8 1 chunk +44 lines, -0 lines 0 comments Download
A mojom/mojom_parser/generated/mojom_files/mojom_files.mojom.go View 1 chunk +1102 lines, -0 lines 0 comments Download
A mojom/mojom_parser/generated/mojom_types/mojom_types.mojom.go View 1 chunk +5173 lines, -0 lines 0 comments Download
M mojom/mojom_parser/mojom/mojom_descriptor.go View 1 2 3 4 5 6 7 8 9 1 chunk +5 lines, -3 lines 0 comments Download
M mojom/mojom_parser/serialization/serialization.go View 1 2 3 4 5 6 7 8 9 2 chunks +543 lines, -3 lines 0 comments Download
A mojom/mojom_parser/serialization/serialization_test.go View 1 2 3 4 5 6 7 8 9 10 1 chunk +301 lines, -0 lines 0 comments Download

Messages

Total messages: 22 (9 generated)
rudominer
Alex and Matt, ptal. Note that serialization_test.go is not complete. I will continue working on ...
5 years, 1 month ago (2015-11-03 23:03:33 UTC) #5
rudominer
Alex & Matt, serialization_test.go is now ready for you to look at. In the course ...
5 years, 1 month ago (2015-11-05 18:49:01 UTC) #10
azani
just a nit really. https://codereview.chromium.org/1421193003/diff/180001/mojo/tools/get_test_list.py File mojo/tools/get_test_list.py (right): https://codereview.chromium.org/1421193003/diff/180001/mojo/tools/get_test_list.py#newcode127 mojo/tools/get_test_list.py:127: # Go mojom parser serialization ...
5 years, 1 month ago (2015-11-05 21:20:46 UTC) #11
rudominer
Thanks Alex. OK Matt whenever you have some time... This should be the last one. ...
5 years, 1 month ago (2015-11-05 21:47:31 UTC) #12
azani
lgtm
5 years, 1 month ago (2015-11-05 21:58:55 UTC) #13
rudominer
Alex, I added a README.md file to the |generated| directory. ptal. (We probably will want ...
5 years, 1 month ago (2015-11-09 17:50:07 UTC) #15
mattr
Dropped a few comments, feel free to ignore if you want. Sorry for being so ...
5 years, 1 month ago (2015-11-10 19:26:49 UTC) #16
azani
https://codereview.chromium.org/1421193003/diff/260001/mojom/mojom_parser/serialization/serialization.go File mojom/mojom_parser/serialization/serialization.go (right): https://codereview.chromium.org/1421193003/diff/260001/mojom/mojom_parser/serialization/serialization.go#newcode310 mojom/mojom_parser/serialization/serialization.go:310: case mojom.ArrayTypeRef: AFAICT, from running this code, you should ...
5 years, 1 month ago (2015-11-10 22:46:07 UTC) #17
rudominer
Thanks Matt. I addressed your comments. ptal. https://codereview.chromium.org/1421193003/diff/260001/mojom/mojom_parser/mojom/mojom_descriptor.go File mojom/mojom_parser/mojom/mojom_descriptor.go (right): https://codereview.chromium.org/1421193003/diff/260001/mojom/mojom_parser/mojom/mojom_descriptor.go#newcode479 mojom/mojom_parser/mojom/mojom_descriptor.go:479: // for ...
5 years, 1 month ago (2015-11-10 23:29:37 UTC) #18
rudominer
I already have an lgtm from azani@ and mattr@ gave me an lgtm over hangouts ...
5 years, 1 month ago (2015-11-10 23:39:47 UTC) #19
rudominer
Committed patchset #11 (id:300001) manually as 3708f59648870ffd4ab7f062e75f9d7ac7375449 (presubmit successful).
5 years, 1 month ago (2015-11-10 23:40:28 UTC) #20
mattr
https://codereview.chromium.org/1421193003/diff/260001/mojom/mojom_parser/serialization/serialization.go File mojom/mojom_parser/serialization/serialization.go (right): https://codereview.chromium.org/1421193003/diff/260001/mojom/mojom_parser/serialization/serialization.go#newcode555 mojom/mojom_parser/serialization/serialization.go:555: func newString(s string) *string { On 2015/11/10 23:29:36, rudominer ...
5 years, 1 month ago (2015-11-10 23:43:40 UTC) #21
rudominer
5 years, 1 month ago (2015-11-11 00:18:11 UTC) #22
Message was sent while issue was closed.
On 2015/11/10 23:43:40, mattr wrote:
>
https://codereview.chromium.org/1421193003/diff/260001/mojom/mojom_parser/ser...
> File mojom/mojom_parser/serialization/serialization.go (right):
> 
>
https://codereview.chromium.org/1421193003/diff/260001/mojom/mojom_parser/ser...
> mojom/mojom_parser/serialization/serialization.go:555: func newString(s
string)
> *string {
> On 2015/11/10 23:29:36, rudominer wrote:
> > On 2015/11/10 19:26:49, mattr wrote:
> > > I don't understand this function.  In Go strings are immutable so it
> shouldn't
> > > be necessary to copy, and actually what you are doing is not copying but
> > > creating a new string header only.  What are you actually trying to
> > accomplish?
> > 
> > The explanation for this peculiarity is similar to the previous one.
> > 
> > I added the following comment to clarify:
> > // newString is a convenience function for creating a pointer to a 
> > // string whose value  is the specified string. It is necessary to 
> > // create pointers to strings because that is how the Mojom type |string?| 
> > // (i.e. nullable string) is represented in the Mojom Go bindings.
> 
> Sure, but you should just do 
> 
> return &s
> 
> In which case there is really no need for the function.

The function is necessary because you cannot take the address of a string value
that is not an lvalue such as a literal or the return value from a function.
I have changed the implementation of the function as you suggests in
https://codereview.chromium.org/1409063008/.

Powered by Google App Engine
This is Rietveld 408576698