1 $$ This is a pump file for generating file templates. Pump is a python
2 $$ script that is part of the Google Test suite of utilities. Description
5 $$ http://code.google.com/p/googletest/wiki/PumpManual
10 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
11 // Use of this source code is governed by a BSD-style license that can be
12 // found in the LICENSE file.
18 #include "base/bind_internal.h"
19 #include "base/callback_internal.h"
21 // See base/callback.h for how to use these functions.
23 // IMPLEMENTATION NOTE
24 // Though Bind()'s result is meant to be stored in a Callback<> type, it
25 // cannot actually return the exact type without requiring a large amount
26 // of extra template specializations. The problem is that in order to
27 // discern the correct specialization of Callback<>, Bind would need to
28 // unwrap the function signature to determine the signature's arity, and
29 // whether or not it is a method.
31 // Each unique combination of (arity, function_type, num_prebound) where
32 // function_type is one of {function, method, const_method} would require
33 // one specialization. We eventually have to do a similar number of
34 // specializations anyways in the implementation (see the FunctionTraitsN,
35 // classes). However, it is avoidable in Bind if we return the result
36 // via an indirection like we do below.
40 $range BOUND 0..MAX_ARITY
42 $range BOUND_ARG 1..BOUND
46 template <typename Sig>
47 internal::InvokerStorageHolder<internal::InvokerStorage0<Sig> >
49 return internal::MakeInvokerStorageHolder(
50 new internal::InvokerStorage0<Sig>(f));
55 template <typename Sig, $for BOUND_ARG , [[typename P$(BOUND_ARG)]]>
56 internal::InvokerStorageHolder<internal::InvokerStorage$(BOUND)<Sig,
57 $for BOUND_ARG , [[P$(BOUND_ARG)]]> >
58 Bind(Sig f, $for BOUND_ARG , [[const P$(BOUND_ARG)& p$(BOUND_ARG)]]) {
59 return internal::MakeInvokerStorageHolder(
60 new internal::InvokerStorage$(BOUND)<Sig, [[]]
61 $for BOUND_ARG , [[P$(BOUND_ARG)]]>(
62 f, $for BOUND_ARG , [[p$(BOUND_ARG)]]));
71 #endif // BASE_BIND_H_