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

Issue 615063003: Mojo cpp bindings: support Clone() for structs and arrays which don't contain handles. (Closed)

Created:
6 years, 2 months ago by yzshen1
Modified:
6 years, 2 months ago
CC:
chromium-reviews, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, ben+mojo_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Mojo cpp bindings: support Clone() for structs and arrays which don't contain handles. With this CL you can do: // It is safe to call even if foo.is_null() is true. FooStructPtr foo_clone = foo.Clone(); Array<Bar> bar_array_clone = bar_array.Clone(); If you call Clone() with a struct or array type which (transitively) contains handles, you will get a compile-time error: 'Clone' : is not a member of 'FooStruct'. BUG=None TEST=Newly added tests in array_unittest and struct_unittest Committed: https://crrev.com/a3f0198fc0a56f1a3c2ffb8384ecf9c40f649b87 Cr-Commit-Position: refs/heads/master@{#297890}

Patch Set 1 #

Patch Set 2 : add a few more tests #

Patch Set 3 : #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+187 lines, -21 lines) Patch
M mojo/public/cpp/bindings/array.h View 1 chunk +10 lines, -0 lines 0 comments Download
M mojo/public/cpp/bindings/lib/array_internal.h View 2 chunks +10 lines, -0 lines 0 comments Download
M mojo/public/cpp/bindings/struct_ptr.h View 2 chunks +11 lines, -0 lines 0 comments Download
M mojo/public/cpp/bindings/tests/array_unittest.cc View 1 2 7 chunks +90 lines, -20 lines 0 comments Download
M mojo/public/cpp/bindings/tests/struct_unittest.cc View 1 1 chunk +28 lines, -0 lines 0 comments Download
M mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl View 1 chunk +3 lines, -0 lines 5 comments Download
M mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl View 1 chunk +14 lines, -1 line 0 comments Download
M mojo/public/tools/bindings/generators/mojom_cpp_generator.py View 2 chunks +2 lines, -0 lines 0 comments Download
M mojo/public/tools/bindings/pylib/mojom/generate/module.py View 1 chunk +19 lines, -0 lines 0 comments Download

Messages

Total messages: 22 (5 generated)
yzshen1
Hi, Darin and Scott. Would you please take a look? Thanks!
6 years, 2 months ago (2014-10-02 00:04:15 UTC) #2
sky
LGTM
6 years, 2 months ago (2014-10-02 17:14:20 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/615063003/40001
6 years, 2 months ago (2014-10-02 19:28:11 UTC) #5
darin (slow to review)
https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl File mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl (right): https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl#newcode25 mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl:25: {{struct.name}}Ptr Clone() const; Doesn't this potentially conflict with a ...
6 years, 2 months ago (2014-10-02 20:14:14 UTC) #6
yzshen1
On 2014/10/02 20:14:14, darin wrote: > https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl > File > mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl > (right): > > ...
6 years, 2 months ago (2014-10-02 20:20:29 UTC) #8
yzshen1
(I have stopped the commit queue. Sorry I thought you probably wouldn't review this CL. ...
6 years, 2 months ago (2014-10-02 20:21:12 UTC) #9
darin (slow to review)
On 2014/10/02 20:21:12, yzshen1 wrote: > (I have stopped the commit queue. Sorry I thought ...
6 years, 2 months ago (2014-10-02 20:25:30 UTC) #10
yzshen1
On 2014/10/02 20:25:30, darin wrote: > On 2014/10/02 20:21:12, yzshen1 wrote: > > (I have ...
6 years, 2 months ago (2014-10-02 20:29:30 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/615063003/40001
6 years, 2 months ago (2014-10-02 20:31:02 UTC) #13
commit-bot: I haz the power
Committed patchset #3 (id:40001) as 05a56fffe533e9466a2073b0eaf100f87486c3b1
6 years, 2 months ago (2014-10-02 20:32:21 UTC) #14
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/a3f0198fc0a56f1a3c2ffb8384ecf9c40f649b87 Cr-Commit-Position: refs/heads/master@{#297890}
6 years, 2 months ago (2014-10-02 20:33:04 UTC) #15
Aaron Boodman
https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl File mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl (right): https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl#newcode25 mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl:25: {{struct.name}}Ptr Clone() const; On 2014/10/02 20:14:13, darin wrote: > ...
6 years, 2 months ago (2014-10-10 20:27:47 UTC) #17
yzshen1
https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl File mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl (right): https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl#newcode25 mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl:25: {{struct.name}}Ptr Clone() const; This question has been resolved. Clone() ...
6 years, 2 months ago (2014-10-10 20:30:22 UTC) #18
Aaron Boodman
https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl File mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl (right): https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl#newcode25 mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl:25: {{struct.name}}Ptr Clone() const; per our IM chat, this isn't ...
6 years, 2 months ago (2014-10-10 21:04:15 UTC) #19
darin (slow to review)
https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl File mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl (right): https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl#newcode25 mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl:25: {{struct.name}}Ptr Clone() const; On 2014/10/10 21:04:15, Aaron Boodman wrote: ...
6 years, 2 months ago (2014-10-12 17:57:30 UTC) #20
Aaron Boodman
On 2014/10/12 17:57:30, darin wrote: > https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl > File > mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl > (right): > > ...
6 years, 2 months ago (2014-10-12 18:01:59 UTC) #21
Aaron Boodman
6 years, 2 months ago (2014-10-12 18:03:19 UTC) #22
Message was sent while issue was closed.
On 2014/10/12 18:01:59, Aaron Boodman wrote:
> On 2014/10/12 17:57:30, darin wrote:
> >
>
https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindin...
> > File
> >
>
mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
> > (right):
> > 
> >
>
https://codereview.chromium.org/615063003/diff/40001/mojo/public/tools/bindin...
> >
>
mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl:25:
> > {{struct.name}}Ptr Clone() const;
> > On 2014/10/10 21:04:15, Aaron Boodman wrote:
> > > per our IM chat, this isn't resolved -- it is possible for user-defined
> fields
> > > to conflict with these methods.
> > > 
> > > Users can't use the field name 'Clone'. In fact, this problem already
> existed
> > --
> > > Users can't use the field names 'New' or 'From' either.
> > > 
> > > The way I see it we can either just declare that mojom fields are always
> > > unix_hacker_style, and so names starting with a capital are an open
> namespace
> > > for bindings systems to use. Or else we can move these bindings-related
> > methods
> > > to some other traits class.
> > > 
> > > Darin, do you have an opinion?
> > 
> > Right, good catch. I'd be OK dictating that field names must start with a
> > lowercase letter. That matches every convention I know of, from
> > unix_hacker_style to camelCase, so it shouldn't make anyone sad.
> 
> ok.

In that case, it would be good to enforce this in the SDK or, even better, at
runtime -- because otherwise there will eventually be an accidental collision.

> > Moving things to a traits class would work fine for Clone, but not for New
and
> > From.
> 
> OOC, why would it not work for New and From. They are static methods
already...

Powered by Google App Engine
This is Rietveld 408576698