| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 // PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T* | 118 // PointerType<T>::type will be scoped_refptr<T> for ref counted types, and T* |
| 119 // otherwise. | 119 // otherwise. |
| 120 template <class T> | 120 template <class T> |
| 121 struct PointerType { | 121 struct PointerType { |
| 122 typedef typename TernaryTypeOperator<IsRefCounted<T>::value, | 122 typedef typename TernaryTypeOperator<IsRefCounted<T>::value, |
| 123 scoped_refptr<T>, | 123 scoped_refptr<T>, |
| 124 T*>::type type; | 124 T*>::type type; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 // RemoveScopedPtrRef will capture scoped_refptr by-value instead of |
| 128 // by-reference. |
| 129 template <class T> struct RemoveScopedPtrRef { typedef T type; }; |
| 130 template <class T> |
| 131 struct RemoveScopedPtrRef<const scoped_refptr<T>&> { |
| 132 typedef scoped_refptr<T> type; |
| 133 }; |
| 134 template <class T> |
| 135 struct RemoveScopedPtrRef<scoped_refptr<T>&> { |
| 136 typedef scoped_refptr<T> type; |
| 137 }; |
| 138 |
| 127 } // namespace detail | 139 } // namespace detail |
| 128 | 140 |
| 129 $var n = 6 | 141 $var n = 6 |
| 130 $range i 0..n | 142 $range i 0..n |
| 131 $for i [[ | 143 $for i [[ |
| 132 $range j 1..i | 144 $range j 1..i |
| 133 | 145 |
| 134 template <class ObjectT, class MethodT, class R$for j [[, | 146 template <class ObjectT, class MethodT, class R$for j [[, |
| 135 class P$j]]> | 147 class P$j]]> |
| 136 class MethodFunctor$i { | 148 class MethodFunctor$i { |
| 137 public: | 149 public: |
| 138 MethodFunctor$i(MethodT method, ObjectT* object$for j [[, | 150 MethodFunctor$i(MethodT method, ObjectT* object$for j [[, |
| 139 P$j p$j]]) | 151 P$j p$j]]) |
| 140 : method_(method), object_(object)$for j [[, | 152 : method_(method), object_(object)$for j [[, |
| 141 p$(j)_(p$j)]] {} | 153 p$(j)_(p$j)]] {} |
| 142 R operator()() const { | 154 R operator()() const { |
| 143 return (object_->*method_)($for j , [[p$(j)_]]); } | 155 return (object_->*method_)($for j , [[p$(j)_]]); } |
| 144 private: | 156 private: |
| 145 MethodT method_; | 157 MethodT method_; |
| 146 typename detail::PointerType<ObjectT>::type object_;$for j [[ | 158 typename detail::PointerType<ObjectT>::type object_;$for j [[ |
| 147 | 159 |
| 148 P$j p$(j)_;]] | 160 typename detail::RemoveScopedPtrRef<P$j>::type p$(j)_;]] |
| 149 | 161 |
| 150 }; | 162 }; |
| 151 | 163 |
| 152 template <class FunctorT, class R$for j [[, | 164 template <class FunctorT, class R$for j [[, |
| 153 class P$j]]> | 165 class P$j]]> |
| 154 class Functor$i { | 166 class Functor$i { |
| 155 public: | 167 public: |
| 156 $if i == 0 [[explicit ]] | 168 $if i == 0 [[explicit ]] |
| 157 Functor$i(const FunctorT& functor$for j [[, P$j p$j]]) | 169 Functor$i(const FunctorT& functor$for j [[, P$j p$j]]) |
| 158 : functor_(functor)$for j [[, | 170 : functor_(functor)$for j [[, |
| 159 p$(j)_(p$j)]] {} | 171 p$(j)_(p$j)]] {} |
| 160 R operator()() const { | 172 R operator()() const { |
| 161 return functor_($for j , [[p$(j)_]]); } | 173 return functor_($for j , [[p$(j)_]]); } |
| 162 private: | 174 private: |
| 163 FunctorT functor_;$for j [[ | 175 FunctorT functor_;$for j [[ |
| 164 | 176 |
| 165 P$j p$(j)_;]] | 177 typename detail::RemoveScopedPtrRef<P$j>::type p$(j)_;]] |
| 166 | 178 |
| 167 }; | 179 }; |
| 168 | 180 |
| 169 | 181 |
| 170 #define FP_T(x) R (ObjectT::*x)($for j , [[P$j]]) | 182 #define FP_T(x) R (ObjectT::*x)($for j , [[P$j]]) |
| 171 | 183 |
| 172 template <class ObjectT, class R$for j [[, | 184 template <class ObjectT, class R$for j [[, |
| 173 class P$j]]> | 185 class P$j]]> |
| 174 MethodFunctor$i<ObjectT, FP_T(NONAME), R$for j [[, P$j]]> | 186 MethodFunctor$i<ObjectT, FP_T(NONAME), R$for j [[, P$j]]> |
| 175 Bind(FP_T(method), ObjectT* object$for j [[, | 187 Bind(FP_T(method), ObjectT* object$for j [[, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 228 |
| 217 #undef FP_T | 229 #undef FP_T |
| 218 | 230 |
| 219 ]] | 231 ]] |
| 220 | 232 |
| 221 } // namespace rtc | 233 } // namespace rtc |
| 222 | 234 |
| 223 #undef NONAME | 235 #undef NONAME |
| 224 | 236 |
| 225 #endif // WEBRTC_BASE_BIND_H_ | 237 #endif // WEBRTC_BASE_BIND_H_ |
| OLD | NEW |