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

Issue 828373008: Allow constructing {Interface,Struct}Ptr from nullptr (Closed)

Created:
5 years, 11 months ago by jamesr
Modified:
5 years, 11 months ago
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:
git@github.com:domokit/mojo.git@master
Target Ref:
refs/heads/master
Project:
mojo
Visibility:
Public.

Description

Allow constructing {Interface,Struct}Ptr from nullptr This allows spelling a null InterfacePtr or StructPtr parameter 'nullptr' instead of namespace::FooPtr(). To do so, this uses C++11 rvalue reference semantics for move support and adds constructor and assignment operator overloads that take the type decltype(nullptr). We still use a macro for move-only types to hide the copy and assignment operators, add Pass(), and add the misleading named type tag MoveOnlyForCPP03 for compatibility with Chromium's base/callback (and anything else that may want to use it). R=darin@chromium.org Committed: https://chromium.googlesource.com/external/mojo/+/e4389610d2f6e842ef79786c3100da363fd1b0a3

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+81 lines, -77 lines) Patch
M mojo/public/cpp/bindings/array.h View 2 chunks +4 lines, -4 lines 0 comments Download
M mojo/public/cpp/bindings/interface_ptr.h View 1 chunk +11 lines, -5 lines 0 comments Download
M mojo/public/cpp/bindings/interface_request.h View 1 chunk +4 lines, -4 lines 0 comments Download
M mojo/public/cpp/bindings/lib/filter_chain.h View 1 chunk +3 lines, -5 lines 0 comments Download
M mojo/public/cpp/bindings/lib/filter_chain.cc View 1 chunk +6 lines, -6 lines 0 comments Download
M mojo/public/cpp/bindings/map.h View 2 chunks +5 lines, -4 lines 0 comments Download
M mojo/public/cpp/bindings/struct_ptr.h View 2 chunks +15 lines, -8 lines 2 comments Download
M mojo/public/cpp/bindings/tests/container_test_util.h View 1 chunk +3 lines, -3 lines 0 comments Download
M mojo/public/cpp/bindings/tests/container_test_util.cc View 1 chunk +4 lines, -4 lines 0 comments Download
M mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc View 1 chunk +2 lines, -6 lines 1 comment Download
M mojo/public/cpp/system/handle.h View 2 chunks +5 lines, -5 lines 0 comments Download
M mojo/public/cpp/system/macros.h View 1 chunk +12 lines, -16 lines 0 comments Download
M mojo/public/cpp/system/tests/macros_unittest.cc View 2 chunks +7 lines, -7 lines 0 comments Download

Messages

Total messages: 8 (1 generated)
jamesr
https://codereview.chromium.org/828373008/diff/1/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc File mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc (right): https://codereview.chromium.org/828373008/diff/1/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc#newcode330 mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc:330: proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr); this is the example use. The ...
5 years, 11 months ago (2015-01-13 23:27:05 UTC) #1
jamesr
We could also add overloads for constructing scoped handle types from 'nullptr' but that's semantically ...
5 years, 11 months ago (2015-01-13 23:27:31 UTC) #2
jamesr
R += trung
5 years, 11 months ago (2015-01-14 18:33:57 UTC) #4
darin (slow to review)
Wow, that's really nice! https://codereview.chromium.org/828373008/diff/1/mojo/public/cpp/bindings/struct_ptr.h File mojo/public/cpp/bindings/struct_ptr.h (right): https://codereview.chromium.org/828373008/diff/1/mojo/public/cpp/bindings/struct_ptr.h#newcode117 mojo/public/cpp/bindings/struct_ptr.h:117: don't you need the nullptr ...
5 years, 11 months ago (2015-01-14 18:38:07 UTC) #5
darin (slow to review)
LGTM
5 years, 11 months ago (2015-01-14 18:38:12 UTC) #6
jamesr
(I stole most of this from Dana's work in base/, fyi) https://codereview.chromium.org/828373008/diff/1/mojo/public/cpp/bindings/struct_ptr.h File mojo/public/cpp/bindings/struct_ptr.h (right): ...
5 years, 11 months ago (2015-01-14 18:39:30 UTC) #7
jamesr
5 years, 11 months ago (2015-01-14 19:15:19 UTC) #8
Message was sent while issue was closed.
Committed patchset #1 (id:1) manually as
e4389610d2f6e842ef79786c3100da363fd1b0a3 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698