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

Side by Side Diff: Source/wtf/Functional.h

Issue 134663006: Update WTF classes to use OVERRIDE / FINAL when needed (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 27 matching lines...) Expand all
38 // that can be stored, copied and invoked, similar to how boost::bind and std::b ind in C++11. 38 // that can be stored, copied and invoked, similar to how boost::bind and std::b ind in C++11.
39 39
40 // A FunctionWrapper is a class template that can wrap a function pointer or a m ember function pointer and 40 // A FunctionWrapper is a class template that can wrap a function pointer or a m ember function pointer and
41 // provide a unified interface for calling that function. 41 // provide a unified interface for calling that function.
42 template<typename> 42 template<typename>
43 class FunctionWrapper; 43 class FunctionWrapper;
44 44
45 // Bound static functions: 45 // Bound static functions:
46 46
47 template<typename R> 47 template<typename R>
48 class FunctionWrapper<R (*)()> { 48 class FunctionWrapper<R(*)()> {
49 public: 49 public:
50 typedef R ResultType; 50 typedef R ResultType;
51 51
52 explicit FunctionWrapper(R (*function)()) 52 explicit FunctionWrapper(R(*function)())
53 : m_function(function) 53 : m_function(function)
54 { 54 {
55 } 55 }
56 56
57 R operator()() 57 R operator()()
58 { 58 {
59 return m_function(); 59 return m_function();
60 } 60 }
61 61
62 private: 62 private:
63 R (*m_function)(); 63 R(*m_function)();
64 }; 64 };
65 65
66 template<typename R, typename P1> 66 template<typename R, typename P1>
67 class FunctionWrapper<R (*)(P1)> { 67 class FunctionWrapper<R(*)(P1)> {
68 public: 68 public:
69 typedef R ResultType; 69 typedef R ResultType;
70 70
71 explicit FunctionWrapper(R (*function)(P1)) 71 explicit FunctionWrapper(R(*function)(P1))
72 : m_function(function) 72 : m_function(function)
73 { 73 {
74 } 74 }
75 75
76 R operator()(P1 p1) 76 R operator()(P1 p1)
77 { 77 {
78 return m_function(p1); 78 return m_function(p1);
79 } 79 }
80 80
81 private: 81 private:
82 R (*m_function)(P1); 82 R(*m_function)(P1);
83 }; 83 };
84 84
85 template<typename R, typename P1, typename P2> 85 template<typename R, typename P1, typename P2>
86 class FunctionWrapper<R (*)(P1, P2)> { 86 class FunctionWrapper<R(*)(P1, P2)> {
87 public: 87 public:
88 typedef R ResultType; 88 typedef R ResultType;
89 89
90 explicit FunctionWrapper(R (*function)(P1, P2)) 90 explicit FunctionWrapper(R(*function)(P1, P2))
91 : m_function(function) 91 : m_function(function)
92 { 92 {
93 } 93 }
94 94
95 R operator()(P1 p1, P2 p2) 95 R operator()(P1 p1, P2 p2)
96 { 96 {
97 return m_function(p1, p2); 97 return m_function(p1, p2);
98 } 98 }
99 99
100 private: 100 private:
101 R (*m_function)(P1, P2); 101 R(*m_function)(P1, P2);
102 }; 102 };
103 103
104 template<typename R, typename P1, typename P2, typename P3> 104 template<typename R, typename P1, typename P2, typename P3>
105 class FunctionWrapper<R (*)(P1, P2, P3)> { 105 class FunctionWrapper<R(*)(P1, P2, P3)> {
106 public: 106 public:
107 typedef R ResultType; 107 typedef R ResultType;
108 108
109 explicit FunctionWrapper(R (*function)(P1, P2, P3)) 109 explicit FunctionWrapper(R(*function)(P1, P2, P3))
110 : m_function(function) 110 : m_function(function)
111 { 111 {
112 } 112 }
113 113
114 R operator()(P1 p1, P2 p2, P3 p3) 114 R operator()(P1 p1, P2 p2, P3 p3)
115 { 115 {
116 return m_function(p1, p2, p3); 116 return m_function(p1, p2, p3);
117 } 117 }
118 118
119 private: 119 private:
120 R (*m_function)(P1, P2, P3); 120 R(*m_function)(P1, P2, P3);
121 }; 121 };
122 122
123 template<typename R, typename P1, typename P2, typename P3, typename P4> 123 template<typename R, typename P1, typename P2, typename P3, typename P4>
124 class FunctionWrapper<R (*)(P1, P2, P3, P4)> { 124 class FunctionWrapper<R(*)(P1, P2, P3, P4)> {
125 public: 125 public:
126 typedef R ResultType; 126 typedef R ResultType;
127 127
128 explicit FunctionWrapper(R (*function)(P1, P2, P3, P4)) 128 explicit FunctionWrapper(R(*function)(P1, P2, P3, P4))
129 : m_function(function) 129 : m_function(function)
130 { 130 {
131 } 131 }
132 132
133 R operator()(P1 p1, P2 p2, P3 p3, P4 p4) 133 R operator()(P1 p1, P2 p2, P3 p3, P4 p4)
134 { 134 {
135 return m_function(p1, p2, p3, p4); 135 return m_function(p1, p2, p3, p4);
136 } 136 }
137 137
138 private: 138 private:
139 R (*m_function)(P1, P2, P3, P4); 139 R(*m_function)(P1, P2, P3, P4);
140 }; 140 };
141 141
142 template<typename R, typename P1, typename P2, typename P3, typename P4, typenam e P5> 142 template<typename R, typename P1, typename P2, typename P3, typename P4, typenam e P5>
143 class FunctionWrapper<R (*)(P1, P2, P3, P4, P5)> { 143 class FunctionWrapper<R(*)(P1, P2, P3, P4, P5)> {
144 public: 144 public:
145 typedef R ResultType; 145 typedef R ResultType;
146 146
147 explicit FunctionWrapper(R (*function)(P1, P2, P3, P4, P5)) 147 explicit FunctionWrapper(R(*function)(P1, P2, P3, P4, P5))
148 : m_function(function) 148 : m_function(function)
149 { 149 {
150 } 150 }
151 151
152 R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 152 R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
153 { 153 {
154 return m_function(p1, p2, p3, p4, p5); 154 return m_function(p1, p2, p3, p4, p5);
155 } 155 }
156 156
157 private: 157 private:
158 R (*m_function)(P1, P2, P3, P4, P5); 158 R(*m_function)(P1, P2, P3, P4, P5);
159 }; 159 };
160 160
161 // Bound member functions: 161 // Bound member functions:
162 162
163 template<typename R, typename C> 163 template<typename R, typename C>
164 class FunctionWrapper<R (C::*)()> { 164 class FunctionWrapper<R(C::*)()> {
165 public: 165 public:
166 typedef R ResultType; 166 typedef R ResultType;
167 167
168 explicit FunctionWrapper(R (C::*function)()) 168 explicit FunctionWrapper(R(C::*function)())
169 : m_function(function) 169 : m_function(function)
170 { 170 {
171 } 171 }
172 172
173 R operator()(C* c) 173 R operator()(C* c)
174 { 174 {
175 return (c->*m_function)(); 175 return (c->*m_function)();
176 } 176 }
177 177
178 R operator()(const WeakPtr<C>& c) 178 R operator()(const WeakPtr<C>& c)
179 { 179 {
180 C* obj = c.get(); 180 C* obj = c.get();
181 if (!obj) 181 if (!obj)
182 return R(); 182 return R();
183 return (obj->*m_function)(); 183 return (obj->*m_function)();
184 } 184 }
185 185
186 private: 186 private:
187 R (C::*m_function)(); 187 R(C::*m_function)();
188 }; 188 };
189 189
190 template<typename R, typename C, typename P1> 190 template<typename R, typename C, typename P1>
191 class FunctionWrapper<R (C::*)(P1)> { 191 class FunctionWrapper<R(C::*)(P1)> {
192 public: 192 public:
193 typedef R ResultType; 193 typedef R ResultType;
194 194
195 explicit FunctionWrapper(R (C::*function)(P1)) 195 explicit FunctionWrapper(R(C::*function)(P1))
196 : m_function(function) 196 : m_function(function)
197 { 197 {
198 } 198 }
199 199
200 R operator()(C* c, P1 p1) 200 R operator()(C* c, P1 p1)
201 { 201 {
202 return (c->*m_function)(p1); 202 return (c->*m_function)(p1);
203 } 203 }
204 204
205 R operator()(const WeakPtr<C>& c, P1 p1) 205 R operator()(const WeakPtr<C>& c, P1 p1)
206 { 206 {
207 C* obj = c.get(); 207 C* obj = c.get();
208 if (!obj) 208 if (!obj)
209 return R(); 209 return R();
210 return (obj->*m_function)(p1); 210 return (obj->*m_function)(p1);
211 } 211 }
212 212
213 private: 213 private:
214 R (C::*m_function)(P1); 214 R(C::*m_function)(P1);
215 }; 215 };
216 216
217 template<typename R, typename C, typename P1, typename P2> 217 template<typename R, typename C, typename P1, typename P2>
218 class FunctionWrapper<R (C::*)(P1, P2)> { 218 class FunctionWrapper<R(C::*)(P1, P2)> {
219 public: 219 public:
220 typedef R ResultType; 220 typedef R ResultType;
221 221
222 explicit FunctionWrapper(R (C::*function)(P1, P2)) 222 explicit FunctionWrapper(R(C::*function)(P1, P2))
223 : m_function(function) 223 : m_function(function)
224 { 224 {
225 } 225 }
226 226
227 R operator()(C* c, P1 p1, P2 p2) 227 R operator()(C* c, P1 p1, P2 p2)
228 { 228 {
229 return (c->*m_function)(p1, p2); 229 return (c->*m_function)(p1, p2);
230 } 230 }
231 231
232 R operator()(const WeakPtr<C>& c, P1 p1, P2 p2) 232 R operator()(const WeakPtr<C>& c, P1 p1, P2 p2)
233 { 233 {
234 C* obj = c.get(); 234 C* obj = c.get();
235 if (!obj) 235 if (!obj)
236 return R(); 236 return R();
237 return (obj->*m_function)(p1, p2); 237 return (obj->*m_function)(p1, p2);
238 } 238 }
239 239
240 private: 240 private:
241 R (C::*m_function)(P1, P2); 241 R(C::*m_function)(P1, P2);
242 }; 242 };
243 243
244 template<typename R, typename C, typename P1, typename P2, typename P3> 244 template<typename R, typename C, typename P1, typename P2, typename P3>
245 class FunctionWrapper<R (C::*)(P1, P2, P3)> { 245 class FunctionWrapper<R(C::*)(P1, P2, P3)> {
246 public: 246 public:
247 typedef R ResultType; 247 typedef R ResultType;
248 248
249 explicit FunctionWrapper(R (C::*function)(P1, P2, P3)) 249 explicit FunctionWrapper(R(C::*function)(P1, P2, P3))
250 : m_function(function) 250 : m_function(function)
251 { 251 {
252 } 252 }
253 253
254 R operator()(C* c, P1 p1, P2 p2, P3 p3) 254 R operator()(C* c, P1 p1, P2 p2, P3 p3)
255 { 255 {
256 return (c->*m_function)(p1, p2, p3); 256 return (c->*m_function)(p1, p2, p3);
257 } 257 }
258 258
259 R operator()(const WeakPtr<C>& c, P1 p1, P2 p2, P3 p3) 259 R operator()(const WeakPtr<C>& c, P1 p1, P2 p2, P3 p3)
260 { 260 {
261 C* obj = c.get(); 261 C* obj = c.get();
262 if (!obj) 262 if (!obj)
263 return R(); 263 return R();
264 return (obj->*m_function)(p1, p2, p3); 264 return (obj->*m_function)(p1, p2, p3);
265 } 265 }
266 266
267 private: 267 private:
268 R (C::*m_function)(P1, P2, P3); 268 R(C::*m_function)(P1, P2, P3);
269 }; 269 };
270 270
271 template<typename R, typename C, typename P1, typename P2, typename P3, typename P4> 271 template<typename R, typename C, typename P1, typename P2, typename P3, typename P4>
272 class FunctionWrapper<R (C::*)(P1, P2, P3, P4)> { 272 class FunctionWrapper<R(C::*)(P1, P2, P3, P4)> {
273 public: 273 public:
274 typedef R ResultType; 274 typedef R ResultType;
275 275
276 explicit FunctionWrapper(R (C::*function)(P1, P2, P3, P4)) 276 explicit FunctionWrapper(R(C::*function)(P1, P2, P3, P4))
277 : m_function(function) 277 : m_function(function)
278 { 278 {
279 } 279 }
280 280
281 R operator()(C* c, P1 p1, P2 p2, P3 p3, P4 p4) 281 R operator()(C* c, P1 p1, P2 p2, P3 p3, P4 p4)
282 { 282 {
283 return (c->*m_function)(p1, p2, p3, p4); 283 return (c->*m_function)(p1, p2, p3, p4);
284 } 284 }
285 285
286 R operator()(const WeakPtr<C>& c, P1 p1, P2 p2, P3 p3, P4 p4) 286 R operator()(const WeakPtr<C>& c, P1 p1, P2 p2, P3 p3, P4 p4)
287 { 287 {
288 C* obj = c.get(); 288 C* obj = c.get();
289 if (!obj) 289 if (!obj)
290 return R(); 290 return R();
291 return (obj->*m_function)(p1, p2, p3, p4); 291 return (obj->*m_function)(p1, p2, p3, p4);
292 } 292 }
293 293
294 private: 294 private:
295 R (C::*m_function)(P1, P2, P3, P4); 295 R(C::*m_function)(P1, P2, P3, P4);
296 }; 296 };
297 297
298 template<typename R, typename C, typename P1, typename P2, typename P3, typename P4, typename P5> 298 template<typename R, typename C, typename P1, typename P2, typename P3, typename P4, typename P5>
299 class FunctionWrapper<R (C::*)(P1, P2, P3, P4, P5)> { 299 class FunctionWrapper<R(C::*)(P1, P2, P3, P4, P5)> {
300 public: 300 public:
301 typedef R ResultType; 301 typedef R ResultType;
302 302
303 explicit FunctionWrapper(R (C::*function)(P1, P2, P3, P4, P5)) 303 explicit FunctionWrapper(R(C::*function)(P1, P2, P3, P4, P5))
304 : m_function(function) 304 : m_function(function)
305 { 305 {
306 } 306 }
307 307
308 R operator()(C* c, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 308 R operator()(C* c, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
309 { 309 {
310 return (c->*m_function)(p1, p2, p3, p4, p5); 310 return (c->*m_function)(p1, p2, p3, p4, p5);
311 } 311 }
312 312
313 R operator()(const WeakPtr<C>& c, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 313 R operator()(const WeakPtr<C>& c, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
314 { 314 {
315 C* obj = c.get(); 315 C* obj = c.get();
316 if (!obj) 316 if (!obj)
317 return R(); 317 return R();
318 return (obj->*m_function)(p1, p2, p3, p4, p5); 318 return (obj->*m_function)(p1, p2, p3, p4, p5);
319 } 319 }
320 320
321 private: 321 private:
322 R (C::*m_function)(P1, P2, P3, P4, P5); 322 R(C::*m_function)(P1, P2, P3, P4, P5);
323 }; 323 };
324 324
325 template<typename T> struct ParamStorageTraits { 325 template<typename T> struct ParamStorageTraits {
326 typedef T StorageType; 326 typedef T StorageType;
327 327
328 static StorageType wrap(const T& value) { return value; } 328 static StorageType wrap(const T& value) { return value; }
329 static const T& unwrap(const StorageType& value) { return value; } 329 static const T& unwrap(const StorageType& value) { return value; }
330 }; 330 };
331 331
332 template<typename T> struct ParamStorageTraits<PassRefPtr<T> > { 332 template<typename T> struct ParamStorageTraits<PassRefPtr<T> > {
(...skipping 21 matching lines...) Expand all
354 354
355 class FunctionImplBase : public ThreadSafeRefCounted<FunctionImplBase> { 355 class FunctionImplBase : public ThreadSafeRefCounted<FunctionImplBase> {
356 public: 356 public:
357 virtual ~FunctionImplBase() { } 357 virtual ~FunctionImplBase() { }
358 }; 358 };
359 359
360 template<typename> 360 template<typename>
361 class FunctionImpl; 361 class FunctionImpl;
362 362
363 template<typename R> 363 template<typename R>
364 class FunctionImpl<R ()> : public FunctionImplBase { 364 class FunctionImpl<R()> : public FunctionImplBase {
365 public: 365 public:
366 virtual R operator()() = 0; 366 virtual R operator()() = 0;
367 }; 367 };
368 368
369 template<typename FunctionWrapper, typename FunctionType> 369 template<typename FunctionWrapper, typename FunctionType>
370 class BoundFunctionImpl; 370 class BoundFunctionImpl;
371 371
372 template<typename FunctionWrapper, typename R> 372 template<typename FunctionWrapper, typename R>
373 class BoundFunctionImpl<FunctionWrapper, R ()> : public FunctionImpl<typename Fu nctionWrapper::ResultType ()> { 373 class BoundFunctionImpl<FunctionWrapper, R()> FINAL : public FunctionImpl<typena me FunctionWrapper::ResultType()> {
374 public: 374 public:
375 explicit BoundFunctionImpl(FunctionWrapper functionWrapper) 375 explicit BoundFunctionImpl(FunctionWrapper functionWrapper)
376 : m_functionWrapper(functionWrapper) 376 : m_functionWrapper(functionWrapper)
377 { 377 {
378 } 378 }
379 379
380 virtual typename FunctionWrapper::ResultType operator()() 380 virtual typename FunctionWrapper::ResultType operator()() OVERRIDE
381 { 381 {
382 return m_functionWrapper(); 382 return m_functionWrapper();
383 } 383 }
384 384
385 private: 385 private:
386 FunctionWrapper m_functionWrapper; 386 FunctionWrapper m_functionWrapper;
387 }; 387 };
388 388
389 template<typename FunctionWrapper, typename R, typename P1> 389 template<typename FunctionWrapper, typename R, typename P1>
390 class BoundFunctionImpl<FunctionWrapper, R (P1)> : public FunctionImpl<typename FunctionWrapper::ResultType ()> { 390 class BoundFunctionImpl<FunctionWrapper, R(P1)> FINAL : public FunctionImpl<type name FunctionWrapper::ResultType()> {
391 public: 391 public:
392 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1) 392 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1)
393 : m_functionWrapper(functionWrapper) 393 : m_functionWrapper(functionWrapper)
394 , m_p1(ParamStorageTraits<P1>::wrap(p1)) 394 , m_p1(ParamStorageTraits<P1>::wrap(p1))
395 { 395 {
396 } 396 }
397 397
398 virtual typename FunctionWrapper::ResultType operator()() 398 virtual typename FunctionWrapper::ResultType operator()() OVERRIDE
399 { 399 {
400 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1)); 400 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1));
401 } 401 }
402 402
403 private: 403 private:
404 FunctionWrapper m_functionWrapper; 404 FunctionWrapper m_functionWrapper;
405 typename ParamStorageTraits<P1>::StorageType m_p1; 405 typename ParamStorageTraits<P1>::StorageType m_p1;
406 }; 406 };
407 407
408 template<typename FunctionWrapper, typename R, typename P1, typename P2> 408 template<typename FunctionWrapper, typename R, typename P1, typename P2>
409 class BoundFunctionImpl<FunctionWrapper, R (P1, P2)> : public FunctionImpl<typen ame FunctionWrapper::ResultType ()> { 409 class BoundFunctionImpl<FunctionWrapper, R(P1, P2)> FINAL : public FunctionImpl< typename FunctionWrapper::ResultType()> {
410 public: 410 public:
411 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2) 411 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2)
412 : m_functionWrapper(functionWrapper) 412 : m_functionWrapper(functionWrapper)
413 , m_p1(ParamStorageTraits<P1>::wrap(p1)) 413 , m_p1(ParamStorageTraits<P1>::wrap(p1))
414 , m_p2(ParamStorageTraits<P2>::wrap(p2)) 414 , m_p2(ParamStorageTraits<P2>::wrap(p2))
415 { 415 {
416 } 416 }
417 417
418 virtual typename FunctionWrapper::ResultType operator()() 418 virtual typename FunctionWrapper::ResultType operator()() OVERRIDE
419 { 419 {
420 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2)); 420 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2));
421 } 421 }
422 422
423 private: 423 private:
424 FunctionWrapper m_functionWrapper; 424 FunctionWrapper m_functionWrapper;
425 typename ParamStorageTraits<P1>::StorageType m_p1; 425 typename ParamStorageTraits<P1>::StorageType m_p1;
426 typename ParamStorageTraits<P2>::StorageType m_p2; 426 typename ParamStorageTraits<P2>::StorageType m_p2;
427 }; 427 };
428 428
429 template<typename FunctionWrapper, typename R, typename P1, typename P2, typenam e P3> 429 template<typename FunctionWrapper, typename R, typename P1, typename P2, typenam e P3>
430 class BoundFunctionImpl<FunctionWrapper, R (P1, P2, P3)> : public FunctionImpl<t ypename FunctionWrapper::ResultType ()> { 430 class BoundFunctionImpl<FunctionWrapper, R(P1, P2, P3)> FINAL : public FunctionI mpl<typename FunctionWrapper::ResultType()> {
431 public: 431 public:
432 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2, const P3& p3) 432 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2, const P3& p3)
433 : m_functionWrapper(functionWrapper) 433 : m_functionWrapper(functionWrapper)
434 , m_p1(ParamStorageTraits<P1>::wrap(p1)) 434 , m_p1(ParamStorageTraits<P1>::wrap(p1))
435 , m_p2(ParamStorageTraits<P2>::wrap(p2)) 435 , m_p2(ParamStorageTraits<P2>::wrap(p2))
436 , m_p3(ParamStorageTraits<P3>::wrap(p3)) 436 , m_p3(ParamStorageTraits<P3>::wrap(p3))
437 { 437 {
438 } 438 }
439 439
440 virtual typename FunctionWrapper::ResultType operator()() 440 virtual typename FunctionWrapper::ResultType operator()() OVERRIDE
441 { 441 {
442 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2), ParamStorageTraits<P3>::unwrap(m_p3)); 442 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2), ParamStorageTraits<P3>::unwrap(m_p3));
443 } 443 }
444 444
445 private: 445 private:
446 FunctionWrapper m_functionWrapper; 446 FunctionWrapper m_functionWrapper;
447 typename ParamStorageTraits<P1>::StorageType m_p1; 447 typename ParamStorageTraits<P1>::StorageType m_p1;
448 typename ParamStorageTraits<P2>::StorageType m_p2; 448 typename ParamStorageTraits<P2>::StorageType m_p2;
449 typename ParamStorageTraits<P3>::StorageType m_p3; 449 typename ParamStorageTraits<P3>::StorageType m_p3;
450 }; 450 };
451 451
452 template<typename FunctionWrapper, typename R, typename P1, typename P2, typenam e P3, typename P4> 452 template<typename FunctionWrapper, typename R, typename P1, typename P2, typenam e P3, typename P4>
453 class BoundFunctionImpl<FunctionWrapper, R (P1, P2, P3, P4)> : public FunctionIm pl<typename FunctionWrapper::ResultType ()> { 453 class BoundFunctionImpl<FunctionWrapper, R(P1, P2, P3, P4)> FINAL : public Funct ionImpl<typename FunctionWrapper::ResultType()> {
454 public: 454 public:
455 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2, const P3& p3, const P4& p4) 455 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2, const P3& p3, const P4& p4)
456 : m_functionWrapper(functionWrapper) 456 : m_functionWrapper(functionWrapper)
457 , m_p1(ParamStorageTraits<P1>::wrap(p1)) 457 , m_p1(ParamStorageTraits<P1>::wrap(p1))
458 , m_p2(ParamStorageTraits<P2>::wrap(p2)) 458 , m_p2(ParamStorageTraits<P2>::wrap(p2))
459 , m_p3(ParamStorageTraits<P3>::wrap(p3)) 459 , m_p3(ParamStorageTraits<P3>::wrap(p3))
460 , m_p4(ParamStorageTraits<P4>::wrap(p4)) 460 , m_p4(ParamStorageTraits<P4>::wrap(p4))
461 { 461 {
462 } 462 }
463 463
464 virtual typename FunctionWrapper::ResultType operator()() 464 virtual typename FunctionWrapper::ResultType operator()() OVERRIDE
465 { 465 {
466 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2), ParamStorageTraits<P3>::unwrap(m_p3), ParamStorageT raits<P4>::unwrap(m_p4)); 466 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2), ParamStorageTraits<P3>::unwrap(m_p3), ParamStorageT raits<P4>::unwrap(m_p4));
467 } 467 }
468 468
469 private: 469 private:
470 FunctionWrapper m_functionWrapper; 470 FunctionWrapper m_functionWrapper;
471 typename ParamStorageTraits<P1>::StorageType m_p1; 471 typename ParamStorageTraits<P1>::StorageType m_p1;
472 typename ParamStorageTraits<P2>::StorageType m_p2; 472 typename ParamStorageTraits<P2>::StorageType m_p2;
473 typename ParamStorageTraits<P3>::StorageType m_p3; 473 typename ParamStorageTraits<P3>::StorageType m_p3;
474 typename ParamStorageTraits<P4>::StorageType m_p4; 474 typename ParamStorageTraits<P4>::StorageType m_p4;
475 }; 475 };
476 476
477 template<typename FunctionWrapper, typename R, typename P1, typename P2, typenam e P3, typename P4, typename P5> 477 template<typename FunctionWrapper, typename R, typename P1, typename P2, typenam e P3, typename P4, typename P5>
478 class BoundFunctionImpl<FunctionWrapper, R (P1, P2, P3, P4, P5)> : public Functi onImpl<typename FunctionWrapper::ResultType ()> { 478 class BoundFunctionImpl<FunctionWrapper, R(P1, P2, P3, P4, P5)> FINAL : public F unctionImpl<typename FunctionWrapper::ResultType()> {
479 public: 479 public:
480 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2, const P3& p3, const P4& p4, const P5& p5) 480 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2, const P3& p3, const P4& p4, const P5& p5)
481 : m_functionWrapper(functionWrapper) 481 : m_functionWrapper(functionWrapper)
482 , m_p1(ParamStorageTraits<P1>::wrap(p1)) 482 , m_p1(ParamStorageTraits<P1>::wrap(p1))
483 , m_p2(ParamStorageTraits<P2>::wrap(p2)) 483 , m_p2(ParamStorageTraits<P2>::wrap(p2))
484 , m_p3(ParamStorageTraits<P3>::wrap(p3)) 484 , m_p3(ParamStorageTraits<P3>::wrap(p3))
485 , m_p4(ParamStorageTraits<P4>::wrap(p4)) 485 , m_p4(ParamStorageTraits<P4>::wrap(p4))
486 , m_p5(ParamStorageTraits<P5>::wrap(p5)) 486 , m_p5(ParamStorageTraits<P5>::wrap(p5))
487 { 487 {
488 } 488 }
489 489
490 virtual typename FunctionWrapper::ResultType operator()() 490 virtual typename FunctionWrapper::ResultType operator()() OVERRIDE
491 { 491 {
492 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2), ParamStorageTraits<P3>::unwrap(m_p3), ParamStorageT raits<P4>::unwrap(m_p4), ParamStorageTraits<P5>::unwrap(m_p5)); 492 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2), ParamStorageTraits<P3>::unwrap(m_p3), ParamStorageT raits<P4>::unwrap(m_p4), ParamStorageTraits<P5>::unwrap(m_p5));
493 } 493 }
494 494
495 private: 495 private:
496 FunctionWrapper m_functionWrapper; 496 FunctionWrapper m_functionWrapper;
497 typename ParamStorageTraits<P1>::StorageType m_p1; 497 typename ParamStorageTraits<P1>::StorageType m_p1;
498 typename ParamStorageTraits<P2>::StorageType m_p2; 498 typename ParamStorageTraits<P2>::StorageType m_p2;
499 typename ParamStorageTraits<P3>::StorageType m_p3; 499 typename ParamStorageTraits<P3>::StorageType m_p3;
500 typename ParamStorageTraits<P4>::StorageType m_p4; 500 typename ParamStorageTraits<P4>::StorageType m_p4;
501 typename ParamStorageTraits<P5>::StorageType m_p5; 501 typename ParamStorageTraits<P5>::StorageType m_p5;
502 }; 502 };
503 503
504 template<typename FunctionWrapper, typename R, typename P1, typename P2, typenam e P3, typename P4, typename P5, typename P6> 504 template<typename FunctionWrapper, typename R, typename P1, typename P2, typenam e P3, typename P4, typename P5, typename P6>
505 class BoundFunctionImpl<FunctionWrapper, R (P1, P2, P3, P4, P5, P6)> : public Fu nctionImpl<typename FunctionWrapper::ResultType ()> { 505 class BoundFunctionImpl<FunctionWrapper, R(P1, P2, P3, P4, P5, P6)> FINAL : publ ic FunctionImpl<typename FunctionWrapper::ResultType()> {
506 public: 506 public:
507 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2, const P3& p3, const P4& p4, const P5& p5, const P6& p6) 507 BoundFunctionImpl(FunctionWrapper functionWrapper, const P1& p1, const P2& p 2, const P3& p3, const P4& p4, const P5& p5, const P6& p6)
508 : m_functionWrapper(functionWrapper) 508 : m_functionWrapper(functionWrapper)
509 , m_p1(ParamStorageTraits<P1>::wrap(p1)) 509 , m_p1(ParamStorageTraits<P1>::wrap(p1))
510 , m_p2(ParamStorageTraits<P2>::wrap(p2)) 510 , m_p2(ParamStorageTraits<P2>::wrap(p2))
511 , m_p3(ParamStorageTraits<P3>::wrap(p3)) 511 , m_p3(ParamStorageTraits<P3>::wrap(p3))
512 , m_p4(ParamStorageTraits<P4>::wrap(p4)) 512 , m_p4(ParamStorageTraits<P4>::wrap(p4))
513 , m_p5(ParamStorageTraits<P5>::wrap(p5)) 513 , m_p5(ParamStorageTraits<P5>::wrap(p5))
514 , m_p6(ParamStorageTraits<P6>::wrap(p6)) 514 , m_p6(ParamStorageTraits<P6>::wrap(p6))
515 { 515 {
516 } 516 }
517 517
518 virtual typename FunctionWrapper::ResultType operator()() 518 virtual typename FunctionWrapper::ResultType operator()() OVERRIDE
519 { 519 {
520 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2), ParamStorageTraits<P3>::unwrap(m_p3), ParamStorageT raits<P4>::unwrap(m_p4), ParamStorageTraits<P5>::unwrap(m_p5), ParamStorageTrait s<P6>::unwrap(m_p6)); 520 return m_functionWrapper(ParamStorageTraits<P1>::unwrap(m_p1), ParamStor ageTraits<P2>::unwrap(m_p2), ParamStorageTraits<P3>::unwrap(m_p3), ParamStorageT raits<P4>::unwrap(m_p4), ParamStorageTraits<P5>::unwrap(m_p5), ParamStorageTrait s<P6>::unwrap(m_p6));
521 } 521 }
522 522
523 private: 523 private:
524 FunctionWrapper m_functionWrapper; 524 FunctionWrapper m_functionWrapper;
525 typename ParamStorageTraits<P1>::StorageType m_p1; 525 typename ParamStorageTraits<P1>::StorageType m_p1;
526 typename ParamStorageTraits<P2>::StorageType m_p2; 526 typename ParamStorageTraits<P2>::StorageType m_p2;
527 typename ParamStorageTraits<P3>::StorageType m_p3; 527 typename ParamStorageTraits<P3>::StorageType m_p3;
528 typename ParamStorageTraits<P4>::StorageType m_p4; 528 typename ParamStorageTraits<P4>::StorageType m_p4;
(...skipping 24 matching lines...) Expand all
553 } 553 }
554 554
555 private: 555 private:
556 RefPtr<FunctionImplBase> m_impl; 556 RefPtr<FunctionImplBase> m_impl;
557 }; 557 };
558 558
559 template<typename> 559 template<typename>
560 class Function; 560 class Function;
561 561
562 template<typename R> 562 template<typename R>
563 class Function<R ()> : public FunctionBase { 563 class Function<R()> : public FunctionBase {
564 public: 564 public:
565 Function() 565 Function()
566 { 566 {
567 } 567 }
568 568
569 Function(PassRefPtr<FunctionImpl<R ()> > impl) 569 Function(PassRefPtr<FunctionImpl<R()> > impl)
570 : FunctionBase(impl) 570 : FunctionBase(impl)
571 { 571 {
572 } 572 }
573 573
574 R operator()() const 574 R operator()() const
575 { 575 {
576 ASSERT(!isNull()); 576 ASSERT(!isNull());
577 return impl<R ()>()->operator()(); 577 return impl<R()>()->operator()();
578 } 578 }
579 }; 579 };
580 580
581 template<typename FunctionType> 581 template<typename FunctionType>
582 Function<typename FunctionWrapper<FunctionType>::ResultType ()> bind(FunctionTyp e function) 582 Function<typename FunctionWrapper<FunctionType>::ResultType()> bind(FunctionType function)
583 { 583 {
584 return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adopt Ref(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrappe r<FunctionType>::ResultType ()>(FunctionWrapper<FunctionType>(function)))); 584 return Function<typename FunctionWrapper<FunctionType>::ResultType()>(adoptR ef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper <FunctionType>::ResultType()>(FunctionWrapper<FunctionType>(function))));
585 } 585 }
586 586
587 template<typename FunctionType, typename A1> 587 template<typename FunctionType, typename A1>
588 Function<typename FunctionWrapper<FunctionType>::ResultType ()> bind(FunctionTyp e function, const A1& a1) 588 Function<typename FunctionWrapper<FunctionType>::ResultType()> bind(FunctionType function, const A1& a1)
589 { 589 {
590 return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adopt Ref(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrappe r<FunctionType>::ResultType (A1)>(FunctionWrapper<FunctionType>(function), a1))) ; 590 return Function<typename FunctionWrapper<FunctionType>::ResultType()>(adoptR ef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper <FunctionType>::ResultType (A1)>(FunctionWrapper<FunctionType>(function), a1)));
591 } 591 }
592 592
593 template<typename FunctionType, typename A1, typename A2> 593 template<typename FunctionType, typename A1, typename A2>
594 Function<typename FunctionWrapper<FunctionType>::ResultType ()> bind(FunctionTyp e function, const A1& a1, const A2& a2) 594 Function<typename FunctionWrapper<FunctionType>::ResultType()> bind(FunctionType function, const A1& a1, const A2& a2)
595 { 595 {
596 return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adopt Ref(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrappe r<FunctionType>::ResultType (A1, A2)>(FunctionWrapper<FunctionType>(function), a 1, a2))); 596 return Function<typename FunctionWrapper<FunctionType>::ResultType()>(adoptR ef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper <FunctionType>::ResultType (A1, A2)>(FunctionWrapper<FunctionType>(function), a1 , a2)));
597 } 597 }
598 598
599 template<typename FunctionType, typename A1, typename A2, typename A3> 599 template<typename FunctionType, typename A1, typename A2, typename A3>
600 Function<typename FunctionWrapper<FunctionType>::ResultType ()> bind(FunctionTyp e function, const A1& a1, const A2& a2, const A3& a3) 600 Function<typename FunctionWrapper<FunctionType>::ResultType()> bind(FunctionType function, const A1& a1, const A2& a2, const A3& a3)
601 { 601 {
602 return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adopt Ref(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrappe r<FunctionType>::ResultType (A1, A2, A3)>(FunctionWrapper<FunctionType>(function ), a1, a2, a3))); 602 return Function<typename FunctionWrapper<FunctionType>::ResultType()>(adoptR ef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper <FunctionType>::ResultType (A1, A2, A3)>(FunctionWrapper<FunctionType>(function) , a1, a2, a3)));
603 } 603 }
604 604
605 template<typename FunctionType, typename A1, typename A2, typename A3, typename A4> 605 template<typename FunctionType, typename A1, typename A2, typename A3, typename A4>
606 Function<typename FunctionWrapper<FunctionType>::ResultType ()> bind(FunctionTyp e function, const A1& a1, const A2& a2, const A3& a3, const A4& a4) 606 Function<typename FunctionWrapper<FunctionType>::ResultType()> bind(FunctionType function, const A1& a1, const A2& a2, const A3& a3, const A4& a4)
607 { 607 {
608 return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adopt Ref(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrappe r<FunctionType>::ResultType (A1, A2, A3, A4)>(FunctionWrapper<FunctionType>(func tion), a1, a2, a3, a4))); 608 return Function<typename FunctionWrapper<FunctionType>::ResultType()>(adoptR ef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper <FunctionType>::ResultType (A1, A2, A3, A4)>(FunctionWrapper<FunctionType>(funct ion), a1, a2, a3, a4)));
609 } 609 }
610 610
611 template<typename FunctionType, typename A1, typename A2, typename A3, typename A4, typename A5> 611 template<typename FunctionType, typename A1, typename A2, typename A3, typename A4, typename A5>
612 Function<typename FunctionWrapper<FunctionType>::ResultType ()> bind(FunctionTyp e function, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5 ) 612 Function<typename FunctionWrapper<FunctionType>::ResultType()> bind(FunctionType function, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5)
613 { 613 {
614 return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adopt Ref(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrappe r<FunctionType>::ResultType (A1, A2, A3, A4, A5)>(FunctionWrapper<FunctionType>( function), a1, a2, a3, a4, a5))); 614 return Function<typename FunctionWrapper<FunctionType>::ResultType()>(adoptR ef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper <FunctionType>::ResultType (A1, A2, A3, A4, A5)>(FunctionWrapper<FunctionType>(f unction), a1, a2, a3, a4, a5)));
615 } 615 }
616 616
617 template<typename FunctionType, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6> 617 template<typename FunctionType, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
618 Function<typename FunctionWrapper<FunctionType>::ResultType ()> bind(FunctionTyp e function, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5 , const A6& a6) 618 Function<typename FunctionWrapper<FunctionType>::ResultType()> bind(FunctionType function, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6)
619 { 619 {
620 return Function<typename FunctionWrapper<FunctionType>::ResultType ()>(adopt Ref(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrappe r<FunctionType>::ResultType (A1, A2, A3, A4, A5, A6)>(FunctionWrapper<FunctionTy pe>(function), a1, a2, a3, a4, a5, a6))); 620 return Function<typename FunctionWrapper<FunctionType>::ResultType()>(adoptR ef(new BoundFunctionImpl<FunctionWrapper<FunctionType>, typename FunctionWrapper <FunctionType>::ResultType (A1, A2, A3, A4, A5, A6)>(FunctionWrapper<FunctionTyp e>(function), a1, a2, a3, a4, a5, a6)));
621 } 621 }
622 622
623 typedef Function<void()> Closure; 623 typedef Function<void()> Closure;
624 624
625 } 625 }
626 626
627 using WTF::Function; 627 using WTF::Function;
628 using WTF::bind; 628 using WTF::bind;
629 using WTF::Closure; 629 using WTF::Closure;
630 630
631 #endif // WTF_Functional_h 631 #endif // WTF_Functional_h
OLDNEW
« no previous file with comments | « Source/wtf/Float64Array.h ('k') | Source/wtf/Int16Array.h » ('j') | Source/wtf/TypedArrayBase.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698