OLD | NEW |
1 // This file was GENERATED by command: | 1 // This file was GENERATED by command: |
2 // pump.py callback.h.pump | 2 // pump.py callback.h.pump |
3 // DO NOT EDIT BY HAND!!! | 3 // DO NOT EDIT BY HAND!!! |
4 | 4 |
5 | 5 |
| 6 |
6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 7 // 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 | 8 // Use of this source code is governed by a BSD-style license that can be |
8 // found in the LICENSE file. | 9 // found in the LICENSE file. |
9 | 10 |
10 #ifndef BASE_CALLBACK_H_ | 11 #ifndef BASE_CALLBACK_H_ |
11 #define BASE_CALLBACK_H_ | 12 #define BASE_CALLBACK_H_ |
12 #pragma once | 13 #pragma once |
13 | 14 |
14 #include "base/callback_internal.h" | 15 #include "base/callback_internal.h" |
15 #include "base/callback_old.h" | 16 #include "base/callback_old.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // | 219 // |
219 // After this, create template specializations for 0-6 parameters. Note that | 220 // After this, create template specializations for 0-6 parameters. Note that |
220 // even though the template typelist grows, the specialization still | 221 // even though the template typelist grows, the specialization still |
221 // only has one type: the function signature. | 222 // only has one type: the function signature. |
222 template <typename Sig> | 223 template <typename Sig> |
223 class Callback; | 224 class Callback; |
224 | 225 |
225 template <typename R> | 226 template <typename R> |
226 class Callback<R(void)> : public internal::CallbackBase { | 227 class Callback<R(void)> : public internal::CallbackBase { |
227 public: | 228 public: |
228 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*); | 229 typedef R(*PolymorphicInvoke)( |
| 230 internal::InvokerStorageBase*); |
229 | 231 |
230 Callback() : CallbackBase(NULL, NULL) { } | 232 Callback() : CallbackBase(NULL, NULL) { } |
231 | 233 |
232 // We pass InvokerStorageHolder by const ref to avoid incurring an | 234 // We pass InvokerStorageHolder by const ref to avoid incurring an |
233 // unnecessary AddRef/Unref pair even though we will modify the object. | 235 // unnecessary AddRef/Unref pair even though we will modify the object. |
234 // We cannot use a normal reference because the compiler will warn | 236 // We cannot use a normal reference because the compiler will warn |
235 // since this is often used on a return value, which is a temporary. | 237 // since this is often used on a return value, which is a temporary. |
236 // | 238 // |
237 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 239 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
238 // return the exact Callback<> type. See base/bind.h for details. | 240 // return the exact Callback<> type. See base/bind.h for details. |
239 template <typename T> | 241 template <typename T> |
240 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 242 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
241 : CallbackBase( | 243 : CallbackBase( |
242 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), | 244 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
243 &invoker_holder.invoker_storage_) { | 245 &invoker_holder.invoker_storage_) { |
244 } | 246 } |
245 | 247 |
246 R Run() const { | 248 R Run() const { |
247 PolymorphicInvoke f = | 249 PolymorphicInvoke f = |
248 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 250 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
249 | 251 |
250 return f(invoker_storage_.get()); | 252 return f(invoker_storage_.get()); |
251 } | 253 } |
252 }; | 254 }; |
253 | 255 |
254 template <typename R, typename A1> | 256 template <typename R, typename A1> |
255 class Callback<R(A1)> : public internal::CallbackBase { | 257 class Callback<R(A1)> : public internal::CallbackBase { |
256 public: | 258 public: |
257 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&); | 259 typedef R(*PolymorphicInvoke)( |
| 260 internal::InvokerStorageBase*, |
| 261 typename internal::ParamTraits<A1>::ForwardType); |
258 | 262 |
259 Callback() : CallbackBase(NULL, NULL) { } | 263 Callback() : CallbackBase(NULL, NULL) { } |
260 | 264 |
261 // We pass InvokerStorageHolder by const ref to avoid incurring an | 265 // We pass InvokerStorageHolder by const ref to avoid incurring an |
262 // unnecessary AddRef/Unref pair even though we will modify the object. | 266 // unnecessary AddRef/Unref pair even though we will modify the object. |
263 // We cannot use a normal reference because the compiler will warn | 267 // We cannot use a normal reference because the compiler will warn |
264 // since this is often used on a return value, which is a temporary. | 268 // since this is often used on a return value, which is a temporary. |
265 // | 269 // |
266 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 270 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
267 // return the exact Callback<> type. See base/bind.h for details. | 271 // return the exact Callback<> type. See base/bind.h for details. |
268 template <typename T> | 272 template <typename T> |
269 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 273 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
270 : CallbackBase( | 274 : CallbackBase( |
271 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), | 275 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
272 &invoker_holder.invoker_storage_) { | 276 &invoker_holder.invoker_storage_) { |
273 } | 277 } |
274 | 278 |
275 R Run(const A1& a1) const { | 279 R Run(typename internal::ParamTraits<A1>::ForwardType a1) const { |
276 PolymorphicInvoke f = | 280 PolymorphicInvoke f = |
277 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 281 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
278 | 282 |
279 return f(invoker_storage_.get(), a1); | 283 return f(invoker_storage_.get(), a1); |
280 } | 284 } |
281 }; | 285 }; |
282 | 286 |
283 template <typename R, typename A1, typename A2> | 287 template <typename R, typename A1, typename A2> |
284 class Callback<R(A1, A2)> : public internal::CallbackBase { | 288 class Callback<R(A1, A2)> : public internal::CallbackBase { |
285 public: | 289 public: |
286 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, | 290 typedef R(*PolymorphicInvoke)( |
287 const A2&); | 291 internal::InvokerStorageBase*, |
| 292 typename internal::ParamTraits<A1>::ForwardType, |
| 293 typename internal::ParamTraits<A2>::ForwardType); |
288 | 294 |
289 Callback() : CallbackBase(NULL, NULL) { } | 295 Callback() : CallbackBase(NULL, NULL) { } |
290 | 296 |
291 // We pass InvokerStorageHolder by const ref to avoid incurring an | 297 // We pass InvokerStorageHolder by const ref to avoid incurring an |
292 // unnecessary AddRef/Unref pair even though we will modify the object. | 298 // unnecessary AddRef/Unref pair even though we will modify the object. |
293 // We cannot use a normal reference because the compiler will warn | 299 // We cannot use a normal reference because the compiler will warn |
294 // since this is often used on a return value, which is a temporary. | 300 // since this is often used on a return value, which is a temporary. |
295 // | 301 // |
296 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 302 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
297 // return the exact Callback<> type. See base/bind.h for details. | 303 // return the exact Callback<> type. See base/bind.h for details. |
298 template <typename T> | 304 template <typename T> |
299 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 305 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
300 : CallbackBase( | 306 : CallbackBase( |
301 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), | 307 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
302 &invoker_holder.invoker_storage_) { | 308 &invoker_holder.invoker_storage_) { |
303 } | 309 } |
304 | 310 |
305 R Run(const A1& a1, | 311 R Run(typename internal::ParamTraits<A1>::ForwardType a1, |
306 const A2& a2) const { | 312 typename internal::ParamTraits<A2>::ForwardType a2) const { |
307 PolymorphicInvoke f = | 313 PolymorphicInvoke f = |
308 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 314 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
309 | 315 |
310 return f(invoker_storage_.get(), a1, | 316 return f(invoker_storage_.get(), a1, |
311 a2); | 317 a2); |
312 } | 318 } |
313 }; | 319 }; |
314 | 320 |
315 template <typename R, typename A1, typename A2, typename A3> | 321 template <typename R, typename A1, typename A2, typename A3> |
316 class Callback<R(A1, A2, A3)> : public internal::CallbackBase { | 322 class Callback<R(A1, A2, A3)> : public internal::CallbackBase { |
317 public: | 323 public: |
318 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, | 324 typedef R(*PolymorphicInvoke)( |
319 const A2&, | 325 internal::InvokerStorageBase*, |
320 const A3&); | 326 typename internal::ParamTraits<A1>::ForwardType, |
| 327 typename internal::ParamTraits<A2>::ForwardType, |
| 328 typename internal::ParamTraits<A3>::ForwardType); |
321 | 329 |
322 Callback() : CallbackBase(NULL, NULL) { } | 330 Callback() : CallbackBase(NULL, NULL) { } |
323 | 331 |
324 // We pass InvokerStorageHolder by const ref to avoid incurring an | 332 // We pass InvokerStorageHolder by const ref to avoid incurring an |
325 // unnecessary AddRef/Unref pair even though we will modify the object. | 333 // unnecessary AddRef/Unref pair even though we will modify the object. |
326 // We cannot use a normal reference because the compiler will warn | 334 // We cannot use a normal reference because the compiler will warn |
327 // since this is often used on a return value, which is a temporary. | 335 // since this is often used on a return value, which is a temporary. |
328 // | 336 // |
329 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 337 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
330 // return the exact Callback<> type. See base/bind.h for details. | 338 // return the exact Callback<> type. See base/bind.h for details. |
331 template <typename T> | 339 template <typename T> |
332 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 340 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
333 : CallbackBase( | 341 : CallbackBase( |
334 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), | 342 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
335 &invoker_holder.invoker_storage_) { | 343 &invoker_holder.invoker_storage_) { |
336 } | 344 } |
337 | 345 |
338 R Run(const A1& a1, | 346 R Run(typename internal::ParamTraits<A1>::ForwardType a1, |
339 const A2& a2, | 347 typename internal::ParamTraits<A2>::ForwardType a2, |
340 const A3& a3) const { | 348 typename internal::ParamTraits<A3>::ForwardType a3) const { |
341 PolymorphicInvoke f = | 349 PolymorphicInvoke f = |
342 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 350 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
343 | 351 |
344 return f(invoker_storage_.get(), a1, | 352 return f(invoker_storage_.get(), a1, |
345 a2, | 353 a2, |
346 a3); | 354 a3); |
347 } | 355 } |
348 }; | 356 }; |
349 | 357 |
350 template <typename R, typename A1, typename A2, typename A3, typename A4> | 358 template <typename R, typename A1, typename A2, typename A3, typename A4> |
351 class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase { | 359 class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase { |
352 public: | 360 public: |
353 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, | 361 typedef R(*PolymorphicInvoke)( |
354 const A2&, | 362 internal::InvokerStorageBase*, |
355 const A3&, | 363 typename internal::ParamTraits<A1>::ForwardType, |
356 const A4&); | 364 typename internal::ParamTraits<A2>::ForwardType, |
| 365 typename internal::ParamTraits<A3>::ForwardType, |
| 366 typename internal::ParamTraits<A4>::ForwardType); |
357 | 367 |
358 Callback() : CallbackBase(NULL, NULL) { } | 368 Callback() : CallbackBase(NULL, NULL) { } |
359 | 369 |
360 // We pass InvokerStorageHolder by const ref to avoid incurring an | 370 // We pass InvokerStorageHolder by const ref to avoid incurring an |
361 // unnecessary AddRef/Unref pair even though we will modify the object. | 371 // unnecessary AddRef/Unref pair even though we will modify the object. |
362 // We cannot use a normal reference because the compiler will warn | 372 // We cannot use a normal reference because the compiler will warn |
363 // since this is often used on a return value, which is a temporary. | 373 // since this is often used on a return value, which is a temporary. |
364 // | 374 // |
365 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 375 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
366 // return the exact Callback<> type. See base/bind.h for details. | 376 // return the exact Callback<> type. See base/bind.h for details. |
367 template <typename T> | 377 template <typename T> |
368 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 378 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
369 : CallbackBase( | 379 : CallbackBase( |
370 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), | 380 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
371 &invoker_holder.invoker_storage_) { | 381 &invoker_holder.invoker_storage_) { |
372 } | 382 } |
373 | 383 |
374 R Run(const A1& a1, | 384 R Run(typename internal::ParamTraits<A1>::ForwardType a1, |
375 const A2& a2, | 385 typename internal::ParamTraits<A2>::ForwardType a2, |
376 const A3& a3, | 386 typename internal::ParamTraits<A3>::ForwardType a3, |
377 const A4& a4) const { | 387 typename internal::ParamTraits<A4>::ForwardType a4) const { |
378 PolymorphicInvoke f = | 388 PolymorphicInvoke f = |
379 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 389 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
380 | 390 |
381 return f(invoker_storage_.get(), a1, | 391 return f(invoker_storage_.get(), a1, |
382 a2, | 392 a2, |
383 a3, | 393 a3, |
384 a4); | 394 a4); |
385 } | 395 } |
386 }; | 396 }; |
387 | 397 |
388 template <typename R, typename A1, typename A2, typename A3, typename A4, | 398 template <typename R, typename A1, typename A2, typename A3, typename A4, |
389 typename A5> | 399 typename A5> |
390 class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase { | 400 class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase { |
391 public: | 401 public: |
392 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, | 402 typedef R(*PolymorphicInvoke)( |
393 const A2&, | 403 internal::InvokerStorageBase*, |
394 const A3&, | 404 typename internal::ParamTraits<A1>::ForwardType, |
395 const A4&, | 405 typename internal::ParamTraits<A2>::ForwardType, |
396 const A5&); | 406 typename internal::ParamTraits<A3>::ForwardType, |
| 407 typename internal::ParamTraits<A4>::ForwardType, |
| 408 typename internal::ParamTraits<A5>::ForwardType); |
397 | 409 |
398 Callback() : CallbackBase(NULL, NULL) { } | 410 Callback() : CallbackBase(NULL, NULL) { } |
399 | 411 |
400 // We pass InvokerStorageHolder by const ref to avoid incurring an | 412 // We pass InvokerStorageHolder by const ref to avoid incurring an |
401 // unnecessary AddRef/Unref pair even though we will modify the object. | 413 // unnecessary AddRef/Unref pair even though we will modify the object. |
402 // We cannot use a normal reference because the compiler will warn | 414 // We cannot use a normal reference because the compiler will warn |
403 // since this is often used on a return value, which is a temporary. | 415 // since this is often used on a return value, which is a temporary. |
404 // | 416 // |
405 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 417 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
406 // return the exact Callback<> type. See base/bind.h for details. | 418 // return the exact Callback<> type. See base/bind.h for details. |
407 template <typename T> | 419 template <typename T> |
408 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 420 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
409 : CallbackBase( | 421 : CallbackBase( |
410 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), | 422 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
411 &invoker_holder.invoker_storage_) { | 423 &invoker_holder.invoker_storage_) { |
412 } | 424 } |
413 | 425 |
414 R Run(const A1& a1, | 426 R Run(typename internal::ParamTraits<A1>::ForwardType a1, |
415 const A2& a2, | 427 typename internal::ParamTraits<A2>::ForwardType a2, |
416 const A3& a3, | 428 typename internal::ParamTraits<A3>::ForwardType a3, |
417 const A4& a4, | 429 typename internal::ParamTraits<A4>::ForwardType a4, |
418 const A5& a5) const { | 430 typename internal::ParamTraits<A5>::ForwardType a5) const { |
419 PolymorphicInvoke f = | 431 PolymorphicInvoke f = |
420 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 432 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
421 | 433 |
422 return f(invoker_storage_.get(), a1, | 434 return f(invoker_storage_.get(), a1, |
423 a2, | 435 a2, |
424 a3, | 436 a3, |
425 a4, | 437 a4, |
426 a5); | 438 a5); |
427 } | 439 } |
428 }; | 440 }; |
429 | 441 |
430 template <typename R, typename A1, typename A2, typename A3, typename A4, | 442 template <typename R, typename A1, typename A2, typename A3, typename A4, |
431 typename A5, typename A6> | 443 typename A5, typename A6> |
432 class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase { | 444 class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase { |
433 public: | 445 public: |
434 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, | 446 typedef R(*PolymorphicInvoke)( |
435 const A2&, | 447 internal::InvokerStorageBase*, |
436 const A3&, | 448 typename internal::ParamTraits<A1>::ForwardType, |
437 const A4&, | 449 typename internal::ParamTraits<A2>::ForwardType, |
438 const A5&, | 450 typename internal::ParamTraits<A3>::ForwardType, |
439 const A6&); | 451 typename internal::ParamTraits<A4>::ForwardType, |
| 452 typename internal::ParamTraits<A5>::ForwardType, |
| 453 typename internal::ParamTraits<A6>::ForwardType); |
440 | 454 |
441 Callback() : CallbackBase(NULL, NULL) { } | 455 Callback() : CallbackBase(NULL, NULL) { } |
442 | 456 |
443 // We pass InvokerStorageHolder by const ref to avoid incurring an | 457 // We pass InvokerStorageHolder by const ref to avoid incurring an |
444 // unnecessary AddRef/Unref pair even though we will modify the object. | 458 // unnecessary AddRef/Unref pair even though we will modify the object. |
445 // We cannot use a normal reference because the compiler will warn | 459 // We cannot use a normal reference because the compiler will warn |
446 // since this is often used on a return value, which is a temporary. | 460 // since this is often used on a return value, which is a temporary. |
447 // | 461 // |
448 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 462 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
449 // return the exact Callback<> type. See base/bind.h for details. | 463 // return the exact Callback<> type. See base/bind.h for details. |
450 template <typename T> | 464 template <typename T> |
451 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 465 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
452 : CallbackBase( | 466 : CallbackBase( |
453 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), | 467 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
454 &invoker_holder.invoker_storage_) { | 468 &invoker_holder.invoker_storage_) { |
455 } | 469 } |
456 | 470 |
457 R Run(const A1& a1, | 471 R Run(typename internal::ParamTraits<A1>::ForwardType a1, |
458 const A2& a2, | 472 typename internal::ParamTraits<A2>::ForwardType a2, |
459 const A3& a3, | 473 typename internal::ParamTraits<A3>::ForwardType a3, |
460 const A4& a4, | 474 typename internal::ParamTraits<A4>::ForwardType a4, |
461 const A5& a5, | 475 typename internal::ParamTraits<A5>::ForwardType a5, |
462 const A6& a6) const { | 476 typename internal::ParamTraits<A6>::ForwardType a6) const { |
463 PolymorphicInvoke f = | 477 PolymorphicInvoke f = |
464 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 478 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
465 | 479 |
466 return f(invoker_storage_.get(), a1, | 480 return f(invoker_storage_.get(), a1, |
467 a2, | 481 a2, |
468 a3, | 482 a3, |
469 a4, | 483 a4, |
470 a5, | 484 a5, |
471 a6); | 485 a6); |
472 } | 486 } |
473 }; | 487 }; |
474 | 488 |
475 | 489 |
476 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it | 490 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it |
477 // will be used in a lot of APIs with delayed execution. | 491 // will be used in a lot of APIs with delayed execution. |
478 typedef Callback<void(void)> Closure; | 492 typedef Callback<void(void)> Closure; |
479 | 493 |
480 } // namespace base | 494 } // namespace base |
481 | 495 |
482 #endif // BASE_CALLBACK_H | 496 #endif // BASE_CALLBACK_H |
OLD | NEW |