summaryrefslogtreecommitdiffstats
path: root/base/bind_internal.h.pump
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-09 01:29:38 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-09 01:29:38 +0000
commit63a822490bb1ac98d4fb8a1e76187ecd3ae5c118 (patch)
tree1cb16380bb4fa9fd56471b31102ad06dc7b16236 /base/bind_internal.h.pump
parentf749f9cee070a7a15107fa9cce6b89ad1d969bcf (diff)
downloadchromium_src-63a822490bb1ac98d4fb8a1e76187ecd3ae5c118.zip
chromium_src-63a822490bb1ac98d4fb8a1e76187ecd3ae5c118.tar.gz
chromium_src-63a822490bb1ac98d4fb8a1e76187ecd3ae5c118.tar.bz2
Add Pass(), which implements move semantics, to scoped_ptr, scoped_array, and scoped_ptr_malloc.
This modification to the scopers implements the "moveable but not copyable" semantics that were introduced in C++11's unique_ptr<>. With this, is now possible to use scopers as an argument type or a return type. This signifies, in the type system, transfer of ownership into a function or out of a function respectively. Calling, or returning such a function MUST use the temporary resulting from the scoper's Pass() function. You CANNOT just pass the scoper by copy as there is still no copy constructor or assignment operator; trying to do so will yield a compilation error. This distinction makes it possible to avoid the implicit ownership transfer issues of auto_ptr, but still allow us to have compiler enforced ownership transfer. Also adds a Passed() helper that allows using a scoper with Bind(). BUG=96118 TEST=new unittests Review URL: http://codereview.chromium.org/8774032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/bind_internal.h.pump')
-rw-r--r--base/bind_internal.h.pump15
1 files changed, 7 insertions, 8 deletions
diff --git a/base/bind_internal.h.pump b/base/bind_internal.h.pump
index 53dcbd3..7fd63d8 100644
--- a/base/bind_internal.h.pump
+++ b/base/bind_internal.h.pump
@@ -82,7 +82,6 @@ namespace internal {
// into the Bind() system, doing most of the type resolution.
// There are ARITY BindState types.
-
// RunnableAdapter<>
//
// The RunnableAdapter<> templates provide a uniform interface for invoking
@@ -121,7 +120,7 @@ class RunnableAdapter<R(*)($for ARG , [[A$(ARG)]])> {
}
R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
- return function_($for ARG , [[a$(ARG)]]);
+ return function_($for ARG , [[CallbackForward(a$(ARG))]]);
}
private:
@@ -143,7 +142,7 @@ $if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]);
R Run(T* object[[]]
$if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
- return (object->*method_)($for ARG , [[a$(ARG)]]);
+ return (object->*method_)($for ARG , [[CallbackForward(a$(ARG))]]);
}
private:
@@ -165,7 +164,7 @@ $if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]);
R Run(const T* object[[]]
$if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
- return (object->*method_)($for ARG , [[a$(ARG)]]);
+ return (object->*method_)($for ARG , [[CallbackForward(a$(ARG))]]);
}
private:
@@ -291,7 +290,7 @@ struct InvokeHelper<false, ReturnType, Runnable,
void($for ARG , [[A$(ARG)]])> {
static ReturnType MakeItSo(Runnable runnable[[]]
$if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) {
- return runnable.Run($for ARG , [[a$(ARG)]]);
+ return runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]);
}
};
@@ -301,7 +300,7 @@ struct InvokeHelper<false, void, Runnable,
void($for ARG , [[A$(ARG)]])> {
static void MakeItSo(Runnable runnable[[]]
$if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) {
- runnable.Run($for ARG , [[a$(ARG)]]);
+ runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]);
}
};
@@ -316,7 +315,7 @@ $if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) {
return;
}
- runnable.Run($for ARG , [[a$(ARG)]]);
+ runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]);
}
};
@@ -404,7 +403,7 @@ typename CallbackParamTraits<X$(UNBOUND_ARG)>::ForwardType x$(UNBOUND_ARG)
]]
)>
::MakeItSo(storage->runnable_
-$if ARITY > 0[[, ]] $for ARG , [[x$(ARG)]]);
+$if ARITY > 0[[, ]] $for ARG , [[CallbackForward(x$(ARG))]]);
}
};