blob: 2ee12ef214d30f651e2cb2a1dc4b6f2c728c5196 [file] [log] [blame]
[email protected]054ac7542011-02-27 01:25:591// 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
3// found in the LICENSE file.
4
[email protected]7296f2762011-11-21 19:23:445// Specializations of RunnableAdapter<> for Windows specific calling
[email protected]054ac7542011-02-27 01:25:596// conventions. Please see base/bind_internal.h for more info.
7
8#ifndef BASE_BIND_INTERNAL_WIN_H_
9#define BASE_BIND_INTERNAL_WIN_H_
[email protected]054ac7542011-02-27 01:25:5910
avi9b6f42932015-12-26 22:15:1411#include "build/build_config.h"
12
[email protected]b224f792011-04-20 16:02:2313// In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all
14// the same as __cdecl which would turn the following specializations into
15// multiple definitions.
16#if !defined(ARCH_CPU_X86_64)
17
[email protected]054ac7542011-02-27 01:25:5918namespace base {
19namespace internal {
20
[email protected]7296f2762011-11-21 19:23:4421template <typename Functor>
22class RunnableAdapter;
[email protected]054ac7542011-02-27 01:25:5923
tzika0125aec2014-10-07 20:03:5424// __stdcall Function.
25template <typename R, typename... Args>
26class RunnableAdapter<R(__stdcall *)(Args...)> {
[email protected]7296f2762011-11-21 19:23:4427 public:
tzik3bc7779b2015-12-19 09:18:4628 // MSVC 2013 doesn't support Type Alias of function types.
29 // Revisit this after we update it to newer version.
30 typedef R RunType(Args...);
[email protected]93540582011-05-16 22:35:1431
tzika0125aec2014-10-07 20:03:5432 explicit RunnableAdapter(R(__stdcall *function)(Args...))
[email protected]7296f2762011-11-21 19:23:4433 : function_(function) {
34 }
35
tzika0125aec2014-10-07 20:03:5436 R Run(typename CallbackParamTraits<Args>::ForwardType... args) {
37 return function_(args...);
[email protected]7296f2762011-11-21 19:23:4438 }
39
40 private:
tzika0125aec2014-10-07 20:03:5441 R (__stdcall *function_)(Args...);
[email protected]054ac7542011-02-27 01:25:5942};
43
tzika0125aec2014-10-07 20:03:5444// __fastcall Function.
45template <typename R, typename... Args>
46class RunnableAdapter<R(__fastcall *)(Args...)> {
[email protected]7296f2762011-11-21 19:23:4447 public:
tzik3bc7779b2015-12-19 09:18:4648 // MSVC 2013 doesn't support Type Alias of function types.
49 // Revisit this after we update it to newer version.
50 typedef R RunType(Args...);
[email protected]93540582011-05-16 22:35:1451
tzika0125aec2014-10-07 20:03:5452 explicit RunnableAdapter(R(__fastcall *function)(Args...))
[email protected]7296f2762011-11-21 19:23:4453 : function_(function) {
54 }
55
tzika0125aec2014-10-07 20:03:5456 R Run(typename CallbackParamTraits<Args>::ForwardType... args) {
57 return function_(args...);
[email protected]7296f2762011-11-21 19:23:4458 }
59
60 private:
tzika0125aec2014-10-07 20:03:5461 R (__fastcall *function_)(Args...);
[email protected]fccef1552011-11-28 22:13:5462};
63
[email protected]054ac7542011-02-27 01:25:5964} // namespace internal
65} // namespace base
66
[email protected]b224f792011-04-20 16:02:2367#endif // !defined(ARCH_CPU_X86_64)
68
[email protected]054ac7542011-02-27 01:25:5969#endif // BASE_BIND_INTERNAL_WIN_H_