[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1 | // This file was GENERATED by command: |
| 2 | // pump.py bind_internal.h.pump |
| 3 | // DO NOT EDIT BY HAND!!! |
| 4 | |
| 5 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 6 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 7 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 8 | // Use of this source code is governed by a BSD-style license that can be |
| 9 | // found in the LICENSE file. |
| 10 | |
| 11 | #ifndef BASE_BIND_INTERNAL_H_ |
| 12 | #define BASE_BIND_INTERNAL_H_ |
| 13 | #pragma once |
| 14 | |
| 15 | #include "base/bind_helpers.h" |
[email protected] | 59eff91 | 2011-02-18 23:29:31 | [diff] [blame] | 16 | #include "base/callback_internal.h" |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 17 | #include "base/memory/raw_scoped_refptr_mismatch_checker.h" |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 18 | #include "base/memory/weak_ptr.h" |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 19 | #include "base/template_util.h" |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 20 | #include "build/build_config.h" |
| 21 | |
| 22 | #if defined(OS_WIN) |
| 23 | #include "base/bind_internal_win.h" |
| 24 | #endif |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 25 | |
| 26 | namespace base { |
| 27 | namespace internal { |
| 28 | |
| 29 | // The method by which a function is invoked is determined by 3 different |
| 30 | // dimensions: |
| 31 | // |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 32 | // 1) The type of function (normal or method). |
| 33 | // 2) The arity of the function. |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 34 | // 3) The number of bound parameters. |
| 35 | // |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 36 | // The templates below handle the determination of each of these dimensions. |
| 37 | // In brief: |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 38 | // |
[email protected] | 7fde470 | 2011-10-19 21:45:15 | [diff] [blame] | 39 | // FunctionTraits<> -- Provides a normalied signature, and other traits. |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 40 | // InvokerN<> -- Provides a DoInvoke() function that actually executes |
[email protected] | 7fde470 | 2011-10-19 21:45:15 | [diff] [blame] | 41 | // a calback. |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 42 | // InvokerStorageN<> -- Provides storage for the bound parameters, and |
| 43 | // typedefs to the above. |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 44 | // IsWeakMethod<> -- Determines if we are binding a method to a WeakPtr<>. |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 45 | // |
| 46 | // More details about the design of each class is included in a comment closer |
[email protected] | 7fde470 | 2011-10-19 21:45:15 | [diff] [blame] | 47 | // to their defition. |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 48 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 49 | |
| 50 | // IsWeakMethod determines if we are binding a method to a WeakPtr<> for an |
| 51 | // object. It is used to select an InvokerN that will no-op itself in the |
| 52 | // event the WeakPtr<> for the target object is invalidated. |
| 53 | template <bool IsMethod, typename T> |
| 54 | struct IsWeakMethod : public false_type {}; |
| 55 | |
| 56 | template <typename T> |
| 57 | struct IsWeakMethod<true, WeakPtr<T> > : public true_type {}; |
| 58 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 59 | // FunctionTraits<> |
| 60 | // |
| 61 | // The FunctionTraits<> template determines the type of function, and also |
| 62 | // creates a NormalizedType used to select the InvokerN classes. It turns out |
| 63 | // that syntactically, you only really have 2 variations when invoking a |
[email protected] | 7fde470 | 2011-10-19 21:45:15 | [diff] [blame] | 64 | // funciton pointer: normal, and method. One is invoked func_ptr(arg1). The |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 65 | // other is invoked (*obj_->method_ptr(arg1)). |
| 66 | // |
| 67 | // However, in the type system, there are many more distinctions. In standard |
| 68 | // C++, there's all variations of const, and volatile on the function pointer. |
| 69 | // In Windows, there are additional calling conventions (eg., __stdcall, |
| 70 | // __fastcall, etc.). FunctionTraits<> handles categorizing each of these into |
| 71 | // a normalized signature. |
| 72 | // |
| 73 | // Having a NormalizedSignature signature, reduces the combinatoric |
[email protected] | 7fde470 | 2011-10-19 21:45:15 | [diff] [blame] | 74 | // complexity of defintions for the InvokerN<> later. Even though there are |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 75 | // only 2 syntactic variations on invoking a function, without normalizing the |
| 76 | // signature, there would need to be one specialization of InvokerN for each |
| 77 | // unique (function_type, bound_arg, unbound_args) tuple in order to match all |
| 78 | // function signatures. |
| 79 | // |
| 80 | // By normalizing the function signature, we reduce function_type to exactly 2. |
| 81 | |
| 82 | template <typename Sig> |
| 83 | struct FunctionTraits; |
| 84 | |
| 85 | // Function: Arity 0. |
| 86 | template <typename R> |
| 87 | struct FunctionTraits<R(*)()> { |
| 88 | typedef R (*NormalizedSig)(); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 89 | typedef false_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 90 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 91 | typedef R Return; |
| 92 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | // Method: Arity 0. |
| 96 | template <typename R, typename T> |
| 97 | struct FunctionTraits<R(T::*)()> { |
| 98 | typedef R (T::*NormalizedSig)(); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 99 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 100 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 101 | typedef R Return; |
| 102 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 103 | // Target type for each bound parameter. |
| 104 | typedef T B1; |
| 105 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | // Const Method: Arity 0. |
| 109 | template <typename R, typename T> |
| 110 | struct FunctionTraits<R(T::*)() const> { |
| 111 | typedef R (T::*NormalizedSig)(); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 112 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 113 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 114 | typedef R Return; |
| 115 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 116 | // Target type for each bound parameter. |
| 117 | typedef T B1; |
| 118 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | // Function: Arity 1. |
| 122 | template <typename R, typename X1> |
| 123 | struct FunctionTraits<R(*)(X1)> { |
| 124 | typedef R (*NormalizedSig)(X1); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 125 | typedef false_type IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 126 | |
| 127 | typedef R Return; |
| 128 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 129 | // Target type for each bound parameter. |
| 130 | typedef X1 B1; |
| 131 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | // Method: Arity 1. |
| 135 | template <typename R, typename T, typename X1> |
| 136 | struct FunctionTraits<R(T::*)(X1)> { |
| 137 | typedef R (T::*NormalizedSig)(X1); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 138 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 139 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 140 | typedef R Return; |
| 141 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 142 | // Target type for each bound parameter. |
| 143 | typedef T B1; |
| 144 | typedef X1 B2; |
| 145 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | // Const Method: Arity 1. |
| 149 | template <typename R, typename T, typename X1> |
| 150 | struct FunctionTraits<R(T::*)(X1) const> { |
| 151 | typedef R (T::*NormalizedSig)(X1); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 152 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 153 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 154 | typedef R Return; |
| 155 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 156 | // Target type for each bound parameter. |
| 157 | typedef T B1; |
| 158 | typedef X1 B2; |
| 159 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | // Function: Arity 2. |
| 163 | template <typename R, typename X1, typename X2> |
| 164 | struct FunctionTraits<R(*)(X1, X2)> { |
| 165 | typedef R (*NormalizedSig)(X1, X2); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 166 | typedef false_type IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 167 | |
| 168 | typedef R Return; |
| 169 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 170 | // Target type for each bound parameter. |
| 171 | typedef X1 B1; |
| 172 | typedef X2 B2; |
| 173 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | // Method: Arity 2. |
| 177 | template <typename R, typename T, typename X1, typename X2> |
| 178 | struct FunctionTraits<R(T::*)(X1, X2)> { |
| 179 | typedef R (T::*NormalizedSig)(X1, X2); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 180 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 181 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 182 | typedef R Return; |
| 183 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 184 | // Target type for each bound parameter. |
| 185 | typedef T B1; |
| 186 | typedef X1 B2; |
| 187 | typedef X2 B3; |
| 188 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 189 | }; |
| 190 | |
| 191 | // Const Method: Arity 2. |
| 192 | template <typename R, typename T, typename X1, typename X2> |
| 193 | struct FunctionTraits<R(T::*)(X1, X2) const> { |
| 194 | typedef R (T::*NormalizedSig)(X1, X2); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 195 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 196 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 197 | typedef R Return; |
| 198 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 199 | // Target type for each bound parameter. |
| 200 | typedef T B1; |
| 201 | typedef X1 B2; |
| 202 | typedef X2 B3; |
| 203 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | // Function: Arity 3. |
| 207 | template <typename R, typename X1, typename X2, typename X3> |
| 208 | struct FunctionTraits<R(*)(X1, X2, X3)> { |
| 209 | typedef R (*NormalizedSig)(X1, X2, X3); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 210 | typedef false_type IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 211 | |
| 212 | typedef R Return; |
| 213 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 214 | // Target type for each bound parameter. |
| 215 | typedef X1 B1; |
| 216 | typedef X2 B2; |
| 217 | typedef X3 B3; |
| 218 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 219 | }; |
| 220 | |
| 221 | // Method: Arity 3. |
| 222 | template <typename R, typename T, typename X1, typename X2, typename X3> |
| 223 | struct FunctionTraits<R(T::*)(X1, X2, X3)> { |
| 224 | typedef R (T::*NormalizedSig)(X1, X2, X3); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 225 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 226 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 227 | typedef R Return; |
| 228 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 229 | // Target type for each bound parameter. |
| 230 | typedef T B1; |
| 231 | typedef X1 B2; |
| 232 | typedef X2 B3; |
| 233 | typedef X3 B4; |
| 234 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 235 | }; |
| 236 | |
| 237 | // Const Method: Arity 3. |
| 238 | template <typename R, typename T, typename X1, typename X2, typename X3> |
| 239 | struct FunctionTraits<R(T::*)(X1, X2, X3) const> { |
| 240 | typedef R (T::*NormalizedSig)(X1, X2, X3); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 241 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 242 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 243 | typedef R Return; |
| 244 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 245 | // Target type for each bound parameter. |
| 246 | typedef T B1; |
| 247 | typedef X1 B2; |
| 248 | typedef X2 B3; |
| 249 | typedef X3 B4; |
| 250 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 251 | }; |
| 252 | |
| 253 | // Function: Arity 4. |
| 254 | template <typename R, typename X1, typename X2, typename X3, typename X4> |
| 255 | struct FunctionTraits<R(*)(X1, X2, X3, X4)> { |
| 256 | typedef R (*NormalizedSig)(X1, X2, X3, X4); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 257 | typedef false_type IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 258 | |
| 259 | typedef R Return; |
| 260 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 261 | // Target type for each bound parameter. |
| 262 | typedef X1 B1; |
| 263 | typedef X2 B2; |
| 264 | typedef X3 B3; |
| 265 | typedef X4 B4; |
| 266 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | // Method: Arity 4. |
| 270 | template <typename R, typename T, typename X1, typename X2, typename X3, |
| 271 | typename X4> |
| 272 | struct FunctionTraits<R(T::*)(X1, X2, X3, X4)> { |
| 273 | typedef R (T::*NormalizedSig)(X1, X2, X3, X4); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 274 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 275 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 276 | typedef R Return; |
| 277 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 278 | // Target type for each bound parameter. |
| 279 | typedef T B1; |
| 280 | typedef X1 B2; |
| 281 | typedef X2 B3; |
| 282 | typedef X3 B4; |
| 283 | typedef X4 B5; |
| 284 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 285 | }; |
| 286 | |
| 287 | // Const Method: Arity 4. |
| 288 | template <typename R, typename T, typename X1, typename X2, typename X3, |
| 289 | typename X4> |
| 290 | struct FunctionTraits<R(T::*)(X1, X2, X3, X4) const> { |
| 291 | typedef R (T::*NormalizedSig)(X1, X2, X3, X4); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 292 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 293 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 294 | typedef R Return; |
| 295 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 296 | // Target type for each bound parameter. |
| 297 | typedef T B1; |
| 298 | typedef X1 B2; |
| 299 | typedef X2 B3; |
| 300 | typedef X3 B4; |
| 301 | typedef X4 B5; |
| 302 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 303 | }; |
| 304 | |
| 305 | // Function: Arity 5. |
| 306 | template <typename R, typename X1, typename X2, typename X3, typename X4, |
| 307 | typename X5> |
| 308 | struct FunctionTraits<R(*)(X1, X2, X3, X4, X5)> { |
| 309 | typedef R (*NormalizedSig)(X1, X2, X3, X4, X5); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 310 | typedef false_type IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 311 | |
| 312 | typedef R Return; |
| 313 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 314 | // Target type for each bound parameter. |
| 315 | typedef X1 B1; |
| 316 | typedef X2 B2; |
| 317 | typedef X3 B3; |
| 318 | typedef X4 B4; |
| 319 | typedef X5 B5; |
| 320 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | // Method: Arity 5. |
| 324 | template <typename R, typename T, typename X1, typename X2, typename X3, |
| 325 | typename X4, typename X5> |
| 326 | struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5)> { |
| 327 | typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 328 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 329 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 330 | typedef R Return; |
| 331 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 332 | // Target type for each bound parameter. |
| 333 | typedef T B1; |
| 334 | typedef X1 B2; |
| 335 | typedef X2 B3; |
| 336 | typedef X3 B4; |
| 337 | typedef X4 B5; |
| 338 | typedef X5 B6; |
| 339 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | // Const Method: Arity 5. |
| 343 | template <typename R, typename T, typename X1, typename X2, typename X3, |
| 344 | typename X4, typename X5> |
| 345 | struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5) const> { |
| 346 | typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 347 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 348 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 349 | typedef R Return; |
| 350 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 351 | // Target type for each bound parameter. |
| 352 | typedef T B1; |
| 353 | typedef X1 B2; |
| 354 | typedef X2 B3; |
| 355 | typedef X3 B4; |
| 356 | typedef X4 B5; |
| 357 | typedef X5 B6; |
| 358 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 359 | }; |
| 360 | |
| 361 | // Function: Arity 6. |
| 362 | template <typename R, typename X1, typename X2, typename X3, typename X4, |
| 363 | typename X5, typename X6> |
| 364 | struct FunctionTraits<R(*)(X1, X2, X3, X4, X5, X6)> { |
| 365 | typedef R (*NormalizedSig)(X1, X2, X3, X4, X5, X6); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 366 | typedef false_type IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 367 | |
| 368 | typedef R Return; |
| 369 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 370 | // Target type for each bound parameter. |
| 371 | typedef X1 B1; |
| 372 | typedef X2 B2; |
| 373 | typedef X3 B3; |
| 374 | typedef X4 B4; |
| 375 | typedef X5 B5; |
| 376 | typedef X6 B6; |
| 377 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 378 | }; |
| 379 | |
| 380 | // Method: Arity 6. |
| 381 | template <typename R, typename T, typename X1, typename X2, typename X3, |
| 382 | typename X4, typename X5, typename X6> |
| 383 | struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6)> { |
| 384 | typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 385 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 386 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 387 | typedef R Return; |
| 388 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 389 | // Target type for each bound parameter. |
| 390 | typedef T B1; |
| 391 | typedef X1 B2; |
| 392 | typedef X2 B3; |
| 393 | typedef X3 B4; |
| 394 | typedef X4 B5; |
| 395 | typedef X5 B6; |
| 396 | typedef X6 B7; |
| 397 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 398 | }; |
| 399 | |
| 400 | // Const Method: Arity 6. |
| 401 | template <typename R, typename T, typename X1, typename X2, typename X3, |
| 402 | typename X4, typename X5, typename X6> |
| 403 | struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6) const> { |
| 404 | typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); |
[email protected] | 054ac754 | 2011-02-27 01:25:59 | [diff] [blame] | 405 | typedef true_type IsMethod; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 406 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 407 | typedef R Return; |
| 408 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 409 | // Target type for each bound parameter. |
| 410 | typedef T B1; |
| 411 | typedef X1 B2; |
| 412 | typedef X2 B3; |
| 413 | typedef X3 B4; |
| 414 | typedef X4 B5; |
| 415 | typedef X5 B6; |
| 416 | typedef X6 B7; |
| 417 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 418 | }; |
| 419 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 420 | // InvokerN<> |
| 421 | // |
| 422 | // The InvokerN templates contain a static DoInvoke() function that is the key |
| 423 | // to implementing type erasure in the Callback() classes. |
| 424 | // |
| 425 | // DoInvoke() is a static function with a fixed signature that is independent |
| 426 | // of StorageType; its first argument is a pointer to the non-templated common |
[email protected] | 7fde470 | 2011-10-19 21:45:15 | [diff] [blame] | 427 | // baseclass of StorageType. This lets us store pointer to DoInvoke() in a |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 428 | // function pointer that has knowledge of the specific StorageType, and thus |
| 429 | // no knowledge of the bound function and bound parameter types. |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 430 | // |
| 431 | // As long as we ensure that DoInvoke() is only used with pointers there were |
[email protected] | 7fde470 | 2011-10-19 21:45:15 | [diff] [blame] | 432 | // upcasted from the correct StorageType, we can be sure that execution is |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 433 | // safe. |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 434 | // |
| 435 | // The InvokerN templates are the only point that knows the number of bound |
| 436 | // and unbound arguments. This is intentional because it allows the other |
| 437 | // templates classes in the system to only have as many specializations as |
| 438 | // the max arity of function we wish to support. |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 439 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 440 | template <bool IsWeak, typename StorageType, typename NormalizedSig> |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 441 | struct Invoker0; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 442 | |
| 443 | // Function: Arity 0 -> 0. |
| 444 | template <typename StorageType, typename R> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 445 | struct Invoker0<false, StorageType, R(*)()> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 446 | typedef R(*DoInvokeType)( |
| 447 | internal::InvokerStorageBase*); |
| 448 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 449 | static R DoInvoke(InvokerStorageBase* base) { |
| 450 | StorageType* invoker = static_cast<StorageType*>(base); |
| 451 | return invoker->f_(); |
| 452 | } |
| 453 | }; |
| 454 | |
| 455 | // Function: Arity 1 -> 1. |
| 456 | template <typename StorageType, typename R,typename X1> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 457 | struct Invoker0<false, StorageType, R(*)(X1)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 458 | typedef R(*DoInvokeType)( |
| 459 | internal::InvokerStorageBase*, |
| 460 | typename internal::ParamTraits<X1>::ForwardType); |
| 461 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 462 | static R DoInvoke(InvokerStorageBase* base, |
| 463 | typename internal::ParamTraits<X1>::ForwardType x1) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 464 | StorageType* invoker = static_cast<StorageType*>(base); |
| 465 | return invoker->f_(x1); |
| 466 | } |
| 467 | }; |
| 468 | |
| 469 | // Function: Arity 2 -> 2. |
| 470 | template <typename StorageType, typename R,typename X1, typename X2> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 471 | struct Invoker0<false, StorageType, R(*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 472 | typedef R(*DoInvokeType)( |
| 473 | internal::InvokerStorageBase*, |
| 474 | typename internal::ParamTraits<X1>::ForwardType, |
| 475 | typename internal::ParamTraits<X2>::ForwardType); |
| 476 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 477 | static R DoInvoke(InvokerStorageBase* base, |
| 478 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 479 | typename internal::ParamTraits<X2>::ForwardType x2) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 480 | StorageType* invoker = static_cast<StorageType*>(base); |
| 481 | return invoker->f_(x1, x2); |
| 482 | } |
| 483 | }; |
| 484 | |
| 485 | // Function: Arity 3 -> 3. |
| 486 | template <typename StorageType, typename R,typename X1, typename X2, |
| 487 | typename X3> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 488 | struct Invoker0<false, StorageType, R(*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 489 | typedef R(*DoInvokeType)( |
| 490 | internal::InvokerStorageBase*, |
| 491 | typename internal::ParamTraits<X1>::ForwardType, |
| 492 | typename internal::ParamTraits<X2>::ForwardType, |
| 493 | typename internal::ParamTraits<X3>::ForwardType); |
| 494 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 495 | static R DoInvoke(InvokerStorageBase* base, |
| 496 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 497 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 498 | typename internal::ParamTraits<X3>::ForwardType x3) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 499 | StorageType* invoker = static_cast<StorageType*>(base); |
| 500 | return invoker->f_(x1, x2, x3); |
| 501 | } |
| 502 | }; |
| 503 | |
| 504 | // Function: Arity 4 -> 4. |
| 505 | template <typename StorageType, typename R,typename X1, typename X2, |
| 506 | typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 507 | struct Invoker0<false, StorageType, R(*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 508 | typedef R(*DoInvokeType)( |
| 509 | internal::InvokerStorageBase*, |
| 510 | typename internal::ParamTraits<X1>::ForwardType, |
| 511 | typename internal::ParamTraits<X2>::ForwardType, |
| 512 | typename internal::ParamTraits<X3>::ForwardType, |
| 513 | typename internal::ParamTraits<X4>::ForwardType); |
| 514 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 515 | static R DoInvoke(InvokerStorageBase* base, |
| 516 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 517 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 518 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 519 | typename internal::ParamTraits<X4>::ForwardType x4) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 520 | StorageType* invoker = static_cast<StorageType*>(base); |
| 521 | return invoker->f_(x1, x2, x3, x4); |
| 522 | } |
| 523 | }; |
| 524 | |
| 525 | // Function: Arity 5 -> 5. |
| 526 | template <typename StorageType, typename R,typename X1, typename X2, |
| 527 | typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 528 | struct Invoker0<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 529 | typedef R(*DoInvokeType)( |
| 530 | internal::InvokerStorageBase*, |
| 531 | typename internal::ParamTraits<X1>::ForwardType, |
| 532 | typename internal::ParamTraits<X2>::ForwardType, |
| 533 | typename internal::ParamTraits<X3>::ForwardType, |
| 534 | typename internal::ParamTraits<X4>::ForwardType, |
| 535 | typename internal::ParamTraits<X5>::ForwardType); |
| 536 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 537 | static R DoInvoke(InvokerStorageBase* base, |
| 538 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 539 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 540 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 541 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 542 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 543 | StorageType* invoker = static_cast<StorageType*>(base); |
| 544 | return invoker->f_(x1, x2, x3, x4, x5); |
| 545 | } |
| 546 | }; |
| 547 | |
| 548 | // Function: Arity 6 -> 6. |
| 549 | template <typename StorageType, typename R,typename X1, typename X2, |
| 550 | typename X3, typename X4, typename X5, typename X6> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 551 | struct Invoker0<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 552 | typedef R(*DoInvokeType)( |
| 553 | internal::InvokerStorageBase*, |
| 554 | typename internal::ParamTraits<X1>::ForwardType, |
| 555 | typename internal::ParamTraits<X2>::ForwardType, |
| 556 | typename internal::ParamTraits<X3>::ForwardType, |
| 557 | typename internal::ParamTraits<X4>::ForwardType, |
| 558 | typename internal::ParamTraits<X5>::ForwardType, |
| 559 | typename internal::ParamTraits<X6>::ForwardType); |
| 560 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 561 | static R DoInvoke(InvokerStorageBase* base, |
| 562 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 563 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 564 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 565 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 566 | typename internal::ParamTraits<X5>::ForwardType x5, |
| 567 | typename internal::ParamTraits<X6>::ForwardType x6) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 568 | StorageType* invoker = static_cast<StorageType*>(base); |
| 569 | return invoker->f_(x1, x2, x3, x4, x5, x6); |
| 570 | } |
| 571 | }; |
| 572 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 573 | template <bool IsWeak, typename StorageType, typename NormalizedSig> |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 574 | struct Invoker1; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 575 | |
| 576 | // Function: Arity 1 -> 0. |
| 577 | template <typename StorageType, typename R,typename X1> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 578 | struct Invoker1<false, StorageType, R(*)(X1)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 579 | typedef R(*DoInvokeType)( |
| 580 | internal::InvokerStorageBase*); |
| 581 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 582 | static R DoInvoke(InvokerStorageBase* base) { |
| 583 | StorageType* invoker = static_cast<StorageType*>(base); |
| 584 | return invoker->f_(Unwrap(invoker->p1_)); |
| 585 | } |
| 586 | }; |
| 587 | |
| 588 | // Method: Arity 0 -> 0. |
| 589 | template <typename StorageType, typename R, typename T> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 590 | struct Invoker1<false, StorageType, R(T::*)()> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 591 | typedef R(*DoInvokeType)( |
| 592 | internal::InvokerStorageBase*); |
| 593 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 594 | static R DoInvoke(InvokerStorageBase* base) { |
| 595 | StorageType* invoker = static_cast<StorageType*>(base); |
| 596 | return (Unwrap(invoker->p1_)->*invoker->f_)(); |
| 597 | } |
| 598 | }; |
| 599 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 600 | // WeakPtr Method: Arity 0 -> 0. |
| 601 | template <typename StorageType, typename T> |
| 602 | struct Invoker1<true, StorageType, void(T::*)()> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 603 | typedef void(*DoInvokeType)( |
| 604 | internal::InvokerStorageBase*); |
| 605 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 606 | static void DoInvoke(InvokerStorageBase* base) { |
| 607 | StorageType* invoker = static_cast<StorageType*>(base); |
| 608 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 609 | if (!weak_ptr.get()) { |
| 610 | return; |
| 611 | } |
| 612 | (weak_ptr->*invoker->f_)(); |
| 613 | } |
| 614 | }; |
| 615 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 616 | // Function: Arity 2 -> 1. |
| 617 | template <typename StorageType, typename R,typename X1, typename X2> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 618 | struct Invoker1<false, StorageType, R(*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 619 | typedef R(*DoInvokeType)( |
| 620 | internal::InvokerStorageBase*, |
| 621 | typename internal::ParamTraits<X2>::ForwardType); |
| 622 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 623 | static R DoInvoke(InvokerStorageBase* base, |
| 624 | typename internal::ParamTraits<X2>::ForwardType x2) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 625 | StorageType* invoker = static_cast<StorageType*>(base); |
| 626 | return invoker->f_(Unwrap(invoker->p1_), x2); |
| 627 | } |
| 628 | }; |
| 629 | |
| 630 | // Method: Arity 1 -> 1. |
| 631 | template <typename StorageType, typename R, typename T, typename X1> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 632 | struct Invoker1<false, StorageType, R(T::*)(X1)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 633 | typedef R(*DoInvokeType)( |
| 634 | internal::InvokerStorageBase*, |
| 635 | typename internal::ParamTraits<X1>::ForwardType); |
| 636 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 637 | static R DoInvoke(InvokerStorageBase* base, |
| 638 | typename internal::ParamTraits<X1>::ForwardType x1) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 639 | StorageType* invoker = static_cast<StorageType*>(base); |
| 640 | return (Unwrap(invoker->p1_)->*invoker->f_)(x1); |
| 641 | } |
| 642 | }; |
| 643 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 644 | // WeakPtr Method: Arity 1 -> 1. |
| 645 | template <typename StorageType, typename T, typename X1> |
| 646 | struct Invoker1<true, StorageType, void(T::*)(X1)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 647 | typedef void(*DoInvokeType)( |
| 648 | internal::InvokerStorageBase*, |
| 649 | typename internal::ParamTraits<X1>::ForwardType); |
| 650 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 651 | static void DoInvoke(InvokerStorageBase* base, |
| 652 | typename internal::ParamTraits<X1>::ForwardType x1) { |
| 653 | StorageType* invoker = static_cast<StorageType*>(base); |
| 654 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 655 | if (!weak_ptr.get()) { |
| 656 | return; |
| 657 | } |
| 658 | (weak_ptr->*invoker->f_)(x1); |
| 659 | } |
| 660 | }; |
| 661 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 662 | // Function: Arity 3 -> 2. |
| 663 | template <typename StorageType, typename R,typename X1, typename X2, |
| 664 | typename X3> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 665 | struct Invoker1<false, StorageType, R(*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 666 | typedef R(*DoInvokeType)( |
| 667 | internal::InvokerStorageBase*, |
| 668 | typename internal::ParamTraits<X2>::ForwardType, |
| 669 | typename internal::ParamTraits<X3>::ForwardType); |
| 670 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 671 | static R DoInvoke(InvokerStorageBase* base, |
| 672 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 673 | typename internal::ParamTraits<X3>::ForwardType x3) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 674 | StorageType* invoker = static_cast<StorageType*>(base); |
| 675 | return invoker->f_(Unwrap(invoker->p1_), x2, x3); |
| 676 | } |
| 677 | }; |
| 678 | |
| 679 | // Method: Arity 2 -> 2. |
| 680 | template <typename StorageType, typename R, typename T, typename X1, |
| 681 | typename X2> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 682 | struct Invoker1<false, StorageType, R(T::*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 683 | typedef R(*DoInvokeType)( |
| 684 | internal::InvokerStorageBase*, |
| 685 | typename internal::ParamTraits<X1>::ForwardType, |
| 686 | typename internal::ParamTraits<X2>::ForwardType); |
| 687 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 688 | static R DoInvoke(InvokerStorageBase* base, |
| 689 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 690 | typename internal::ParamTraits<X2>::ForwardType x2) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 691 | StorageType* invoker = static_cast<StorageType*>(base); |
| 692 | return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2); |
| 693 | } |
| 694 | }; |
| 695 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 696 | // WeakPtr Method: Arity 2 -> 2. |
| 697 | template <typename StorageType, typename T, typename X1, typename X2> |
| 698 | struct Invoker1<true, StorageType, void(T::*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 699 | typedef void(*DoInvokeType)( |
| 700 | internal::InvokerStorageBase*, |
| 701 | typename internal::ParamTraits<X1>::ForwardType, |
| 702 | typename internal::ParamTraits<X2>::ForwardType); |
| 703 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 704 | static void DoInvoke(InvokerStorageBase* base, |
| 705 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 706 | typename internal::ParamTraits<X2>::ForwardType x2) { |
| 707 | StorageType* invoker = static_cast<StorageType*>(base); |
| 708 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 709 | if (!weak_ptr.get()) { |
| 710 | return; |
| 711 | } |
| 712 | (weak_ptr->*invoker->f_)(x1, x2); |
| 713 | } |
| 714 | }; |
| 715 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 716 | // Function: Arity 4 -> 3. |
| 717 | template <typename StorageType, typename R,typename X1, typename X2, |
| 718 | typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 719 | struct Invoker1<false, StorageType, R(*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 720 | typedef R(*DoInvokeType)( |
| 721 | internal::InvokerStorageBase*, |
| 722 | typename internal::ParamTraits<X2>::ForwardType, |
| 723 | typename internal::ParamTraits<X3>::ForwardType, |
| 724 | typename internal::ParamTraits<X4>::ForwardType); |
| 725 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 726 | static R DoInvoke(InvokerStorageBase* base, |
| 727 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 728 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 729 | typename internal::ParamTraits<X4>::ForwardType x4) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 730 | StorageType* invoker = static_cast<StorageType*>(base); |
| 731 | return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4); |
| 732 | } |
| 733 | }; |
| 734 | |
| 735 | // Method: Arity 3 -> 3. |
| 736 | template <typename StorageType, typename R, typename T, typename X1, |
| 737 | typename X2, typename X3> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 738 | struct Invoker1<false, StorageType, R(T::*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 739 | typedef R(*DoInvokeType)( |
| 740 | internal::InvokerStorageBase*, |
| 741 | typename internal::ParamTraits<X1>::ForwardType, |
| 742 | typename internal::ParamTraits<X2>::ForwardType, |
| 743 | typename internal::ParamTraits<X3>::ForwardType); |
| 744 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 745 | static R DoInvoke(InvokerStorageBase* base, |
| 746 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 747 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 748 | typename internal::ParamTraits<X3>::ForwardType x3) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 749 | StorageType* invoker = static_cast<StorageType*>(base); |
| 750 | return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3); |
| 751 | } |
| 752 | }; |
| 753 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 754 | // WeakPtr Method: Arity 3 -> 3. |
| 755 | template <typename StorageType, typename T, typename X1, typename X2, |
| 756 | typename X3> |
| 757 | struct Invoker1<true, StorageType, void(T::*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 758 | typedef void(*DoInvokeType)( |
| 759 | internal::InvokerStorageBase*, |
| 760 | typename internal::ParamTraits<X1>::ForwardType, |
| 761 | typename internal::ParamTraits<X2>::ForwardType, |
| 762 | typename internal::ParamTraits<X3>::ForwardType); |
| 763 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 764 | static void DoInvoke(InvokerStorageBase* base, |
| 765 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 766 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 767 | typename internal::ParamTraits<X3>::ForwardType x3) { |
| 768 | StorageType* invoker = static_cast<StorageType*>(base); |
| 769 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 770 | if (!weak_ptr.get()) { |
| 771 | return; |
| 772 | } |
| 773 | (weak_ptr->*invoker->f_)(x1, x2, x3); |
| 774 | } |
| 775 | }; |
| 776 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 777 | // Function: Arity 5 -> 4. |
| 778 | template <typename StorageType, typename R,typename X1, typename X2, |
| 779 | typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 780 | struct Invoker1<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 781 | typedef R(*DoInvokeType)( |
| 782 | internal::InvokerStorageBase*, |
| 783 | typename internal::ParamTraits<X2>::ForwardType, |
| 784 | typename internal::ParamTraits<X3>::ForwardType, |
| 785 | typename internal::ParamTraits<X4>::ForwardType, |
| 786 | typename internal::ParamTraits<X5>::ForwardType); |
| 787 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 788 | static R DoInvoke(InvokerStorageBase* base, |
| 789 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 790 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 791 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 792 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 793 | StorageType* invoker = static_cast<StorageType*>(base); |
| 794 | return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5); |
| 795 | } |
| 796 | }; |
| 797 | |
| 798 | // Method: Arity 4 -> 4. |
| 799 | template <typename StorageType, typename R, typename T, typename X1, |
| 800 | typename X2, typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 801 | struct Invoker1<false, StorageType, R(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 802 | typedef R(*DoInvokeType)( |
| 803 | internal::InvokerStorageBase*, |
| 804 | typename internal::ParamTraits<X1>::ForwardType, |
| 805 | typename internal::ParamTraits<X2>::ForwardType, |
| 806 | typename internal::ParamTraits<X3>::ForwardType, |
| 807 | typename internal::ParamTraits<X4>::ForwardType); |
| 808 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 809 | static R DoInvoke(InvokerStorageBase* base, |
| 810 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 811 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 812 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 813 | typename internal::ParamTraits<X4>::ForwardType x4) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 814 | StorageType* invoker = static_cast<StorageType*>(base); |
| 815 | return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4); |
| 816 | } |
| 817 | }; |
| 818 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 819 | // WeakPtr Method: Arity 4 -> 4. |
| 820 | template <typename StorageType, typename T, typename X1, typename X2, |
| 821 | typename X3, typename X4> |
| 822 | struct Invoker1<true, StorageType, void(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 823 | typedef void(*DoInvokeType)( |
| 824 | internal::InvokerStorageBase*, |
| 825 | typename internal::ParamTraits<X1>::ForwardType, |
| 826 | typename internal::ParamTraits<X2>::ForwardType, |
| 827 | typename internal::ParamTraits<X3>::ForwardType, |
| 828 | typename internal::ParamTraits<X4>::ForwardType); |
| 829 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 830 | static void DoInvoke(InvokerStorageBase* base, |
| 831 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 832 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 833 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 834 | typename internal::ParamTraits<X4>::ForwardType x4) { |
| 835 | StorageType* invoker = static_cast<StorageType*>(base); |
| 836 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 837 | if (!weak_ptr.get()) { |
| 838 | return; |
| 839 | } |
| 840 | (weak_ptr->*invoker->f_)(x1, x2, x3, x4); |
| 841 | } |
| 842 | }; |
| 843 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 844 | // Function: Arity 6 -> 5. |
| 845 | template <typename StorageType, typename R,typename X1, typename X2, |
| 846 | typename X3, typename X4, typename X5, typename X6> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 847 | struct Invoker1<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 848 | typedef R(*DoInvokeType)( |
| 849 | internal::InvokerStorageBase*, |
| 850 | typename internal::ParamTraits<X2>::ForwardType, |
| 851 | typename internal::ParamTraits<X3>::ForwardType, |
| 852 | typename internal::ParamTraits<X4>::ForwardType, |
| 853 | typename internal::ParamTraits<X5>::ForwardType, |
| 854 | typename internal::ParamTraits<X6>::ForwardType); |
| 855 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 856 | static R DoInvoke(InvokerStorageBase* base, |
| 857 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 858 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 859 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 860 | typename internal::ParamTraits<X5>::ForwardType x5, |
| 861 | typename internal::ParamTraits<X6>::ForwardType x6) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 862 | StorageType* invoker = static_cast<StorageType*>(base); |
| 863 | return invoker->f_(Unwrap(invoker->p1_), x2, x3, x4, x5, x6); |
| 864 | } |
| 865 | }; |
| 866 | |
| 867 | // Method: Arity 5 -> 5. |
| 868 | template <typename StorageType, typename R, typename T, typename X1, |
| 869 | typename X2, typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 870 | struct Invoker1<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 871 | typedef R(*DoInvokeType)( |
| 872 | internal::InvokerStorageBase*, |
| 873 | typename internal::ParamTraits<X1>::ForwardType, |
| 874 | typename internal::ParamTraits<X2>::ForwardType, |
| 875 | typename internal::ParamTraits<X3>::ForwardType, |
| 876 | typename internal::ParamTraits<X4>::ForwardType, |
| 877 | typename internal::ParamTraits<X5>::ForwardType); |
| 878 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 879 | static R DoInvoke(InvokerStorageBase* base, |
| 880 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 881 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 882 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 883 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 884 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 885 | StorageType* invoker = static_cast<StorageType*>(base); |
| 886 | return (Unwrap(invoker->p1_)->*invoker->f_)(x1, x2, x3, x4, x5); |
| 887 | } |
| 888 | }; |
| 889 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 890 | // WeakPtr Method: Arity 5 -> 5. |
| 891 | template <typename StorageType, typename T, typename X1, typename X2, |
| 892 | typename X3, typename X4, typename X5> |
| 893 | struct Invoker1<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 894 | typedef void(*DoInvokeType)( |
| 895 | internal::InvokerStorageBase*, |
| 896 | typename internal::ParamTraits<X1>::ForwardType, |
| 897 | typename internal::ParamTraits<X2>::ForwardType, |
| 898 | typename internal::ParamTraits<X3>::ForwardType, |
| 899 | typename internal::ParamTraits<X4>::ForwardType, |
| 900 | typename internal::ParamTraits<X5>::ForwardType); |
| 901 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 902 | static void DoInvoke(InvokerStorageBase* base, |
| 903 | typename internal::ParamTraits<X1>::ForwardType x1, |
| 904 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 905 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 906 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 907 | typename internal::ParamTraits<X5>::ForwardType x5) { |
| 908 | StorageType* invoker = static_cast<StorageType*>(base); |
| 909 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 910 | if (!weak_ptr.get()) { |
| 911 | return; |
| 912 | } |
| 913 | (weak_ptr->*invoker->f_)(x1, x2, x3, x4, x5); |
| 914 | } |
| 915 | }; |
| 916 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 917 | template <bool IsWeak, typename StorageType, typename NormalizedSig> |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 918 | struct Invoker2; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 919 | |
| 920 | // Function: Arity 2 -> 0. |
| 921 | template <typename StorageType, typename R,typename X1, typename X2> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 922 | struct Invoker2<false, StorageType, R(*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 923 | typedef R(*DoInvokeType)( |
| 924 | internal::InvokerStorageBase*); |
| 925 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 926 | static R DoInvoke(InvokerStorageBase* base) { |
| 927 | StorageType* invoker = static_cast<StorageType*>(base); |
| 928 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_)); |
| 929 | } |
| 930 | }; |
| 931 | |
| 932 | // Method: Arity 1 -> 0. |
| 933 | template <typename StorageType, typename R, typename T, typename X1> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 934 | struct Invoker2<false, StorageType, R(T::*)(X1)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 935 | typedef R(*DoInvokeType)( |
| 936 | internal::InvokerStorageBase*); |
| 937 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 938 | static R DoInvoke(InvokerStorageBase* base) { |
| 939 | StorageType* invoker = static_cast<StorageType*>(base); |
| 940 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_)); |
| 941 | } |
| 942 | }; |
| 943 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 944 | // WeakPtr Method: Arity 1 -> 0. |
| 945 | template <typename StorageType, typename T, typename X1> |
| 946 | struct Invoker2<true, StorageType, void(T::*)(X1)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 947 | typedef void(*DoInvokeType)( |
| 948 | internal::InvokerStorageBase*); |
| 949 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 950 | static void DoInvoke(InvokerStorageBase* base) { |
| 951 | StorageType* invoker = static_cast<StorageType*>(base); |
| 952 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 953 | if (!weak_ptr.get()) { |
| 954 | return; |
| 955 | } |
| 956 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_)); |
| 957 | } |
| 958 | }; |
| 959 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 960 | // Function: Arity 3 -> 1. |
| 961 | template <typename StorageType, typename R,typename X1, typename X2, |
| 962 | typename X3> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 963 | struct Invoker2<false, StorageType, R(*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 964 | typedef R(*DoInvokeType)( |
| 965 | internal::InvokerStorageBase*, |
| 966 | typename internal::ParamTraits<X3>::ForwardType); |
| 967 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 968 | static R DoInvoke(InvokerStorageBase* base, |
| 969 | typename internal::ParamTraits<X3>::ForwardType x3) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 970 | StorageType* invoker = static_cast<StorageType*>(base); |
| 971 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3); |
| 972 | } |
| 973 | }; |
| 974 | |
| 975 | // Method: Arity 2 -> 1. |
| 976 | template <typename StorageType, typename R, typename T, typename X1, |
| 977 | typename X2> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 978 | struct Invoker2<false, StorageType, R(T::*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 979 | typedef R(*DoInvokeType)( |
| 980 | internal::InvokerStorageBase*, |
| 981 | typename internal::ParamTraits<X2>::ForwardType); |
| 982 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 983 | static R DoInvoke(InvokerStorageBase* base, |
| 984 | typename internal::ParamTraits<X2>::ForwardType x2) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 985 | StorageType* invoker = static_cast<StorageType*>(base); |
| 986 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2); |
| 987 | } |
| 988 | }; |
| 989 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 990 | // WeakPtr Method: Arity 2 -> 1. |
| 991 | template <typename StorageType, typename T, typename X1, typename X2> |
| 992 | struct Invoker2<true, StorageType, void(T::*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 993 | typedef void(*DoInvokeType)( |
| 994 | internal::InvokerStorageBase*, |
| 995 | typename internal::ParamTraits<X2>::ForwardType); |
| 996 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 997 | static void DoInvoke(InvokerStorageBase* base, |
| 998 | typename internal::ParamTraits<X2>::ForwardType x2) { |
| 999 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1000 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1001 | if (!weak_ptr.get()) { |
| 1002 | return; |
| 1003 | } |
| 1004 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), x2); |
| 1005 | } |
| 1006 | }; |
| 1007 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1008 | // Function: Arity 4 -> 2. |
| 1009 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1010 | typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1011 | struct Invoker2<false, StorageType, R(*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1012 | typedef R(*DoInvokeType)( |
| 1013 | internal::InvokerStorageBase*, |
| 1014 | typename internal::ParamTraits<X3>::ForwardType, |
| 1015 | typename internal::ParamTraits<X4>::ForwardType); |
| 1016 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1017 | static R DoInvoke(InvokerStorageBase* base, |
| 1018 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1019 | typename internal::ParamTraits<X4>::ForwardType x4) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1020 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1021 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4); |
| 1022 | } |
| 1023 | }; |
| 1024 | |
| 1025 | // Method: Arity 3 -> 2. |
| 1026 | template <typename StorageType, typename R, typename T, typename X1, |
| 1027 | typename X2, typename X3> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1028 | struct Invoker2<false, StorageType, R(T::*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1029 | typedef R(*DoInvokeType)( |
| 1030 | internal::InvokerStorageBase*, |
| 1031 | typename internal::ParamTraits<X2>::ForwardType, |
| 1032 | typename internal::ParamTraits<X3>::ForwardType); |
| 1033 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1034 | static R DoInvoke(InvokerStorageBase* base, |
| 1035 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 1036 | typename internal::ParamTraits<X3>::ForwardType x3) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1037 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1038 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); |
| 1039 | } |
| 1040 | }; |
| 1041 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1042 | // WeakPtr Method: Arity 3 -> 2. |
| 1043 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1044 | typename X3> |
| 1045 | struct Invoker2<true, StorageType, void(T::*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1046 | typedef void(*DoInvokeType)( |
| 1047 | internal::InvokerStorageBase*, |
| 1048 | typename internal::ParamTraits<X2>::ForwardType, |
| 1049 | typename internal::ParamTraits<X3>::ForwardType); |
| 1050 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1051 | static void DoInvoke(InvokerStorageBase* base, |
| 1052 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 1053 | typename internal::ParamTraits<X3>::ForwardType x3) { |
| 1054 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1055 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1056 | if (!weak_ptr.get()) { |
| 1057 | return; |
| 1058 | } |
| 1059 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), x2, x3); |
| 1060 | } |
| 1061 | }; |
| 1062 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1063 | // Function: Arity 5 -> 3. |
| 1064 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1065 | typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1066 | struct Invoker2<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1067 | typedef R(*DoInvokeType)( |
| 1068 | internal::InvokerStorageBase*, |
| 1069 | typename internal::ParamTraits<X3>::ForwardType, |
| 1070 | typename internal::ParamTraits<X4>::ForwardType, |
| 1071 | typename internal::ParamTraits<X5>::ForwardType); |
| 1072 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1073 | static R DoInvoke(InvokerStorageBase* base, |
| 1074 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1075 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1076 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1077 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1078 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5); |
| 1079 | } |
| 1080 | }; |
| 1081 | |
| 1082 | // Method: Arity 4 -> 3. |
| 1083 | template <typename StorageType, typename R, typename T, typename X1, |
| 1084 | typename X2, typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1085 | struct Invoker2<false, StorageType, R(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1086 | typedef R(*DoInvokeType)( |
| 1087 | internal::InvokerStorageBase*, |
| 1088 | typename internal::ParamTraits<X2>::ForwardType, |
| 1089 | typename internal::ParamTraits<X3>::ForwardType, |
| 1090 | typename internal::ParamTraits<X4>::ForwardType); |
| 1091 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1092 | static R DoInvoke(InvokerStorageBase* base, |
| 1093 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 1094 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1095 | typename internal::ParamTraits<X4>::ForwardType x4) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1096 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1097 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, |
| 1098 | x4); |
| 1099 | } |
| 1100 | }; |
| 1101 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1102 | // WeakPtr Method: Arity 4 -> 3. |
| 1103 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1104 | typename X3, typename X4> |
| 1105 | struct Invoker2<true, StorageType, void(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1106 | typedef void(*DoInvokeType)( |
| 1107 | internal::InvokerStorageBase*, |
| 1108 | typename internal::ParamTraits<X2>::ForwardType, |
| 1109 | typename internal::ParamTraits<X3>::ForwardType, |
| 1110 | typename internal::ParamTraits<X4>::ForwardType); |
| 1111 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1112 | static void DoInvoke(InvokerStorageBase* base, |
| 1113 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 1114 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1115 | typename internal::ParamTraits<X4>::ForwardType x4) { |
| 1116 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1117 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1118 | if (!weak_ptr.get()) { |
| 1119 | return; |
| 1120 | } |
| 1121 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, x4); |
| 1122 | } |
| 1123 | }; |
| 1124 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1125 | // Function: Arity 6 -> 4. |
| 1126 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1127 | typename X3, typename X4, typename X5, typename X6> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1128 | struct Invoker2<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1129 | typedef R(*DoInvokeType)( |
| 1130 | internal::InvokerStorageBase*, |
| 1131 | typename internal::ParamTraits<X3>::ForwardType, |
| 1132 | typename internal::ParamTraits<X4>::ForwardType, |
| 1133 | typename internal::ParamTraits<X5>::ForwardType, |
| 1134 | typename internal::ParamTraits<X6>::ForwardType); |
| 1135 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1136 | static R DoInvoke(InvokerStorageBase* base, |
| 1137 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1138 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1139 | typename internal::ParamTraits<X5>::ForwardType x5, |
| 1140 | typename internal::ParamTraits<X6>::ForwardType x6) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1141 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1142 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), x3, x4, x5, |
| 1143 | x6); |
| 1144 | } |
| 1145 | }; |
| 1146 | |
| 1147 | // Method: Arity 5 -> 4. |
| 1148 | template <typename StorageType, typename R, typename T, typename X1, |
| 1149 | typename X2, typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1150 | struct Invoker2<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1151 | typedef R(*DoInvokeType)( |
| 1152 | internal::InvokerStorageBase*, |
| 1153 | typename internal::ParamTraits<X2>::ForwardType, |
| 1154 | typename internal::ParamTraits<X3>::ForwardType, |
| 1155 | typename internal::ParamTraits<X4>::ForwardType, |
| 1156 | typename internal::ParamTraits<X5>::ForwardType); |
| 1157 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1158 | static R DoInvoke(InvokerStorageBase* base, |
| 1159 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 1160 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1161 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1162 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1163 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1164 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, |
| 1165 | x4, x5); |
| 1166 | } |
| 1167 | }; |
| 1168 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1169 | // WeakPtr Method: Arity 5 -> 4. |
| 1170 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1171 | typename X3, typename X4, typename X5> |
| 1172 | struct Invoker2<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1173 | typedef void(*DoInvokeType)( |
| 1174 | internal::InvokerStorageBase*, |
| 1175 | typename internal::ParamTraits<X2>::ForwardType, |
| 1176 | typename internal::ParamTraits<X3>::ForwardType, |
| 1177 | typename internal::ParamTraits<X4>::ForwardType, |
| 1178 | typename internal::ParamTraits<X5>::ForwardType); |
| 1179 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1180 | static void DoInvoke(InvokerStorageBase* base, |
| 1181 | typename internal::ParamTraits<X2>::ForwardType x2, |
| 1182 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1183 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1184 | typename internal::ParamTraits<X5>::ForwardType x5) { |
| 1185 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1186 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1187 | if (!weak_ptr.get()) { |
| 1188 | return; |
| 1189 | } |
| 1190 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), x2, x3, x4, x5); |
| 1191 | } |
| 1192 | }; |
| 1193 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1194 | template <bool IsWeak, typename StorageType, typename NormalizedSig> |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1195 | struct Invoker3; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1196 | |
| 1197 | // Function: Arity 3 -> 0. |
| 1198 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1199 | typename X3> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1200 | struct Invoker3<false, StorageType, R(*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1201 | typedef R(*DoInvokeType)( |
| 1202 | internal::InvokerStorageBase*); |
| 1203 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1204 | static R DoInvoke(InvokerStorageBase* base) { |
| 1205 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1206 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1207 | Unwrap(invoker->p3_)); |
| 1208 | } |
| 1209 | }; |
| 1210 | |
| 1211 | // Method: Arity 2 -> 0. |
| 1212 | template <typename StorageType, typename R, typename T, typename X1, |
| 1213 | typename X2> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1214 | struct Invoker3<false, StorageType, R(T::*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1215 | typedef R(*DoInvokeType)( |
| 1216 | internal::InvokerStorageBase*); |
| 1217 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1218 | static R DoInvoke(InvokerStorageBase* base) { |
| 1219 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1220 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1221 | Unwrap(invoker->p3_)); |
| 1222 | } |
| 1223 | }; |
| 1224 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1225 | // WeakPtr Method: Arity 2 -> 0. |
| 1226 | template <typename StorageType, typename T, typename X1, typename X2> |
| 1227 | struct Invoker3<true, StorageType, void(T::*)(X1, X2)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1228 | typedef void(*DoInvokeType)( |
| 1229 | internal::InvokerStorageBase*); |
| 1230 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1231 | static void DoInvoke(InvokerStorageBase* base) { |
| 1232 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1233 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1234 | if (!weak_ptr.get()) { |
| 1235 | return; |
| 1236 | } |
| 1237 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_)); |
| 1238 | } |
| 1239 | }; |
| 1240 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1241 | // Function: Arity 4 -> 1. |
| 1242 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1243 | typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1244 | struct Invoker3<false, StorageType, R(*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1245 | typedef R(*DoInvokeType)( |
| 1246 | internal::InvokerStorageBase*, |
| 1247 | typename internal::ParamTraits<X4>::ForwardType); |
| 1248 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1249 | static R DoInvoke(InvokerStorageBase* base, |
| 1250 | typename internal::ParamTraits<X4>::ForwardType x4) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1251 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1252 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1253 | Unwrap(invoker->p3_), x4); |
| 1254 | } |
| 1255 | }; |
| 1256 | |
| 1257 | // Method: Arity 3 -> 1. |
| 1258 | template <typename StorageType, typename R, typename T, typename X1, |
| 1259 | typename X2, typename X3> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1260 | struct Invoker3<false, StorageType, R(T::*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1261 | typedef R(*DoInvokeType)( |
| 1262 | internal::InvokerStorageBase*, |
| 1263 | typename internal::ParamTraits<X3>::ForwardType); |
| 1264 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1265 | static R DoInvoke(InvokerStorageBase* base, |
| 1266 | typename internal::ParamTraits<X3>::ForwardType x3) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1267 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1268 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1269 | Unwrap(invoker->p3_), x3); |
| 1270 | } |
| 1271 | }; |
| 1272 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1273 | // WeakPtr Method: Arity 3 -> 1. |
| 1274 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1275 | typename X3> |
| 1276 | struct Invoker3<true, StorageType, void(T::*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1277 | typedef void(*DoInvokeType)( |
| 1278 | internal::InvokerStorageBase*, |
| 1279 | typename internal::ParamTraits<X3>::ForwardType); |
| 1280 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1281 | static void DoInvoke(InvokerStorageBase* base, |
| 1282 | typename internal::ParamTraits<X3>::ForwardType x3) { |
| 1283 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1284 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1285 | if (!weak_ptr.get()) { |
| 1286 | return; |
| 1287 | } |
| 1288 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3); |
| 1289 | } |
| 1290 | }; |
| 1291 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1292 | // Function: Arity 5 -> 2. |
| 1293 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1294 | typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1295 | struct Invoker3<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1296 | typedef R(*DoInvokeType)( |
| 1297 | internal::InvokerStorageBase*, |
| 1298 | typename internal::ParamTraits<X4>::ForwardType, |
| 1299 | typename internal::ParamTraits<X5>::ForwardType); |
| 1300 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1301 | static R DoInvoke(InvokerStorageBase* base, |
| 1302 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1303 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1304 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1305 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1306 | Unwrap(invoker->p3_), x4, x5); |
| 1307 | } |
| 1308 | }; |
| 1309 | |
| 1310 | // Method: Arity 4 -> 2. |
| 1311 | template <typename StorageType, typename R, typename T, typename X1, |
| 1312 | typename X2, typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1313 | struct Invoker3<false, StorageType, R(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1314 | typedef R(*DoInvokeType)( |
| 1315 | internal::InvokerStorageBase*, |
| 1316 | typename internal::ParamTraits<X3>::ForwardType, |
| 1317 | typename internal::ParamTraits<X4>::ForwardType); |
| 1318 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1319 | static R DoInvoke(InvokerStorageBase* base, |
| 1320 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1321 | typename internal::ParamTraits<X4>::ForwardType x4) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1322 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1323 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1324 | Unwrap(invoker->p3_), x3, x4); |
| 1325 | } |
| 1326 | }; |
| 1327 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1328 | // WeakPtr Method: Arity 4 -> 2. |
| 1329 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1330 | typename X3, typename X4> |
| 1331 | struct Invoker3<true, StorageType, void(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1332 | typedef void(*DoInvokeType)( |
| 1333 | internal::InvokerStorageBase*, |
| 1334 | typename internal::ParamTraits<X3>::ForwardType, |
| 1335 | typename internal::ParamTraits<X4>::ForwardType); |
| 1336 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1337 | static void DoInvoke(InvokerStorageBase* base, |
| 1338 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1339 | typename internal::ParamTraits<X4>::ForwardType x4) { |
| 1340 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1341 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1342 | if (!weak_ptr.get()) { |
| 1343 | return; |
| 1344 | } |
| 1345 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3, |
| 1346 | x4); |
| 1347 | } |
| 1348 | }; |
| 1349 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1350 | // Function: Arity 6 -> 3. |
| 1351 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1352 | typename X3, typename X4, typename X5, typename X6> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1353 | struct Invoker3<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1354 | typedef R(*DoInvokeType)( |
| 1355 | internal::InvokerStorageBase*, |
| 1356 | typename internal::ParamTraits<X4>::ForwardType, |
| 1357 | typename internal::ParamTraits<X5>::ForwardType, |
| 1358 | typename internal::ParamTraits<X6>::ForwardType); |
| 1359 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1360 | static R DoInvoke(InvokerStorageBase* base, |
| 1361 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1362 | typename internal::ParamTraits<X5>::ForwardType x5, |
| 1363 | typename internal::ParamTraits<X6>::ForwardType x6) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1364 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1365 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1366 | Unwrap(invoker->p3_), x4, x5, x6); |
| 1367 | } |
| 1368 | }; |
| 1369 | |
| 1370 | // Method: Arity 5 -> 3. |
| 1371 | template <typename StorageType, typename R, typename T, typename X1, |
| 1372 | typename X2, typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1373 | struct Invoker3<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1374 | typedef R(*DoInvokeType)( |
| 1375 | internal::InvokerStorageBase*, |
| 1376 | typename internal::ParamTraits<X3>::ForwardType, |
| 1377 | typename internal::ParamTraits<X4>::ForwardType, |
| 1378 | typename internal::ParamTraits<X5>::ForwardType); |
| 1379 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1380 | static R DoInvoke(InvokerStorageBase* base, |
| 1381 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1382 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1383 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1384 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1385 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1386 | Unwrap(invoker->p3_), x3, x4, x5); |
| 1387 | } |
| 1388 | }; |
| 1389 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1390 | // WeakPtr Method: Arity 5 -> 3. |
| 1391 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1392 | typename X3, typename X4, typename X5> |
| 1393 | struct Invoker3<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1394 | typedef void(*DoInvokeType)( |
| 1395 | internal::InvokerStorageBase*, |
| 1396 | typename internal::ParamTraits<X3>::ForwardType, |
| 1397 | typename internal::ParamTraits<X4>::ForwardType, |
| 1398 | typename internal::ParamTraits<X5>::ForwardType); |
| 1399 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1400 | static void DoInvoke(InvokerStorageBase* base, |
| 1401 | typename internal::ParamTraits<X3>::ForwardType x3, |
| 1402 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1403 | typename internal::ParamTraits<X5>::ForwardType x5) { |
| 1404 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1405 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1406 | if (!weak_ptr.get()) { |
| 1407 | return; |
| 1408 | } |
| 1409 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), x3, |
| 1410 | x4, x5); |
| 1411 | } |
| 1412 | }; |
| 1413 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1414 | template <bool IsWeak, typename StorageType, typename NormalizedSig> |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1415 | struct Invoker4; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1416 | |
| 1417 | // Function: Arity 4 -> 0. |
| 1418 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1419 | typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1420 | struct Invoker4<false, StorageType, R(*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1421 | typedef R(*DoInvokeType)( |
| 1422 | internal::InvokerStorageBase*); |
| 1423 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1424 | static R DoInvoke(InvokerStorageBase* base) { |
| 1425 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1426 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1427 | Unwrap(invoker->p3_), Unwrap(invoker->p4_)); |
| 1428 | } |
| 1429 | }; |
| 1430 | |
| 1431 | // Method: Arity 3 -> 0. |
| 1432 | template <typename StorageType, typename R, typename T, typename X1, |
| 1433 | typename X2, typename X3> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1434 | struct Invoker4<false, StorageType, R(T::*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1435 | typedef R(*DoInvokeType)( |
| 1436 | internal::InvokerStorageBase*); |
| 1437 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1438 | static R DoInvoke(InvokerStorageBase* base) { |
| 1439 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1440 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1441 | Unwrap(invoker->p3_), Unwrap(invoker->p4_)); |
| 1442 | } |
| 1443 | }; |
| 1444 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1445 | // WeakPtr Method: Arity 3 -> 0. |
| 1446 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1447 | typename X3> |
| 1448 | struct Invoker4<true, StorageType, void(T::*)(X1, X2, X3)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1449 | typedef void(*DoInvokeType)( |
| 1450 | internal::InvokerStorageBase*); |
| 1451 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1452 | static void DoInvoke(InvokerStorageBase* base) { |
| 1453 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1454 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1455 | if (!weak_ptr.get()) { |
| 1456 | return; |
| 1457 | } |
| 1458 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), |
| 1459 | Unwrap(invoker->p4_)); |
| 1460 | } |
| 1461 | }; |
| 1462 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1463 | // Function: Arity 5 -> 1. |
| 1464 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1465 | typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1466 | struct Invoker4<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1467 | typedef R(*DoInvokeType)( |
| 1468 | internal::InvokerStorageBase*, |
| 1469 | typename internal::ParamTraits<X5>::ForwardType); |
| 1470 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1471 | static R DoInvoke(InvokerStorageBase* base, |
| 1472 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1473 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1474 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1475 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5); |
| 1476 | } |
| 1477 | }; |
| 1478 | |
| 1479 | // Method: Arity 4 -> 1. |
| 1480 | template <typename StorageType, typename R, typename T, typename X1, |
| 1481 | typename X2, typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1482 | struct Invoker4<false, StorageType, R(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1483 | typedef R(*DoInvokeType)( |
| 1484 | internal::InvokerStorageBase*, |
| 1485 | typename internal::ParamTraits<X4>::ForwardType); |
| 1486 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1487 | static R DoInvoke(InvokerStorageBase* base, |
| 1488 | typename internal::ParamTraits<X4>::ForwardType x4) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1489 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1490 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1491 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4); |
| 1492 | } |
| 1493 | }; |
| 1494 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1495 | // WeakPtr Method: Arity 4 -> 1. |
| 1496 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1497 | typename X3, typename X4> |
| 1498 | struct Invoker4<true, StorageType, void(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1499 | typedef void(*DoInvokeType)( |
| 1500 | internal::InvokerStorageBase*, |
| 1501 | typename internal::ParamTraits<X4>::ForwardType); |
| 1502 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1503 | static void DoInvoke(InvokerStorageBase* base, |
| 1504 | typename internal::ParamTraits<X4>::ForwardType x4) { |
| 1505 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1506 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1507 | if (!weak_ptr.get()) { |
| 1508 | return; |
| 1509 | } |
| 1510 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), |
| 1511 | Unwrap(invoker->p4_), x4); |
| 1512 | } |
| 1513 | }; |
| 1514 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1515 | // Function: Arity 6 -> 2. |
| 1516 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1517 | typename X3, typename X4, typename X5, typename X6> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1518 | struct Invoker4<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1519 | typedef R(*DoInvokeType)( |
| 1520 | internal::InvokerStorageBase*, |
| 1521 | typename internal::ParamTraits<X5>::ForwardType, |
| 1522 | typename internal::ParamTraits<X6>::ForwardType); |
| 1523 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1524 | static R DoInvoke(InvokerStorageBase* base, |
| 1525 | typename internal::ParamTraits<X5>::ForwardType x5, |
| 1526 | typename internal::ParamTraits<X6>::ForwardType x6) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1527 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1528 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1529 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), x5, x6); |
| 1530 | } |
| 1531 | }; |
| 1532 | |
| 1533 | // Method: Arity 5 -> 2. |
| 1534 | template <typename StorageType, typename R, typename T, typename X1, |
| 1535 | typename X2, typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1536 | struct Invoker4<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1537 | typedef R(*DoInvokeType)( |
| 1538 | internal::InvokerStorageBase*, |
| 1539 | typename internal::ParamTraits<X4>::ForwardType, |
| 1540 | typename internal::ParamTraits<X5>::ForwardType); |
| 1541 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1542 | static R DoInvoke(InvokerStorageBase* base, |
| 1543 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1544 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1545 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1546 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1547 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), x4, x5); |
| 1548 | } |
| 1549 | }; |
| 1550 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1551 | // WeakPtr Method: Arity 5 -> 2. |
| 1552 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1553 | typename X3, typename X4, typename X5> |
| 1554 | struct Invoker4<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1555 | typedef void(*DoInvokeType)( |
| 1556 | internal::InvokerStorageBase*, |
| 1557 | typename internal::ParamTraits<X4>::ForwardType, |
| 1558 | typename internal::ParamTraits<X5>::ForwardType); |
| 1559 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1560 | static void DoInvoke(InvokerStorageBase* base, |
| 1561 | typename internal::ParamTraits<X4>::ForwardType x4, |
| 1562 | typename internal::ParamTraits<X5>::ForwardType x5) { |
| 1563 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1564 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1565 | if (!weak_ptr.get()) { |
| 1566 | return; |
| 1567 | } |
| 1568 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), |
| 1569 | Unwrap(invoker->p4_), x4, x5); |
| 1570 | } |
| 1571 | }; |
| 1572 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1573 | template <bool IsWeak, typename StorageType, typename NormalizedSig> |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1574 | struct Invoker5; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1575 | |
| 1576 | // Function: Arity 5 -> 0. |
| 1577 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1578 | typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1579 | struct Invoker5<false, StorageType, R(*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1580 | typedef R(*DoInvokeType)( |
| 1581 | internal::InvokerStorageBase*); |
| 1582 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1583 | static R DoInvoke(InvokerStorageBase* base) { |
| 1584 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1585 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1586 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); |
| 1587 | } |
| 1588 | }; |
| 1589 | |
| 1590 | // Method: Arity 4 -> 0. |
| 1591 | template <typename StorageType, typename R, typename T, typename X1, |
| 1592 | typename X2, typename X3, typename X4> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1593 | struct Invoker5<false, StorageType, R(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1594 | typedef R(*DoInvokeType)( |
| 1595 | internal::InvokerStorageBase*); |
| 1596 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1597 | static R DoInvoke(InvokerStorageBase* base) { |
| 1598 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1599 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1600 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_)); |
| 1601 | } |
| 1602 | }; |
| 1603 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1604 | // WeakPtr Method: Arity 4 -> 0. |
| 1605 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1606 | typename X3, typename X4> |
| 1607 | struct Invoker5<true, StorageType, void(T::*)(X1, X2, X3, X4)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1608 | typedef void(*DoInvokeType)( |
| 1609 | internal::InvokerStorageBase*); |
| 1610 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1611 | static void DoInvoke(InvokerStorageBase* base) { |
| 1612 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1613 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1614 | if (!weak_ptr.get()) { |
| 1615 | return; |
| 1616 | } |
| 1617 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), |
| 1618 | Unwrap(invoker->p4_), Unwrap(invoker->p5_)); |
| 1619 | } |
| 1620 | }; |
| 1621 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1622 | // Function: Arity 6 -> 1. |
| 1623 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1624 | typename X3, typename X4, typename X5, typename X6> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1625 | struct Invoker5<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1626 | typedef R(*DoInvokeType)( |
| 1627 | internal::InvokerStorageBase*, |
| 1628 | typename internal::ParamTraits<X6>::ForwardType); |
| 1629 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1630 | static R DoInvoke(InvokerStorageBase* base, |
| 1631 | typename internal::ParamTraits<X6>::ForwardType x6) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1632 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1633 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1634 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x6); |
| 1635 | } |
| 1636 | }; |
| 1637 | |
| 1638 | // Method: Arity 5 -> 1. |
| 1639 | template <typename StorageType, typename R, typename T, typename X1, |
| 1640 | typename X2, typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1641 | struct Invoker5<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1642 | typedef R(*DoInvokeType)( |
| 1643 | internal::InvokerStorageBase*, |
| 1644 | typename internal::ParamTraits<X5>::ForwardType); |
| 1645 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1646 | static R DoInvoke(InvokerStorageBase* base, |
| 1647 | typename internal::ParamTraits<X5>::ForwardType x5) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1648 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1649 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1650 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); |
| 1651 | } |
| 1652 | }; |
| 1653 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1654 | // WeakPtr Method: Arity 5 -> 1. |
| 1655 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1656 | typename X3, typename X4, typename X5> |
| 1657 | struct Invoker5<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1658 | typedef void(*DoInvokeType)( |
| 1659 | internal::InvokerStorageBase*, |
| 1660 | typename internal::ParamTraits<X5>::ForwardType); |
| 1661 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1662 | static void DoInvoke(InvokerStorageBase* base, |
| 1663 | typename internal::ParamTraits<X5>::ForwardType x5) { |
| 1664 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1665 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1666 | if (!weak_ptr.get()) { |
| 1667 | return; |
| 1668 | } |
| 1669 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), |
| 1670 | Unwrap(invoker->p4_), Unwrap(invoker->p5_), x5); |
| 1671 | } |
| 1672 | }; |
| 1673 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1674 | template <bool IsWeak, typename StorageType, typename NormalizedSig> |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1675 | struct Invoker6; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1676 | |
| 1677 | // Function: Arity 6 -> 0. |
| 1678 | template <typename StorageType, typename R,typename X1, typename X2, |
| 1679 | typename X3, typename X4, typename X5, typename X6> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1680 | struct Invoker6<false, StorageType, R(*)(X1, X2, X3, X4, X5, X6)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1681 | typedef R(*DoInvokeType)( |
| 1682 | internal::InvokerStorageBase*); |
| 1683 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1684 | static R DoInvoke(InvokerStorageBase* base) { |
| 1685 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1686 | return invoker->f_(Unwrap(invoker->p1_), Unwrap(invoker->p2_), |
| 1687 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), |
| 1688 | Unwrap(invoker->p6_)); |
| 1689 | } |
| 1690 | }; |
| 1691 | |
| 1692 | // Method: Arity 5 -> 0. |
| 1693 | template <typename StorageType, typename R, typename T, typename X1, |
| 1694 | typename X2, typename X3, typename X4, typename X5> |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1695 | struct Invoker6<false, StorageType, R(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1696 | typedef R(*DoInvokeType)( |
| 1697 | internal::InvokerStorageBase*); |
| 1698 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1699 | static R DoInvoke(InvokerStorageBase* base) { |
| 1700 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1701 | return (Unwrap(invoker->p1_)->*invoker->f_)(Unwrap(invoker->p2_), |
| 1702 | Unwrap(invoker->p3_), Unwrap(invoker->p4_), Unwrap(invoker->p5_), |
| 1703 | Unwrap(invoker->p6_)); |
| 1704 | } |
| 1705 | }; |
| 1706 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1707 | // WeakPtr Method: Arity 5 -> 0. |
| 1708 | template <typename StorageType, typename T, typename X1, typename X2, |
| 1709 | typename X3, typename X4, typename X5> |
| 1710 | struct Invoker6<true, StorageType, void(T::*)(X1, X2, X3, X4, X5)> { |
[email protected] | 6a341fb | 2011-06-26 16:22:50 | [diff] [blame] | 1711 | typedef void(*DoInvokeType)( |
| 1712 | internal::InvokerStorageBase*); |
| 1713 | |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1714 | static void DoInvoke(InvokerStorageBase* base) { |
| 1715 | StorageType* invoker = static_cast<StorageType*>(base); |
| 1716 | typename StorageType::P1Traits::StorageType& weak_ptr = invoker->p1_; |
| 1717 | if (!weak_ptr.get()) { |
| 1718 | return; |
| 1719 | } |
| 1720 | (weak_ptr->*invoker->f_)(Unwrap(invoker->p2_), Unwrap(invoker->p3_), |
| 1721 | Unwrap(invoker->p4_), Unwrap(invoker->p5_), Unwrap(invoker->p6_)); |
| 1722 | } |
| 1723 | }; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1724 | |
[email protected] | cea20fe4 | 2011-09-30 09:09:34 | [diff] [blame] | 1725 | // BindMoreFuncN<> |
| 1726 | // |
| 1727 | // This set of functions help in fully binding the free parameters in a |
| 1728 | // Callback<>. |
| 1729 | template <typename Sig, typename P1> |
| 1730 | void BindMoreFunc1(const base::Callback<Sig>& callback, const P1& p1) { |
| 1731 | callback.Run(p1); |
| 1732 | } |
| 1733 | |
| 1734 | template <typename Sig, typename P1, typename P2> |
| 1735 | void BindMoreFunc2(const base::Callback<Sig>& callback, const P1& p1, |
| 1736 | const P2& p2) { |
| 1737 | callback.Run(p1, p2); |
| 1738 | } |
| 1739 | |
| 1740 | template <typename Sig, typename P1, typename P2, typename P3> |
| 1741 | void BindMoreFunc3(const base::Callback<Sig>& callback, const P1& p1, |
| 1742 | const P2& p2, const P3& p3) { |
| 1743 | callback.Run(p1, p2, p3); |
| 1744 | } |
| 1745 | |
| 1746 | template <typename Sig, typename P1, typename P2, typename P3, typename P4> |
| 1747 | void BindMoreFunc4(const base::Callback<Sig>& callback, const P1& p1, |
| 1748 | const P2& p2, const P3& p3, const P4& p4) { |
| 1749 | callback.Run(p1, p2, p3, p4); |
| 1750 | } |
| 1751 | |
| 1752 | template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
| 1753 | typename P5> |
| 1754 | void BindMoreFunc5(const base::Callback<Sig>& callback, const P1& p1, |
| 1755 | const P2& p2, const P3& p3, const P4& p4, const P5& p5) { |
| 1756 | callback.Run(p1, p2, p3, p4, p5); |
| 1757 | } |
| 1758 | |
| 1759 | template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
| 1760 | typename P5, typename P6> |
| 1761 | void BindMoreFunc6(const base::Callback<Sig>& callback, const P1& p1, |
| 1762 | const P2& p2, const P3& p3, const P4& p4, const P5& p5, const P6& p6) { |
| 1763 | callback.Run(p1, p2, p3, p4, p5, p6); |
| 1764 | } |
| 1765 | |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1766 | // InvokerStorageN<> |
| 1767 | // |
| 1768 | // These are the actual storage classes for the Invokers. |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1769 | // |
| 1770 | // Though these types are "classes", they are being used as structs with |
| 1771 | // all member variable public. We cannot make it a struct because it inherits |
| 1772 | // from a class which causes a compiler warning. We cannot add a "Run()" method |
| 1773 | // that forwards the unbound arguments because that would require we unwrap the |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1774 | // Sig type like in InvokerN above to know the return type, and the arity |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1775 | // of Run(). |
| 1776 | // |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1777 | // An alternate solution would be to merge InvokerN and InvokerStorageN, |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1778 | // but the generated code seemed harder to read. |
| 1779 | |
| 1780 | template <typename Sig> |
| 1781 | class InvokerStorage0 : public InvokerStorageBase { |
| 1782 | public: |
| 1783 | typedef InvokerStorage0 StorageType; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1784 | typedef FunctionTraits<Sig> TargetTraits; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1785 | typedef typename TargetTraits::IsMethod IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1786 | typedef Sig Signature; |
| 1787 | typedef Invoker0<false, StorageType, |
| 1788 | typename TargetTraits::NormalizedSig> Invoker; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1789 | |
| 1790 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1791 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1792 | InvokerStorage0(Sig f) |
| 1793 | : f_(f) { |
| 1794 | } |
| 1795 | |
| 1796 | virtual ~InvokerStorage0() { } |
| 1797 | |
| 1798 | Sig f_; |
| 1799 | }; |
| 1800 | |
| 1801 | template <typename Sig, typename P1> |
| 1802 | class InvokerStorage1 : public InvokerStorageBase { |
| 1803 | public: |
| 1804 | typedef InvokerStorage1 StorageType; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1805 | typedef FunctionTraits<Sig> TargetTraits; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1806 | typedef typename TargetTraits::IsMethod IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1807 | typedef Sig Signature; |
| 1808 | typedef ParamTraits<P1> P1Traits; |
| 1809 | typedef Invoker1<IsWeakMethod<IsMethod::value, P1>::value, StorageType, |
| 1810 | typename TargetTraits::NormalizedSig> Invoker; |
| 1811 | COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || |
| 1812 | is_void<typename TargetTraits::Return>::value, |
| 1813 | weak_ptrs_can_only_bind_to_methods_without_return_values); |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1814 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1815 | // For methods, we need to be careful for parameter 1. We skip the |
| 1816 | // scoped_refptr check because the binder itself takes care of this. We also |
| 1817 | // disallow binding of an array as the method's target object. |
| 1818 | COMPILE_ASSERT(IsMethod::value || |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 1819 | internal::NeedsScopedRefptrButGetsRawPtr< |
| 1820 | typename ParamTraits<P1>::StorageType>::value == 0, |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1821 | p1_is_refcounted_type_and_needs_scoped_refptr); |
| 1822 | COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
| 1823 | first_bound_argument_to_method_cannot_be_array); |
| 1824 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1825 | // Do not allow binding a non-const reference parameter. Non-const reference |
| 1826 | // parameters are disallowed by the Google style guide. Also, binding a |
| 1827 | // non-const reference parameter can make for subtle bugs because the |
| 1828 | // invoked function will receive a reference to the stored copy of the |
| 1829 | // argument and not the original. |
| 1830 | COMPILE_ASSERT( |
| 1831 | !( is_non_const_reference<typename TargetTraits::B1>::value ), |
| 1832 | do_not_bind_functions_with_nonconst_ref); |
| 1833 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1834 | |
| 1835 | InvokerStorage1(Sig f, const P1& p1) |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1836 | : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1837 | MaybeRefcount<IsMethod, P1>::AddRef(p1_); |
| 1838 | } |
| 1839 | |
| 1840 | virtual ~InvokerStorage1() { |
| 1841 | MaybeRefcount<IsMethod, P1>::Release(p1_); |
| 1842 | } |
| 1843 | |
| 1844 | Sig f_; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1845 | typename ParamTraits<P1>::StorageType p1_; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1846 | }; |
| 1847 | |
| 1848 | template <typename Sig, typename P1, typename P2> |
| 1849 | class InvokerStorage2 : public InvokerStorageBase { |
| 1850 | public: |
| 1851 | typedef InvokerStorage2 StorageType; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1852 | typedef FunctionTraits<Sig> TargetTraits; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1853 | typedef typename TargetTraits::IsMethod IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1854 | typedef Sig Signature; |
| 1855 | typedef ParamTraits<P1> P1Traits; |
| 1856 | typedef ParamTraits<P2> P2Traits; |
| 1857 | typedef Invoker2<IsWeakMethod<IsMethod::value, P1>::value, StorageType, |
| 1858 | typename TargetTraits::NormalizedSig> Invoker; |
| 1859 | COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || |
| 1860 | is_void<typename TargetTraits::Return>::value, |
| 1861 | weak_ptrs_can_only_bind_to_methods_without_return_values); |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1862 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1863 | // For methods, we need to be careful for parameter 1. We skip the |
| 1864 | // scoped_refptr check because the binder itself takes care of this. We also |
| 1865 | // disallow binding of an array as the method's target object. |
| 1866 | COMPILE_ASSERT(IsMethod::value || |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 1867 | internal::NeedsScopedRefptrButGetsRawPtr< |
| 1868 | typename ParamTraits<P1>::StorageType>::value == 0, |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1869 | p1_is_refcounted_type_and_needs_scoped_refptr); |
| 1870 | COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
| 1871 | first_bound_argument_to_method_cannot_be_array); |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 1872 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 1873 | typename ParamTraits<P2>::StorageType>::value == 0, |
| 1874 | p2_is_refcounted_type_and_needs_scoped_refptr); |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1875 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1876 | // Do not allow binding a non-const reference parameter. Non-const reference |
| 1877 | // parameters are disallowed by the Google style guide. Also, binding a |
| 1878 | // non-const reference parameter can make for subtle bugs because the |
| 1879 | // invoked function will receive a reference to the stored copy of the |
| 1880 | // argument and not the original. |
| 1881 | COMPILE_ASSERT( |
| 1882 | !( is_non_const_reference<typename TargetTraits::B1>::value || |
| 1883 | is_non_const_reference<typename TargetTraits::B2>::value ), |
| 1884 | do_not_bind_functions_with_nonconst_ref); |
| 1885 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1886 | |
| 1887 | InvokerStorage2(Sig f, const P1& p1, const P2& p2) |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1888 | : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), |
| 1889 | p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1890 | MaybeRefcount<IsMethod, P1>::AddRef(p1_); |
| 1891 | } |
| 1892 | |
| 1893 | virtual ~InvokerStorage2() { |
| 1894 | MaybeRefcount<IsMethod, P1>::Release(p1_); |
| 1895 | } |
| 1896 | |
| 1897 | Sig f_; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1898 | typename ParamTraits<P1>::StorageType p1_; |
| 1899 | typename ParamTraits<P2>::StorageType p2_; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1900 | }; |
| 1901 | |
| 1902 | template <typename Sig, typename P1, typename P2, typename P3> |
| 1903 | class InvokerStorage3 : public InvokerStorageBase { |
| 1904 | public: |
| 1905 | typedef InvokerStorage3 StorageType; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1906 | typedef FunctionTraits<Sig> TargetTraits; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1907 | typedef typename TargetTraits::IsMethod IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1908 | typedef Sig Signature; |
| 1909 | typedef ParamTraits<P1> P1Traits; |
| 1910 | typedef ParamTraits<P2> P2Traits; |
| 1911 | typedef ParamTraits<P3> P3Traits; |
| 1912 | typedef Invoker3<IsWeakMethod<IsMethod::value, P1>::value, StorageType, |
| 1913 | typename TargetTraits::NormalizedSig> Invoker; |
| 1914 | COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || |
| 1915 | is_void<typename TargetTraits::Return>::value, |
| 1916 | weak_ptrs_can_only_bind_to_methods_without_return_values); |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1917 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1918 | // For methods, we need to be careful for parameter 1. We skip the |
| 1919 | // scoped_refptr check because the binder itself takes care of this. We also |
| 1920 | // disallow binding of an array as the method's target object. |
| 1921 | COMPILE_ASSERT(IsMethod::value || |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 1922 | internal::NeedsScopedRefptrButGetsRawPtr< |
| 1923 | typename ParamTraits<P1>::StorageType>::value == 0, |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1924 | p1_is_refcounted_type_and_needs_scoped_refptr); |
| 1925 | COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
| 1926 | first_bound_argument_to_method_cannot_be_array); |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 1927 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 1928 | typename ParamTraits<P2>::StorageType>::value == 0, |
| 1929 | p2_is_refcounted_type_and_needs_scoped_refptr); |
| 1930 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 1931 | typename ParamTraits<P3>::StorageType>::value == 0, |
| 1932 | p3_is_refcounted_type_and_needs_scoped_refptr); |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1933 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1934 | // Do not allow binding a non-const reference parameter. Non-const reference |
| 1935 | // parameters are disallowed by the Google style guide. Also, binding a |
| 1936 | // non-const reference parameter can make for subtle bugs because the |
| 1937 | // invoked function will receive a reference to the stored copy of the |
| 1938 | // argument and not the original. |
| 1939 | COMPILE_ASSERT( |
| 1940 | !( is_non_const_reference<typename TargetTraits::B1>::value || |
| 1941 | is_non_const_reference<typename TargetTraits::B2>::value || |
| 1942 | is_non_const_reference<typename TargetTraits::B3>::value ), |
| 1943 | do_not_bind_functions_with_nonconst_ref); |
| 1944 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1945 | |
| 1946 | InvokerStorage3(Sig f, const P1& p1, const P2& p2, const P3& p3) |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1947 | : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), |
| 1948 | p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)), |
| 1949 | p3_(static_cast<typename ParamTraits<P3>::StorageType>(p3)) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1950 | MaybeRefcount<IsMethod, P1>::AddRef(p1_); |
| 1951 | } |
| 1952 | |
| 1953 | virtual ~InvokerStorage3() { |
| 1954 | MaybeRefcount<IsMethod, P1>::Release(p1_); |
| 1955 | } |
| 1956 | |
| 1957 | Sig f_; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1958 | typename ParamTraits<P1>::StorageType p1_; |
| 1959 | typename ParamTraits<P2>::StorageType p2_; |
| 1960 | typename ParamTraits<P3>::StorageType p3_; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1961 | }; |
| 1962 | |
| 1963 | template <typename Sig, typename P1, typename P2, typename P3, typename P4> |
| 1964 | class InvokerStorage4 : public InvokerStorageBase { |
| 1965 | public: |
| 1966 | typedef InvokerStorage4 StorageType; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1967 | typedef FunctionTraits<Sig> TargetTraits; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 1968 | typedef typename TargetTraits::IsMethod IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 1969 | typedef Sig Signature; |
| 1970 | typedef ParamTraits<P1> P1Traits; |
| 1971 | typedef ParamTraits<P2> P2Traits; |
| 1972 | typedef ParamTraits<P3> P3Traits; |
| 1973 | typedef ParamTraits<P4> P4Traits; |
| 1974 | typedef Invoker4<IsWeakMethod<IsMethod::value, P1>::value, StorageType, |
| 1975 | typename TargetTraits::NormalizedSig> Invoker; |
| 1976 | COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || |
| 1977 | is_void<typename TargetTraits::Return>::value, |
| 1978 | weak_ptrs_can_only_bind_to_methods_without_return_values); |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1979 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1980 | // For methods, we need to be careful for parameter 1. We skip the |
| 1981 | // scoped_refptr check because the binder itself takes care of this. We also |
| 1982 | // disallow binding of an array as the method's target object. |
| 1983 | COMPILE_ASSERT(IsMethod::value || |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 1984 | internal::NeedsScopedRefptrButGetsRawPtr< |
| 1985 | typename ParamTraits<P1>::StorageType>::value == 0, |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1986 | p1_is_refcounted_type_and_needs_scoped_refptr); |
| 1987 | COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
| 1988 | first_bound_argument_to_method_cannot_be_array); |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 1989 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 1990 | typename ParamTraits<P2>::StorageType>::value == 0, |
| 1991 | p2_is_refcounted_type_and_needs_scoped_refptr); |
| 1992 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 1993 | typename ParamTraits<P3>::StorageType>::value == 0, |
| 1994 | p3_is_refcounted_type_and_needs_scoped_refptr); |
| 1995 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 1996 | typename ParamTraits<P4>::StorageType>::value == 0, |
| 1997 | p4_is_refcounted_type_and_needs_scoped_refptr); |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 1998 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 1999 | // Do not allow binding a non-const reference parameter. Non-const reference |
| 2000 | // parameters are disallowed by the Google style guide. Also, binding a |
| 2001 | // non-const reference parameter can make for subtle bugs because the |
| 2002 | // invoked function will receive a reference to the stored copy of the |
| 2003 | // argument and not the original. |
| 2004 | COMPILE_ASSERT( |
| 2005 | !( is_non_const_reference<typename TargetTraits::B1>::value || |
| 2006 | is_non_const_reference<typename TargetTraits::B2>::value || |
| 2007 | is_non_const_reference<typename TargetTraits::B3>::value || |
| 2008 | is_non_const_reference<typename TargetTraits::B4>::value ), |
| 2009 | do_not_bind_functions_with_nonconst_ref); |
| 2010 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2011 | |
| 2012 | InvokerStorage4(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4) |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2013 | : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), |
| 2014 | p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)), |
| 2015 | p3_(static_cast<typename ParamTraits<P3>::StorageType>(p3)), |
| 2016 | p4_(static_cast<typename ParamTraits<P4>::StorageType>(p4)) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2017 | MaybeRefcount<IsMethod, P1>::AddRef(p1_); |
| 2018 | } |
| 2019 | |
| 2020 | virtual ~InvokerStorage4() { |
| 2021 | MaybeRefcount<IsMethod, P1>::Release(p1_); |
| 2022 | } |
| 2023 | |
| 2024 | Sig f_; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2025 | typename ParamTraits<P1>::StorageType p1_; |
| 2026 | typename ParamTraits<P2>::StorageType p2_; |
| 2027 | typename ParamTraits<P3>::StorageType p3_; |
| 2028 | typename ParamTraits<P4>::StorageType p4_; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2029 | }; |
| 2030 | |
| 2031 | template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
| 2032 | typename P5> |
| 2033 | class InvokerStorage5 : public InvokerStorageBase { |
| 2034 | public: |
| 2035 | typedef InvokerStorage5 StorageType; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 2036 | typedef FunctionTraits<Sig> TargetTraits; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 2037 | typedef typename TargetTraits::IsMethod IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 2038 | typedef Sig Signature; |
| 2039 | typedef ParamTraits<P1> P1Traits; |
| 2040 | typedef ParamTraits<P2> P2Traits; |
| 2041 | typedef ParamTraits<P3> P3Traits; |
| 2042 | typedef ParamTraits<P4> P4Traits; |
| 2043 | typedef ParamTraits<P5> P5Traits; |
| 2044 | typedef Invoker5<IsWeakMethod<IsMethod::value, P1>::value, StorageType, |
| 2045 | typename TargetTraits::NormalizedSig> Invoker; |
| 2046 | COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || |
| 2047 | is_void<typename TargetTraits::Return>::value, |
| 2048 | weak_ptrs_can_only_bind_to_methods_without_return_values); |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2049 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2050 | // For methods, we need to be careful for parameter 1. We skip the |
| 2051 | // scoped_refptr check because the binder itself takes care of this. We also |
| 2052 | // disallow binding of an array as the method's target object. |
| 2053 | COMPILE_ASSERT(IsMethod::value || |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 2054 | internal::NeedsScopedRefptrButGetsRawPtr< |
| 2055 | typename ParamTraits<P1>::StorageType>::value == 0, |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2056 | p1_is_refcounted_type_and_needs_scoped_refptr); |
| 2057 | COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
| 2058 | first_bound_argument_to_method_cannot_be_array); |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 2059 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2060 | typename ParamTraits<P2>::StorageType>::value == 0, |
| 2061 | p2_is_refcounted_type_and_needs_scoped_refptr); |
| 2062 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2063 | typename ParamTraits<P3>::StorageType>::value == 0, |
| 2064 | p3_is_refcounted_type_and_needs_scoped_refptr); |
| 2065 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2066 | typename ParamTraits<P4>::StorageType>::value == 0, |
| 2067 | p4_is_refcounted_type_and_needs_scoped_refptr); |
| 2068 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2069 | typename ParamTraits<P5>::StorageType>::value == 0, |
| 2070 | p5_is_refcounted_type_and_needs_scoped_refptr); |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2071 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2072 | // Do not allow binding a non-const reference parameter. Non-const reference |
| 2073 | // parameters are disallowed by the Google style guide. Also, binding a |
| 2074 | // non-const reference parameter can make for subtle bugs because the |
| 2075 | // invoked function will receive a reference to the stored copy of the |
| 2076 | // argument and not the original. |
| 2077 | COMPILE_ASSERT( |
| 2078 | !( is_non_const_reference<typename TargetTraits::B1>::value || |
| 2079 | is_non_const_reference<typename TargetTraits::B2>::value || |
| 2080 | is_non_const_reference<typename TargetTraits::B3>::value || |
| 2081 | is_non_const_reference<typename TargetTraits::B4>::value || |
| 2082 | is_non_const_reference<typename TargetTraits::B5>::value ), |
| 2083 | do_not_bind_functions_with_nonconst_ref); |
| 2084 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2085 | |
| 2086 | InvokerStorage5(Sig f, const P1& p1, const P2& p2, const P3& p3, |
| 2087 | const P4& p4, const P5& p5) |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2088 | : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), |
| 2089 | p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)), |
| 2090 | p3_(static_cast<typename ParamTraits<P3>::StorageType>(p3)), |
| 2091 | p4_(static_cast<typename ParamTraits<P4>::StorageType>(p4)), |
| 2092 | p5_(static_cast<typename ParamTraits<P5>::StorageType>(p5)) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2093 | MaybeRefcount<IsMethod, P1>::AddRef(p1_); |
| 2094 | } |
| 2095 | |
| 2096 | virtual ~InvokerStorage5() { |
| 2097 | MaybeRefcount<IsMethod, P1>::Release(p1_); |
| 2098 | } |
| 2099 | |
| 2100 | Sig f_; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2101 | typename ParamTraits<P1>::StorageType p1_; |
| 2102 | typename ParamTraits<P2>::StorageType p2_; |
| 2103 | typename ParamTraits<P3>::StorageType p3_; |
| 2104 | typename ParamTraits<P4>::StorageType p4_; |
| 2105 | typename ParamTraits<P5>::StorageType p5_; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2106 | }; |
| 2107 | |
| 2108 | template <typename Sig, typename P1, typename P2, typename P3, typename P4, |
| 2109 | typename P5, typename P6> |
| 2110 | class InvokerStorage6 : public InvokerStorageBase { |
| 2111 | public: |
| 2112 | typedef InvokerStorage6 StorageType; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 2113 | typedef FunctionTraits<Sig> TargetTraits; |
[email protected] | 4346ef91 | 2011-02-19 00:52:15 | [diff] [blame] | 2114 | typedef typename TargetTraits::IsMethod IsMethod; |
[email protected] | 9354058 | 2011-05-16 22:35:14 | [diff] [blame] | 2115 | typedef Sig Signature; |
| 2116 | typedef ParamTraits<P1> P1Traits; |
| 2117 | typedef ParamTraits<P2> P2Traits; |
| 2118 | typedef ParamTraits<P3> P3Traits; |
| 2119 | typedef ParamTraits<P4> P4Traits; |
| 2120 | typedef ParamTraits<P5> P5Traits; |
| 2121 | typedef ParamTraits<P6> P6Traits; |
| 2122 | typedef Invoker6<IsWeakMethod<IsMethod::value, P1>::value, StorageType, |
| 2123 | typename TargetTraits::NormalizedSig> Invoker; |
| 2124 | COMPILE_ASSERT(!(IsWeakMethod<IsMethod::value, P1>::value) || |
| 2125 | is_void<typename TargetTraits::Return>::value, |
| 2126 | weak_ptrs_can_only_bind_to_methods_without_return_values); |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2127 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2128 | // For methods, we need to be careful for parameter 1. We skip the |
| 2129 | // scoped_refptr check because the binder itself takes care of this. We also |
| 2130 | // disallow binding of an array as the method's target object. |
| 2131 | COMPILE_ASSERT(IsMethod::value || |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 2132 | internal::NeedsScopedRefptrButGetsRawPtr< |
| 2133 | typename ParamTraits<P1>::StorageType>::value == 0, |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2134 | p1_is_refcounted_type_and_needs_scoped_refptr); |
| 2135 | COMPILE_ASSERT(!IsMethod::value || !is_array<P1>::value, |
| 2136 | first_bound_argument_to_method_cannot_be_array); |
[email protected] | 8217d454 | 2011-10-01 06:31:41 | [diff] [blame] | 2137 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2138 | typename ParamTraits<P2>::StorageType>::value == 0, |
| 2139 | p2_is_refcounted_type_and_needs_scoped_refptr); |
| 2140 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2141 | typename ParamTraits<P3>::StorageType>::value == 0, |
| 2142 | p3_is_refcounted_type_and_needs_scoped_refptr); |
| 2143 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2144 | typename ParamTraits<P4>::StorageType>::value == 0, |
| 2145 | p4_is_refcounted_type_and_needs_scoped_refptr); |
| 2146 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2147 | typename ParamTraits<P5>::StorageType>::value == 0, |
| 2148 | p5_is_refcounted_type_and_needs_scoped_refptr); |
| 2149 | COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< |
| 2150 | typename ParamTraits<P6>::StorageType>::value == 0, |
| 2151 | p6_is_refcounted_type_and_needs_scoped_refptr); |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2152 | |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2153 | // Do not allow binding a non-const reference parameter. Non-const reference |
| 2154 | // parameters are disallowed by the Google style guide. Also, binding a |
| 2155 | // non-const reference parameter can make for subtle bugs because the |
| 2156 | // invoked function will receive a reference to the stored copy of the |
| 2157 | // argument and not the original. |
| 2158 | COMPILE_ASSERT( |
| 2159 | !( is_non_const_reference<typename TargetTraits::B1>::value || |
| 2160 | is_non_const_reference<typename TargetTraits::B2>::value || |
| 2161 | is_non_const_reference<typename TargetTraits::B3>::value || |
| 2162 | is_non_const_reference<typename TargetTraits::B4>::value || |
| 2163 | is_non_const_reference<typename TargetTraits::B5>::value || |
| 2164 | is_non_const_reference<typename TargetTraits::B6>::value ), |
| 2165 | do_not_bind_functions_with_nonconst_ref); |
| 2166 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2167 | |
| 2168 | InvokerStorage6(Sig f, const P1& p1, const P2& p2, const P3& p3, |
| 2169 | const P4& p4, const P5& p5, const P6& p6) |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2170 | : f_(f), p1_(static_cast<typename ParamTraits<P1>::StorageType>(p1)), |
| 2171 | p2_(static_cast<typename ParamTraits<P2>::StorageType>(p2)), |
| 2172 | p3_(static_cast<typename ParamTraits<P3>::StorageType>(p3)), |
| 2173 | p4_(static_cast<typename ParamTraits<P4>::StorageType>(p4)), |
| 2174 | p5_(static_cast<typename ParamTraits<P5>::StorageType>(p5)), |
| 2175 | p6_(static_cast<typename ParamTraits<P6>::StorageType>(p6)) { |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2176 | MaybeRefcount<IsMethod, P1>::AddRef(p1_); |
| 2177 | } |
| 2178 | |
| 2179 | virtual ~InvokerStorage6() { |
| 2180 | MaybeRefcount<IsMethod, P1>::Release(p1_); |
| 2181 | } |
| 2182 | |
| 2183 | Sig f_; |
[email protected] | c18b105 | 2011-03-24 02:02:17 | [diff] [blame] | 2184 | typename ParamTraits<P1>::StorageType p1_; |
| 2185 | typename ParamTraits<P2>::StorageType p2_; |
| 2186 | typename ParamTraits<P3>::StorageType p3_; |
| 2187 | typename ParamTraits<P4>::StorageType p4_; |
| 2188 | typename ParamTraits<P5>::StorageType p5_; |
| 2189 | typename ParamTraits<P6>::StorageType p6_; |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2190 | }; |
| 2191 | |
[email protected] | b38d357 | 2011-02-15 01:27:38 | [diff] [blame] | 2192 | } // namespace internal |
| 2193 | } // namespace base |
| 2194 | |
| 2195 | #endif // BASE_BIND_INTERNAL_H_ |