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

Issue 6718021: Callback support for unbound reference and array arguments. (Closed)

Created:
9 years, 9 months ago by awong
Modified:
9 years, 7 months ago
Reviewers:
akalin
CC:
chromium-reviews, Paweł Hajdan Jr., brettw-cc_chromium.org, James Su, willchan no longer on Chromium, darin (slow to review), brettw
Visibility:
Public.

Description

Callback support for unbound reference and array arguments. Because the callback object uses const An& for the type of the Run() function in argument forwarding, the code breaks for An=T& or An=T[]. This CL adds in code to modify the parameter type to remove duplicate references, and other fun. BUG=35223 TEST=new unittests Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=79239

Patch Set 1 #

Patch Set 2 : silly fix. #

Patch Set 3 : git try #

Patch Set 4 : Fix copies #

Patch Set 5 : Fix up unittests and asserts #

Patch Set 6 : Cleaned up. #

Total comments: 6

Patch Set 7 : comment fixes. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+648 lines, -524 lines) Patch
M base/bind_helpers.h View 1 2 3 4 2 chunks +5 lines, -38 lines 0 comments Download
M base/bind_internal.h View 1 2 3 4 5 88 chunks +378 lines, -417 lines 0 comments Download
M base/bind_internal.h.pump View 1 2 3 4 5 9 chunks +47 lines, -20 lines 0 comments Download
M base/bind_internal_win.h View 1 2 3 4 13 chunks +55 lines, -0 lines 0 comments Download
M base/bind_internal_win.h.pump View 1 2 3 4 5 2 chunks +20 lines, -0 lines 0 comments Download
M base/bind_unittest.cc View 1 2 3 4 5 3 chunks +36 lines, -2 lines 0 comments Download
M base/callback.h View 1 2 3 4 5 14 chunks +57 lines, -43 lines 0 comments Download
M base/callback.h.pump View 1 2 3 4 5 2 chunks +4 lines, -4 lines 0 comments Download
M base/callback_internal.h View 1 2 3 4 5 6 1 chunk +46 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
awong
Fred, your turn! James, I think this will fix your issue with the reference parameter.
9 years, 9 months ago (2011-03-22 05:09:27 UTC) #1
akalin
http://codereview.chromium.org/6718021/diff/4002/base/callback_internal.h File base/callback_internal.h (right): http://codereview.chromium.org/6718021/diff/4002/base/callback_internal.h#newcode83 base/callback_internal.h:83: // This is a typetraits object that's used to ...
9 years, 9 months ago (2011-03-24 00:40:19 UTC) #2
awong
http://codereview.chromium.org/6718021/diff/4002/base/callback_internal.h File base/callback_internal.h (right): http://codereview.chromium.org/6718021/diff/4002/base/callback_internal.h#newcode83 base/callback_internal.h:83: // This is a typetraits object that's used to ...
9 years, 9 months ago (2011-03-24 01:37:17 UTC) #3
akalin
LGTM http://codereview.chromium.org/6718021/diff/4002/base/callback_internal.h File base/callback_internal.h (right): http://codereview.chromium.org/6718021/diff/4002/base/callback_internal.h#newcode122 base/callback_internal.h:122: template <typename T> On 2011/03/24 01:37:17, awong wrote: ...
9 years, 9 months ago (2011-03-24 01:49:17 UTC) #4
awong
9 years, 9 months ago (2011-03-24 01:58:56 UTC) #5
Thanks for the review!

Submitting.

http://codereview.chromium.org/6718021/diff/4002/base/callback_internal.h
File base/callback_internal.h (right):

http://codereview.chromium.org/6718021/diff/4002/base/callback_internal.h#new...
base/callback_internal.h:122: template <typename T>
On 2011/03/24 01:49:18, akalin wrote:
> On 2011/03/24 01:37:17, awong wrote:
> > On 2011/03/24 00:40:19, akalin wrote:
> > > in this context, and in arguments, T[] means T*, right?
> > 
> > Yes. As far as I know.  See the comment above for why we adorn a "const."
> 
> It might be less confusing to have the template type as "T*", and/or add a
> comment reminding about the T*/T[] equivalence and when it applies.

Unforutnately, during the actual pattern match for the type of the template, T[]
is still actually T[] and distinct from T*.  It's just that it effectively
"promotes" to T* when you use it as a parameter.

This code is used to make the template system do the equivalent promotion.

Powered by Google App Engine
This is Rietveld 408576698