@@ -149,6 +149,8 @@ template <class AsyncSignature>
149
149
class AsyncFunctionPointer ;
150
150
template <class AsyncSignature >
151
151
struct AsyncFunctionTypeImpl ;
152
+ template <class AsyncSignature >
153
+ struct AsyncContinuationTypeImpl ;
152
154
153
155
// / The abstract signature for an asynchronous function.
154
156
template <class Sig , bool HasErrorResult>
@@ -163,6 +165,7 @@ struct AsyncSignature<DirectResultTy(ArgTys...), HasErrorResult> {
163
165
164
166
using FunctionPointer = AsyncFunctionPointer<AsyncSignature>;
165
167
using FunctionType = typename AsyncFunctionTypeImpl<AsyncSignature>::type;
168
+ using ContinuationType = typename AsyncContinuationTypeImpl<AsyncSignature>::type;
166
169
};
167
170
168
171
// / A signature for a thin async function that takes no arguments
@@ -175,30 +178,58 @@ using ThinNullaryAsyncSignature =
175
178
using ThickNullaryAsyncSignature =
176
179
AsyncSignature<void (HeapObject*), false >;
177
180
178
- // / A class which can be used to statically query whether a type
179
- // / is a specialization of AsyncSignature.
180
- template <class T >
181
- struct IsAsyncSignature {
182
- static const bool value = false ;
183
- };
181
+ template <class Signature >
182
+ struct AsyncFunctionTypeImpl ;
183
+
184
184
template <class DirectResultTy , class ... ArgTys, bool HasErrorResult>
185
- struct IsAsyncSignature <AsyncSignature<DirectResultTy(ArgTys...),
186
- HasErrorResult>> {
187
- static const bool value = true ;
185
+ struct AsyncFunctionTypeImpl <
186
+ AsyncSignature<DirectResultTy(ArgTys...), HasErrorResult>> {
187
+
188
+ using type = SWIFT_CC(swiftasync) void (SWIFT_ASYNC_CONTEXT AsyncContext *,
189
+ ArgTys...);
188
190
};
189
191
190
192
template <class Signature >
191
- struct AsyncFunctionTypeImpl {
192
- static_assert (IsAsyncSignature<Signature>::value,
193
- " template argument is not an AsyncSignature" );
193
+ struct AsyncContinuationTypeImpl ;
194
+
195
+ template <class DirectResultTy , class ... ArgTys>
196
+ struct AsyncContinuationTypeImpl <
197
+ AsyncSignature<DirectResultTy(ArgTys...), /* throws=*/ true >> {
198
+
199
+ using type = SWIFT_CC(swiftasync) void (SWIFT_ASYNC_CONTEXT AsyncContext *,
200
+ DirectResultTy,
201
+ SWIFT_CONTEXT void *);
202
+ };
194
203
195
- // TODO: expand and include the arguments in the parameters.
196
- using type = TaskContinuationFunction;
204
+ template <class DirectResultTy , class ... ArgTys>
205
+ struct AsyncContinuationTypeImpl <
206
+ AsyncSignature<DirectResultTy(ArgTys...), /* throws=*/ false >> {
207
+
208
+ using type = SWIFT_CC(swiftasync) void (SWIFT_ASYNC_CONTEXT AsyncContext *,
209
+ DirectResultTy);
210
+ };
211
+
212
+ template <class ... ArgTys>
213
+ struct AsyncContinuationTypeImpl <
214
+ AsyncSignature<void (ArgTys...), /* throws=*/ true >> {
215
+
216
+ using type = SWIFT_CC(swiftasync) void (SWIFT_ASYNC_CONTEXT AsyncContext *,
217
+ SWIFT_CONTEXT void *);
218
+ };
219
+
220
+ template <class ... ArgTys>
221
+ struct AsyncContinuationTypeImpl <
222
+ AsyncSignature<void (ArgTys...), /* throws=*/ false >> {
223
+
224
+ using type = SWIFT_CC(swiftasync) void (SWIFT_ASYNC_CONTEXT AsyncContext *);
197
225
};
198
226
199
227
template <class Fn >
200
228
using AsyncFunctionType = typename AsyncFunctionTypeImpl<Fn>::type;
201
229
230
+ template <class Fn >
231
+ using AsyncContinuationType = typename AsyncContinuationTypeImpl<Fn>::type;
232
+
202
233
// / A "function pointer" for an async function.
203
234
// /
204
235
// / Eventually, this will always be signed with the data key
0 commit comments