| OLD | NEW |
| 1 // This file was GENERATED by command: | 1 // This file was GENERATED by command: |
| 2 // pump.py bind_internal.h.pump | 2 // pump.py bind_internal.h.pump |
| 3 // DO NOT EDIT BY HAND!!! | 3 // DO NOT EDIT BY HAND!!! |
| 4 | 4 |
| 5 | 5 |
| 6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 7 // Use of this source code is governed by a BSD-style license that can be | 7 // Use of this source code is governed by a BSD-style license that can be |
| 8 // found in the LICENSE file. | 8 // found in the LICENSE file. |
| 9 | 9 |
| 10 #ifndef BASE_BIND_INTERNAL_H_ | 10 #ifndef BASE_BIND_INTERNAL_H_ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // (Bound)ArgsType -- A function type that is being (ab)used to store the | 44 // (Bound)ArgsType -- A function type that is being (ab)used to store the |
| 45 // types of set of arguments. The "return" type is always | 45 // types of set of arguments. The "return" type is always |
| 46 // void here. We use this hack so that we do not need | 46 // void here. We use this hack so that we do not need |
| 47 // a new type name for each arity of type. (eg., | 47 // a new type name for each arity of type. (eg., |
| 48 // BindState1, BindState2). This makes forward | 48 // BindState1, BindState2). This makes forward |
| 49 // declarations and friending much much easier. | 49 // declarations and friending much much easier. |
| 50 // | 50 // |
| 51 // Types: | 51 // Types: |
| 52 // RunnableAdapter<> -- Wraps the various "function" pointer types into an | 52 // RunnableAdapter<> -- Wraps the various "function" pointer types into an |
| 53 // object that adheres to the Runnable interface. | 53 // object that adheres to the Runnable interface. |
| 54 // There are |3*ARITY| RunnableAdapter types. | |
| 55 // FunctionTraits<> -- Type traits that unwrap a function signature into a | 54 // FunctionTraits<> -- Type traits that unwrap a function signature into a |
| 56 // a set of easier to use typedefs. Used mainly for | 55 // a set of easier to use typedefs. Used mainly for |
| 57 // compile time asserts. | 56 // compile time asserts. |
| 58 // There are |ARITY| FunctionTraits types. | 57 // There are |ARITY| FunctionTraits types. |
| 59 // ForceVoidReturn<> -- Helper class for translating function signatures to | 58 // ForceVoidReturn<> -- Helper class for translating function signatures to |
| 60 // equivalent forms with a "void" return type. | 59 // equivalent forms with a "void" return type. |
| 61 // There are |ARITY| ForceVoidReturn types. | |
| 62 // FunctorTraits<> -- Type traits used determine the correct RunType and | 60 // FunctorTraits<> -- Type traits used determine the correct RunType and |
| 63 // RunnableType for a Functor. This is where function | 61 // RunnableType for a Functor. This is where function |
| 64 // signature adapters are applied. | 62 // signature adapters are applied. |
| 65 // There are |ARITY| ForceVoidReturn types. | |
| 66 // MakeRunnable<> -- Takes a Functor and returns an object in the Runnable | 63 // MakeRunnable<> -- Takes a Functor and returns an object in the Runnable |
| 67 // type class that represents the underlying Functor. | 64 // type class that represents the underlying Functor. |
| 68 // There are |O(1)| MakeRunnable types. | 65 // There are |O(1)| MakeRunnable types. |
| 69 // InvokeHelper<> -- Take a Runnable + arguments and actully invokes it. | 66 // InvokeHelper<> -- Take a Runnable + arguments and actully invokes it. |
| 70 // Handle the differing syntaxes needed for WeakPtr<> support, | 67 // Handle the differing syntaxes needed for WeakPtr<> support, |
| 71 // and for ignoring return values. This is separate from | 68 // and for ignoring return values. This is separate from |
| 72 // Invoker to avoid creating multiple version of Invoker<> | 69 // Invoker to avoid creating multiple version of Invoker<> |
| 73 // which grows at O(n^2) with the arity. | 70 // which grows at O(n^2) with the arity. |
| 74 // There are |k*ARITY| InvokeHelper types. | |
| 75 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. | 71 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. |
| 76 // There are |(ARITY^2 + ARITY)/2| Invoketypes. | 72 // There are |(ARITY^2 + ARITY)/2| Invoketypes. |
| 77 // BindState<> -- Stores the curried parameters, and is the main entry point | 73 // BindState<> -- Stores the curried parameters, and is the main entry point |
| 78 // into the Bind() system, doing most of the type resolution. | 74 // into the Bind() system, doing most of the type resolution. |
| 79 // There are ARITY BindState types. | 75 // There are ARITY BindState types. |
| 80 | 76 |
| 81 // RunnableAdapter<> | 77 // RunnableAdapter<> |
| 82 // | 78 // |
| 83 // The RunnableAdapter<> templates provide a uniform interface for invoking | 79 // The RunnableAdapter<> templates provide a uniform interface for invoking |
| 84 // a function pointer, method pointer, or const method pointer. The adapter | 80 // a function pointer, method pointer, or const method pointer. The adapter |
| 85 // exposes a Run() method with an appropriate signature. Using this wrapper | 81 // exposes a Run() method with an appropriate signature. Using this wrapper |
| 86 // allows for writing code that supports all three pointer types without | 82 // allows for writing code that supports all three pointer types without |
| 87 // undue repetition. Without it, a lot of code would need to be repeated 3 | 83 // undue repetition. Without it, a lot of code would need to be repeated 3 |
| 88 // times. | 84 // times. |
| 89 // | 85 // |
| 90 // For method pointers and const method pointers the first argument to Run() | 86 // For method pointers and const method pointers the first argument to Run() |
| 91 // is considered to be the received of the method. This is similar to STL's | 87 // is considered to be the received of the method. This is similar to STL's |
| 92 // mem_fun(). | 88 // mem_fun(). |
| 93 // | 89 // |
| 94 // This class also exposes a RunType typedef that is the function type of the | 90 // This class also exposes a RunType typedef that is the function type of the |
| 95 // Run() function. | 91 // Run() function. |
| 96 // | 92 // |
| 97 // If and only if the wrapper contains a method or const method pointer, an | 93 // If and only if the wrapper contains a method or const method pointer, an |
| 98 // IsMethod typedef is exposed. The existence of this typedef (NOT the value) | 94 // IsMethod typedef is exposed. The existence of this typedef (NOT the value) |
| 99 // marks that the wrapper should be considered a method wrapper. | 95 // marks that the wrapper should be considered a method wrapper. |
| 100 | 96 |
| 101 template <typename Functor> | 97 template <typename Functor> |
| 102 class RunnableAdapter; | 98 class RunnableAdapter; |
| 103 | 99 |
| 104 // Function: Arity 0. | 100 // Function. |
| 105 template <typename R> | 101 template <typename R, typename... Args> |
| 106 class RunnableAdapter<R(*)()> { | 102 class RunnableAdapter<R(*)(Args...)> { |
| 107 public: | 103 public: |
| 108 typedef R (RunType)(); | 104 typedef R (RunType)(Args...); |
| 109 | 105 |
| 110 explicit RunnableAdapter(R(*function)()) | 106 explicit RunnableAdapter(R(*function)(Args...)) |
| 111 : function_(function) { | 107 : function_(function) { |
| 112 } | 108 } |
| 113 | 109 |
| 114 R Run() { | 110 R Run(typename CallbackParamTraits<Args>::ForwardType... args) { |
| 115 return function_(); | 111 return function_(CallbackForward(args)...); |
| 116 } | 112 } |
| 117 | 113 |
| 118 private: | 114 private: |
| 119 R (*function_)(); | 115 R (*function_)(Args...); |
| 120 }; | 116 }; |
| 121 | 117 |
| 122 // Method: Arity 0. | 118 // Method. |
| 123 template <typename R, typename T> | 119 template <typename R, typename T, typename... Args> |
| 124 class RunnableAdapter<R(T::*)()> { | 120 class RunnableAdapter<R(T::*)(Args...)> { |
| 125 public: | 121 public: |
| 126 typedef R (RunType)(T*); | 122 typedef R (RunType)(T*, Args...); |
| 127 typedef true_type IsMethod; | 123 typedef true_type IsMethod; |
| 128 | 124 |
| 129 explicit RunnableAdapter(R(T::*method)()) | 125 explicit RunnableAdapter(R(T::*method)(Args...)) |
| 130 : method_(method) { | 126 : method_(method) { |
| 131 } | 127 } |
| 132 | 128 |
| 133 R Run(T* object) { | 129 R Run(T* object, typename CallbackParamTraits<Args>::ForwardType... args) { |
| 134 return (object->*method_)(); | 130 return (object->*method_)(CallbackForward(args)...); |
| 135 } | 131 } |
| 136 | 132 |
| 137 private: | 133 private: |
| 138 R (T::*method_)(); | 134 R (T::*method_)(Args...); |
| 139 }; | 135 }; |
| 140 | 136 |
| 141 // Const Method: Arity 0. | 137 // Const Method. |
| 142 template <typename R, typename T> | 138 template <typename R, typename T, typename... Args> |
| 143 class RunnableAdapter<R(T::*)() const> { | 139 class RunnableAdapter<R(T::*)(Args...) const> { |
| 144 public: | 140 public: |
| 145 typedef R (RunType)(const T*); | 141 typedef R (RunType)(const T*, Args...); |
| 146 typedef true_type IsMethod; | 142 typedef true_type IsMethod; |
| 147 | 143 |
| 148 explicit RunnableAdapter(R(T::*method)() const) | 144 explicit RunnableAdapter(R(T::*method)(Args...) const) |
| 149 : method_(method) { | 145 : method_(method) { |
| 150 } | 146 } |
| 151 | 147 |
| 152 R Run(const T* object) { | 148 R Run(const T* object, |
| 153 return (object->*method_)(); | 149 typename CallbackParamTraits<Args>::ForwardType... args) { |
| 150 return (object->*method_)(CallbackForward(args)...); |
| 154 } | 151 } |
| 155 | 152 |
| 156 private: | 153 private: |
| 157 R (T::*method_)() const; | 154 R (T::*method_)(Args...) const; |
| 158 }; | 155 }; |
| 159 | 156 |
| 160 // Function: Arity 1. | 157 // TODO(tzik): Remove FunctionTraits after we finish removing bind.pump. |
| 161 template <typename R, typename A1> | |
| 162 class RunnableAdapter<R(*)(A1)> { | |
| 163 public: | |
| 164 typedef R (RunType)(A1); | |
| 165 | |
| 166 explicit RunnableAdapter(R(*function)(A1)) | |
| 167 : function_(function) { | |
| 168 } | |
| 169 | |
| 170 R Run(typename CallbackParamTraits<A1>::ForwardType a1) { | |
| 171 return function_(CallbackForward(a1)); | |
| 172 } | |
| 173 | |
| 174 private: | |
| 175 R (*function_)(A1); | |
| 176 }; | |
| 177 | |
| 178 // Method: Arity 1. | |
| 179 template <typename R, typename T, typename A1> | |
| 180 class RunnableAdapter<R(T::*)(A1)> { | |
| 181 public: | |
| 182 typedef R (RunType)(T*, A1); | |
| 183 typedef true_type IsMethod; | |
| 184 | |
| 185 explicit RunnableAdapter(R(T::*method)(A1)) | |
| 186 : method_(method) { | |
| 187 } | |
| 188 | |
| 189 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1) { | |
| 190 return (object->*method_)(CallbackForward(a1)); | |
| 191 } | |
| 192 | |
| 193 private: | |
| 194 R (T::*method_)(A1); | |
| 195 }; | |
| 196 | |
| 197 // Const Method: Arity 1. | |
| 198 template <typename R, typename T, typename A1> | |
| 199 class RunnableAdapter<R(T::*)(A1) const> { | |
| 200 public: | |
| 201 typedef R (RunType)(const T*, A1); | |
| 202 typedef true_type IsMethod; | |
| 203 | |
| 204 explicit RunnableAdapter(R(T::*method)(A1) const) | |
| 205 : method_(method) { | |
| 206 } | |
| 207 | |
| 208 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1) { | |
| 209 return (object->*method_)(CallbackForward(a1)); | |
| 210 } | |
| 211 | |
| 212 private: | |
| 213 R (T::*method_)(A1) const; | |
| 214 }; | |
| 215 | |
| 216 // Function: Arity 2. | |
| 217 template <typename R, typename A1, typename A2> | |
| 218 class RunnableAdapter<R(*)(A1, A2)> { | |
| 219 public: | |
| 220 typedef R (RunType)(A1, A2); | |
| 221 | |
| 222 explicit RunnableAdapter(R(*function)(A1, A2)) | |
| 223 : function_(function) { | |
| 224 } | |
| 225 | |
| 226 R Run(typename CallbackParamTraits<A1>::ForwardType a1, | |
| 227 typename CallbackParamTraits<A2>::ForwardType a2) { | |
| 228 return function_(CallbackForward(a1), CallbackForward(a2)); | |
| 229 } | |
| 230 | |
| 231 private: | |
| 232 R (*function_)(A1, A2); | |
| 233 }; | |
| 234 | |
| 235 // Method: Arity 2. | |
| 236 template <typename R, typename T, typename A1, typename A2> | |
| 237 class RunnableAdapter<R(T::*)(A1, A2)> { | |
| 238 public: | |
| 239 typedef R (RunType)(T*, A1, A2); | |
| 240 typedef true_type IsMethod; | |
| 241 | |
| 242 explicit RunnableAdapter(R(T::*method)(A1, A2)) | |
| 243 : method_(method) { | |
| 244 } | |
| 245 | |
| 246 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 247 typename CallbackParamTraits<A2>::ForwardType a2) { | |
| 248 return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); | |
| 249 } | |
| 250 | |
| 251 private: | |
| 252 R (T::*method_)(A1, A2); | |
| 253 }; | |
| 254 | |
| 255 // Const Method: Arity 2. | |
| 256 template <typename R, typename T, typename A1, typename A2> | |
| 257 class RunnableAdapter<R(T::*)(A1, A2) const> { | |
| 258 public: | |
| 259 typedef R (RunType)(const T*, A1, A2); | |
| 260 typedef true_type IsMethod; | |
| 261 | |
| 262 explicit RunnableAdapter(R(T::*method)(A1, A2) const) | |
| 263 : method_(method) { | |
| 264 } | |
| 265 | |
| 266 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 267 typename CallbackParamTraits<A2>::ForwardType a2) { | |
| 268 return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); | |
| 269 } | |
| 270 | |
| 271 private: | |
| 272 R (T::*method_)(A1, A2) const; | |
| 273 }; | |
| 274 | |
| 275 // Function: Arity 3. | |
| 276 template <typename R, typename A1, typename A2, typename A3> | |
| 277 class RunnableAdapter<R(*)(A1, A2, A3)> { | |
| 278 public: | |
| 279 typedef R (RunType)(A1, A2, A3); | |
| 280 | |
| 281 explicit RunnableAdapter(R(*function)(A1, A2, A3)) | |
| 282 : function_(function) { | |
| 283 } | |
| 284 | |
| 285 R Run(typename CallbackParamTraits<A1>::ForwardType a1, | |
| 286 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 287 typename CallbackParamTraits<A3>::ForwardType a3) { | |
| 288 return function_(CallbackForward(a1), CallbackForward(a2), | |
| 289 CallbackForward(a3)); | |
| 290 } | |
| 291 | |
| 292 private: | |
| 293 R (*function_)(A1, A2, A3); | |
| 294 }; | |
| 295 | |
| 296 // Method: Arity 3. | |
| 297 template <typename R, typename T, typename A1, typename A2, typename A3> | |
| 298 class RunnableAdapter<R(T::*)(A1, A2, A3)> { | |
| 299 public: | |
| 300 typedef R (RunType)(T*, A1, A2, A3); | |
| 301 typedef true_type IsMethod; | |
| 302 | |
| 303 explicit RunnableAdapter(R(T::*method)(A1, A2, A3)) | |
| 304 : method_(method) { | |
| 305 } | |
| 306 | |
| 307 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 308 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 309 typename CallbackParamTraits<A3>::ForwardType a3) { | |
| 310 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 311 CallbackForward(a3)); | |
| 312 } | |
| 313 | |
| 314 private: | |
| 315 R (T::*method_)(A1, A2, A3); | |
| 316 }; | |
| 317 | |
| 318 // Const Method: Arity 3. | |
| 319 template <typename R, typename T, typename A1, typename A2, typename A3> | |
| 320 class RunnableAdapter<R(T::*)(A1, A2, A3) const> { | |
| 321 public: | |
| 322 typedef R (RunType)(const T*, A1, A2, A3); | |
| 323 typedef true_type IsMethod; | |
| 324 | |
| 325 explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const) | |
| 326 : method_(method) { | |
| 327 } | |
| 328 | |
| 329 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 330 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 331 typename CallbackParamTraits<A3>::ForwardType a3) { | |
| 332 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 333 CallbackForward(a3)); | |
| 334 } | |
| 335 | |
| 336 private: | |
| 337 R (T::*method_)(A1, A2, A3) const; | |
| 338 }; | |
| 339 | |
| 340 // Function: Arity 4. | |
| 341 template <typename R, typename A1, typename A2, typename A3, typename A4> | |
| 342 class RunnableAdapter<R(*)(A1, A2, A3, A4)> { | |
| 343 public: | |
| 344 typedef R (RunType)(A1, A2, A3, A4); | |
| 345 | |
| 346 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4)) | |
| 347 : function_(function) { | |
| 348 } | |
| 349 | |
| 350 R Run(typename CallbackParamTraits<A1>::ForwardType a1, | |
| 351 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 352 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 353 typename CallbackParamTraits<A4>::ForwardType a4) { | |
| 354 return function_(CallbackForward(a1), CallbackForward(a2), | |
| 355 CallbackForward(a3), CallbackForward(a4)); | |
| 356 } | |
| 357 | |
| 358 private: | |
| 359 R (*function_)(A1, A2, A3, A4); | |
| 360 }; | |
| 361 | |
| 362 // Method: Arity 4. | |
| 363 template <typename R, typename T, typename A1, typename A2, typename A3, | |
| 364 typename A4> | |
| 365 class RunnableAdapter<R(T::*)(A1, A2, A3, A4)> { | |
| 366 public: | |
| 367 typedef R (RunType)(T*, A1, A2, A3, A4); | |
| 368 typedef true_type IsMethod; | |
| 369 | |
| 370 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4)) | |
| 371 : method_(method) { | |
| 372 } | |
| 373 | |
| 374 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 375 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 376 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 377 typename CallbackParamTraits<A4>::ForwardType a4) { | |
| 378 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 379 CallbackForward(a3), CallbackForward(a4)); | |
| 380 } | |
| 381 | |
| 382 private: | |
| 383 R (T::*method_)(A1, A2, A3, A4); | |
| 384 }; | |
| 385 | |
| 386 // Const Method: Arity 4. | |
| 387 template <typename R, typename T, typename A1, typename A2, typename A3, | |
| 388 typename A4> | |
| 389 class RunnableAdapter<R(T::*)(A1, A2, A3, A4) const> { | |
| 390 public: | |
| 391 typedef R (RunType)(const T*, A1, A2, A3, A4); | |
| 392 typedef true_type IsMethod; | |
| 393 | |
| 394 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const) | |
| 395 : method_(method) { | |
| 396 } | |
| 397 | |
| 398 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 399 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 400 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 401 typename CallbackParamTraits<A4>::ForwardType a4) { | |
| 402 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 403 CallbackForward(a3), CallbackForward(a4)); | |
| 404 } | |
| 405 | |
| 406 private: | |
| 407 R (T::*method_)(A1, A2, A3, A4) const; | |
| 408 }; | |
| 409 | |
| 410 // Function: Arity 5. | |
| 411 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| 412 typename A5> | |
| 413 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5)> { | |
| 414 public: | |
| 415 typedef R (RunType)(A1, A2, A3, A4, A5); | |
| 416 | |
| 417 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5)) | |
| 418 : function_(function) { | |
| 419 } | |
| 420 | |
| 421 R Run(typename CallbackParamTraits<A1>::ForwardType a1, | |
| 422 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 423 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 424 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 425 typename CallbackParamTraits<A5>::ForwardType a5) { | |
| 426 return function_(CallbackForward(a1), CallbackForward(a2), | |
| 427 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); | |
| 428 } | |
| 429 | |
| 430 private: | |
| 431 R (*function_)(A1, A2, A3, A4, A5); | |
| 432 }; | |
| 433 | |
| 434 // Method: Arity 5. | |
| 435 template <typename R, typename T, typename A1, typename A2, typename A3, | |
| 436 typename A4, typename A5> | |
| 437 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5)> { | |
| 438 public: | |
| 439 typedef R (RunType)(T*, A1, A2, A3, A4, A5); | |
| 440 typedef true_type IsMethod; | |
| 441 | |
| 442 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5)) | |
| 443 : method_(method) { | |
| 444 } | |
| 445 | |
| 446 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 447 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 448 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 449 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 450 typename CallbackParamTraits<A5>::ForwardType a5) { | |
| 451 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 452 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); | |
| 453 } | |
| 454 | |
| 455 private: | |
| 456 R (T::*method_)(A1, A2, A3, A4, A5); | |
| 457 }; | |
| 458 | |
| 459 // Const Method: Arity 5. | |
| 460 template <typename R, typename T, typename A1, typename A2, typename A3, | |
| 461 typename A4, typename A5> | |
| 462 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5) const> { | |
| 463 public: | |
| 464 typedef R (RunType)(const T*, A1, A2, A3, A4, A5); | |
| 465 typedef true_type IsMethod; | |
| 466 | |
| 467 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const) | |
| 468 : method_(method) { | |
| 469 } | |
| 470 | |
| 471 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 472 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 473 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 474 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 475 typename CallbackParamTraits<A5>::ForwardType a5) { | |
| 476 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 477 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); | |
| 478 } | |
| 479 | |
| 480 private: | |
| 481 R (T::*method_)(A1, A2, A3, A4, A5) const; | |
| 482 }; | |
| 483 | |
| 484 // Function: Arity 6. | |
| 485 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| 486 typename A5, typename A6> | |
| 487 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6)> { | |
| 488 public: | |
| 489 typedef R (RunType)(A1, A2, A3, A4, A5, A6); | |
| 490 | |
| 491 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6)) | |
| 492 : function_(function) { | |
| 493 } | |
| 494 | |
| 495 R Run(typename CallbackParamTraits<A1>::ForwardType a1, | |
| 496 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 497 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 498 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 499 typename CallbackParamTraits<A5>::ForwardType a5, | |
| 500 typename CallbackParamTraits<A6>::ForwardType a6) { | |
| 501 return function_(CallbackForward(a1), CallbackForward(a2), | |
| 502 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), | |
| 503 CallbackForward(a6)); | |
| 504 } | |
| 505 | |
| 506 private: | |
| 507 R (*function_)(A1, A2, A3, A4, A5, A6); | |
| 508 }; | |
| 509 | |
| 510 // Method: Arity 6. | |
| 511 template <typename R, typename T, typename A1, typename A2, typename A3, | |
| 512 typename A4, typename A5, typename A6> | |
| 513 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6)> { | |
| 514 public: | |
| 515 typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6); | |
| 516 typedef true_type IsMethod; | |
| 517 | |
| 518 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6)) | |
| 519 : method_(method) { | |
| 520 } | |
| 521 | |
| 522 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 523 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 524 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 525 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 526 typename CallbackParamTraits<A5>::ForwardType a5, | |
| 527 typename CallbackParamTraits<A6>::ForwardType a6) { | |
| 528 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 529 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), | |
| 530 CallbackForward(a6)); | |
| 531 } | |
| 532 | |
| 533 private: | |
| 534 R (T::*method_)(A1, A2, A3, A4, A5, A6); | |
| 535 }; | |
| 536 | |
| 537 // Const Method: Arity 6. | |
| 538 template <typename R, typename T, typename A1, typename A2, typename A3, | |
| 539 typename A4, typename A5, typename A6> | |
| 540 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6) const> { | |
| 541 public: | |
| 542 typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6); | |
| 543 typedef true_type IsMethod; | |
| 544 | |
| 545 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const) | |
| 546 : method_(method) { | |
| 547 } | |
| 548 | |
| 549 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 550 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 551 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 552 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 553 typename CallbackParamTraits<A5>::ForwardType a5, | |
| 554 typename CallbackParamTraits<A6>::ForwardType a6) { | |
| 555 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 556 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), | |
| 557 CallbackForward(a6)); | |
| 558 } | |
| 559 | |
| 560 private: | |
| 561 R (T::*method_)(A1, A2, A3, A4, A5, A6) const; | |
| 562 }; | |
| 563 | |
| 564 // Function: Arity 7. | |
| 565 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| 566 typename A5, typename A6, typename A7> | |
| 567 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6, A7)> { | |
| 568 public: | |
| 569 typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7); | |
| 570 | |
| 571 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7)) | |
| 572 : function_(function) { | |
| 573 } | |
| 574 | |
| 575 R Run(typename CallbackParamTraits<A1>::ForwardType a1, | |
| 576 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 577 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 578 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 579 typename CallbackParamTraits<A5>::ForwardType a5, | |
| 580 typename CallbackParamTraits<A6>::ForwardType a6, | |
| 581 typename CallbackParamTraits<A7>::ForwardType a7) { | |
| 582 return function_(CallbackForward(a1), CallbackForward(a2), | |
| 583 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), | |
| 584 CallbackForward(a6), CallbackForward(a7)); | |
| 585 } | |
| 586 | |
| 587 private: | |
| 588 R (*function_)(A1, A2, A3, A4, A5, A6, A7); | |
| 589 }; | |
| 590 | |
| 591 // Method: Arity 7. | |
| 592 template <typename R, typename T, typename A1, typename A2, typename A3, | |
| 593 typename A4, typename A5, typename A6, typename A7> | |
| 594 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7)> { | |
| 595 public: | |
| 596 typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7); | |
| 597 typedef true_type IsMethod; | |
| 598 | |
| 599 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7)) | |
| 600 : method_(method) { | |
| 601 } | |
| 602 | |
| 603 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 604 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 605 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 606 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 607 typename CallbackParamTraits<A5>::ForwardType a5, | |
| 608 typename CallbackParamTraits<A6>::ForwardType a6, | |
| 609 typename CallbackParamTraits<A7>::ForwardType a7) { | |
| 610 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 611 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), | |
| 612 CallbackForward(a6), CallbackForward(a7)); | |
| 613 } | |
| 614 | |
| 615 private: | |
| 616 R (T::*method_)(A1, A2, A3, A4, A5, A6, A7); | |
| 617 }; | |
| 618 | |
| 619 // Const Method: Arity 7. | |
| 620 template <typename R, typename T, typename A1, typename A2, typename A3, | |
| 621 typename A4, typename A5, typename A6, typename A7> | |
| 622 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7) const> { | |
| 623 public: | |
| 624 typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7); | |
| 625 typedef true_type IsMethod; | |
| 626 | |
| 627 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const) | |
| 628 : method_(method) { | |
| 629 } | |
| 630 | |
| 631 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1, | |
| 632 typename CallbackParamTraits<A2>::ForwardType a2, | |
| 633 typename CallbackParamTraits<A3>::ForwardType a3, | |
| 634 typename CallbackParamTraits<A4>::ForwardType a4, | |
| 635 typename CallbackParamTraits<A5>::ForwardType a5, | |
| 636 typename CallbackParamTraits<A6>::ForwardType a6, | |
| 637 typename CallbackParamTraits<A7>::ForwardType a7) { | |
| 638 return (object->*method_)(CallbackForward(a1), CallbackForward(a2), | |
| 639 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), | |
| 640 CallbackForward(a6), CallbackForward(a7)); | |
| 641 } | |
| 642 | |
| 643 private: | |
| 644 R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const; | |
| 645 }; | |
| 646 | |
| 647 | |
| 648 // FunctionTraits<> | 158 // FunctionTraits<> |
| 649 // | 159 // |
| 650 // Breaks a function signature apart into typedefs for easier introspection. | 160 // Breaks a function signature apart into typedefs for easier introspection. |
| 651 template <typename Sig> | 161 template <typename Sig> |
| 652 struct FunctionTraits; | 162 struct FunctionTraits; |
| 653 | 163 |
| 654 template <typename R> | 164 template <typename R> |
| 655 struct FunctionTraits<R()> { | 165 struct FunctionTraits<R()> { |
| 656 typedef R ReturnType; | 166 typedef R ReturnType; |
| 657 }; | 167 }; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 typedef A7 A7Type; | 232 typedef A7 A7Type; |
| 723 }; | 233 }; |
| 724 | 234 |
| 725 | 235 |
| 726 // ForceVoidReturn<> | 236 // ForceVoidReturn<> |
| 727 // | 237 // |
| 728 // Set of templates that support forcing the function return type to void. | 238 // Set of templates that support forcing the function return type to void. |
| 729 template <typename Sig> | 239 template <typename Sig> |
| 730 struct ForceVoidReturn; | 240 struct ForceVoidReturn; |
| 731 | 241 |
| 732 template <typename R> | 242 template <typename R, typename... Args> |
| 733 struct ForceVoidReturn<R()> { | 243 struct ForceVoidReturn<R(Args...)> { |
| 734 typedef void(RunType)(); | 244 typedef void(RunType)(Args...); |
| 735 }; | |
| 736 | |
| 737 template <typename R, typename A1> | |
| 738 struct ForceVoidReturn<R(A1)> { | |
| 739 typedef void(RunType)(A1); | |
| 740 }; | |
| 741 | |
| 742 template <typename R, typename A1, typename A2> | |
| 743 struct ForceVoidReturn<R(A1, A2)> { | |
| 744 typedef void(RunType)(A1, A2); | |
| 745 }; | |
| 746 | |
| 747 template <typename R, typename A1, typename A2, typename A3> | |
| 748 struct ForceVoidReturn<R(A1, A2, A3)> { | |
| 749 typedef void(RunType)(A1, A2, A3); | |
| 750 }; | |
| 751 | |
| 752 template <typename R, typename A1, typename A2, typename A3, typename A4> | |
| 753 struct ForceVoidReturn<R(A1, A2, A3, A4)> { | |
| 754 typedef void(RunType)(A1, A2, A3, A4); | |
| 755 }; | |
| 756 | |
| 757 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| 758 typename A5> | |
| 759 struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> { | |
| 760 typedef void(RunType)(A1, A2, A3, A4, A5); | |
| 761 }; | |
| 762 | |
| 763 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| 764 typename A5, typename A6> | |
| 765 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6)> { | |
| 766 typedef void(RunType)(A1, A2, A3, A4, A5, A6); | |
| 767 }; | |
| 768 | |
| 769 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| 770 typename A5, typename A6, typename A7> | |
| 771 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6, A7)> { | |
| 772 typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7); | |
| 773 }; | 245 }; |
| 774 | 246 |
| 775 | 247 |
| 776 // FunctorTraits<> | 248 // FunctorTraits<> |
| 777 // | 249 // |
| 778 // See description at top of file. | 250 // See description at top of file. |
| 779 template <typename T> | 251 template <typename T> |
| 780 struct FunctorTraits { | 252 struct FunctorTraits { |
| 781 typedef RunnableAdapter<T> RunnableType; | 253 typedef RunnableAdapter<T> RunnableType; |
| 782 typedef typename RunnableType::RunType RunType; | 254 typedef typename RunnableType::RunType RunType; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 // sugar breaks though when the Runnable's RunType is not void. Thus, we | 305 // sugar breaks though when the Runnable's RunType is not void. Thus, we |
| 834 // need a partial specialization to change the syntax to drop the "return" | 306 // need a partial specialization to change the syntax to drop the "return" |
| 835 // from the invocation call. | 307 // from the invocation call. |
| 836 // | 308 // |
| 837 // WeakCalls similarly need special syntax that is applied to the first | 309 // WeakCalls similarly need special syntax that is applied to the first |
| 838 // argument to check if they should no-op themselves. | 310 // argument to check if they should no-op themselves. |
| 839 template <bool IsWeakCall, typename ReturnType, typename Runnable, | 311 template <bool IsWeakCall, typename ReturnType, typename Runnable, |
| 840 typename ArgsType> | 312 typename ArgsType> |
| 841 struct InvokeHelper; | 313 struct InvokeHelper; |
| 842 | 314 |
| 843 template <typename ReturnType, typename Runnable> | 315 template <typename ReturnType, typename Runnable, typename... Args> |
| 844 struct InvokeHelper<false, ReturnType, Runnable, | 316 struct InvokeHelper<false, ReturnType, Runnable, |
| 845 void()> { | 317 void(Args...)> { |
| 846 static ReturnType MakeItSo(Runnable runnable) { | 318 static ReturnType MakeItSo(Runnable runnable, Args... args) { |
| 847 return runnable.Run(); | 319 return runnable.Run(CallbackForward(args)...); |
| 848 } | 320 } |
| 849 }; | 321 }; |
| 850 | 322 |
| 851 template <typename Runnable> | 323 template <typename Runnable, typename... Args> |
| 852 struct InvokeHelper<false, void, Runnable, | 324 struct InvokeHelper<false, void, Runnable, void(Args...)> { |
| 853 void()> { | 325 static void MakeItSo(Runnable runnable, Args... args) { |
| 854 static void MakeItSo(Runnable runnable) { | 326 runnable.Run(CallbackForward(args)...); |
| 855 runnable.Run(); | |
| 856 } | 327 } |
| 857 }; | 328 }; |
| 858 | 329 |
| 859 template <typename ReturnType, typename Runnable,typename A1> | 330 template <typename Runnable, typename BoundWeakPtr, typename... Args> |
| 860 struct InvokeHelper<false, ReturnType, Runnable, | 331 struct InvokeHelper<true, void, Runnable, void(BoundWeakPtr, Args...)> { |
| 861 void(A1)> { | 332 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, Args... args) { |
| 862 static ReturnType MakeItSo(Runnable runnable, A1 a1) { | 333 if (!weak_ptr.get()) { |
| 863 return runnable.Run(CallbackForward(a1)); | 334 return; |
| 335 } |
| 336 runnable.Run(weak_ptr.get(), CallbackForward(args)...); |
| 864 } | 337 } |
| 865 }; | 338 }; |
| 866 | 339 |
| 867 template <typename Runnable,typename A1> | |
| 868 struct InvokeHelper<false, void, Runnable, | |
| 869 void(A1)> { | |
| 870 static void MakeItSo(Runnable runnable, A1 a1) { | |
| 871 runnable.Run(CallbackForward(a1)); | |
| 872 } | |
| 873 }; | |
| 874 | |
| 875 template <typename Runnable, typename BoundWeakPtr> | |
| 876 struct InvokeHelper<true, void, Runnable, | |
| 877 void(BoundWeakPtr)> { | |
| 878 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr) { | |
| 879 if (!weak_ptr.get()) { | |
| 880 return; | |
| 881 } | |
| 882 runnable.Run(weak_ptr.get()); | |
| 883 } | |
| 884 }; | |
| 885 | |
| 886 template <typename ReturnType, typename Runnable,typename A1, typename A2> | |
| 887 struct InvokeHelper<false, ReturnType, Runnable, | |
| 888 void(A1, A2)> { | |
| 889 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) { | |
| 890 return runnable.Run(CallbackForward(a1), CallbackForward(a2)); | |
| 891 } | |
| 892 }; | |
| 893 | |
| 894 template <typename Runnable,typename A1, typename A2> | |
| 895 struct InvokeHelper<false, void, Runnable, | |
| 896 void(A1, A2)> { | |
| 897 static void MakeItSo(Runnable runnable, A1 a1, A2 a2) { | |
| 898 runnable.Run(CallbackForward(a1), CallbackForward(a2)); | |
| 899 } | |
| 900 }; | |
| 901 | |
| 902 template <typename Runnable, typename BoundWeakPtr, typename A2> | |
| 903 struct InvokeHelper<true, void, Runnable, | |
| 904 void(BoundWeakPtr, A2)> { | |
| 905 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2) { | |
| 906 if (!weak_ptr.get()) { | |
| 907 return; | |
| 908 } | |
| 909 runnable.Run(weak_ptr.get(), CallbackForward(a2)); | |
| 910 } | |
| 911 }; | |
| 912 | |
| 913 template <typename ReturnType, typename Runnable,typename A1, typename A2, | |
| 914 typename A3> | |
| 915 struct InvokeHelper<false, ReturnType, Runnable, | |
| 916 void(A1, A2, A3)> { | |
| 917 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { | |
| 918 return runnable.Run(CallbackForward(a1), CallbackForward(a2), | |
| 919 CallbackForward(a3)); | |
| 920 } | |
| 921 }; | |
| 922 | |
| 923 template <typename Runnable,typename A1, typename A2, typename A3> | |
| 924 struct InvokeHelper<false, void, Runnable, | |
| 925 void(A1, A2, A3)> { | |
| 926 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { | |
| 927 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3)); | |
| 928 } | |
| 929 }; | |
| 930 | |
| 931 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3> | |
| 932 struct InvokeHelper<true, void, Runnable, | |
| 933 void(BoundWeakPtr, A2, A3)> { | |
| 934 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3) { | |
| 935 if (!weak_ptr.get()) { | |
| 936 return; | |
| 937 } | |
| 938 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3)); | |
| 939 } | |
| 940 }; | |
| 941 | |
| 942 template <typename ReturnType, typename Runnable,typename A1, typename A2, | |
| 943 typename A3, typename A4> | |
| 944 struct InvokeHelper<false, ReturnType, Runnable, | |
| 945 void(A1, A2, A3, A4)> { | |
| 946 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { | |
| 947 return runnable.Run(CallbackForward(a1), CallbackForward(a2), | |
| 948 CallbackForward(a3), CallbackForward(a4)); | |
| 949 } | |
| 950 }; | |
| 951 | |
| 952 template <typename Runnable,typename A1, typename A2, typename A3, typename A4> | |
| 953 struct InvokeHelper<false, void, Runnable, | |
| 954 void(A1, A2, A3, A4)> { | |
| 955 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { | |
| 956 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), | |
| 957 CallbackForward(a4)); | |
| 958 } | |
| 959 }; | |
| 960 | |
| 961 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3, | |
| 962 typename A4> | |
| 963 struct InvokeHelper<true, void, Runnable, | |
| 964 void(BoundWeakPtr, A2, A3, A4)> { | |
| 965 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, | |
| 966 A4 a4) { | |
| 967 if (!weak_ptr.get()) { | |
| 968 return; | |
| 969 } | |
| 970 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), | |
| 971 CallbackForward(a4)); | |
| 972 } | |
| 973 }; | |
| 974 | |
| 975 template <typename ReturnType, typename Runnable,typename A1, typename A2, | |
| 976 typename A3, typename A4, typename A5> | |
| 977 struct InvokeHelper<false, ReturnType, Runnable, | |
| 978 void(A1, A2, A3, A4, A5)> { | |
| 979 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, | |
| 980 A5 a5) { | |
| 981 return runnable.Run(CallbackForward(a1), CallbackForward(a2), | |
| 982 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); | |
| 983 } | |
| 984 }; | |
| 985 | |
| 986 template <typename Runnable,typename A1, typename A2, typename A3, typename A4, | |
| 987 typename A5> | |
| 988 struct InvokeHelper<false, void, Runnable, | |
| 989 void(A1, A2, A3, A4, A5)> { | |
| 990 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { | |
| 991 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), | |
| 992 CallbackForward(a4), CallbackForward(a5)); | |
| 993 } | |
| 994 }; | |
| 995 | |
| 996 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3, | |
| 997 typename A4, typename A5> | |
| 998 struct InvokeHelper<true, void, Runnable, | |
| 999 void(BoundWeakPtr, A2, A3, A4, A5)> { | |
| 1000 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, | |
| 1001 A4 a4, A5 a5) { | |
| 1002 if (!weak_ptr.get()) { | |
| 1003 return; | |
| 1004 } | |
| 1005 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), | |
| 1006 CallbackForward(a4), CallbackForward(a5)); | |
| 1007 } | |
| 1008 }; | |
| 1009 | |
| 1010 template <typename ReturnType, typename Runnable,typename A1, typename A2, | |
| 1011 typename A3, typename A4, typename A5, typename A6> | |
| 1012 struct InvokeHelper<false, ReturnType, Runnable, | |
| 1013 void(A1, A2, A3, A4, A5, A6)> { | |
| 1014 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, | |
| 1015 A5 a5, A6 a6) { | |
| 1016 return runnable.Run(CallbackForward(a1), CallbackForward(a2), | |
| 1017 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), | |
| 1018 CallbackForward(a6)); | |
| 1019 } | |
| 1020 }; | |
| 1021 | |
| 1022 template <typename Runnable,typename A1, typename A2, typename A3, typename A4, | |
| 1023 typename A5, typename A6> | |
| 1024 struct InvokeHelper<false, void, Runnable, | |
| 1025 void(A1, A2, A3, A4, A5, A6)> { | |
| 1026 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, | |
| 1027 A6 a6) { | |
| 1028 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), | |
| 1029 CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); | |
| 1030 } | |
| 1031 }; | |
| 1032 | |
| 1033 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3, | |
| 1034 typename A4, typename A5, typename A6> | |
| 1035 struct InvokeHelper<true, void, Runnable, | |
| 1036 void(BoundWeakPtr, A2, A3, A4, A5, A6)> { | |
| 1037 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, | |
| 1038 A4 a4, A5 a5, A6 a6) { | |
| 1039 if (!weak_ptr.get()) { | |
| 1040 return; | |
| 1041 } | |
| 1042 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), | |
| 1043 CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); | |
| 1044 } | |
| 1045 }; | |
| 1046 | |
| 1047 template <typename ReturnType, typename Runnable,typename A1, typename A2, | |
| 1048 typename A3, typename A4, typename A5, typename A6, typename A7> | |
| 1049 struct InvokeHelper<false, ReturnType, Runnable, | |
| 1050 void(A1, A2, A3, A4, A5, A6, A7)> { | |
| 1051 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, | |
| 1052 A5 a5, A6 a6, A7 a7) { | |
| 1053 return runnable.Run(CallbackForward(a1), CallbackForward(a2), | |
| 1054 CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), | |
| 1055 CallbackForward(a6), CallbackForward(a7)); | |
| 1056 } | |
| 1057 }; | |
| 1058 | |
| 1059 template <typename Runnable,typename A1, typename A2, typename A3, typename A4, | |
| 1060 typename A5, typename A6, typename A7> | |
| 1061 struct InvokeHelper<false, void, Runnable, | |
| 1062 void(A1, A2, A3, A4, A5, A6, A7)> { | |
| 1063 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, | |
| 1064 A6 a6, A7 a7) { | |
| 1065 runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), | |
| 1066 CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), | |
| 1067 CallbackForward(a7)); | |
| 1068 } | |
| 1069 }; | |
| 1070 | |
| 1071 template <typename Runnable, typename BoundWeakPtr, typename A2, typename A3, | |
| 1072 typename A4, typename A5, typename A6, typename A7> | |
| 1073 struct InvokeHelper<true, void, Runnable, | |
| 1074 void(BoundWeakPtr, A2, A3, A4, A5, A6, A7)> { | |
| 1075 static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, | |
| 1076 A4 a4, A5 a5, A6 a6, A7 a7) { | |
| 1077 if (!weak_ptr.get()) { | |
| 1078 return; | |
| 1079 } | |
| 1080 runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), | |
| 1081 CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), | |
| 1082 CallbackForward(a7)); | |
| 1083 } | |
| 1084 }; | |
| 1085 | |
| 1086 #if !defined(_MSC_VER) | 340 #if !defined(_MSC_VER) |
| 1087 | 341 |
| 1088 template <typename ReturnType, typename Runnable, typename ArgsType> | 342 template <typename ReturnType, typename Runnable, typename ArgsType> |
| 1089 struct InvokeHelper<true, ReturnType, Runnable, ArgsType> { | 343 struct InvokeHelper<true, ReturnType, Runnable, ArgsType> { |
| 1090 // WeakCalls are only supported for functions with a void return type. | 344 // WeakCalls are only supported for functions with a void return type. |
| 1091 // Otherwise, the function result would be undefined if the the WeakPtr<> | 345 // Otherwise, the function result would be undefined if the the WeakPtr<> |
| 1092 // is invalidated. | 346 // is invalidated. |
| 1093 COMPILE_ASSERT(is_void<ReturnType>::value, | 347 COMPILE_ASSERT(is_void<ReturnType>::value, |
| 1094 weak_ptrs_can_only_bind_to_methods_without_return_values); | 348 weak_ptrs_can_only_bind_to_methods_without_return_values); |
| 1095 }; | 349 }; |
| (...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 P4 p4_; | 2034 P4 p4_; |
| 2781 P5 p5_; | 2035 P5 p5_; |
| 2782 P6 p6_; | 2036 P6 p6_; |
| 2783 P7 p7_; | 2037 P7 p7_; |
| 2784 }; | 2038 }; |
| 2785 | 2039 |
| 2786 } // namespace internal | 2040 } // namespace internal |
| 2787 } // namespace base | 2041 } // namespace base |
| 2788 | 2042 |
| 2789 #endif // BASE_BIND_INTERNAL_H_ | 2043 #endif // BASE_BIND_INTERNAL_H_ |
| OLD | NEW |