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 // 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_CALLBACK_H_ | 10 #ifndef BASE_CALLBACK_H_ |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 // First, we forward declare the Callback class template. This informs the | 215 // First, we forward declare the Callback class template. This informs the |
216 // compiler that the template only has 1 type parameter which is the function | 216 // compiler that the template only has 1 type parameter which is the function |
217 // signature that the Callback is representing. | 217 // signature that the Callback is representing. |
218 // | 218 // |
219 // After this, create template specializations for 0-6 parameters. Note that | 219 // After this, create template specializations for 0-6 parameters. Note that |
220 // even though the template typelist grows, the specialization still | 220 // even though the template typelist grows, the specialization still |
221 // only has one type: the function signature. | 221 // only has one type: the function signature. |
222 template <typename Sig> | 222 template <typename Sig> |
223 class Callback; | 223 class Callback; |
| 224 |
224 template <typename R> | 225 template <typename R> |
225 class Callback<R(void)> : public internal::CallbackBase { | 226 class Callback<R(void)> : public internal::CallbackBase { |
226 public: | 227 public: |
227 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*); | 228 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*); |
228 | 229 |
229 Callback() : CallbackBase(NULL, NULL) { } | 230 Callback() : CallbackBase(NULL, NULL) { } |
230 | 231 |
231 // We pass InvokerStorageHolder by const ref to avoid incurring an | 232 // We pass InvokerStorageHolder by const ref to avoid incurring an |
232 // unnecessary AddRef/Unref pair even though we will modify the object. | 233 // unnecessary AddRef/Unref pair even though we will modify the object. |
233 // We cannot use a normal reference because the compiler will warn | 234 // We cannot use a normal reference because the compiler will warn |
234 // since this is often used on a return value, which is a temporary. | 235 // since this is often used on a return value, which is a temporary. |
235 // | 236 // |
236 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 237 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
237 // return the exact Callback<> type. See base/bind.h for details. | 238 // return the exact Callback<> type. See base/bind.h for details. |
238 template <typename T> | 239 template <typename T> |
239 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 240 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
240 : CallbackBase( | 241 : CallbackBase( |
241 reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), | 242 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
242 &invoker_holder.invoker_storage_) { | 243 &invoker_holder.invoker_storage_) { |
243 } | 244 } |
244 | 245 |
245 R Run() const { | 246 R Run() const { |
246 PolymorphicInvoke f = | 247 PolymorphicInvoke f = |
247 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 248 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
248 | 249 |
249 return f(invoker_storage_.get()); | 250 return f(invoker_storage_.get()); |
250 } | 251 } |
251 }; | 252 }; |
252 | 253 |
253 template <typename R, typename A1> | 254 template <typename R, typename A1> |
254 class Callback<R(A1)> : public internal::CallbackBase { | 255 class Callback<R(A1)> : public internal::CallbackBase { |
255 public: | 256 public: |
256 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&); | 257 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&); |
257 | 258 |
258 Callback() : CallbackBase(NULL, NULL) { } | 259 Callback() : CallbackBase(NULL, NULL) { } |
259 | 260 |
260 // We pass InvokerStorageHolder by const ref to avoid incurring an | 261 // We pass InvokerStorageHolder by const ref to avoid incurring an |
261 // unnecessary AddRef/Unref pair even though we will modify the object. | 262 // unnecessary AddRef/Unref pair even though we will modify the object. |
262 // We cannot use a normal reference because the compiler will warn | 263 // We cannot use a normal reference because the compiler will warn |
263 // since this is often used on a return value, which is a temporary. | 264 // since this is often used on a return value, which is a temporary. |
264 // | 265 // |
265 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 266 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
266 // return the exact Callback<> type. See base/bind.h for details. | 267 // return the exact Callback<> type. See base/bind.h for details. |
267 template <typename T> | 268 template <typename T> |
268 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 269 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
269 : CallbackBase( | 270 : CallbackBase( |
270 reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), | 271 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
271 &invoker_holder.invoker_storage_) { | 272 &invoker_holder.invoker_storage_) { |
272 } | 273 } |
273 | 274 |
274 R Run(const A1& a1) const { | 275 R Run(const A1& a1) const { |
275 PolymorphicInvoke f = | 276 PolymorphicInvoke f = |
276 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 277 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
277 | 278 |
278 return f(invoker_storage_.get(), a1); | 279 return f(invoker_storage_.get(), a1); |
279 } | 280 } |
280 }; | 281 }; |
281 | 282 |
282 template <typename R, typename A1, typename A2> | 283 template <typename R, typename A1, typename A2> |
283 class Callback<R(A1, A2)> : public internal::CallbackBase { | 284 class Callback<R(A1, A2)> : public internal::CallbackBase { |
284 public: | 285 public: |
285 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, | 286 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, |
286 const A2&); | 287 const A2&); |
287 | 288 |
288 Callback() : CallbackBase(NULL, NULL) { } | 289 Callback() : CallbackBase(NULL, NULL) { } |
289 | 290 |
290 // We pass InvokerStorageHolder by const ref to avoid incurring an | 291 // We pass InvokerStorageHolder by const ref to avoid incurring an |
291 // unnecessary AddRef/Unref pair even though we will modify the object. | 292 // unnecessary AddRef/Unref pair even though we will modify the object. |
292 // We cannot use a normal reference because the compiler will warn | 293 // We cannot use a normal reference because the compiler will warn |
293 // since this is often used on a return value, which is a temporary. | 294 // since this is often used on a return value, which is a temporary. |
294 // | 295 // |
295 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 296 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
296 // return the exact Callback<> type. See base/bind.h for details. | 297 // return the exact Callback<> type. See base/bind.h for details. |
297 template <typename T> | 298 template <typename T> |
298 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 299 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
299 : CallbackBase( | 300 : CallbackBase( |
300 reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), | 301 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
301 &invoker_holder.invoker_storage_) { | 302 &invoker_holder.invoker_storage_) { |
302 } | 303 } |
303 | 304 |
304 R Run(const A1& a1, | 305 R Run(const A1& a1, |
305 const A2& a2) const { | 306 const A2& a2) const { |
306 PolymorphicInvoke f = | 307 PolymorphicInvoke f = |
307 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 308 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
308 | 309 |
309 return f(invoker_storage_.get(), a1, | 310 return f(invoker_storage_.get(), a1, |
310 a2); | 311 a2); |
(...skipping 12 matching lines...) Expand all Loading... |
323 // We pass InvokerStorageHolder by const ref to avoid incurring an | 324 // We pass InvokerStorageHolder by const ref to avoid incurring an |
324 // unnecessary AddRef/Unref pair even though we will modify the object. | 325 // unnecessary AddRef/Unref pair even though we will modify the object. |
325 // We cannot use a normal reference because the compiler will warn | 326 // We cannot use a normal reference because the compiler will warn |
326 // since this is often used on a return value, which is a temporary. | 327 // since this is often used on a return value, which is a temporary. |
327 // | 328 // |
328 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 329 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
329 // return the exact Callback<> type. See base/bind.h for details. | 330 // return the exact Callback<> type. See base/bind.h for details. |
330 template <typename T> | 331 template <typename T> |
331 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 332 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
332 : CallbackBase( | 333 : CallbackBase( |
333 reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), | 334 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
334 &invoker_holder.invoker_storage_) { | 335 &invoker_holder.invoker_storage_) { |
335 } | 336 } |
336 | 337 |
337 R Run(const A1& a1, | 338 R Run(const A1& a1, |
338 const A2& a2, | 339 const A2& a2, |
339 const A3& a3) const { | 340 const A3& a3) const { |
340 PolymorphicInvoke f = | 341 PolymorphicInvoke f = |
341 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 342 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
342 | 343 |
343 return f(invoker_storage_.get(), a1, | 344 return f(invoker_storage_.get(), a1, |
(...skipping 15 matching lines...) Expand all Loading... |
359 // We pass InvokerStorageHolder by const ref to avoid incurring an | 360 // We pass InvokerStorageHolder by const ref to avoid incurring an |
360 // unnecessary AddRef/Unref pair even though we will modify the object. | 361 // unnecessary AddRef/Unref pair even though we will modify the object. |
361 // We cannot use a normal reference because the compiler will warn | 362 // We cannot use a normal reference because the compiler will warn |
362 // since this is often used on a return value, which is a temporary. | 363 // since this is often used on a return value, which is a temporary. |
363 // | 364 // |
364 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 365 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
365 // return the exact Callback<> type. See base/bind.h for details. | 366 // return the exact Callback<> type. See base/bind.h for details. |
366 template <typename T> | 367 template <typename T> |
367 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 368 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
368 : CallbackBase( | 369 : CallbackBase( |
369 reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), | 370 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
370 &invoker_holder.invoker_storage_) { | 371 &invoker_holder.invoker_storage_) { |
371 } | 372 } |
372 | 373 |
373 R Run(const A1& a1, | 374 R Run(const A1& a1, |
374 const A2& a2, | 375 const A2& a2, |
375 const A3& a3, | 376 const A3& a3, |
376 const A4& a4) const { | 377 const A4& a4) const { |
377 PolymorphicInvoke f = | 378 PolymorphicInvoke f = |
378 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 379 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
379 | 380 |
(...skipping 19 matching lines...) Expand all Loading... |
399 // We pass InvokerStorageHolder by const ref to avoid incurring an | 400 // We pass InvokerStorageHolder by const ref to avoid incurring an |
400 // unnecessary AddRef/Unref pair even though we will modify the object. | 401 // unnecessary AddRef/Unref pair even though we will modify the object. |
401 // We cannot use a normal reference because the compiler will warn | 402 // We cannot use a normal reference because the compiler will warn |
402 // since this is often used on a return value, which is a temporary. | 403 // since this is often used on a return value, which is a temporary. |
403 // | 404 // |
404 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 405 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
405 // return the exact Callback<> type. See base/bind.h for details. | 406 // return the exact Callback<> type. See base/bind.h for details. |
406 template <typename T> | 407 template <typename T> |
407 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 408 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
408 : CallbackBase( | 409 : CallbackBase( |
409 reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), | 410 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
410 &invoker_holder.invoker_storage_) { | 411 &invoker_holder.invoker_storage_) { |
411 } | 412 } |
412 | 413 |
413 R Run(const A1& a1, | 414 R Run(const A1& a1, |
414 const A2& a2, | 415 const A2& a2, |
415 const A3& a3, | 416 const A3& a3, |
416 const A4& a4, | 417 const A4& a4, |
417 const A5& a5) const { | 418 const A5& a5) const { |
418 PolymorphicInvoke f = | 419 PolymorphicInvoke f = |
419 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 420 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
(...skipping 22 matching lines...) Expand all Loading... |
442 // We pass InvokerStorageHolder by const ref to avoid incurring an | 443 // We pass InvokerStorageHolder by const ref to avoid incurring an |
443 // unnecessary AddRef/Unref pair even though we will modify the object. | 444 // unnecessary AddRef/Unref pair even though we will modify the object. |
444 // We cannot use a normal reference because the compiler will warn | 445 // We cannot use a normal reference because the compiler will warn |
445 // since this is often used on a return value, which is a temporary. | 446 // since this is often used on a return value, which is a temporary. |
446 // | 447 // |
447 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 448 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
448 // return the exact Callback<> type. See base/bind.h for details. | 449 // return the exact Callback<> type. See base/bind.h for details. |
449 template <typename T> | 450 template <typename T> |
450 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 451 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
451 : CallbackBase( | 452 : CallbackBase( |
452 reinterpret_cast<InvokeFuncStorage>(&T::FunctionTraits::DoInvoke), | 453 reinterpret_cast<InvokeFuncStorage>(&T::Invoker::DoInvoke), |
453 &invoker_holder.invoker_storage_) { | 454 &invoker_holder.invoker_storage_) { |
454 } | 455 } |
455 | 456 |
456 R Run(const A1& a1, | 457 R Run(const A1& a1, |
457 const A2& a2, | 458 const A2& a2, |
458 const A3& a3, | 459 const A3& a3, |
459 const A4& a4, | 460 const A4& a4, |
460 const A5& a5, | 461 const A5& a5, |
461 const A6& a6) const { | 462 const A6& a6) const { |
462 PolymorphicInvoke f = | 463 PolymorphicInvoke f = |
463 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 464 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
464 | 465 |
465 return f(invoker_storage_.get(), a1, | 466 return f(invoker_storage_.get(), a1, |
466 a2, | 467 a2, |
467 a3, | 468 a3, |
468 a4, | 469 a4, |
469 a5, | 470 a5, |
470 a6); | 471 a6); |
471 } | 472 } |
472 }; | 473 }; |
473 | 474 |
474 | 475 |
475 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it | 476 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it |
476 // will be used in a lot of APIs with delayed execution. | 477 // will be used in a lot of APIs with delayed execution. |
477 typedef Callback<void(void)> Closure; | 478 typedef Callback<void(void)> Closure; |
478 | 479 |
479 } // namespace base | 480 } // namespace base |
480 | 481 |
481 #endif // BASE_CALLBACK_H | 482 #endif // BASE_CALLBACK_H |
OLD | NEW |