OLD | NEW |
---|---|
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 |
11 * in the file PATENTS. All contributing project authors may | 11 * in the file PATENTS. All contributing project authors may |
12 * be found in the AUTHORS file in the root of the source tree. | 12 * be found in the AUTHORS file in the root of the source tree. |
13 */ | 13 */ |
14 | 14 |
15 // To generate bind.h from bind.h.pump, execute: | 15 // To generate bind.h from bind.h.pump, execute: |
16 // /home/build/google3/third_party/gtest/scripts/pump.py bind.h.pump | 16 // /home/build/google3/third_party/gtest/scripts/pump.py bind.h.pump |
17 | 17 |
18 // Bind() is an overloaded function that converts method calls into function | 18 // Bind() is an overloaded function that converts method calls into function |
19 // objects (aka functors). It captures any arguments to the method by value | 19 // objects (aka functors). The method object is captured as a scoped_refptr<> if |
20 // when Bind is called, producing a stateful, nullary function object. Care | 20 // the class inherits from RefCountInterface, and as a raw pointer otherwise. |
21 // should be taken about the lifetime of objects captured by Bind(); the | 21 // Any arguments to the method are captured by value. The return value of Bind |
22 // returned functor knows nothing about the lifetime of the method's object or | 22 // is a stateful, nullary function object. Care should be taken about the |
23 // any arguments passed by pointer, and calling the functor with a destroyed | 23 // lifetime of objects captured by Bind(); the returned functor knows nothing |
24 // object will surely do bad things. | 24 // about the lifetime of a non ref-counted method object or any arguments passed |
25 // by pointer, and calling the functor with a destroyed object will surely do | |
26 // bad things. | |
25 // | 27 // |
26 // Example usage: | 28 // Example usage: |
27 // struct Foo { | 29 // struct Foo { |
28 // int Test1() { return 42; } | 30 // int Test1() { return 42; } |
29 // int Test2() const { return 52; } | 31 // int Test2() const { return 52; } |
30 // int Test3(int x) { return x*x; } | 32 // int Test3(int x) { return x*x; } |
31 // float Test4(int x, float y) { return x + y; } | 33 // float Test4(int x, float y) { return x + y; } |
32 // }; | 34 // }; |
33 // | 35 // |
34 // int main() { | 36 // int main() { |
35 // Foo foo; | 37 // Foo foo; |
36 // cout << rtc::Bind(&Foo::Test1, &foo)() << endl; | 38 // cout << rtc::Bind(&Foo::Test1, &foo)() << endl; |
37 // cout << rtc::Bind(&Foo::Test2, &foo)() << endl; | 39 // cout << rtc::Bind(&Foo::Test2, &foo)() << endl; |
38 // cout << rtc::Bind(&Foo::Test3, &foo, 3)() << endl; | 40 // cout << rtc::Bind(&Foo::Test3, &foo, 3)() << endl; |
39 // cout << rtc::Bind(&Foo::Test4, &foo, 7, 8.5f)() << endl; | 41 // cout << rtc::Bind(&Foo::Test4, &foo, 7, 8.5f)() << endl; |
40 // } | 42 // } |
43 // | |
44 // Example usage for ref counted objects: | |
45 // struct Bar : public rtc::RefCountInterface { | |
46 // void Test() {} | |
47 // void BindThis() { | |
48 // // The functor passed to AsyncInvoke() will keep this object alive. | |
49 // invoker.AsyncInvoke(rtc::Bind(&Bar::Test, this)); | |
50 // } | |
51 // }; | |
52 // | |
53 // int main() { | |
54 // rtc::scoped_refptr<Bar> bar = new rtc::RefCountedObject<Bar>(); | |
55 // auto functor = rtc::Bind(&Bar::Test, bar); | |
56 // bar = nullptr; | |
57 // // The functor stores an internal scoped_refptr<Bar>, so this is safe. | |
58 // functor(); | |
59 // } | |
60 // | |
41 | 61 |
42 #ifndef WEBRTC_BASE_BIND_H_ | 62 #ifndef WEBRTC_BASE_BIND_H_ |
43 #define WEBRTC_BASE_BIND_H_ | 63 #define WEBRTC_BASE_BIND_H_ |
44 | 64 |
65 #include "webrtc/base/refcount.h" | |
66 #include "webrtc/base/scoped_ref_ptr.h" | |
67 #include "webrtc/base/template_util.h" | |
68 | |
45 #define NONAME | 69 #define NONAME |
46 | 70 |
47 namespace rtc { | 71 namespace rtc { |
48 namespace detail { | 72 namespace detail { |
49 // This is needed because the template parameters in Bind can't be resolved | 73 // This is needed because the template parameters in Bind can't be resolved |
50 // if they're used both as parameters of the function pointer type and as | 74 // if they're used both as parameters of the function pointer type and as |
51 // parameters to Bind itself: the function pointer parameters are exact | 75 // parameters to Bind itself: the function pointer parameters are exact |
52 // matches to the function prototype, but the parameters to bind have | 76 // matches to the function prototype, but the parameters to bind have |
53 // references stripped. This trick allows the compiler to dictate the Bind | 77 // references stripped. This trick allows the compiler to dictate the Bind |
54 // parameter types rather than deduce them. | 78 // parameter types rather than deduce them. |
55 template <class T> struct identity { typedef T type; }; | 79 template <class T> struct identity { typedef T type; }; |
80 | |
81 // IsRefCounted<T>::value is a static bool that represents if T implements | |
82 // RefCountInterface. rtc::is_convertible<> does the heavy lifting. It is a | |
83 // substitute for C++11 std::is_convertible<>. | |
84 template <class T> | |
85 struct IsRefCounted { | |
86 static const bool value = is_convertible<T*, RefCountInterface*>::value; | |
tommi (sloooow) - chröme
2015/08/19 13:13:32
is there a way to detect presence of an AddRef() m
| |
87 }; | |
88 | |
89 // TernaryTypeOperator is a helper class to select a type based on a static bool | |
90 // value. | |
91 template <bool condition, typename IfTrueT, typename IfFalseT> | |
92 struct TernaryTypeOperator {}; | |
93 | |
94 template <typename IfTrueT, typename IfFalseT> | |
95 struct TernaryTypeOperator<true, IfTrueT, IfFalseT> { | |
96 typedef IfTrueT type; | |
97 }; | |
98 | |
99 template <typename IfTrueT, typename IfFalseT> | |
100 struct TernaryTypeOperator<false, IfTrueT, IfFalseT> { | |
101 typedef IfFalseT type; | |
102 }; | |
103 | |
104 // PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T* | |
105 // otherwise. | |
106 template <class T> | |
107 struct PointerType { | |
108 typedef typename TernaryTypeOperator<IsRefCounted<T>::value, | |
109 scoped_refptr<T>, | |
110 T*>::type type; | |
111 }; | |
112 | |
56 } // namespace detail | 113 } // namespace detail |
57 | 114 |
58 template <class ObjectT, class MethodT, class R> | 115 template <class ObjectT, class MethodT, class R> |
59 class MethodFunctor0 { | 116 class MethodFunctor0 { |
60 public: | 117 public: |
61 MethodFunctor0(MethodT method, ObjectT* object) | 118 MethodFunctor0(MethodT method, ObjectT* object) |
62 : method_(method), object_(object) {} | 119 : method_(method), object_(object) {} |
63 R operator()() const { | 120 R operator()() const { |
64 return (object_->*method_)(); } | 121 return (object_->*method_)(); } |
65 private: | 122 private: |
66 MethodT method_; | 123 MethodT method_; |
67 ObjectT* object_; | 124 typename detail::PointerType<ObjectT>::type object_; |
68 }; | 125 }; |
69 | 126 |
70 template <class FunctorT, class R> | 127 template <class FunctorT, class R> |
71 class Functor0 { | 128 class Functor0 { |
72 public: | 129 public: |
73 explicit Functor0(const FunctorT& functor) | 130 explicit Functor0(const FunctorT& functor) |
74 : functor_(functor) {} | 131 : functor_(functor) {} |
75 R operator()() const { | 132 R operator()() const { |
76 return functor_(); } | 133 return functor_(); } |
77 private: | 134 private: |
(...skipping 14 matching lines...) Expand all Loading... | |
92 #define FP_T(x) R (ObjectT::*x)() const | 149 #define FP_T(x) R (ObjectT::*x)() const |
93 | 150 |
94 template <class ObjectT, class R> | 151 template <class ObjectT, class R> |
95 MethodFunctor0<const ObjectT, FP_T(NONAME), R> | 152 MethodFunctor0<const ObjectT, FP_T(NONAME), R> |
96 Bind(FP_T(method), const ObjectT* object) { | 153 Bind(FP_T(method), const ObjectT* object) { |
97 return MethodFunctor0<const ObjectT, FP_T(NONAME), R>( | 154 return MethodFunctor0<const ObjectT, FP_T(NONAME), R>( |
98 method, object); | 155 method, object); |
99 } | 156 } |
100 | 157 |
101 #undef FP_T | 158 #undef FP_T |
159 #define FP_T(x) R (ObjectT::*x)() | |
160 | |
161 template <class ObjectT, class R> | |
162 MethodFunctor0<ObjectT, FP_T(NONAME), R> | |
163 Bind(FP_T(method), const scoped_refptr<ObjectT>& object) { | |
164 return MethodFunctor0<ObjectT, FP_T(NONAME), R>( | |
165 method, object.get()); | |
166 } | |
167 | |
168 #undef FP_T | |
102 #define FP_T(x) R (*x)() | 169 #define FP_T(x) R (*x)() |
103 | 170 |
104 template <class R> | 171 template <class R> |
105 Functor0<FP_T(NONAME), R> | 172 Functor0<FP_T(NONAME), R> |
106 Bind(FP_T(function)) { | 173 Bind(FP_T(function)) { |
107 return Functor0<FP_T(NONAME), R>( | 174 return Functor0<FP_T(NONAME), R>( |
108 function); | 175 function); |
109 } | 176 } |
110 | 177 |
111 #undef FP_T | 178 #undef FP_T |
112 | 179 |
113 template <class ObjectT, class MethodT, class R, | 180 template <class ObjectT, class MethodT, class R, |
114 class P1> | 181 class P1> |
115 class MethodFunctor1 { | 182 class MethodFunctor1 { |
116 public: | 183 public: |
117 MethodFunctor1(MethodT method, ObjectT* object, | 184 MethodFunctor1(MethodT method, ObjectT* object, |
118 P1 p1) | 185 P1 p1) |
119 : method_(method), object_(object), | 186 : method_(method), object_(object), |
120 p1_(p1) {} | 187 p1_(p1) {} |
121 R operator()() const { | 188 R operator()() const { |
122 return (object_->*method_)(p1_); } | 189 return (object_->*method_)(p1_); } |
123 private: | 190 private: |
124 MethodT method_; | 191 MethodT method_; |
125 ObjectT* object_; | 192 typename detail::PointerType<ObjectT>::type object_; |
126 P1 p1_; | 193 P1 p1_; |
127 }; | 194 }; |
128 | 195 |
129 template <class FunctorT, class R, | 196 template <class FunctorT, class R, |
130 class P1> | 197 class P1> |
131 class Functor1 { | 198 class Functor1 { |
132 public: | 199 public: |
133 Functor1(const FunctorT& functor, P1 p1) | 200 Functor1(const FunctorT& functor, P1 p1) |
134 : functor_(functor), | 201 : functor_(functor), |
135 p1_(p1) {} | 202 p1_(p1) {} |
(...skipping 22 matching lines...) Expand all Loading... | |
158 template <class ObjectT, class R, | 225 template <class ObjectT, class R, |
159 class P1> | 226 class P1> |
160 MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1> | 227 MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1> |
161 Bind(FP_T(method), const ObjectT* object, | 228 Bind(FP_T(method), const ObjectT* object, |
162 typename detail::identity<P1>::type p1) { | 229 typename detail::identity<P1>::type p1) { |
163 return MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1>( | 230 return MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1>( |
164 method, object, p1); | 231 method, object, p1); |
165 } | 232 } |
166 | 233 |
167 #undef FP_T | 234 #undef FP_T |
235 #define FP_T(x) R (ObjectT::*x)(P1) | |
236 | |
237 template <class ObjectT, class R, | |
238 class P1> | |
239 MethodFunctor1<ObjectT, FP_T(NONAME), R, P1> | |
240 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
241 typename detail::identity<P1>::type p1) { | |
242 return MethodFunctor1<ObjectT, FP_T(NONAME), R, P1>( | |
243 method, object.get(), p1); | |
244 } | |
245 | |
246 #undef FP_T | |
168 #define FP_T(x) R (*x)(P1) | 247 #define FP_T(x) R (*x)(P1) |
169 | 248 |
170 template <class R, | 249 template <class R, |
171 class P1> | 250 class P1> |
172 Functor1<FP_T(NONAME), R, P1> | 251 Functor1<FP_T(NONAME), R, P1> |
173 Bind(FP_T(function), | 252 Bind(FP_T(function), |
174 typename detail::identity<P1>::type p1) { | 253 typename detail::identity<P1>::type p1) { |
175 return Functor1<FP_T(NONAME), R, P1>( | 254 return Functor1<FP_T(NONAME), R, P1>( |
176 function, p1); | 255 function, p1); |
177 } | 256 } |
178 | 257 |
179 #undef FP_T | 258 #undef FP_T |
180 | 259 |
181 template <class ObjectT, class MethodT, class R, | 260 template <class ObjectT, class MethodT, class R, |
182 class P1, | 261 class P1, |
183 class P2> | 262 class P2> |
184 class MethodFunctor2 { | 263 class MethodFunctor2 { |
185 public: | 264 public: |
186 MethodFunctor2(MethodT method, ObjectT* object, | 265 MethodFunctor2(MethodT method, ObjectT* object, |
187 P1 p1, | 266 P1 p1, |
188 P2 p2) | 267 P2 p2) |
189 : method_(method), object_(object), | 268 : method_(method), object_(object), |
190 p1_(p1), | 269 p1_(p1), |
191 p2_(p2) {} | 270 p2_(p2) {} |
192 R operator()() const { | 271 R operator()() const { |
193 return (object_->*method_)(p1_, p2_); } | 272 return (object_->*method_)(p1_, p2_); } |
194 private: | 273 private: |
195 MethodT method_; | 274 MethodT method_; |
196 ObjectT* object_; | 275 typename detail::PointerType<ObjectT>::type object_; |
197 P1 p1_; | 276 P1 p1_; |
198 P2 p2_; | 277 P2 p2_; |
199 }; | 278 }; |
200 | 279 |
201 template <class FunctorT, class R, | 280 template <class FunctorT, class R, |
202 class P1, | 281 class P1, |
203 class P2> | 282 class P2> |
204 class Functor2 { | 283 class Functor2 { |
205 public: | 284 public: |
206 Functor2(const FunctorT& functor, P1 p1, P2 p2) | 285 Functor2(const FunctorT& functor, P1 p1, P2 p2) |
(...skipping 30 matching lines...) Expand all Loading... | |
237 class P2> | 316 class P2> |
238 MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2> | 317 MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2> |
239 Bind(FP_T(method), const ObjectT* object, | 318 Bind(FP_T(method), const ObjectT* object, |
240 typename detail::identity<P1>::type p1, | 319 typename detail::identity<P1>::type p1, |
241 typename detail::identity<P2>::type p2) { | 320 typename detail::identity<P2>::type p2) { |
242 return MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2>( | 321 return MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2>( |
243 method, object, p1, p2); | 322 method, object, p1, p2); |
244 } | 323 } |
245 | 324 |
246 #undef FP_T | 325 #undef FP_T |
326 #define FP_T(x) R (ObjectT::*x)(P1, P2) | |
327 | |
328 template <class ObjectT, class R, | |
329 class P1, | |
330 class P2> | |
331 MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2> | |
332 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
333 typename detail::identity<P1>::type p1, | |
334 typename detail::identity<P2>::type p2) { | |
335 return MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2>( | |
336 method, object.get(), p1, p2); | |
337 } | |
338 | |
339 #undef FP_T | |
247 #define FP_T(x) R (*x)(P1, P2) | 340 #define FP_T(x) R (*x)(P1, P2) |
248 | 341 |
249 template <class R, | 342 template <class R, |
250 class P1, | 343 class P1, |
251 class P2> | 344 class P2> |
252 Functor2<FP_T(NONAME), R, P1, P2> | 345 Functor2<FP_T(NONAME), R, P1, P2> |
253 Bind(FP_T(function), | 346 Bind(FP_T(function), |
254 typename detail::identity<P1>::type p1, | 347 typename detail::identity<P1>::type p1, |
255 typename detail::identity<P2>::type p2) { | 348 typename detail::identity<P2>::type p2) { |
256 return Functor2<FP_T(NONAME), R, P1, P2>( | 349 return Functor2<FP_T(NONAME), R, P1, P2>( |
(...skipping 13 matching lines...) Expand all Loading... | |
270 P2 p2, | 363 P2 p2, |
271 P3 p3) | 364 P3 p3) |
272 : method_(method), object_(object), | 365 : method_(method), object_(object), |
273 p1_(p1), | 366 p1_(p1), |
274 p2_(p2), | 367 p2_(p2), |
275 p3_(p3) {} | 368 p3_(p3) {} |
276 R operator()() const { | 369 R operator()() const { |
277 return (object_->*method_)(p1_, p2_, p3_); } | 370 return (object_->*method_)(p1_, p2_, p3_); } |
278 private: | 371 private: |
279 MethodT method_; | 372 MethodT method_; |
280 ObjectT* object_; | 373 typename detail::PointerType<ObjectT>::type object_; |
281 P1 p1_; | 374 P1 p1_; |
282 P2 p2_; | 375 P2 p2_; |
283 P3 p3_; | 376 P3 p3_; |
284 }; | 377 }; |
285 | 378 |
286 template <class FunctorT, class R, | 379 template <class FunctorT, class R, |
287 class P1, | 380 class P1, |
288 class P2, | 381 class P2, |
289 class P3> | 382 class P3> |
290 class Functor3 { | 383 class Functor3 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3> | 422 MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3> |
330 Bind(FP_T(method), const ObjectT* object, | 423 Bind(FP_T(method), const ObjectT* object, |
331 typename detail::identity<P1>::type p1, | 424 typename detail::identity<P1>::type p1, |
332 typename detail::identity<P2>::type p2, | 425 typename detail::identity<P2>::type p2, |
333 typename detail::identity<P3>::type p3) { | 426 typename detail::identity<P3>::type p3) { |
334 return MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3>( | 427 return MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3>( |
335 method, object, p1, p2, p3); | 428 method, object, p1, p2, p3); |
336 } | 429 } |
337 | 430 |
338 #undef FP_T | 431 #undef FP_T |
432 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3) | |
433 | |
434 template <class ObjectT, class R, | |
435 class P1, | |
436 class P2, | |
437 class P3> | |
438 MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3> | |
439 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
440 typename detail::identity<P1>::type p1, | |
441 typename detail::identity<P2>::type p2, | |
442 typename detail::identity<P3>::type p3) { | |
443 return MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3>( | |
444 method, object.get(), p1, p2, p3); | |
445 } | |
446 | |
447 #undef FP_T | |
339 #define FP_T(x) R (*x)(P1, P2, P3) | 448 #define FP_T(x) R (*x)(P1, P2, P3) |
340 | 449 |
341 template <class R, | 450 template <class R, |
342 class P1, | 451 class P1, |
343 class P2, | 452 class P2, |
344 class P3> | 453 class P3> |
345 Functor3<FP_T(NONAME), R, P1, P2, P3> | 454 Functor3<FP_T(NONAME), R, P1, P2, P3> |
346 Bind(FP_T(function), | 455 Bind(FP_T(function), |
347 typename detail::identity<P1>::type p1, | 456 typename detail::identity<P1>::type p1, |
348 typename detail::identity<P2>::type p2, | 457 typename detail::identity<P2>::type p2, |
(...skipping 18 matching lines...) Expand all Loading... | |
367 P4 p4) | 476 P4 p4) |
368 : method_(method), object_(object), | 477 : method_(method), object_(object), |
369 p1_(p1), | 478 p1_(p1), |
370 p2_(p2), | 479 p2_(p2), |
371 p3_(p3), | 480 p3_(p3), |
372 p4_(p4) {} | 481 p4_(p4) {} |
373 R operator()() const { | 482 R operator()() const { |
374 return (object_->*method_)(p1_, p2_, p3_, p4_); } | 483 return (object_->*method_)(p1_, p2_, p3_, p4_); } |
375 private: | 484 private: |
376 MethodT method_; | 485 MethodT method_; |
377 ObjectT* object_; | 486 typename detail::PointerType<ObjectT>::type object_; |
378 P1 p1_; | 487 P1 p1_; |
379 P2 p2_; | 488 P2 p2_; |
380 P3 p3_; | 489 P3 p3_; |
381 P4 p4_; | 490 P4 p4_; |
382 }; | 491 }; |
383 | 492 |
384 template <class FunctorT, class R, | 493 template <class FunctorT, class R, |
385 class P1, | 494 class P1, |
386 class P2, | 495 class P2, |
387 class P3, | 496 class P3, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 Bind(FP_T(method), const ObjectT* object, | 543 Bind(FP_T(method), const ObjectT* object, |
435 typename detail::identity<P1>::type p1, | 544 typename detail::identity<P1>::type p1, |
436 typename detail::identity<P2>::type p2, | 545 typename detail::identity<P2>::type p2, |
437 typename detail::identity<P3>::type p3, | 546 typename detail::identity<P3>::type p3, |
438 typename detail::identity<P4>::type p4) { | 547 typename detail::identity<P4>::type p4) { |
439 return MethodFunctor4<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>( | 548 return MethodFunctor4<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>( |
440 method, object, p1, p2, p3, p4); | 549 method, object, p1, p2, p3, p4); |
441 } | 550 } |
442 | 551 |
443 #undef FP_T | 552 #undef FP_T |
553 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4) | |
554 | |
555 template <class ObjectT, class R, | |
556 class P1, | |
557 class P2, | |
558 class P3, | |
559 class P4> | |
560 MethodFunctor4<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4> | |
561 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
562 typename detail::identity<P1>::type p1, | |
563 typename detail::identity<P2>::type p2, | |
564 typename detail::identity<P3>::type p3, | |
565 typename detail::identity<P4>::type p4) { | |
566 return MethodFunctor4<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>( | |
567 method, object.get(), p1, p2, p3, p4); | |
568 } | |
569 | |
570 #undef FP_T | |
444 #define FP_T(x) R (*x)(P1, P2, P3, P4) | 571 #define FP_T(x) R (*x)(P1, P2, P3, P4) |
445 | 572 |
446 template <class R, | 573 template <class R, |
447 class P1, | 574 class P1, |
448 class P2, | 575 class P2, |
449 class P3, | 576 class P3, |
450 class P4> | 577 class P4> |
451 Functor4<FP_T(NONAME), R, P1, P2, P3, P4> | 578 Functor4<FP_T(NONAME), R, P1, P2, P3, P4> |
452 Bind(FP_T(function), | 579 Bind(FP_T(function), |
453 typename detail::identity<P1>::type p1, | 580 typename detail::identity<P1>::type p1, |
(...skipping 23 matching lines...) Expand all Loading... | |
477 : method_(method), object_(object), | 604 : method_(method), object_(object), |
478 p1_(p1), | 605 p1_(p1), |
479 p2_(p2), | 606 p2_(p2), |
480 p3_(p3), | 607 p3_(p3), |
481 p4_(p4), | 608 p4_(p4), |
482 p5_(p5) {} | 609 p5_(p5) {} |
483 R operator()() const { | 610 R operator()() const { |
484 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); } | 611 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); } |
485 private: | 612 private: |
486 MethodT method_; | 613 MethodT method_; |
487 ObjectT* object_; | 614 typename detail::PointerType<ObjectT>::type object_; |
488 P1 p1_; | 615 P1 p1_; |
489 P2 p2_; | 616 P2 p2_; |
490 P3 p3_; | 617 P3 p3_; |
491 P4 p4_; | 618 P4 p4_; |
492 P5 p5_; | 619 P5 p5_; |
493 }; | 620 }; |
494 | 621 |
495 template <class FunctorT, class R, | 622 template <class FunctorT, class R, |
496 class P1, | 623 class P1, |
497 class P2, | 624 class P2, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 typename detail::identity<P1>::type p1, | 679 typename detail::identity<P1>::type p1, |
553 typename detail::identity<P2>::type p2, | 680 typename detail::identity<P2>::type p2, |
554 typename detail::identity<P3>::type p3, | 681 typename detail::identity<P3>::type p3, |
555 typename detail::identity<P4>::type p4, | 682 typename detail::identity<P4>::type p4, |
556 typename detail::identity<P5>::type p5) { | 683 typename detail::identity<P5>::type p5) { |
557 return MethodFunctor5<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>( | 684 return MethodFunctor5<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>( |
558 method, object, p1, p2, p3, p4, p5); | 685 method, object, p1, p2, p3, p4, p5); |
559 } | 686 } |
560 | 687 |
561 #undef FP_T | 688 #undef FP_T |
689 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5) | |
690 | |
691 template <class ObjectT, class R, | |
692 class P1, | |
693 class P2, | |
694 class P3, | |
695 class P4, | |
696 class P5> | |
697 MethodFunctor5<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5> | |
698 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
699 typename detail::identity<P1>::type p1, | |
700 typename detail::identity<P2>::type p2, | |
701 typename detail::identity<P3>::type p3, | |
702 typename detail::identity<P4>::type p4, | |
703 typename detail::identity<P5>::type p5) { | |
704 return MethodFunctor5<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>( | |
705 method, object.get(), p1, p2, p3, p4, p5); | |
706 } | |
707 | |
708 #undef FP_T | |
562 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5) | 709 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5) |
563 | 710 |
564 template <class R, | 711 template <class R, |
565 class P1, | 712 class P1, |
566 class P2, | 713 class P2, |
567 class P3, | 714 class P3, |
568 class P4, | 715 class P4, |
569 class P5> | 716 class P5> |
570 Functor5<FP_T(NONAME), R, P1, P2, P3, P4, P5> | 717 Functor5<FP_T(NONAME), R, P1, P2, P3, P4, P5> |
571 Bind(FP_T(function), | 718 Bind(FP_T(function), |
(...skipping 28 matching lines...) Expand all Loading... | |
600 p1_(p1), | 747 p1_(p1), |
601 p2_(p2), | 748 p2_(p2), |
602 p3_(p3), | 749 p3_(p3), |
603 p4_(p4), | 750 p4_(p4), |
604 p5_(p5), | 751 p5_(p5), |
605 p6_(p6) {} | 752 p6_(p6) {} |
606 R operator()() const { | 753 R operator()() const { |
607 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); } | 754 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); } |
608 private: | 755 private: |
609 MethodT method_; | 756 MethodT method_; |
610 ObjectT* object_; | 757 typename detail::PointerType<ObjectT>::type object_; |
611 P1 p1_; | 758 P1 p1_; |
612 P2 p2_; | 759 P2 p2_; |
613 P3 p3_; | 760 P3 p3_; |
614 P4 p4_; | 761 P4 p4_; |
615 P5 p5_; | 762 P5 p5_; |
616 P6 p6_; | 763 P6 p6_; |
617 }; | 764 }; |
618 | 765 |
619 template <class FunctorT, class R, | 766 template <class FunctorT, class R, |
620 class P1, | 767 class P1, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 typename detail::identity<P2>::type p2, | 830 typename detail::identity<P2>::type p2, |
684 typename detail::identity<P3>::type p3, | 831 typename detail::identity<P3>::type p3, |
685 typename detail::identity<P4>::type p4, | 832 typename detail::identity<P4>::type p4, |
686 typename detail::identity<P5>::type p5, | 833 typename detail::identity<P5>::type p5, |
687 typename detail::identity<P6>::type p6) { | 834 typename detail::identity<P6>::type p6) { |
688 return MethodFunctor6<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( | 835 return MethodFunctor6<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( |
689 method, object, p1, p2, p3, p4, p5, p6); | 836 method, object, p1, p2, p3, p4, p5, p6); |
690 } | 837 } |
691 | 838 |
692 #undef FP_T | 839 #undef FP_T |
840 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6) | |
841 | |
842 template <class ObjectT, class R, | |
843 class P1, | |
844 class P2, | |
845 class P3, | |
846 class P4, | |
847 class P5, | |
848 class P6> | |
849 MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> | |
850 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
851 typename detail::identity<P1>::type p1, | |
852 typename detail::identity<P2>::type p2, | |
853 typename detail::identity<P3>::type p3, | |
854 typename detail::identity<P4>::type p4, | |
855 typename detail::identity<P5>::type p5, | |
856 typename detail::identity<P6>::type p6) { | |
857 return MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( | |
858 method, object.get(), p1, p2, p3, p4, p5, p6); | |
859 } | |
860 | |
861 #undef FP_T | |
693 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6) | 862 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6) |
694 | 863 |
695 template <class R, | 864 template <class R, |
696 class P1, | 865 class P1, |
697 class P2, | 866 class P2, |
698 class P3, | 867 class P3, |
699 class P4, | 868 class P4, |
700 class P5, | 869 class P5, |
701 class P6> | 870 class P6> |
702 Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> | 871 Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> |
703 Bind(FP_T(function), | 872 Bind(FP_T(function), |
704 typename detail::identity<P1>::type p1, | 873 typename detail::identity<P1>::type p1, |
705 typename detail::identity<P2>::type p2, | 874 typename detail::identity<P2>::type p2, |
706 typename detail::identity<P3>::type p3, | 875 typename detail::identity<P3>::type p3, |
707 typename detail::identity<P4>::type p4, | 876 typename detail::identity<P4>::type p4, |
708 typename detail::identity<P5>::type p5, | 877 typename detail::identity<P5>::type p5, |
709 typename detail::identity<P6>::type p6) { | 878 typename detail::identity<P6>::type p6) { |
710 return Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( | 879 return Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( |
711 function, p1, p2, p3, p4, p5, p6); | 880 function, p1, p2, p3, p4, p5, p6); |
712 } | 881 } |
713 | 882 |
714 #undef FP_T | 883 #undef FP_T |
715 | 884 |
716 } // namespace rtc | 885 } // namespace rtc |
717 | 886 |
718 #undef NONAME | 887 #undef NONAME |
719 | 888 |
720 #endif // WEBRTC_BASE_BIND_H_ | 889 #endif // WEBRTC_BASE_BIND_H_ |
OLD | NEW |