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

Side by Side Diff: base/bind_internal_win.h.pump

Issue 8483003: Callback API Change: Reimplement Bind(); support IgnoreResult, full currying, and use less types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 1 month 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
« no previous file with comments | « base/bind_internal_win.h ('k') | base/bind_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 $$ This is a pump file for generating file templates. Pump is a python 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 2 $$ script that is part of the Google Test suite of utilities. Description
3 $$ can be found here: 3 $$ can be found here:
4 $$ 4 $$
5 $$ http://code.google.com/p/googletest/wiki/PumpManual 5 $$ http://code.google.com/p/googletest/wiki/PumpManual
6 $$ 6 $$
7 7
8 $var MAX_ARITY = 6 8 $var MAX_ARITY = 6
9 9
10 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 10 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
11 // Use of this source code is governed by a BSD-style license that can be 11 // Use of this source code is governed by a BSD-style license that can be
12 // found in the LICENSE file. 12 // found in the LICENSE file.
13 13
14 // Specializations of FunctionTraits<> for Windows specific calling 14 // Specializations of RunnableAdapter<> for Windows specific calling
15 // conventions. Please see base/bind_internal.h for more info. 15 // conventions. Please see base/bind_internal.h for more info.
16 16
17 #ifndef BASE_BIND_INTERNAL_WIN_H_ 17 #ifndef BASE_BIND_INTERNAL_WIN_H_
18 #define BASE_BIND_INTERNAL_WIN_H_ 18 #define BASE_BIND_INTERNAL_WIN_H_
19 #pragma once 19 #pragma once
20 20
21 // In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all 21 // In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all
22 // the same as __cdecl which would turn the following specializations into 22 // the same as __cdecl which would turn the following specializations into
23 // multiple definitions. 23 // multiple definitions.
24 #if !defined(ARCH_CPU_X86_64) 24 #if !defined(ARCH_CPU_X86_64)
25 25
26 namespace base { 26 namespace base {
27 namespace internal { 27 namespace internal {
28 28
29 template <typename Sig> 29 template <typename Functor>
30 struct FunctionTraits; 30 class RunnableAdapter;
31 31
32 $range ARITY 0..MAX_ARITY 32 $range ARITY 0..MAX_ARITY
33 $for ARITY [[ 33 $for ARITY [[
34 $range ARG 1..ARITY 34 $range ARG 1..ARITY
35 35
36 // __stdcall Function: Arity $(ARITY). 36 // __stdcall Function: Arity $(ARITY).
37 template <typename R[[]] 37 template <typename R[[]]
38 $if ARITY > 0[[, ]] $for ARG , [[typename X$(ARG)]]> 38 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
39 struct FunctionTraits<R(__stdcall *)($for ARG , [[X$(ARG)]])> { 39 class RunnableAdapter<R(__stdcall *)($for ARG , [[A$(ARG)]])> {
40 typedef R (*NormalizedSig)($for ARG , [[X$(ARG)]]); 40 public:
41 typedef false_type IsMethod; 41 typedef R (RunType)($for ARG , [[A$(ARG)]]);
42 42
43 typedef R Return; 43 explicit RunnableAdapter(R(__stdcall *function)($for ARG , [[A$(ARG)]]))
44 : function_(function) {
45 }
44 46
45 $if ARITY > 0 [[ 47 R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)] ]) {
48 return function_($for ARG , [[a$(ARG)]]);
49 }
46 50
47 // Target type for each bound parameter. 51 private:
48 52 R (__stdcall *function_)($for ARG , [[A$(ARG)]]);
49 $for ARG [[
50 typedef X$(ARG) B$(ARG);
51
52 ]] $$ for ARG
53 ]] $$ if ARITY > 0
54 }; 53 };
55 54
56 // __fastcall Function: Arity $(ARITY). 55 // __fastcall Function: Arity $(ARITY).
57 template <typename R[[]] 56 template <typename R[[]]
58 $if ARITY > 0[[, ]] $for ARG , [[typename X$(ARG)]]> 57 $if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
59 struct FunctionTraits<R(__fastcall *)($for ARG , [[X$(ARG)]])> { 58 class RunnableAdapter<R(__fastcall *)($for ARG , [[A$(ARG)]])> {
60 typedef R (*NormalizedSig)($for ARG , [[X$(ARG)]]); 59 public:
61 typedef false_type IsMethod; 60 typedef R (RunType)($for ARG , [[A$(ARG)]]);
62 61
63 typedef R Return; 62 explicit RunnableAdapter(R(__fastcall *function)($for ARG , [[A$(ARG)]]))
63 : function_(function) {
64 }
64 65
65 $if ARITY > 0 [[ 66 R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)] ]) {
67 return function_($for ARG , [[a$(ARG)]]);
68 }
66 69
67 // Target type for each bound parameter. 70 private:
68 71 R (__fastcall *function_)($for ARG , [[A$(ARG)]]);
69 $for ARG [[
70 typedef X$(ARG) B$(ARG);
71
72 ]] $$ for ARG
73 ]] $$ if ARITY > 0
74 }; 72 };
75 73
76 ]] $$for ARITY 74 ]] $$for ARITY
77 75
78 } // namespace internal 76 } // namespace internal
79 } // namespace base 77 } // namespace base
80 78
81 #endif // !defined(ARCH_CPU_X86_64) 79 #endif // !defined(ARCH_CPU_X86_64)
82 80
83 #endif // BASE_BIND_INTERNAL_WIN_H_ 81 #endif // BASE_BIND_INTERNAL_WIN_H_
OLDNEW
« no previous file with comments | « base/bind_internal_win.h ('k') | base/bind_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698