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

Side by Side Diff: base/bind_internal.h

Issue 6561004: Callback support for __fastcall and __stdcall functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: Address will's comments. Created 9 years, 10 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 // This file was GENERATED by command: 1 // This file was GENERATED by command:
2 // pump.py bind_internal.h.pump 2 // pump.py bind_internal.h.pump
3 // DO NOT EDIT BY HAND!!! 3 // DO NOT EDIT BY HAND!!!
4 4
5 5
6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 6 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be 7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file. 8 // found in the LICENSE file.
9 9
10 #ifndef BASE_BIND_INTERNAL_H_ 10 #ifndef BASE_BIND_INTERNAL_H_
11 #define BASE_BIND_INTERNAL_H_ 11 #define BASE_BIND_INTERNAL_H_
12 #pragma once 12 #pragma once
13 13
14 #include "build/build_config.h"
15
14 #include "base/bind_helpers.h" 16 #include "base/bind_helpers.h"
15 #include "base/callback_internal.h" 17 #include "base/callback_internal.h"
16 #include "base/template_util.h" 18 #include "base/template_util.h"
17 19
20 #if defined(OS_WIN)
21 #include "base/bind_internal_win.h"
22 #endif
23
18 namespace base { 24 namespace base {
19 namespace internal { 25 namespace internal {
20 26
21 // The method by which a function is invoked is determined by 3 different 27 // The method by which a function is invoked is determined by 3 different
22 // dimensions: 28 // dimensions:
23 // 29 //
24 // 1) The type of function (normal or method). 30 // 1) The type of function (normal or method).
25 // 2) The arity of the function. 31 // 2) The arity of the function.
26 // 3) The number of bound parameters. 32 // 3) The number of bound parameters.
27 // 33 //
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // 66 //
61 // By normalizing the function signature, we reduce function_type to exactly 2. 67 // By normalizing the function signature, we reduce function_type to exactly 2.
62 68
63 template <typename Sig> 69 template <typename Sig>
64 struct FunctionTraits; 70 struct FunctionTraits;
65 71
66 // Function: Arity 0. 72 // Function: Arity 0.
67 template <typename R> 73 template <typename R>
68 struct FunctionTraits<R(*)()> { 74 struct FunctionTraits<R(*)()> {
69 typedef R (*NormalizedSig)(); 75 typedef R (*NormalizedSig)();
70 typedef base::false_type IsMethod; 76 typedef false_type IsMethod;
71 }; 77 };
72 78
73 // Method: Arity 0. 79 // Method: Arity 0.
74 template <typename R, typename T> 80 template <typename R, typename T>
75 struct FunctionTraits<R(T::*)()> { 81 struct FunctionTraits<R(T::*)()> {
76 typedef R (T::*NormalizedSig)(); 82 typedef R (T::*NormalizedSig)();
77 typedef base::true_type IsMethod; 83 typedef true_type IsMethod;
78 }; 84 };
79 85
80 // Const Method: Arity 0. 86 // Const Method: Arity 0.
81 template <typename R, typename T> 87 template <typename R, typename T>
82 struct FunctionTraits<R(T::*)() const> { 88 struct FunctionTraits<R(T::*)() const> {
83 typedef R (T::*NormalizedSig)(); 89 typedef R (T::*NormalizedSig)();
84 typedef base::true_type IsMethod; 90 typedef true_type IsMethod;
85 }; 91 };
86 92
87 // Function: Arity 1. 93 // Function: Arity 1.
88 template <typename R, typename X1> 94 template <typename R, typename X1>
89 struct FunctionTraits<R(*)(X1)> { 95 struct FunctionTraits<R(*)(X1)> {
90 typedef R (*NormalizedSig)(X1); 96 typedef R (*NormalizedSig)(X1);
91 typedef base::false_type IsMethod; 97 typedef false_type IsMethod;
92 }; 98 };
93 99
94 // Method: Arity 1. 100 // Method: Arity 1.
95 template <typename R, typename T, typename X1> 101 template <typename R, typename T, typename X1>
96 struct FunctionTraits<R(T::*)(X1)> { 102 struct FunctionTraits<R(T::*)(X1)> {
97 typedef R (T::*NormalizedSig)(X1); 103 typedef R (T::*NormalizedSig)(X1);
98 typedef base::true_type IsMethod; 104 typedef true_type IsMethod;
99 }; 105 };
100 106
101 // Const Method: Arity 1. 107 // Const Method: Arity 1.
102 template <typename R, typename T, typename X1> 108 template <typename R, typename T, typename X1>
103 struct FunctionTraits<R(T::*)(X1) const> { 109 struct FunctionTraits<R(T::*)(X1) const> {
104 typedef R (T::*NormalizedSig)(X1); 110 typedef R (T::*NormalizedSig)(X1);
105 typedef base::true_type IsMethod; 111 typedef true_type IsMethod;
106 }; 112 };
107 113
108 // Function: Arity 2. 114 // Function: Arity 2.
109 template <typename R, typename X1, typename X2> 115 template <typename R, typename X1, typename X2>
110 struct FunctionTraits<R(*)(X1, X2)> { 116 struct FunctionTraits<R(*)(X1, X2)> {
111 typedef R (*NormalizedSig)(X1, X2); 117 typedef R (*NormalizedSig)(X1, X2);
112 typedef base::false_type IsMethod; 118 typedef false_type IsMethod;
113 }; 119 };
114 120
115 // Method: Arity 2. 121 // Method: Arity 2.
116 template <typename R, typename T, typename X1, typename X2> 122 template <typename R, typename T, typename X1, typename X2>
117 struct FunctionTraits<R(T::*)(X1, X2)> { 123 struct FunctionTraits<R(T::*)(X1, X2)> {
118 typedef R (T::*NormalizedSig)(X1, X2); 124 typedef R (T::*NormalizedSig)(X1, X2);
119 typedef base::true_type IsMethod; 125 typedef true_type IsMethod;
120 }; 126 };
121 127
122 // Const Method: Arity 2. 128 // Const Method: Arity 2.
123 template <typename R, typename T, typename X1, typename X2> 129 template <typename R, typename T, typename X1, typename X2>
124 struct FunctionTraits<R(T::*)(X1, X2) const> { 130 struct FunctionTraits<R(T::*)(X1, X2) const> {
125 typedef R (T::*NormalizedSig)(X1, X2); 131 typedef R (T::*NormalizedSig)(X1, X2);
126 typedef base::true_type IsMethod; 132 typedef true_type IsMethod;
127 }; 133 };
128 134
129 // Function: Arity 3. 135 // Function: Arity 3.
130 template <typename R, typename X1, typename X2, typename X3> 136 template <typename R, typename X1, typename X2, typename X3>
131 struct FunctionTraits<R(*)(X1, X2, X3)> { 137 struct FunctionTraits<R(*)(X1, X2, X3)> {
132 typedef R (*NormalizedSig)(X1, X2, X3); 138 typedef R (*NormalizedSig)(X1, X2, X3);
133 typedef base::false_type IsMethod; 139 typedef false_type IsMethod;
134 }; 140 };
135 141
136 // Method: Arity 3. 142 // Method: Arity 3.
137 template <typename R, typename T, typename X1, typename X2, typename X3> 143 template <typename R, typename T, typename X1, typename X2, typename X3>
138 struct FunctionTraits<R(T::*)(X1, X2, X3)> { 144 struct FunctionTraits<R(T::*)(X1, X2, X3)> {
139 typedef R (T::*NormalizedSig)(X1, X2, X3); 145 typedef R (T::*NormalizedSig)(X1, X2, X3);
140 typedef base::true_type IsMethod; 146 typedef true_type IsMethod;
141 }; 147 };
142 148
143 // Const Method: Arity 3. 149 // Const Method: Arity 3.
144 template <typename R, typename T, typename X1, typename X2, typename X3> 150 template <typename R, typename T, typename X1, typename X2, typename X3>
145 struct FunctionTraits<R(T::*)(X1, X2, X3) const> { 151 struct FunctionTraits<R(T::*)(X1, X2, X3) const> {
146 typedef R (T::*NormalizedSig)(X1, X2, X3); 152 typedef R (T::*NormalizedSig)(X1, X2, X3);
147 typedef base::true_type IsMethod; 153 typedef true_type IsMethod;
148 }; 154 };
149 155
150 // Function: Arity 4. 156 // Function: Arity 4.
151 template <typename R, typename X1, typename X2, typename X3, typename X4> 157 template <typename R, typename X1, typename X2, typename X3, typename X4>
152 struct FunctionTraits<R(*)(X1, X2, X3, X4)> { 158 struct FunctionTraits<R(*)(X1, X2, X3, X4)> {
153 typedef R (*NormalizedSig)(X1, X2, X3, X4); 159 typedef R (*NormalizedSig)(X1, X2, X3, X4);
154 typedef base::false_type IsMethod; 160 typedef false_type IsMethod;
155 }; 161 };
156 162
157 // Method: Arity 4. 163 // Method: Arity 4.
158 template <typename R, typename T, typename X1, typename X2, typename X3, 164 template <typename R, typename T, typename X1, typename X2, typename X3,
159 typename X4> 165 typename X4>
160 struct FunctionTraits<R(T::*)(X1, X2, X3, X4)> { 166 struct FunctionTraits<R(T::*)(X1, X2, X3, X4)> {
161 typedef R (T::*NormalizedSig)(X1, X2, X3, X4); 167 typedef R (T::*NormalizedSig)(X1, X2, X3, X4);
162 typedef base::true_type IsMethod; 168 typedef true_type IsMethod;
163 }; 169 };
164 170
165 // Const Method: Arity 4. 171 // Const Method: Arity 4.
166 template <typename R, typename T, typename X1, typename X2, typename X3, 172 template <typename R, typename T, typename X1, typename X2, typename X3,
167 typename X4> 173 typename X4>
168 struct FunctionTraits<R(T::*)(X1, X2, X3, X4) const> { 174 struct FunctionTraits<R(T::*)(X1, X2, X3, X4) const> {
169 typedef R (T::*NormalizedSig)(X1, X2, X3, X4); 175 typedef R (T::*NormalizedSig)(X1, X2, X3, X4);
170 typedef base::true_type IsMethod; 176 typedef true_type IsMethod;
171 }; 177 };
172 178
173 // Function: Arity 5. 179 // Function: Arity 5.
174 template <typename R, typename X1, typename X2, typename X3, typename X4, 180 template <typename R, typename X1, typename X2, typename X3, typename X4,
175 typename X5> 181 typename X5>
176 struct FunctionTraits<R(*)(X1, X2, X3, X4, X5)> { 182 struct FunctionTraits<R(*)(X1, X2, X3, X4, X5)> {
177 typedef R (*NormalizedSig)(X1, X2, X3, X4, X5); 183 typedef R (*NormalizedSig)(X1, X2, X3, X4, X5);
178 typedef base::false_type IsMethod; 184 typedef false_type IsMethod;
179 }; 185 };
180 186
181 // Method: Arity 5. 187 // Method: Arity 5.
182 template <typename R, typename T, typename X1, typename X2, typename X3, 188 template <typename R, typename T, typename X1, typename X2, typename X3,
183 typename X4, typename X5> 189 typename X4, typename X5>
184 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5)> { 190 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5)> {
185 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); 191 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5);
186 typedef base::true_type IsMethod; 192 typedef true_type IsMethod;
187 }; 193 };
188 194
189 // Const Method: Arity 5. 195 // Const Method: Arity 5.
190 template <typename R, typename T, typename X1, typename X2, typename X3, 196 template <typename R, typename T, typename X1, typename X2, typename X3,
191 typename X4, typename X5> 197 typename X4, typename X5>
192 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5) const> { 198 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5) const> {
193 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5); 199 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5);
194 typedef base::true_type IsMethod; 200 typedef true_type IsMethod;
195 }; 201 };
196 202
197 // Function: Arity 6. 203 // Function: Arity 6.
198 template <typename R, typename X1, typename X2, typename X3, typename X4, 204 template <typename R, typename X1, typename X2, typename X3, typename X4,
199 typename X5, typename X6> 205 typename X5, typename X6>
200 struct FunctionTraits<R(*)(X1, X2, X3, X4, X5, X6)> { 206 struct FunctionTraits<R(*)(X1, X2, X3, X4, X5, X6)> {
201 typedef R (*NormalizedSig)(X1, X2, X3, X4, X5, X6); 207 typedef R (*NormalizedSig)(X1, X2, X3, X4, X5, X6);
202 typedef base::false_type IsMethod; 208 typedef false_type IsMethod;
203 }; 209 };
204 210
205 // Method: Arity 6. 211 // Method: Arity 6.
206 template <typename R, typename T, typename X1, typename X2, typename X3, 212 template <typename R, typename T, typename X1, typename X2, typename X3,
207 typename X4, typename X5, typename X6> 213 typename X4, typename X5, typename X6>
208 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6)> { 214 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6)> {
209 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); 215 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6);
210 typedef base::true_type IsMethod; 216 typedef true_type IsMethod;
211 }; 217 };
212 218
213 // Const Method: Arity 6. 219 // Const Method: Arity 6.
214 template <typename R, typename T, typename X1, typename X2, typename X3, 220 template <typename R, typename T, typename X1, typename X2, typename X3,
215 typename X4, typename X5, typename X6> 221 typename X4, typename X5, typename X6>
216 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6) const> { 222 struct FunctionTraits<R(T::*)(X1, X2, X3, X4, X5, X6) const> {
217 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6); 223 typedef R (T::*NormalizedSig)(X1, X2, X3, X4, X5, X6);
218 typedef base::true_type IsMethod; 224 typedef true_type IsMethod;
219 }; 225 };
220 226
221 // InvokerN<> 227 // InvokerN<>
222 // 228 //
223 // The InvokerN templates contain a static DoInvoke() function that is the key 229 // The InvokerN templates contain a static DoInvoke() function that is the key
224 // to implementing type erasure in the Callback() classes. 230 // to implementing type erasure in the Callback() classes.
225 // 231 //
226 // DoInvoke() is a static function with a fixed signature that is independent 232 // DoInvoke() is a static function with a fixed signature that is independent
227 // of StorageType; its first argument is a pointer to the non-templated common 233 // of StorageType; its first argument is a pointer to the non-templated common
228 // baseclass of StorageType. This lets us store pointer to DoInvoke() in a 234 // baseclass of StorageType. This lets us store pointer to DoInvoke() in a
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 typename BindType<P3>::StorageType p3_; 1384 typename BindType<P3>::StorageType p3_;
1379 typename BindType<P4>::StorageType p4_; 1385 typename BindType<P4>::StorageType p4_;
1380 typename BindType<P5>::StorageType p5_; 1386 typename BindType<P5>::StorageType p5_;
1381 typename BindType<P6>::StorageType p6_; 1387 typename BindType<P6>::StorageType p6_;
1382 }; 1388 };
1383 1389
1384 } // namespace internal 1390 } // namespace internal
1385 } // namespace base 1391 } // namespace base
1386 1392
1387 #endif // BASE_BIND_INTERNAL_H_ 1393 #endif // BASE_BIND_INTERNAL_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/bind_internal.h.pump » ('j') | base/bind_internal.h.pump » ('J')

Powered by Google App Engine
This is Rietveld 408576698