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!!! |
tommi
2015/08/20 12:35:41
just checking - changes in this file are the resul
magjed_webrtc
2015/08/20 13:05:33
yep :)
| |
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 // possible, and as a raw pointer otherwise. Any arguments to the method are |
21 // should be taken about the lifetime of objects captured by Bind(); the | 21 // captured by value. The return value of Bind is a stateful, nullary function |
22 // returned functor knows nothing about the lifetime of the method's object or | 22 // object. Care should be taken about the lifetime of objects captured by |
23 // any arguments passed by pointer, and calling the functor with a destroyed | 23 // Bind(); the returned functor knows nothing about the lifetime of a non |
24 // object will surely do bad things. | 24 // ref-counted method object or any arguments passed by pointer, and calling the |
25 // functor with a destroyed object will surely do bad things. | |
25 // | 26 // |
26 // Example usage: | 27 // Example usage: |
27 // struct Foo { | 28 // struct Foo { |
28 // int Test1() { return 42; } | 29 // int Test1() { return 42; } |
29 // int Test2() const { return 52; } | 30 // int Test2() const { return 52; } |
30 // int Test3(int x) { return x*x; } | 31 // int Test3(int x) { return x*x; } |
31 // float Test4(int x, float y) { return x + y; } | 32 // float Test4(int x, float y) { return x + y; } |
32 // }; | 33 // }; |
33 // | 34 // |
34 // int main() { | 35 // int main() { |
35 // Foo foo; | 36 // Foo foo; |
36 // cout << rtc::Bind(&Foo::Test1, &foo)() << endl; | 37 // cout << rtc::Bind(&Foo::Test1, &foo)() << endl; |
37 // cout << rtc::Bind(&Foo::Test2, &foo)() << endl; | 38 // cout << rtc::Bind(&Foo::Test2, &foo)() << endl; |
38 // cout << rtc::Bind(&Foo::Test3, &foo, 3)() << endl; | 39 // cout << rtc::Bind(&Foo::Test3, &foo, 3)() << endl; |
39 // cout << rtc::Bind(&Foo::Test4, &foo, 7, 8.5f)() << endl; | 40 // cout << rtc::Bind(&Foo::Test4, &foo, 7, 8.5f)() << endl; |
40 // } | 41 // } |
42 // | |
43 // Example usage of ref counted objects: | |
44 // struct Bar { | |
45 // int AddRef(); | |
46 // int Release(); | |
47 // | |
48 // void Test() {} | |
49 // void BindThis() { | |
50 // // The functor passed to AsyncInvoke() will keep this object alive. | |
51 // invoker.AsyncInvoke(rtc::Bind(&Bar::Test, this)); | |
52 // } | |
53 // }; | |
54 // | |
55 // int main() { | |
56 // rtc::scoped_refptr<Bar> bar = new rtc::RefCountedObject<Bar>(); | |
57 // auto functor = rtc::Bind(&Bar::Test, bar); | |
58 // bar = nullptr; | |
tommi
2015/08/20 12:35:41
good example
| |
59 // // The functor stores an internal scoped_refptr<Bar>, so this is safe. | |
60 // functor(); | |
61 // } | |
62 // | |
41 | 63 |
42 #ifndef WEBRTC_BASE_BIND_H_ | 64 #ifndef WEBRTC_BASE_BIND_H_ |
43 #define WEBRTC_BASE_BIND_H_ | 65 #define WEBRTC_BASE_BIND_H_ |
44 | 66 |
67 #include "webrtc/base/scoped_ref_ptr.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 will be true for types that can be used in | |
82 // rtc::scoped_refptr<T>, i.e. types that implements nullary functions AddRef() | |
83 // and Release(), regardless of their return types. AddRef() and Release() can | |
84 // be defined in T or any superclass of T. | |
85 template <typename T> | |
86 class IsRefCounted { | |
87 // Once you have figured out how the following code works, and realized what a | |
88 // terrible mistake that was, please increment the following counter as a | |
89 // warning to the next guy: | |
90 // total_hours_wasted_here = 5 | |
91 | |
92 // Define types such that sizeof(Yes) != sizeof(No). | |
93 struct Yes { char dummy[1]; }; | |
94 struct No { char dummy[2]; }; | |
95 // Define two overloaded template functions with return types of different | |
96 // size. This way, we can use sizeof() on the return type to determine which | |
97 // function the compiler would have chosen. One function will be preferred | |
98 // over the other if it is possible to create it without compiler errors, | |
99 // otherwise the compiler will simply remove it, and default to the less | |
100 // preferred function. | |
101 template <typename R> | |
102 static Yes test(R* r, decltype(r->AddRef(), r->Release(), 42)); | |
103 template <typename C> static No test(...); | |
104 | |
105 public: | |
106 // Trick the compiler to tell if it's possible to call AddRef() and Release(). | |
107 static const bool value = sizeof(test<T>((T*)nullptr, 42)) == sizeof(Yes); | |
108 }; | |
109 | |
110 // TernaryTypeOperator is a helper class to select a type based on a static bool | |
111 // value. | |
112 template <bool condition, typename IfTrueT, typename IfFalseT> | |
113 struct TernaryTypeOperator {}; | |
114 | |
115 template <typename IfTrueT, typename IfFalseT> | |
116 struct TernaryTypeOperator<true, IfTrueT, IfFalseT> { | |
117 typedef IfTrueT type; | |
118 }; | |
119 | |
120 template <typename IfTrueT, typename IfFalseT> | |
121 struct TernaryTypeOperator<false, IfTrueT, IfFalseT> { | |
122 typedef IfFalseT type; | |
123 }; | |
124 | |
125 // PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T* | |
126 // otherwise. | |
127 template <class T> | |
128 struct PointerType { | |
129 typedef typename TernaryTypeOperator<IsRefCounted<T>::value, | |
130 scoped_refptr<T>, | |
131 T*>::type type; | |
132 }; | |
133 | |
56 } // namespace detail | 134 } // namespace detail |
57 | 135 |
58 template <class ObjectT, class MethodT, class R> | 136 template <class ObjectT, class MethodT, class R> |
59 class MethodFunctor0 { | 137 class MethodFunctor0 { |
60 public: | 138 public: |
61 MethodFunctor0(MethodT method, ObjectT* object) | 139 MethodFunctor0(MethodT method, ObjectT* object) |
62 : method_(method), object_(object) {} | 140 : method_(method), object_(object) {} |
63 R operator()() const { | 141 R operator()() const { |
64 return (object_->*method_)(); } | 142 return (object_->*method_)(); } |
65 private: | 143 private: |
66 MethodT method_; | 144 MethodT method_; |
67 ObjectT* object_; | 145 typename detail::PointerType<ObjectT>::type object_; |
68 }; | 146 }; |
69 | 147 |
70 template <class FunctorT, class R> | 148 template <class FunctorT, class R> |
71 class Functor0 { | 149 class Functor0 { |
72 public: | 150 public: |
73 explicit Functor0(const FunctorT& functor) | 151 explicit Functor0(const FunctorT& functor) |
74 : functor_(functor) {} | 152 : functor_(functor) {} |
75 R operator()() const { | 153 R operator()() const { |
76 return functor_(); } | 154 return functor_(); } |
77 private: | 155 private: |
(...skipping 14 matching lines...) Expand all Loading... | |
92 #define FP_T(x) R (ObjectT::*x)() const | 170 #define FP_T(x) R (ObjectT::*x)() const |
93 | 171 |
94 template <class ObjectT, class R> | 172 template <class ObjectT, class R> |
95 MethodFunctor0<const ObjectT, FP_T(NONAME), R> | 173 MethodFunctor0<const ObjectT, FP_T(NONAME), R> |
96 Bind(FP_T(method), const ObjectT* object) { | 174 Bind(FP_T(method), const ObjectT* object) { |
97 return MethodFunctor0<const ObjectT, FP_T(NONAME), R>( | 175 return MethodFunctor0<const ObjectT, FP_T(NONAME), R>( |
98 method, object); | 176 method, object); |
99 } | 177 } |
100 | 178 |
101 #undef FP_T | 179 #undef FP_T |
180 #define FP_T(x) R (ObjectT::*x)() | |
181 | |
182 template <class ObjectT, class R> | |
183 MethodFunctor0<ObjectT, FP_T(NONAME), R> | |
184 Bind(FP_T(method), const scoped_refptr<ObjectT>& object) { | |
185 return MethodFunctor0<ObjectT, FP_T(NONAME), R>( | |
186 method, object.get()); | |
187 } | |
188 | |
189 #undef FP_T | |
102 #define FP_T(x) R (*x)() | 190 #define FP_T(x) R (*x)() |
103 | 191 |
104 template <class R> | 192 template <class R> |
105 Functor0<FP_T(NONAME), R> | 193 Functor0<FP_T(NONAME), R> |
106 Bind(FP_T(function)) { | 194 Bind(FP_T(function)) { |
107 return Functor0<FP_T(NONAME), R>( | 195 return Functor0<FP_T(NONAME), R>( |
108 function); | 196 function); |
109 } | 197 } |
110 | 198 |
111 #undef FP_T | 199 #undef FP_T |
112 | 200 |
113 template <class ObjectT, class MethodT, class R, | 201 template <class ObjectT, class MethodT, class R, |
114 class P1> | 202 class P1> |
115 class MethodFunctor1 { | 203 class MethodFunctor1 { |
116 public: | 204 public: |
117 MethodFunctor1(MethodT method, ObjectT* object, | 205 MethodFunctor1(MethodT method, ObjectT* object, |
118 P1 p1) | 206 P1 p1) |
119 : method_(method), object_(object), | 207 : method_(method), object_(object), |
120 p1_(p1) {} | 208 p1_(p1) {} |
121 R operator()() const { | 209 R operator()() const { |
122 return (object_->*method_)(p1_); } | 210 return (object_->*method_)(p1_); } |
123 private: | 211 private: |
124 MethodT method_; | 212 MethodT method_; |
125 ObjectT* object_; | 213 typename detail::PointerType<ObjectT>::type object_; |
126 P1 p1_; | 214 P1 p1_; |
127 }; | 215 }; |
128 | 216 |
129 template <class FunctorT, class R, | 217 template <class FunctorT, class R, |
130 class P1> | 218 class P1> |
131 class Functor1 { | 219 class Functor1 { |
132 public: | 220 public: |
133 Functor1(const FunctorT& functor, P1 p1) | 221 Functor1(const FunctorT& functor, P1 p1) |
134 : functor_(functor), | 222 : functor_(functor), |
135 p1_(p1) {} | 223 p1_(p1) {} |
(...skipping 22 matching lines...) Expand all Loading... | |
158 template <class ObjectT, class R, | 246 template <class ObjectT, class R, |
159 class P1> | 247 class P1> |
160 MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1> | 248 MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1> |
161 Bind(FP_T(method), const ObjectT* object, | 249 Bind(FP_T(method), const ObjectT* object, |
162 typename detail::identity<P1>::type p1) { | 250 typename detail::identity<P1>::type p1) { |
163 return MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1>( | 251 return MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1>( |
164 method, object, p1); | 252 method, object, p1); |
165 } | 253 } |
166 | 254 |
167 #undef FP_T | 255 #undef FP_T |
256 #define FP_T(x) R (ObjectT::*x)(P1) | |
257 | |
258 template <class ObjectT, class R, | |
259 class P1> | |
260 MethodFunctor1<ObjectT, FP_T(NONAME), R, P1> | |
261 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
262 typename detail::identity<P1>::type p1) { | |
263 return MethodFunctor1<ObjectT, FP_T(NONAME), R, P1>( | |
264 method, object.get(), p1); | |
265 } | |
266 | |
267 #undef FP_T | |
168 #define FP_T(x) R (*x)(P1) | 268 #define FP_T(x) R (*x)(P1) |
169 | 269 |
170 template <class R, | 270 template <class R, |
171 class P1> | 271 class P1> |
172 Functor1<FP_T(NONAME), R, P1> | 272 Functor1<FP_T(NONAME), R, P1> |
173 Bind(FP_T(function), | 273 Bind(FP_T(function), |
174 typename detail::identity<P1>::type p1) { | 274 typename detail::identity<P1>::type p1) { |
175 return Functor1<FP_T(NONAME), R, P1>( | 275 return Functor1<FP_T(NONAME), R, P1>( |
176 function, p1); | 276 function, p1); |
177 } | 277 } |
178 | 278 |
179 #undef FP_T | 279 #undef FP_T |
180 | 280 |
181 template <class ObjectT, class MethodT, class R, | 281 template <class ObjectT, class MethodT, class R, |
182 class P1, | 282 class P1, |
183 class P2> | 283 class P2> |
184 class MethodFunctor2 { | 284 class MethodFunctor2 { |
185 public: | 285 public: |
186 MethodFunctor2(MethodT method, ObjectT* object, | 286 MethodFunctor2(MethodT method, ObjectT* object, |
187 P1 p1, | 287 P1 p1, |
188 P2 p2) | 288 P2 p2) |
189 : method_(method), object_(object), | 289 : method_(method), object_(object), |
190 p1_(p1), | 290 p1_(p1), |
191 p2_(p2) {} | 291 p2_(p2) {} |
192 R operator()() const { | 292 R operator()() const { |
193 return (object_->*method_)(p1_, p2_); } | 293 return (object_->*method_)(p1_, p2_); } |
194 private: | 294 private: |
195 MethodT method_; | 295 MethodT method_; |
196 ObjectT* object_; | 296 typename detail::PointerType<ObjectT>::type object_; |
197 P1 p1_; | 297 P1 p1_; |
198 P2 p2_; | 298 P2 p2_; |
199 }; | 299 }; |
200 | 300 |
201 template <class FunctorT, class R, | 301 template <class FunctorT, class R, |
202 class P1, | 302 class P1, |
203 class P2> | 303 class P2> |
204 class Functor2 { | 304 class Functor2 { |
205 public: | 305 public: |
206 Functor2(const FunctorT& functor, P1 p1, P2 p2) | 306 Functor2(const FunctorT& functor, P1 p1, P2 p2) |
(...skipping 30 matching lines...) Expand all Loading... | |
237 class P2> | 337 class P2> |
238 MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2> | 338 MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2> |
239 Bind(FP_T(method), const ObjectT* object, | 339 Bind(FP_T(method), const ObjectT* object, |
240 typename detail::identity<P1>::type p1, | 340 typename detail::identity<P1>::type p1, |
241 typename detail::identity<P2>::type p2) { | 341 typename detail::identity<P2>::type p2) { |
242 return MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2>( | 342 return MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2>( |
243 method, object, p1, p2); | 343 method, object, p1, p2); |
244 } | 344 } |
245 | 345 |
246 #undef FP_T | 346 #undef FP_T |
347 #define FP_T(x) R (ObjectT::*x)(P1, P2) | |
348 | |
349 template <class ObjectT, class R, | |
350 class P1, | |
351 class P2> | |
352 MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2> | |
353 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
354 typename detail::identity<P1>::type p1, | |
355 typename detail::identity<P2>::type p2) { | |
356 return MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2>( | |
357 method, object.get(), p1, p2); | |
358 } | |
359 | |
360 #undef FP_T | |
247 #define FP_T(x) R (*x)(P1, P2) | 361 #define FP_T(x) R (*x)(P1, P2) |
248 | 362 |
249 template <class R, | 363 template <class R, |
250 class P1, | 364 class P1, |
251 class P2> | 365 class P2> |
252 Functor2<FP_T(NONAME), R, P1, P2> | 366 Functor2<FP_T(NONAME), R, P1, P2> |
253 Bind(FP_T(function), | 367 Bind(FP_T(function), |
254 typename detail::identity<P1>::type p1, | 368 typename detail::identity<P1>::type p1, |
255 typename detail::identity<P2>::type p2) { | 369 typename detail::identity<P2>::type p2) { |
256 return Functor2<FP_T(NONAME), R, P1, P2>( | 370 return Functor2<FP_T(NONAME), R, P1, P2>( |
(...skipping 13 matching lines...) Expand all Loading... | |
270 P2 p2, | 384 P2 p2, |
271 P3 p3) | 385 P3 p3) |
272 : method_(method), object_(object), | 386 : method_(method), object_(object), |
273 p1_(p1), | 387 p1_(p1), |
274 p2_(p2), | 388 p2_(p2), |
275 p3_(p3) {} | 389 p3_(p3) {} |
276 R operator()() const { | 390 R operator()() const { |
277 return (object_->*method_)(p1_, p2_, p3_); } | 391 return (object_->*method_)(p1_, p2_, p3_); } |
278 private: | 392 private: |
279 MethodT method_; | 393 MethodT method_; |
280 ObjectT* object_; | 394 typename detail::PointerType<ObjectT>::type object_; |
281 P1 p1_; | 395 P1 p1_; |
282 P2 p2_; | 396 P2 p2_; |
283 P3 p3_; | 397 P3 p3_; |
284 }; | 398 }; |
285 | 399 |
286 template <class FunctorT, class R, | 400 template <class FunctorT, class R, |
287 class P1, | 401 class P1, |
288 class P2, | 402 class P2, |
289 class P3> | 403 class P3> |
290 class Functor3 { | 404 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> | 443 MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3> |
330 Bind(FP_T(method), const ObjectT* object, | 444 Bind(FP_T(method), const ObjectT* object, |
331 typename detail::identity<P1>::type p1, | 445 typename detail::identity<P1>::type p1, |
332 typename detail::identity<P2>::type p2, | 446 typename detail::identity<P2>::type p2, |
333 typename detail::identity<P3>::type p3) { | 447 typename detail::identity<P3>::type p3) { |
334 return MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3>( | 448 return MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3>( |
335 method, object, p1, p2, p3); | 449 method, object, p1, p2, p3); |
336 } | 450 } |
337 | 451 |
338 #undef FP_T | 452 #undef FP_T |
453 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3) | |
454 | |
455 template <class ObjectT, class R, | |
456 class P1, | |
457 class P2, | |
458 class P3> | |
459 MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3> | |
460 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
461 typename detail::identity<P1>::type p1, | |
462 typename detail::identity<P2>::type p2, | |
463 typename detail::identity<P3>::type p3) { | |
464 return MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3>( | |
465 method, object.get(), p1, p2, p3); | |
466 } | |
467 | |
468 #undef FP_T | |
339 #define FP_T(x) R (*x)(P1, P2, P3) | 469 #define FP_T(x) R (*x)(P1, P2, P3) |
340 | 470 |
341 template <class R, | 471 template <class R, |
342 class P1, | 472 class P1, |
343 class P2, | 473 class P2, |
344 class P3> | 474 class P3> |
345 Functor3<FP_T(NONAME), R, P1, P2, P3> | 475 Functor3<FP_T(NONAME), R, P1, P2, P3> |
346 Bind(FP_T(function), | 476 Bind(FP_T(function), |
347 typename detail::identity<P1>::type p1, | 477 typename detail::identity<P1>::type p1, |
348 typename detail::identity<P2>::type p2, | 478 typename detail::identity<P2>::type p2, |
(...skipping 18 matching lines...) Expand all Loading... | |
367 P4 p4) | 497 P4 p4) |
368 : method_(method), object_(object), | 498 : method_(method), object_(object), |
369 p1_(p1), | 499 p1_(p1), |
370 p2_(p2), | 500 p2_(p2), |
371 p3_(p3), | 501 p3_(p3), |
372 p4_(p4) {} | 502 p4_(p4) {} |
373 R operator()() const { | 503 R operator()() const { |
374 return (object_->*method_)(p1_, p2_, p3_, p4_); } | 504 return (object_->*method_)(p1_, p2_, p3_, p4_); } |
375 private: | 505 private: |
376 MethodT method_; | 506 MethodT method_; |
377 ObjectT* object_; | 507 typename detail::PointerType<ObjectT>::type object_; |
378 P1 p1_; | 508 P1 p1_; |
379 P2 p2_; | 509 P2 p2_; |
380 P3 p3_; | 510 P3 p3_; |
381 P4 p4_; | 511 P4 p4_; |
382 }; | 512 }; |
383 | 513 |
384 template <class FunctorT, class R, | 514 template <class FunctorT, class R, |
385 class P1, | 515 class P1, |
386 class P2, | 516 class P2, |
387 class P3, | 517 class P3, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 Bind(FP_T(method), const ObjectT* object, | 564 Bind(FP_T(method), const ObjectT* object, |
435 typename detail::identity<P1>::type p1, | 565 typename detail::identity<P1>::type p1, |
436 typename detail::identity<P2>::type p2, | 566 typename detail::identity<P2>::type p2, |
437 typename detail::identity<P3>::type p3, | 567 typename detail::identity<P3>::type p3, |
438 typename detail::identity<P4>::type p4) { | 568 typename detail::identity<P4>::type p4) { |
439 return MethodFunctor4<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>( | 569 return MethodFunctor4<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>( |
440 method, object, p1, p2, p3, p4); | 570 method, object, p1, p2, p3, p4); |
441 } | 571 } |
442 | 572 |
443 #undef FP_T | 573 #undef FP_T |
574 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4) | |
575 | |
576 template <class ObjectT, class R, | |
577 class P1, | |
578 class P2, | |
579 class P3, | |
580 class P4> | |
581 MethodFunctor4<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4> | |
582 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
583 typename detail::identity<P1>::type p1, | |
584 typename detail::identity<P2>::type p2, | |
585 typename detail::identity<P3>::type p3, | |
586 typename detail::identity<P4>::type p4) { | |
587 return MethodFunctor4<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>( | |
588 method, object.get(), p1, p2, p3, p4); | |
589 } | |
590 | |
591 #undef FP_T | |
444 #define FP_T(x) R (*x)(P1, P2, P3, P4) | 592 #define FP_T(x) R (*x)(P1, P2, P3, P4) |
445 | 593 |
446 template <class R, | 594 template <class R, |
447 class P1, | 595 class P1, |
448 class P2, | 596 class P2, |
449 class P3, | 597 class P3, |
450 class P4> | 598 class P4> |
451 Functor4<FP_T(NONAME), R, P1, P2, P3, P4> | 599 Functor4<FP_T(NONAME), R, P1, P2, P3, P4> |
452 Bind(FP_T(function), | 600 Bind(FP_T(function), |
453 typename detail::identity<P1>::type p1, | 601 typename detail::identity<P1>::type p1, |
(...skipping 23 matching lines...) Expand all Loading... | |
477 : method_(method), object_(object), | 625 : method_(method), object_(object), |
478 p1_(p1), | 626 p1_(p1), |
479 p2_(p2), | 627 p2_(p2), |
480 p3_(p3), | 628 p3_(p3), |
481 p4_(p4), | 629 p4_(p4), |
482 p5_(p5) {} | 630 p5_(p5) {} |
483 R operator()() const { | 631 R operator()() const { |
484 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); } | 632 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); } |
485 private: | 633 private: |
486 MethodT method_; | 634 MethodT method_; |
487 ObjectT* object_; | 635 typename detail::PointerType<ObjectT>::type object_; |
488 P1 p1_; | 636 P1 p1_; |
489 P2 p2_; | 637 P2 p2_; |
490 P3 p3_; | 638 P3 p3_; |
491 P4 p4_; | 639 P4 p4_; |
492 P5 p5_; | 640 P5 p5_; |
493 }; | 641 }; |
494 | 642 |
495 template <class FunctorT, class R, | 643 template <class FunctorT, class R, |
496 class P1, | 644 class P1, |
497 class P2, | 645 class P2, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 typename detail::identity<P1>::type p1, | 700 typename detail::identity<P1>::type p1, |
553 typename detail::identity<P2>::type p2, | 701 typename detail::identity<P2>::type p2, |
554 typename detail::identity<P3>::type p3, | 702 typename detail::identity<P3>::type p3, |
555 typename detail::identity<P4>::type p4, | 703 typename detail::identity<P4>::type p4, |
556 typename detail::identity<P5>::type p5) { | 704 typename detail::identity<P5>::type p5) { |
557 return MethodFunctor5<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>( | 705 return MethodFunctor5<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>( |
558 method, object, p1, p2, p3, p4, p5); | 706 method, object, p1, p2, p3, p4, p5); |
559 } | 707 } |
560 | 708 |
561 #undef FP_T | 709 #undef FP_T |
710 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5) | |
711 | |
712 template <class ObjectT, class R, | |
713 class P1, | |
714 class P2, | |
715 class P3, | |
716 class P4, | |
717 class P5> | |
718 MethodFunctor5<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5> | |
719 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
720 typename detail::identity<P1>::type p1, | |
721 typename detail::identity<P2>::type p2, | |
722 typename detail::identity<P3>::type p3, | |
723 typename detail::identity<P4>::type p4, | |
724 typename detail::identity<P5>::type p5) { | |
725 return MethodFunctor5<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>( | |
726 method, object.get(), p1, p2, p3, p4, p5); | |
727 } | |
728 | |
729 #undef FP_T | |
562 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5) | 730 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5) |
563 | 731 |
564 template <class R, | 732 template <class R, |
565 class P1, | 733 class P1, |
566 class P2, | 734 class P2, |
567 class P3, | 735 class P3, |
568 class P4, | 736 class P4, |
569 class P5> | 737 class P5> |
570 Functor5<FP_T(NONAME), R, P1, P2, P3, P4, P5> | 738 Functor5<FP_T(NONAME), R, P1, P2, P3, P4, P5> |
571 Bind(FP_T(function), | 739 Bind(FP_T(function), |
(...skipping 28 matching lines...) Expand all Loading... | |
600 p1_(p1), | 768 p1_(p1), |
601 p2_(p2), | 769 p2_(p2), |
602 p3_(p3), | 770 p3_(p3), |
603 p4_(p4), | 771 p4_(p4), |
604 p5_(p5), | 772 p5_(p5), |
605 p6_(p6) {} | 773 p6_(p6) {} |
606 R operator()() const { | 774 R operator()() const { |
607 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); } | 775 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); } |
608 private: | 776 private: |
609 MethodT method_; | 777 MethodT method_; |
610 ObjectT* object_; | 778 typename detail::PointerType<ObjectT>::type object_; |
611 P1 p1_; | 779 P1 p1_; |
612 P2 p2_; | 780 P2 p2_; |
613 P3 p3_; | 781 P3 p3_; |
614 P4 p4_; | 782 P4 p4_; |
615 P5 p5_; | 783 P5 p5_; |
616 P6 p6_; | 784 P6 p6_; |
617 }; | 785 }; |
618 | 786 |
619 template <class FunctorT, class R, | 787 template <class FunctorT, class R, |
620 class P1, | 788 class P1, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 typename detail::identity<P2>::type p2, | 851 typename detail::identity<P2>::type p2, |
684 typename detail::identity<P3>::type p3, | 852 typename detail::identity<P3>::type p3, |
685 typename detail::identity<P4>::type p4, | 853 typename detail::identity<P4>::type p4, |
686 typename detail::identity<P5>::type p5, | 854 typename detail::identity<P5>::type p5, |
687 typename detail::identity<P6>::type p6) { | 855 typename detail::identity<P6>::type p6) { |
688 return MethodFunctor6<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( | 856 return MethodFunctor6<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( |
689 method, object, p1, p2, p3, p4, p5, p6); | 857 method, object, p1, p2, p3, p4, p5, p6); |
690 } | 858 } |
691 | 859 |
692 #undef FP_T | 860 #undef FP_T |
861 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6) | |
862 | |
863 template <class ObjectT, class R, | |
864 class P1, | |
865 class P2, | |
866 class P3, | |
867 class P4, | |
868 class P5, | |
869 class P6> | |
870 MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> | |
871 Bind(FP_T(method), const scoped_refptr<ObjectT>& object, | |
872 typename detail::identity<P1>::type p1, | |
873 typename detail::identity<P2>::type p2, | |
874 typename detail::identity<P3>::type p3, | |
875 typename detail::identity<P4>::type p4, | |
876 typename detail::identity<P5>::type p5, | |
877 typename detail::identity<P6>::type p6) { | |
878 return MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( | |
879 method, object.get(), p1, p2, p3, p4, p5, p6); | |
880 } | |
881 | |
882 #undef FP_T | |
693 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6) | 883 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6) |
694 | 884 |
695 template <class R, | 885 template <class R, |
696 class P1, | 886 class P1, |
697 class P2, | 887 class P2, |
698 class P3, | 888 class P3, |
699 class P4, | 889 class P4, |
700 class P5, | 890 class P5, |
701 class P6> | 891 class P6> |
702 Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> | 892 Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> |
703 Bind(FP_T(function), | 893 Bind(FP_T(function), |
704 typename detail::identity<P1>::type p1, | 894 typename detail::identity<P1>::type p1, |
705 typename detail::identity<P2>::type p2, | 895 typename detail::identity<P2>::type p2, |
706 typename detail::identity<P3>::type p3, | 896 typename detail::identity<P3>::type p3, |
707 typename detail::identity<P4>::type p4, | 897 typename detail::identity<P4>::type p4, |
708 typename detail::identity<P5>::type p5, | 898 typename detail::identity<P5>::type p5, |
709 typename detail::identity<P6>::type p6) { | 899 typename detail::identity<P6>::type p6) { |
710 return Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( | 900 return Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>( |
711 function, p1, p2, p3, p4, p5, p6); | 901 function, p1, p2, p3, p4, p5, p6); |
712 } | 902 } |
713 | 903 |
714 #undef FP_T | 904 #undef FP_T |
715 | 905 |
716 } // namespace rtc | 906 } // namespace rtc |
717 | 907 |
718 #undef NONAME | 908 #undef NONAME |
719 | 909 |
720 #endif // WEBRTC_BASE_BIND_H_ | 910 #endif // WEBRTC_BASE_BIND_H_ |
OLD | NEW |