Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / base / bind_internal_win.h.pump
1 $$ This is a pump file for generating file templates.  Pump is a python
2 $$ script that is part of the Google Test suite of utilities.  Description
3 $$ can be found here:
4 $$
5 $$ http://code.google.com/p/googletest/wiki/PumpManual
6 $$
7
8 $$ See comment for MAX_ARITY in base/bind.h.pump.
9 $var MAX_ARITY = 7
10
11 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
12 // Use of this source code is governed by a BSD-style license that can be
13 // found in the LICENSE file.
14
15 // Specializations of RunnableAdapter<> for Windows specific calling
16 // conventions.  Please see base/bind_internal.h for more info.
17
18 #ifndef BASE_BIND_INTERNAL_WIN_H_
19 #define BASE_BIND_INTERNAL_WIN_H_
20
21 // In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all
22 // the same as __cdecl which would turn the following specializations into
23 // multiple definitions.
24 #if !defined(ARCH_CPU_X86_64)
25
26 namespace base {
27 namespace internal {
28
29 template <typename Functor>
30 class RunnableAdapter;
31
32 $range ARITY 0..MAX_ARITY
33 $for ARITY [[
34 $range ARG 1..ARITY
35
36 // __stdcall Function: Arity $(ARITY).
37 template <typename R[[]]
38 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
39 class RunnableAdapter<R(__stdcall *)($for ARG , [[A$(ARG)]])> {
40  public:
41   typedef R (RunType)($for ARG , [[A$(ARG)]]);
42
43   explicit RunnableAdapter(R(__stdcall *function)($for ARG , [[A$(ARG)]]))
44       : function_(function) {
45   }
46
47   R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
48     return function_($for ARG , [[a$(ARG)]]);
49   }
50
51  private:
52   R (__stdcall *function_)($for ARG , [[A$(ARG)]]);
53 };
54
55 // __fastcall Function: Arity $(ARITY).
56 template <typename R[[]]
57 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
58 class RunnableAdapter<R(__fastcall *)($for ARG , [[A$(ARG)]])> {
59  public:
60   typedef R (RunType)($for ARG , [[A$(ARG)]]);
61
62   explicit RunnableAdapter(R(__fastcall *function)($for ARG , [[A$(ARG)]]))
63       : function_(function) {
64   }
65
66   R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
67     return function_($for ARG , [[a$(ARG)]]);
68   }
69
70  private:
71   R (__fastcall *function_)($for ARG , [[A$(ARG)]]);
72 };
73
74 ]]  $$for ARITY
75
76 }  // namespace internal
77 }  // namespace base
78
79 #endif  // !defined(ARCH_CPU_X86_64)
80
81 #endif  // BASE_BIND_INTERNAL_WIN_H_