Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 $$ This is a pump file for generating file templates. Pump is a python | 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 | 2 $$ script that is part of the Google Test suite of utilities. Description |
| 3 $$ can be found here: | 3 $$ can be found here: |
| 4 $$ | 4 $$ |
| 5 $$ http://code.google.com/p/googletest/wiki/PumpManual | 5 $$ http://code.google.com/p/googletest/wiki/PumpManual |
| 6 $$ | 6 $$ |
| 7 | 7 |
| 8 $var MAX_ARITY = 6 | 8 $var MAX_ARITY = 6 |
| 9 | 9 |
| 10 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 11 // Use of this source code is governed by a BSD-style license that can be |
| 12 // found in the LICENSE file. | 12 // found in the LICENSE file. |
| 13 | 13 |
| 14 #ifndef BASE_BIND_INTERNAL_H_ | 14 #ifndef BASE_BIND_INTERNAL_H_ |
| 15 #define BASE_BIND_INTERNAL_H_ | 15 #define BASE_BIND_INTERNAL_H_ |
| 16 #pragma once | 16 #pragma once |
| 17 | 17 |
| 18 #include "build/build_config.h" | |
|
willchan no longer on Chromium
2011/02/25 21:52:09
You can sort this alphabetically, it'll still be a
| |
| 19 | |
| 18 #include "base/bind_helpers.h" | 20 #include "base/bind_helpers.h" |
| 19 #include "base/callback_internal.h" | 21 #include "base/callback_internal.h" |
| 20 #include "base/template_util.h" | 22 #include "base/template_util.h" |
| 21 | 23 |
| 24 #if defined(OS_WIN) | |
| 25 #include "base/bind_internal_win.h" | |
| 26 #endif | |
| 27 | |
| 22 namespace base { | 28 namespace base { |
| 23 namespace internal { | 29 namespace internal { |
| 24 | 30 |
| 25 // The method by which a function is invoked is determined by 3 different | 31 // The method by which a function is invoked is determined by 3 different |
| 26 // dimensions: | 32 // dimensions: |
| 27 // | 33 // |
| 28 // 1) The type of function (normal or method). | 34 // 1) The type of function (normal or method). |
| 29 // 2) The arity of the function. | 35 // 2) The arity of the function. |
| 30 // 3) The number of bound parameters. | 36 // 3) The number of bound parameters. |
| 31 // | 37 // |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 75 |
| 70 $range ARITY 0..MAX_ARITY | 76 $range ARITY 0..MAX_ARITY |
| 71 $for ARITY [[ | 77 $for ARITY [[ |
| 72 $range ARG 1..ARITY | 78 $range ARG 1..ARITY |
| 73 | 79 |
| 74 // Function: Arity $(ARITY). | 80 // Function: Arity $(ARITY). |
| 75 template <typename R[[]] | 81 template <typename R[[]] |
| 76 $if ARITY > 0[[, ]] $for ARG , [[typename X$(ARG)]]> | 82 $if ARITY > 0[[, ]] $for ARG , [[typename X$(ARG)]]> |
| 77 struct FunctionTraits<R(*)($for ARG , [[X$(ARG)]])> { | 83 struct FunctionTraits<R(*)($for ARG , [[X$(ARG)]])> { |
| 78 typedef R (*NormalizedSig)($for ARG , [[X$(ARG)]]); | 84 typedef R (*NormalizedSig)($for ARG , [[X$(ARG)]]); |
| 79 typedef base::false_type IsMethod; | 85 typedef false_type IsMethod; |
| 80 }; | 86 }; |
| 81 | 87 |
| 82 // Method: Arity $(ARITY). | 88 // Method: Arity $(ARITY). |
| 83 template <typename R, typename T[[]] | 89 template <typename R, typename T[[]] |
| 84 $if ARITY > 0[[, ]] $for ARG , [[typename X$(ARG)]]> | 90 $if ARITY > 0[[, ]] $for ARG , [[typename X$(ARG)]]> |
| 85 struct FunctionTraits<R(T::*)($for ARG , [[X$(ARG)]])> { | 91 struct FunctionTraits<R(T::*)($for ARG , [[X$(ARG)]])> { |
| 86 typedef R (T::*NormalizedSig)($for ARG , [[X$(ARG)]]); | 92 typedef R (T::*NormalizedSig)($for ARG , [[X$(ARG)]]); |
| 87 typedef base::true_type IsMethod; | 93 typedef true_type IsMethod; |
| 88 }; | 94 }; |
| 89 | 95 |
| 90 // Const Method: Arity $(ARITY). | 96 // Const Method: Arity $(ARITY). |
| 91 template <typename R, typename T[[]] | 97 template <typename R, typename T[[]] |
| 92 $if ARITY > 0[[, ]] $for ARG , [[typename X$(ARG)]]> | 98 $if ARITY > 0[[, ]] $for ARG , [[typename X$(ARG)]]> |
| 93 struct FunctionTraits<R(T::*)($for ARG , [[X$(ARG)]]) const> { | 99 struct FunctionTraits<R(T::*)($for ARG , [[X$(ARG)]]) const> { |
| 94 typedef R (T::*NormalizedSig)($for ARG , [[X$(ARG)]]); | 100 typedef R (T::*NormalizedSig)($for ARG , [[X$(ARG)]]); |
| 95 typedef base::true_type IsMethod; | 101 typedef true_type IsMethod; |
| 96 }; | 102 }; |
| 97 | 103 |
| 98 ]] $$for ARITY | 104 ]] $$for ARITY |
| 99 | 105 |
| 100 // InvokerN<> | 106 // InvokerN<> |
| 101 // | 107 // |
| 102 // The InvokerN templates contain a static DoInvoke() function that is the key | 108 // The InvokerN templates contain a static DoInvoke() function that is the key |
| 103 // to implementing type erasure in the Callback() classes. | 109 // to implementing type erasure in the Callback() classes. |
| 104 // | 110 // |
| 105 // DoInvoke() is a static function with a fixed signature that is independent | 111 // DoInvoke() is a static function with a fixed signature that is independent |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 | 278 |
| 273 ]] | 279 ]] |
| 274 }; | 280 }; |
| 275 | 281 |
| 276 ]] $$ for BOUND | 282 ]] $$ for BOUND |
| 277 | 283 |
| 278 } // namespace internal | 284 } // namespace internal |
| 279 } // namespace base | 285 } // namespace base |
| 280 | 286 |
| 281 #endif // BASE_BIND_INTERNAL_H_ | 287 #endif // BASE_BIND_INTERNAL_H_ |
| OLD | NEW |