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 $$ See comment for MAX_ARITY in base/bind.h.pump. | 8 $$ See comment for MAX_ARITY in base/bind.h.pump. |
9 $var MAX_ARITY = 7 | 9 $var MAX_ARITY = 7 |
10 $range ARITY 0..MAX_ARITY | 10 $range ARITY 0..MAX_ARITY |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // Handle the differing syntaxes needed for WeakPtr<> support
, | 73 // Handle the differing syntaxes needed for WeakPtr<> support
, |
74 // and for ignoring return values. This is separate from | 74 // and for ignoring return values. This is separate from |
75 // Invoker to avoid creating multiple version of Invoker<> | 75 // Invoker to avoid creating multiple version of Invoker<> |
76 // which grows at O(n^2) with the arity. | 76 // which grows at O(n^2) with the arity. |
77 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. | 77 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. |
78 // There are |(ARITY^2 + ARITY)/2| Invoketypes. | 78 // There are |(ARITY^2 + ARITY)/2| Invoketypes. |
79 // BindState<> -- Stores the curried parameters, and is the main entry point | 79 // BindState<> -- Stores the curried parameters, and is the main entry point |
80 // into the Bind() system, doing most of the type resolution. | 80 // into the Bind() system, doing most of the type resolution. |
81 // There are ARITY BindState types. | 81 // There are ARITY BindState types. |
82 | 82 |
| 83 // HasNonConstReferenceParam selects true_type when any of the parameters in |
| 84 // |Sig| is a non-const reference. |
| 85 // Implementation note: This non-specialized case handles zero-arity case only. |
| 86 // Non-zero-arity cases should be handled by the specialization below. |
| 87 template <typename Sig> |
| 88 struct HasNonConstReferenceParam : false_type {}; |
| 89 |
| 90 // Implementation note: Select true_type if the first parameter is a non-const |
| 91 // reference. Otherwise, skip the first parameter and check rest of parameters |
| 92 // recursively. |
| 93 template <typename R, typename T, typename... Args> |
| 94 struct HasNonConstReferenceParam<R(T, Args...)> |
| 95 : SelectType<is_non_const_reference<T>::value, |
| 96 true_type, |
| 97 HasNonConstReferenceParam<R(Args...)>>::Type {}; |
| 98 |
| 99 // HasRefCountedTypeAsRawPtr selects true_type when any of the |Args| is a raw |
| 100 // pointer to a RefCounted type. |
| 101 // Implementation note: This non-specialized case handles zero-arity case only. |
| 102 // Non-zero-arity cases should be handled by the specialization below. |
| 103 template <typename... Args> |
| 104 struct HasRefCountedTypeAsRawPtr : false_type {}; |
| 105 |
| 106 // Implementation note: Select true_type if the first parameter is a raw pointer |
| 107 // to a RefCounted type. Otherwise, skip the first parameter and check rest of |
| 108 // parameters recursively. |
| 109 template <typename T, typename... Args> |
| 110 struct HasRefCountedTypeAsRawPtr<T, Args...> |
| 111 : SelectType<NeedsScopedRefptrButGetsRawPtr<T>::value, |
| 112 true_type, |
| 113 HasRefCountedTypeAsRawPtr<Args...>>::Type {}; |
| 114 |
| 115 // BindsArrayToFirstArg selects true_type when |is_method| is true and the first |
| 116 // item of |Args| is an array type. |
| 117 // Implementation note: This non-specialized case handles !is_method case and |
| 118 // zero-arity case only. Other cases should be handled by the specialization |
| 119 // below. |
| 120 template <bool is_method, typename... Args> |
| 121 struct BindsArrayToFirstArg : false_type {}; |
| 122 |
| 123 template <typename T, typename... Args> |
| 124 struct BindsArrayToFirstArg<true, T, Args...> : is_array<T> {}; |
| 125 |
| 126 // HasRefCountedParamAsRawPtr is the same to HasRefCountedTypeAsRawPtr except |
| 127 // when |is_method| is true HasRefCountedParamAsRawPtr skips the first argument. |
| 128 // Implementation note: This non-specialized case handles !is_method case and |
| 129 // zero-arity case only. Other cases should be handled by the specialization |
| 130 // below. |
| 131 template <bool is_method, typename... Args> |
| 132 struct HasRefCountedParamAsRawPtr : HasRefCountedTypeAsRawPtr<Args...> {}; |
| 133 |
| 134 template <typename T, typename... Args> |
| 135 struct HasRefCountedParamAsRawPtr<true, T, Args...> |
| 136 : HasRefCountedTypeAsRawPtr<Args...> {}; |
| 137 |
83 // RunnableAdapter<> | 138 // RunnableAdapter<> |
84 // | 139 // |
85 // The RunnableAdapter<> templates provide a uniform interface for invoking | 140 // The RunnableAdapter<> templates provide a uniform interface for invoking |
86 // a function pointer, method pointer, or const method pointer. The adapter | 141 // a function pointer, method pointer, or const method pointer. The adapter |
87 // exposes a Run() method with an appropriate signature. Using this wrapper | 142 // exposes a Run() method with an appropriate signature. Using this wrapper |
88 // allows for writing code that supports all three pointer types without | 143 // allows for writing code that supports all three pointer types without |
89 // undue repetition. Without it, a lot of code would need to be repeated 3 | 144 // undue repetition. Without it, a lot of code would need to be repeated 3 |
90 // times. | 145 // times. |
91 // | 146 // |
92 // For method pointers and const method pointers the first argument to Run() | 147 // For method pointers and const method pointers the first argument to Run() |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 505 |
451 ]] | 506 ]] |
452 }; | 507 }; |
453 | 508 |
454 ]] $$ for ARITY | 509 ]] $$ for ARITY |
455 | 510 |
456 } // namespace internal | 511 } // namespace internal |
457 } // namespace base | 512 } // namespace base |
458 | 513 |
459 #endif // BASE_BIND_INTERNAL_H_ | 514 #endif // BASE_BIND_INTERNAL_H_ |
OLD | NEW |