@@ -149,6 +149,8 @@ template <class AsyncSignature>
149149class AsyncFunctionPointer ;
150150template <class AsyncSignature >
151151struct AsyncFunctionTypeImpl ;
152+ template <class AsyncSignature >
153+ struct AsyncContinuationTypeImpl ;
152154
153155// / The abstract signature for an asynchronous function.
154156template <class Sig , bool HasErrorResult>
@@ -163,6 +165,7 @@ struct AsyncSignature<DirectResultTy(ArgTys...), HasErrorResult> {
163165
164166 using FunctionPointer = AsyncFunctionPointer<AsyncSignature>;
165167 using FunctionType = typename AsyncFunctionTypeImpl<AsyncSignature>::type;
168+ using ContinuationType = typename AsyncContinuationTypeImpl<AsyncSignature>::type;
166169};
167170
168171// / A signature for a thin async function that takes no arguments
@@ -175,30 +178,58 @@ using ThinNullaryAsyncSignature =
175178using ThickNullaryAsyncSignature =
176179 AsyncSignature<void (HeapObject*), false >;
177180
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+
184184template <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...);
188190};
189191
190192template <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+ };
194203
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 *);
197225};
198226
199227template <class Fn >
200228using AsyncFunctionType = typename AsyncFunctionTypeImpl<Fn>::type;
201229
230+ template <class Fn >
231+ using AsyncContinuationType = typename AsyncContinuationTypeImpl<Fn>::type;
232+
202233// / A "function pointer" for an async function.
203234// /
204235// / Eventually, this will always be signed with the data key
0 commit comments