Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Side by Side Diff: webrtc/base/bind.h

Issue 1291543006: Update Bind to match its comments and always capture by value. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed android missed deref. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // This file was GENERATED by command: 1 // This file was GENERATED by command:
2 // pump.py bind.h.pump 2 // pump.py bind.h.pump
3 // DO NOT EDIT BY HAND!!! 3 // DO NOT EDIT BY HAND!!!
4 4
5 /* 5 /*
6 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 6 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
7 * 7 *
8 * Use of this source code is governed by a BSD-style license 8 * Use of this source code is governed by a BSD-style license
9 * that can be found in the LICENSE file in the root of the source 9 * that can be found in the LICENSE file in the root of the source
10 * tree. An additional intellectual property rights grant can be found 10 * tree. An additional intellectual property rights grant can be found
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // auto functor = rtc::Bind(&Bar::Test, bar); 57 // auto functor = rtc::Bind(&Bar::Test, bar);
58 // bar = nullptr; 58 // bar = nullptr;
59 // // The functor stores an internal scoped_refptr<Bar>, so this is safe. 59 // // The functor stores an internal scoped_refptr<Bar>, so this is safe.
60 // functor(); 60 // functor();
61 // } 61 // }
62 // 62 //
63 63
64 #ifndef WEBRTC_BASE_BIND_H_ 64 #ifndef WEBRTC_BASE_BIND_H_
65 #define WEBRTC_BASE_BIND_H_ 65 #define WEBRTC_BASE_BIND_H_
66 66
67 #include <ciso646> // Small include to detect c++ std lib.
68 #if defined(_LIBCPP_VERSION) || defined(_MSC_VER)
69 #include <type_traits>
70 #define STD_REMOVE_REFERENCE std::remove_reference
71 #else
72 #include <tr1/type_traits>
73 #define STD_REMOVE_REFERENCE std::tr1::remove_reference
74 #endif
75
67 #include "webrtc/base/scoped_ref_ptr.h" 76 #include "webrtc/base/scoped_ref_ptr.h"
68 77
69 #define NONAME 78 #define NONAME
70 79
71 namespace rtc { 80 namespace rtc {
72 namespace detail { 81 namespace detail {
73 // This is needed because the template parameters in Bind can't be resolved 82 // This is needed because the template parameters in Bind can't be resolved
74 // if they're used both as parameters of the function pointer type and as 83 // if they're used both as parameters of the function pointer type and as
75 // parameters to Bind itself: the function pointer parameters are exact 84 // parameters to Bind itself: the function pointer parameters are exact
76 // matches to the function prototype, but the parameters to bind have 85 // matches to the function prototype, but the parameters to bind have
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 130
122 // PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T* 131 // PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T*
123 // otherwise. 132 // otherwise.
124 template <class T> 133 template <class T>
125 struct PointerType { 134 struct PointerType {
126 typedef typename TernaryTypeOperator<IsRefCounted<T>::value, 135 typedef typename TernaryTypeOperator<IsRefCounted<T>::value,
127 scoped_refptr<T>, 136 scoped_refptr<T>,
128 T*>::type type; 137 T*>::type type;
129 }; 138 };
130 139
131 // RemoveScopedPtrRef will capture scoped_refptr by-value instead of 140 // RemoveAllRef will capture scoped_refptr by-value instead of
132 // by-reference. 141 // by-reference. It will additionally capture non-refptr T types by value.
133 template <class T> struct RemoveScopedPtrRef { typedef T type; };
134 template <class T> 142 template <class T>
135 struct RemoveScopedPtrRef<const scoped_refptr<T>&> { 143 struct RemoveAllRef {
144 typedef typename STD_REMOVE_REFERENCE<T>::type type;
145 };
146 template <class T>
147 struct RemoveAllRef<const scoped_refptr<T>&> {
136 typedef scoped_refptr<T> type; 148 typedef scoped_refptr<T> type;
137 }; 149 };
138 template <class T> 150 template <class T>
139 struct RemoveScopedPtrRef<scoped_refptr<T>&> { 151 struct RemoveAllRef<scoped_refptr<T>&> {
140 typedef scoped_refptr<T> type; 152 typedef scoped_refptr<T> type;
141 }; 153 };
142 154
143 } // namespace detail 155 } // namespace detail
144 156
145 template <class ObjectT, class MethodT, class R> 157 template <class ObjectT, class MethodT, class R>
146 class MethodFunctor0 { 158 class MethodFunctor0 {
147 public: 159 public:
148 MethodFunctor0(MethodT method, ObjectT* object) 160 MethodFunctor0(MethodT method, ObjectT* object)
149 : method_(method), object_(object) {} 161 : method_(method), object_(object) {}
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 public: 225 public:
214 MethodFunctor1(MethodT method, ObjectT* object, 226 MethodFunctor1(MethodT method, ObjectT* object,
215 P1 p1) 227 P1 p1)
216 : method_(method), object_(object), 228 : method_(method), object_(object),
217 p1_(p1) {} 229 p1_(p1) {}
218 R operator()() const { 230 R operator()() const {
219 return (object_->*method_)(p1_); } 231 return (object_->*method_)(p1_); }
220 private: 232 private:
221 MethodT method_; 233 MethodT method_;
222 typename detail::PointerType<ObjectT>::type object_; 234 typename detail::PointerType<ObjectT>::type object_;
223 typename detail::RemoveScopedPtrRef<P1>::type p1_; 235 typename detail::RemoveAllRef<P1>::type p1_;
224 }; 236 };
225 237
226 template <class FunctorT, class R, 238 template <class FunctorT, class R,
227 class P1> 239 class P1>
228 class Functor1 { 240 class Functor1 {
229 public: 241 public:
230 Functor1(const FunctorT& functor, P1 p1) 242 Functor1(const FunctorT& functor, P1 p1)
231 : functor_(functor), 243 : functor_(functor),
232 p1_(p1) {} 244 p1_(p1) {}
233 R operator()() const { 245 R operator()() const {
234 return functor_(p1_); } 246 return functor_(p1_); }
235 private: 247 private:
236 FunctorT functor_; 248 FunctorT functor_;
237 typename detail::RemoveScopedPtrRef<P1>::type p1_; 249 typename detail::RemoveAllRef<P1>::type p1_;
238 }; 250 };
239 251
240 252
241 #define FP_T(x) R (ObjectT::*x)(P1) 253 #define FP_T(x) R (ObjectT::*x)(P1)
242 254
243 template <class ObjectT, class R, 255 template <class ObjectT, class R,
244 class P1> 256 class P1>
245 MethodFunctor1<ObjectT, FP_T(NONAME), R, P1> 257 MethodFunctor1<ObjectT, FP_T(NONAME), R, P1>
246 Bind(FP_T(method), ObjectT* object, 258 Bind(FP_T(method), ObjectT* object,
247 typename detail::identity<P1>::type p1) { 259 typename detail::identity<P1>::type p1) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 P1 p1, 308 P1 p1,
297 P2 p2) 309 P2 p2)
298 : method_(method), object_(object), 310 : method_(method), object_(object),
299 p1_(p1), 311 p1_(p1),
300 p2_(p2) {} 312 p2_(p2) {}
301 R operator()() const { 313 R operator()() const {
302 return (object_->*method_)(p1_, p2_); } 314 return (object_->*method_)(p1_, p2_); }
303 private: 315 private:
304 MethodT method_; 316 MethodT method_;
305 typename detail::PointerType<ObjectT>::type object_; 317 typename detail::PointerType<ObjectT>::type object_;
306 typename detail::RemoveScopedPtrRef<P1>::type p1_; 318 typename detail::RemoveAllRef<P1>::type p1_;
307 typename detail::RemoveScopedPtrRef<P2>::type p2_; 319 typename detail::RemoveAllRef<P2>::type p2_;
308 }; 320 };
309 321
310 template <class FunctorT, class R, 322 template <class FunctorT, class R,
311 class P1, 323 class P1,
312 class P2> 324 class P2>
313 class Functor2 { 325 class Functor2 {
314 public: 326 public:
315 Functor2(const FunctorT& functor, P1 p1, P2 p2) 327 Functor2(const FunctorT& functor, P1 p1, P2 p2)
316 : functor_(functor), 328 : functor_(functor),
317 p1_(p1), 329 p1_(p1),
318 p2_(p2) {} 330 p2_(p2) {}
319 R operator()() const { 331 R operator()() const {
320 return functor_(p1_, p2_); } 332 return functor_(p1_, p2_); }
321 private: 333 private:
322 FunctorT functor_; 334 FunctorT functor_;
323 typename detail::RemoveScopedPtrRef<P1>::type p1_; 335 typename detail::RemoveAllRef<P1>::type p1_;
324 typename detail::RemoveScopedPtrRef<P2>::type p2_; 336 typename detail::RemoveAllRef<P2>::type p2_;
325 }; 337 };
326 338
327 339
328 #define FP_T(x) R (ObjectT::*x)(P1, P2) 340 #define FP_T(x) R (ObjectT::*x)(P1, P2)
329 341
330 template <class ObjectT, class R, 342 template <class ObjectT, class R,
331 class P1, 343 class P1,
332 class P2> 344 class P2>
333 MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2> 345 MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2>
334 Bind(FP_T(method), ObjectT* object, 346 Bind(FP_T(method), ObjectT* object,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 P3 p3) 406 P3 p3)
395 : method_(method), object_(object), 407 : method_(method), object_(object),
396 p1_(p1), 408 p1_(p1),
397 p2_(p2), 409 p2_(p2),
398 p3_(p3) {} 410 p3_(p3) {}
399 R operator()() const { 411 R operator()() const {
400 return (object_->*method_)(p1_, p2_, p3_); } 412 return (object_->*method_)(p1_, p2_, p3_); }
401 private: 413 private:
402 MethodT method_; 414 MethodT method_;
403 typename detail::PointerType<ObjectT>::type object_; 415 typename detail::PointerType<ObjectT>::type object_;
404 typename detail::RemoveScopedPtrRef<P1>::type p1_; 416 typename detail::RemoveAllRef<P1>::type p1_;
405 typename detail::RemoveScopedPtrRef<P2>::type p2_; 417 typename detail::RemoveAllRef<P2>::type p2_;
406 typename detail::RemoveScopedPtrRef<P3>::type p3_; 418 typename detail::RemoveAllRef<P3>::type p3_;
407 }; 419 };
408 420
409 template <class FunctorT, class R, 421 template <class FunctorT, class R,
410 class P1, 422 class P1,
411 class P2, 423 class P2,
412 class P3> 424 class P3>
413 class Functor3 { 425 class Functor3 {
414 public: 426 public:
415 Functor3(const FunctorT& functor, P1 p1, P2 p2, P3 p3) 427 Functor3(const FunctorT& functor, P1 p1, P2 p2, P3 p3)
416 : functor_(functor), 428 : functor_(functor),
417 p1_(p1), 429 p1_(p1),
418 p2_(p2), 430 p2_(p2),
419 p3_(p3) {} 431 p3_(p3) {}
420 R operator()() const { 432 R operator()() const {
421 return functor_(p1_, p2_, p3_); } 433 return functor_(p1_, p2_, p3_); }
422 private: 434 private:
423 FunctorT functor_; 435 FunctorT functor_;
424 typename detail::RemoveScopedPtrRef<P1>::type p1_; 436 typename detail::RemoveAllRef<P1>::type p1_;
425 typename detail::RemoveScopedPtrRef<P2>::type p2_; 437 typename detail::RemoveAllRef<P2>::type p2_;
426 typename detail::RemoveScopedPtrRef<P3>::type p3_; 438 typename detail::RemoveAllRef<P3>::type p3_;
427 }; 439 };
428 440
429 441
430 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3) 442 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3)
431 443
432 template <class ObjectT, class R, 444 template <class ObjectT, class R,
433 class P1, 445 class P1,
434 class P2, 446 class P2,
435 class P3> 447 class P3>
436 MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3> 448 MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 : method_(method), object_(object), 519 : method_(method), object_(object),
508 p1_(p1), 520 p1_(p1),
509 p2_(p2), 521 p2_(p2),
510 p3_(p3), 522 p3_(p3),
511 p4_(p4) {} 523 p4_(p4) {}
512 R operator()() const { 524 R operator()() const {
513 return (object_->*method_)(p1_, p2_, p3_, p4_); } 525 return (object_->*method_)(p1_, p2_, p3_, p4_); }
514 private: 526 private:
515 MethodT method_; 527 MethodT method_;
516 typename detail::PointerType<ObjectT>::type object_; 528 typename detail::PointerType<ObjectT>::type object_;
517 typename detail::RemoveScopedPtrRef<P1>::type p1_; 529 typename detail::RemoveAllRef<P1>::type p1_;
518 typename detail::RemoveScopedPtrRef<P2>::type p2_; 530 typename detail::RemoveAllRef<P2>::type p2_;
519 typename detail::RemoveScopedPtrRef<P3>::type p3_; 531 typename detail::RemoveAllRef<P3>::type p3_;
520 typename detail::RemoveScopedPtrRef<P4>::type p4_; 532 typename detail::RemoveAllRef<P4>::type p4_;
521 }; 533 };
522 534
523 template <class FunctorT, class R, 535 template <class FunctorT, class R,
524 class P1, 536 class P1,
525 class P2, 537 class P2,
526 class P3, 538 class P3,
527 class P4> 539 class P4>
528 class Functor4 { 540 class Functor4 {
529 public: 541 public:
530 Functor4(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4) 542 Functor4(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4)
531 : functor_(functor), 543 : functor_(functor),
532 p1_(p1), 544 p1_(p1),
533 p2_(p2), 545 p2_(p2),
534 p3_(p3), 546 p3_(p3),
535 p4_(p4) {} 547 p4_(p4) {}
536 R operator()() const { 548 R operator()() const {
537 return functor_(p1_, p2_, p3_, p4_); } 549 return functor_(p1_, p2_, p3_, p4_); }
538 private: 550 private:
539 FunctorT functor_; 551 FunctorT functor_;
540 typename detail::RemoveScopedPtrRef<P1>::type p1_; 552 typename detail::RemoveAllRef<P1>::type p1_;
541 typename detail::RemoveScopedPtrRef<P2>::type p2_; 553 typename detail::RemoveAllRef<P2>::type p2_;
542 typename detail::RemoveScopedPtrRef<P3>::type p3_; 554 typename detail::RemoveAllRef<P3>::type p3_;
543 typename detail::RemoveScopedPtrRef<P4>::type p4_; 555 typename detail::RemoveAllRef<P4>::type p4_;
544 }; 556 };
545 557
546 558
547 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4) 559 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4)
548 560
549 template <class ObjectT, class R, 561 template <class ObjectT, class R,
550 class P1, 562 class P1,
551 class P2, 563 class P2,
552 class P3, 564 class P3,
553 class P4> 565 class P4>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 p1_(p1), 647 p1_(p1),
636 p2_(p2), 648 p2_(p2),
637 p3_(p3), 649 p3_(p3),
638 p4_(p4), 650 p4_(p4),
639 p5_(p5) {} 651 p5_(p5) {}
640 R operator()() const { 652 R operator()() const {
641 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); } 653 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); }
642 private: 654 private:
643 MethodT method_; 655 MethodT method_;
644 typename detail::PointerType<ObjectT>::type object_; 656 typename detail::PointerType<ObjectT>::type object_;
645 typename detail::RemoveScopedPtrRef<P1>::type p1_; 657 typename detail::RemoveAllRef<P1>::type p1_;
646 typename detail::RemoveScopedPtrRef<P2>::type p2_; 658 typename detail::RemoveAllRef<P2>::type p2_;
647 typename detail::RemoveScopedPtrRef<P3>::type p3_; 659 typename detail::RemoveAllRef<P3>::type p3_;
648 typename detail::RemoveScopedPtrRef<P4>::type p4_; 660 typename detail::RemoveAllRef<P4>::type p4_;
649 typename detail::RemoveScopedPtrRef<P5>::type p5_; 661 typename detail::RemoveAllRef<P5>::type p5_;
650 }; 662 };
651 663
652 template <class FunctorT, class R, 664 template <class FunctorT, class R,
653 class P1, 665 class P1,
654 class P2, 666 class P2,
655 class P3, 667 class P3,
656 class P4, 668 class P4,
657 class P5> 669 class P5>
658 class Functor5 { 670 class Functor5 {
659 public: 671 public:
660 Functor5(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 672 Functor5(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
661 : functor_(functor), 673 : functor_(functor),
662 p1_(p1), 674 p1_(p1),
663 p2_(p2), 675 p2_(p2),
664 p3_(p3), 676 p3_(p3),
665 p4_(p4), 677 p4_(p4),
666 p5_(p5) {} 678 p5_(p5) {}
667 R operator()() const { 679 R operator()() const {
668 return functor_(p1_, p2_, p3_, p4_, p5_); } 680 return functor_(p1_, p2_, p3_, p4_, p5_); }
669 private: 681 private:
670 FunctorT functor_; 682 FunctorT functor_;
671 typename detail::RemoveScopedPtrRef<P1>::type p1_; 683 typename detail::RemoveAllRef<P1>::type p1_;
672 typename detail::RemoveScopedPtrRef<P2>::type p2_; 684 typename detail::RemoveAllRef<P2>::type p2_;
673 typename detail::RemoveScopedPtrRef<P3>::type p3_; 685 typename detail::RemoveAllRef<P3>::type p3_;
674 typename detail::RemoveScopedPtrRef<P4>::type p4_; 686 typename detail::RemoveAllRef<P4>::type p4_;
675 typename detail::RemoveScopedPtrRef<P5>::type p5_; 687 typename detail::RemoveAllRef<P5>::type p5_;
676 }; 688 };
677 689
678 690
679 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5) 691 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5)
680 692
681 template <class ObjectT, class R, 693 template <class ObjectT, class R,
682 class P1, 694 class P1,
683 class P2, 695 class P2,
684 class P3, 696 class P3,
685 class P4, 697 class P4,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 p2_(p2), 790 p2_(p2),
779 p3_(p3), 791 p3_(p3),
780 p4_(p4), 792 p4_(p4),
781 p5_(p5), 793 p5_(p5),
782 p6_(p6) {} 794 p6_(p6) {}
783 R operator()() const { 795 R operator()() const {
784 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); } 796 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); }
785 private: 797 private:
786 MethodT method_; 798 MethodT method_;
787 typename detail::PointerType<ObjectT>::type object_; 799 typename detail::PointerType<ObjectT>::type object_;
788 typename detail::RemoveScopedPtrRef<P1>::type p1_; 800 typename detail::RemoveAllRef<P1>::type p1_;
789 typename detail::RemoveScopedPtrRef<P2>::type p2_; 801 typename detail::RemoveAllRef<P2>::type p2_;
790 typename detail::RemoveScopedPtrRef<P3>::type p3_; 802 typename detail::RemoveAllRef<P3>::type p3_;
791 typename detail::RemoveScopedPtrRef<P4>::type p4_; 803 typename detail::RemoveAllRef<P4>::type p4_;
792 typename detail::RemoveScopedPtrRef<P5>::type p5_; 804 typename detail::RemoveAllRef<P5>::type p5_;
793 typename detail::RemoveScopedPtrRef<P6>::type p6_; 805 typename detail::RemoveAllRef<P6>::type p6_;
794 }; 806 };
795 807
796 template <class FunctorT, class R, 808 template <class FunctorT, class R,
797 class P1, 809 class P1,
798 class P2, 810 class P2,
799 class P3, 811 class P3,
800 class P4, 812 class P4,
801 class P5, 813 class P5,
802 class P6> 814 class P6>
803 class Functor6 { 815 class Functor6 {
804 public: 816 public:
805 Functor6(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) 817 Functor6(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
806 : functor_(functor), 818 : functor_(functor),
807 p1_(p1), 819 p1_(p1),
808 p2_(p2), 820 p2_(p2),
809 p3_(p3), 821 p3_(p3),
810 p4_(p4), 822 p4_(p4),
811 p5_(p5), 823 p5_(p5),
812 p6_(p6) {} 824 p6_(p6) {}
813 R operator()() const { 825 R operator()() const {
814 return functor_(p1_, p2_, p3_, p4_, p5_, p6_); } 826 return functor_(p1_, p2_, p3_, p4_, p5_, p6_); }
815 private: 827 private:
816 FunctorT functor_; 828 FunctorT functor_;
817 typename detail::RemoveScopedPtrRef<P1>::type p1_; 829 typename detail::RemoveAllRef<P1>::type p1_;
818 typename detail::RemoveScopedPtrRef<P2>::type p2_; 830 typename detail::RemoveAllRef<P2>::type p2_;
819 typename detail::RemoveScopedPtrRef<P3>::type p3_; 831 typename detail::RemoveAllRef<P3>::type p3_;
820 typename detail::RemoveScopedPtrRef<P4>::type p4_; 832 typename detail::RemoveAllRef<P4>::type p4_;
821 typename detail::RemoveScopedPtrRef<P5>::type p5_; 833 typename detail::RemoveAllRef<P5>::type p5_;
822 typename detail::RemoveScopedPtrRef<P6>::type p6_; 834 typename detail::RemoveAllRef<P6>::type p6_;
823 }; 835 };
824 836
825 837
826 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6) 838 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6)
827 839
828 template <class ObjectT, class R, 840 template <class ObjectT, class R,
829 class P1, 841 class P1,
830 class P2, 842 class P2,
831 class P3, 843 class P3,
832 class P4, 844 class P4,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 typename detail::identity<P3>::type p3, 917 typename detail::identity<P3>::type p3,
906 typename detail::identity<P4>::type p4, 918 typename detail::identity<P4>::type p4,
907 typename detail::identity<P5>::type p5, 919 typename detail::identity<P5>::type p5,
908 typename detail::identity<P6>::type p6) { 920 typename detail::identity<P6>::type p6) {
909 return Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( 921 return Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>(
910 function, p1, p2, p3, p4, p5, p6); 922 function, p1, p2, p3, p4, p5, p6);
911 } 923 }
912 924
913 #undef FP_T 925 #undef FP_T
914 926
927 template <class ObjectT, class MethodT, class R,
928 class P1,
929 class P2,
930 class P3,
931 class P4,
932 class P5,
933 class P6,
934 class P7>
935 class MethodFunctor7 {
936 public:
937 MethodFunctor7(MethodT method, ObjectT* object,
938 P1 p1,
939 P2 p2,
940 P3 p3,
941 P4 p4,
942 P5 p5,
943 P6 p6,
944 P7 p7)
945 : method_(method), object_(object),
946 p1_(p1),
947 p2_(p2),
948 p3_(p3),
949 p4_(p4),
950 p5_(p5),
951 p6_(p6),
952 p7_(p7) {}
953 R operator()() const {
954 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_, p7_); }
955 private:
956 MethodT method_;
957 typename detail::PointerType<ObjectT>::type object_;
958 typename detail::RemoveAllRef<P1>::type p1_;
959 typename detail::RemoveAllRef<P2>::type p2_;
960 typename detail::RemoveAllRef<P3>::type p3_;
961 typename detail::RemoveAllRef<P4>::type p4_;
962 typename detail::RemoveAllRef<P5>::type p5_;
963 typename detail::RemoveAllRef<P6>::type p6_;
964 typename detail::RemoveAllRef<P7>::type p7_;
965 };
966
967 template <class FunctorT, class R,
968 class P1,
969 class P2,
970 class P3,
971 class P4,
972 class P5,
973 class P6,
974 class P7>
975 class Functor7 {
976 public:
977 Functor7(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
978 P7 p7)
979 : functor_(functor),
980 p1_(p1),
981 p2_(p2),
982 p3_(p3),
983 p4_(p4),
984 p5_(p5),
985 p6_(p6),
986 p7_(p7) {}
987 R operator()() const {
988 return functor_(p1_, p2_, p3_, p4_, p5_, p6_, p7_); }
989 private:
990 FunctorT functor_;
991 typename detail::RemoveAllRef<P1>::type p1_;
992 typename detail::RemoveAllRef<P2>::type p2_;
993 typename detail::RemoveAllRef<P3>::type p3_;
994 typename detail::RemoveAllRef<P4>::type p4_;
995 typename detail::RemoveAllRef<P5>::type p5_;
996 typename detail::RemoveAllRef<P6>::type p6_;
997 typename detail::RemoveAllRef<P7>::type p7_;
998 };
999
1000
1001 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7)
1002
1003 template <class ObjectT, class R,
1004 class P1,
1005 class P2,
1006 class P3,
1007 class P4,
1008 class P5,
1009 class P6,
1010 class P7>
1011 MethodFunctor7<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>
1012 Bind(FP_T(method), ObjectT* object,
1013 typename detail::identity<P1>::type p1,
1014 typename detail::identity<P2>::type p2,
1015 typename detail::identity<P3>::type p3,
1016 typename detail::identity<P4>::type p4,
1017 typename detail::identity<P5>::type p5,
1018 typename detail::identity<P6>::type p6,
1019 typename detail::identity<P7>::type p7) {
1020 return MethodFunctor7<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>(
1021 method, object, p1, p2, p3, p4, p5, p6, p7);
1022 }
1023
1024 #undef FP_T
1025 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7) const
1026
1027 template <class ObjectT, class R,
1028 class P1,
1029 class P2,
1030 class P3,
1031 class P4,
1032 class P5,
1033 class P6,
1034 class P7>
1035 MethodFunctor7<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>
1036 Bind(FP_T(method), const ObjectT* object,
1037 typename detail::identity<P1>::type p1,
1038 typename detail::identity<P2>::type p2,
1039 typename detail::identity<P3>::type p3,
1040 typename detail::identity<P4>::type p4,
1041 typename detail::identity<P5>::type p5,
1042 typename detail::identity<P6>::type p6,
1043 typename detail::identity<P7>::type p7) {
1044 return MethodFunctor7<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6,
1045 P7>(
1046 method, object, p1, p2, p3, p4, p5, p6, p7);
1047 }
1048
1049 #undef FP_T
1050 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7)
1051
1052 template <class ObjectT, class R,
1053 class P1,
1054 class P2,
1055 class P3,
1056 class P4,
1057 class P5,
1058 class P6,
1059 class P7>
1060 MethodFunctor7<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>
1061 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
1062 typename detail::identity<P1>::type p1,
1063 typename detail::identity<P2>::type p2,
1064 typename detail::identity<P3>::type p3,
1065 typename detail::identity<P4>::type p4,
1066 typename detail::identity<P5>::type p5,
1067 typename detail::identity<P6>::type p6,
1068 typename detail::identity<P7>::type p7) {
1069 return MethodFunctor7<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>(
1070 method, object.get(), p1, p2, p3, p4, p5, p6, p7);
1071 }
1072
1073 #undef FP_T
1074 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6, P7)
1075
1076 template <class R,
1077 class P1,
1078 class P2,
1079 class P3,
1080 class P4,
1081 class P5,
1082 class P6,
1083 class P7>
1084 Functor7<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>
1085 Bind(FP_T(function),
1086 typename detail::identity<P1>::type p1,
1087 typename detail::identity<P2>::type p2,
1088 typename detail::identity<P3>::type p3,
1089 typename detail::identity<P4>::type p4,
1090 typename detail::identity<P5>::type p5,
1091 typename detail::identity<P6>::type p6,
1092 typename detail::identity<P7>::type p7) {
1093 return Functor7<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>(
1094 function, p1, p2, p3, p4, p5, p6, p7);
1095 }
1096
1097 #undef FP_T
1098
1099 template <class ObjectT, class MethodT, class R,
1100 class P1,
1101 class P2,
1102 class P3,
1103 class P4,
1104 class P5,
1105 class P6,
1106 class P7,
1107 class P8>
1108 class MethodFunctor8 {
1109 public:
1110 MethodFunctor8(MethodT method, ObjectT* object,
1111 P1 p1,
1112 P2 p2,
1113 P3 p3,
1114 P4 p4,
1115 P5 p5,
1116 P6 p6,
1117 P7 p7,
1118 P8 p8)
1119 : method_(method), object_(object),
1120 p1_(p1),
1121 p2_(p2),
1122 p3_(p3),
1123 p4_(p4),
1124 p5_(p5),
1125 p6_(p6),
1126 p7_(p7),
1127 p8_(p8) {}
1128 R operator()() const {
1129 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_); }
1130 private:
1131 MethodT method_;
1132 typename detail::PointerType<ObjectT>::type object_;
1133 typename detail::RemoveAllRef<P1>::type p1_;
1134 typename detail::RemoveAllRef<P2>::type p2_;
1135 typename detail::RemoveAllRef<P3>::type p3_;
1136 typename detail::RemoveAllRef<P4>::type p4_;
1137 typename detail::RemoveAllRef<P5>::type p5_;
1138 typename detail::RemoveAllRef<P6>::type p6_;
1139 typename detail::RemoveAllRef<P7>::type p7_;
1140 typename detail::RemoveAllRef<P8>::type p8_;
1141 };
1142
1143 template <class FunctorT, class R,
1144 class P1,
1145 class P2,
1146 class P3,
1147 class P4,
1148 class P5,
1149 class P6,
1150 class P7,
1151 class P8>
1152 class Functor8 {
1153 public:
1154 Functor8(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
1155 P7 p7, P8 p8)
1156 : functor_(functor),
1157 p1_(p1),
1158 p2_(p2),
1159 p3_(p3),
1160 p4_(p4),
1161 p5_(p5),
1162 p6_(p6),
1163 p7_(p7),
1164 p8_(p8) {}
1165 R operator()() const {
1166 return functor_(p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_); }
1167 private:
1168 FunctorT functor_;
1169 typename detail::RemoveAllRef<P1>::type p1_;
1170 typename detail::RemoveAllRef<P2>::type p2_;
1171 typename detail::RemoveAllRef<P3>::type p3_;
1172 typename detail::RemoveAllRef<P4>::type p4_;
1173 typename detail::RemoveAllRef<P5>::type p5_;
1174 typename detail::RemoveAllRef<P6>::type p6_;
1175 typename detail::RemoveAllRef<P7>::type p7_;
1176 typename detail::RemoveAllRef<P8>::type p8_;
1177 };
1178
1179
1180 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8)
1181
1182 template <class ObjectT, class R,
1183 class P1,
1184 class P2,
1185 class P3,
1186 class P4,
1187 class P5,
1188 class P6,
1189 class P7,
1190 class P8>
1191 MethodFunctor8<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8>
1192 Bind(FP_T(method), ObjectT* object,
1193 typename detail::identity<P1>::type p1,
1194 typename detail::identity<P2>::type p2,
1195 typename detail::identity<P3>::type p3,
1196 typename detail::identity<P4>::type p4,
1197 typename detail::identity<P5>::type p5,
1198 typename detail::identity<P6>::type p6,
1199 typename detail::identity<P7>::type p7,
1200 typename detail::identity<P8>::type p8) {
1201 return MethodFunctor8<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7,
1202 P8>(
1203 method, object, p1, p2, p3, p4, p5, p6, p7, p8);
1204 }
1205
1206 #undef FP_T
1207 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8) const
1208
1209 template <class ObjectT, class R,
1210 class P1,
1211 class P2,
1212 class P3,
1213 class P4,
1214 class P5,
1215 class P6,
1216 class P7,
1217 class P8>
1218 MethodFunctor8<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8>
1219 Bind(FP_T(method), const ObjectT* object,
1220 typename detail::identity<P1>::type p1,
1221 typename detail::identity<P2>::type p2,
1222 typename detail::identity<P3>::type p3,
1223 typename detail::identity<P4>::type p4,
1224 typename detail::identity<P5>::type p5,
1225 typename detail::identity<P6>::type p6,
1226 typename detail::identity<P7>::type p7,
1227 typename detail::identity<P8>::type p8) {
1228 return MethodFunctor8<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6,
1229 P7, P8>(
1230 method, object, p1, p2, p3, p4, p5, p6, p7, p8);
1231 }
1232
1233 #undef FP_T
1234 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8)
1235
1236 template <class ObjectT, class R,
1237 class P1,
1238 class P2,
1239 class P3,
1240 class P4,
1241 class P5,
1242 class P6,
1243 class P7,
1244 class P8>
1245 MethodFunctor8<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8>
1246 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
1247 typename detail::identity<P1>::type p1,
1248 typename detail::identity<P2>::type p2,
1249 typename detail::identity<P3>::type p3,
1250 typename detail::identity<P4>::type p4,
1251 typename detail::identity<P5>::type p5,
1252 typename detail::identity<P6>::type p6,
1253 typename detail::identity<P7>::type p7,
1254 typename detail::identity<P8>::type p8) {
1255 return MethodFunctor8<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7,
1256 P8>(
1257 method, object.get(), p1, p2, p3, p4, p5, p6, p7, p8);
1258 }
1259
1260 #undef FP_T
1261 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6, P7, P8)
1262
1263 template <class R,
1264 class P1,
1265 class P2,
1266 class P3,
1267 class P4,
1268 class P5,
1269 class P6,
1270 class P7,
1271 class P8>
1272 Functor8<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8>
1273 Bind(FP_T(function),
1274 typename detail::identity<P1>::type p1,
1275 typename detail::identity<P2>::type p2,
1276 typename detail::identity<P3>::type p3,
1277 typename detail::identity<P4>::type p4,
1278 typename detail::identity<P5>::type p5,
1279 typename detail::identity<P6>::type p6,
1280 typename detail::identity<P7>::type p7,
1281 typename detail::identity<P8>::type p8) {
1282 return Functor8<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8>(
1283 function, p1, p2, p3, p4, p5, p6, p7, p8);
1284 }
1285
1286 #undef FP_T
1287
1288 template <class ObjectT, class MethodT, class R,
1289 class P1,
1290 class P2,
1291 class P3,
1292 class P4,
1293 class P5,
1294 class P6,
1295 class P7,
1296 class P8,
1297 class P9>
1298 class MethodFunctor9 {
1299 public:
1300 MethodFunctor9(MethodT method, ObjectT* object,
1301 P1 p1,
1302 P2 p2,
1303 P3 p3,
1304 P4 p4,
1305 P5 p5,
1306 P6 p6,
1307 P7 p7,
1308 P8 p8,
1309 P9 p9)
1310 : method_(method), object_(object),
1311 p1_(p1),
1312 p2_(p2),
1313 p3_(p3),
1314 p4_(p4),
1315 p5_(p5),
1316 p6_(p6),
1317 p7_(p7),
1318 p8_(p8),
1319 p9_(p9) {}
1320 R operator()() const {
1321 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_, p9_); }
1322 private:
1323 MethodT method_;
1324 typename detail::PointerType<ObjectT>::type object_;
1325 typename detail::RemoveAllRef<P1>::type p1_;
1326 typename detail::RemoveAllRef<P2>::type p2_;
1327 typename detail::RemoveAllRef<P3>::type p3_;
1328 typename detail::RemoveAllRef<P4>::type p4_;
1329 typename detail::RemoveAllRef<P5>::type p5_;
1330 typename detail::RemoveAllRef<P6>::type p6_;
1331 typename detail::RemoveAllRef<P7>::type p7_;
1332 typename detail::RemoveAllRef<P8>::type p8_;
1333 typename detail::RemoveAllRef<P9>::type p9_;
1334 };
1335
1336 template <class FunctorT, class R,
1337 class P1,
1338 class P2,
1339 class P3,
1340 class P4,
1341 class P5,
1342 class P6,
1343 class P7,
1344 class P8,
1345 class P9>
1346 class Functor9 {
1347 public:
1348 Functor9(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,
1349 P7 p7, P8 p8, P9 p9)
1350 : functor_(functor),
1351 p1_(p1),
1352 p2_(p2),
1353 p3_(p3),
1354 p4_(p4),
1355 p5_(p5),
1356 p6_(p6),
1357 p7_(p7),
1358 p8_(p8),
1359 p9_(p9) {}
1360 R operator()() const {
1361 return functor_(p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_, p9_); }
1362 private:
1363 FunctorT functor_;
1364 typename detail::RemoveAllRef<P1>::type p1_;
1365 typename detail::RemoveAllRef<P2>::type p2_;
1366 typename detail::RemoveAllRef<P3>::type p3_;
1367 typename detail::RemoveAllRef<P4>::type p4_;
1368 typename detail::RemoveAllRef<P5>::type p5_;
1369 typename detail::RemoveAllRef<P6>::type p6_;
1370 typename detail::RemoveAllRef<P7>::type p7_;
1371 typename detail::RemoveAllRef<P8>::type p8_;
1372 typename detail::RemoveAllRef<P9>::type p9_;
1373 };
1374
1375
1376 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8, P9)
1377
1378 template <class ObjectT, class R,
1379 class P1,
1380 class P2,
1381 class P3,
1382 class P4,
1383 class P5,
1384 class P6,
1385 class P7,
1386 class P8,
1387 class P9>
1388 MethodFunctor9<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8, P9>
1389 Bind(FP_T(method), ObjectT* object,
1390 typename detail::identity<P1>::type p1,
1391 typename detail::identity<P2>::type p2,
1392 typename detail::identity<P3>::type p3,
1393 typename detail::identity<P4>::type p4,
1394 typename detail::identity<P5>::type p5,
1395 typename detail::identity<P6>::type p6,
1396 typename detail::identity<P7>::type p7,
1397 typename detail::identity<P8>::type p8,
1398 typename detail::identity<P9>::type p9) {
1399 return MethodFunctor9<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7,
1400 P8, P9>(
1401 method, object, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1402 }
1403
1404 #undef FP_T
1405 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8, P9) const
1406
1407 template <class ObjectT, class R,
1408 class P1,
1409 class P2,
1410 class P3,
1411 class P4,
1412 class P5,
1413 class P6,
1414 class P7,
1415 class P8,
1416 class P9>
1417 MethodFunctor9<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8,
1418 P9>
1419 Bind(FP_T(method), const ObjectT* object,
1420 typename detail::identity<P1>::type p1,
1421 typename detail::identity<P2>::type p2,
1422 typename detail::identity<P3>::type p3,
1423 typename detail::identity<P4>::type p4,
1424 typename detail::identity<P5>::type p5,
1425 typename detail::identity<P6>::type p6,
1426 typename detail::identity<P7>::type p7,
1427 typename detail::identity<P8>::type p8,
1428 typename detail::identity<P9>::type p9) {
1429 return MethodFunctor9<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6,
1430 P7, P8, P9>(
1431 method, object, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1432 }
1433
1434 #undef FP_T
1435 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8, P9)
1436
1437 template <class ObjectT, class R,
1438 class P1,
1439 class P2,
1440 class P3,
1441 class P4,
1442 class P5,
1443 class P6,
1444 class P7,
1445 class P8,
1446 class P9>
1447 MethodFunctor9<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8, P9>
1448 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
1449 typename detail::identity<P1>::type p1,
1450 typename detail::identity<P2>::type p2,
1451 typename detail::identity<P3>::type p3,
1452 typename detail::identity<P4>::type p4,
1453 typename detail::identity<P5>::type p5,
1454 typename detail::identity<P6>::type p6,
1455 typename detail::identity<P7>::type p7,
1456 typename detail::identity<P8>::type p8,
1457 typename detail::identity<P9>::type p9) {
1458 return MethodFunctor9<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7,
1459 P8, P9>(
1460 method, object.get(), p1, p2, p3, p4, p5, p6, p7, p8, p9);
1461 }
1462
1463 #undef FP_T
1464 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6, P7, P8, P9)
1465
1466 template <class R,
1467 class P1,
1468 class P2,
1469 class P3,
1470 class P4,
1471 class P5,
1472 class P6,
1473 class P7,
1474 class P8,
1475 class P9>
1476 Functor9<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8, P9>
1477 Bind(FP_T(function),
1478 typename detail::identity<P1>::type p1,
1479 typename detail::identity<P2>::type p2,
1480 typename detail::identity<P3>::type p3,
1481 typename detail::identity<P4>::type p4,
1482 typename detail::identity<P5>::type p5,
1483 typename detail::identity<P6>::type p6,
1484 typename detail::identity<P7>::type p7,
1485 typename detail::identity<P8>::type p8,
1486 typename detail::identity<P9>::type p9) {
1487 return Functor9<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8, P9>(
1488 function, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1489 }
1490
1491 #undef FP_T
1492
915 } // namespace rtc 1493 } // namespace rtc
916 1494
917 #undef NONAME 1495 #undef NONAME
918 1496
919 #endif // WEBRTC_BASE_BIND_H_ 1497 #endif // WEBRTC_BASE_BIND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698