OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Specializations of RunnableAdapter<> for Windows specific calling | 5 // Specializations of RunnableAdapter<> for Windows specific calling |
6 // conventions. Please see base/bind_internal.h for more info. | 6 // conventions. Please see base/bind_internal.h for more info. |
7 | 7 |
8 #ifndef BASE_BIND_INTERNAL_WIN_H_ | 8 #ifndef BASE_BIND_INTERNAL_WIN_H_ |
9 #define BASE_BIND_INTERNAL_WIN_H_ | 9 #define BASE_BIND_INTERNAL_WIN_H_ |
10 | 10 |
11 // In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all | 11 // In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all |
12 // the same as __cdecl which would turn the following specializations into | 12 // the same as __cdecl which would turn the following specializations into |
13 // multiple definitions. | 13 // multiple definitions. |
14 #if !defined(ARCH_CPU_X86_64) | 14 #if !defined(ARCH_CPU_X86_64) |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 template <typename Functor> | 19 template <typename Functor> |
20 class RunnableAdapter; | 20 class RunnableAdapter; |
21 | 21 |
22 // __stdcall Function. | 22 // __stdcall Function. |
23 template <typename R, typename... Args> | 23 template <typename R, typename... Args> |
24 class RunnableAdapter<R(__stdcall *)(Args...)> { | 24 class RunnableAdapter<R(__stdcall *)(Args...)> { |
25 public: | 25 public: |
26 typedef R (RunType)(Args...); | 26 // MSVC 2013 doesn't support Type Alias of function types. |
| 27 // Revisit this after we update it to newer version. |
| 28 typedef R RunType(Args...); |
27 | 29 |
28 explicit RunnableAdapter(R(__stdcall *function)(Args...)) | 30 explicit RunnableAdapter(R(__stdcall *function)(Args...)) |
29 : function_(function) { | 31 : function_(function) { |
30 } | 32 } |
31 | 33 |
32 R Run(typename CallbackParamTraits<Args>::ForwardType... args) { | 34 R Run(typename CallbackParamTraits<Args>::ForwardType... args) { |
33 return function_(args...); | 35 return function_(args...); |
34 } | 36 } |
35 | 37 |
36 private: | 38 private: |
37 R (__stdcall *function_)(Args...); | 39 R (__stdcall *function_)(Args...); |
38 }; | 40 }; |
39 | 41 |
40 // __fastcall Function. | 42 // __fastcall Function. |
41 template <typename R, typename... Args> | 43 template <typename R, typename... Args> |
42 class RunnableAdapter<R(__fastcall *)(Args...)> { | 44 class RunnableAdapter<R(__fastcall *)(Args...)> { |
43 public: | 45 public: |
44 typedef R (RunType)(Args...); | 46 // MSVC 2013 doesn't support Type Alias of function types. |
| 47 // Revisit this after we update it to newer version. |
| 48 typedef R RunType(Args...); |
45 | 49 |
46 explicit RunnableAdapter(R(__fastcall *function)(Args...)) | 50 explicit RunnableAdapter(R(__fastcall *function)(Args...)) |
47 : function_(function) { | 51 : function_(function) { |
48 } | 52 } |
49 | 53 |
50 R Run(typename CallbackParamTraits<Args>::ForwardType... args) { | 54 R Run(typename CallbackParamTraits<Args>::ForwardType... args) { |
51 return function_(args...); | 55 return function_(args...); |
52 } | 56 } |
53 | 57 |
54 private: | 58 private: |
55 R (__fastcall *function_)(Args...); | 59 R (__fastcall *function_)(Args...); |
56 }; | 60 }; |
57 | 61 |
58 } // namespace internal | 62 } // namespace internal |
59 } // namespace base | 63 } // namespace base |
60 | 64 |
61 #endif // !defined(ARCH_CPU_X86_64) | 65 #endif // !defined(ARCH_CPU_X86_64) |
62 | 66 |
63 #endif // BASE_BIND_INTERNAL_WIN_H_ | 67 #endif // BASE_BIND_INTERNAL_WIN_H_ |
OLD | NEW |