From d9b3ce2e4ba73134b491648b8ad6a8bcd9461158 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov <0x7fffff@guattari.ru> Date: Tue, 30 Aug 2022 09:46:14 +0400 Subject: [async_function] Fix coroutine name --- source/kit/async_function.h | 10 +++------- source/test/unittests/async_function.test.c | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/kit/async_function.h b/source/kit/async_function.h index 3954aca..58d432c 100644 --- a/source/kit/async_function.h +++ b/source/kit/async_function.h @@ -48,10 +48,7 @@ typedef struct { __VA_ARGS__ \ } -#define KIT_AF_NAME(name_) name_##_coro_ - -#define KIT_AF_DECL(name_) \ - void KIT_AF_NAME(name_)(void *self_void_, int request_) +#define KIT_AF_DECL(name_) void name_(void *self_void_, int request_) #define KIT_CORO_IMPL(name_) \ KIT_AF_DECL(name_) { \ @@ -151,8 +148,8 @@ typedef struct { #define KIT_AF_TYPE(coro_) struct coro_##_coro_state_ -#define KIT_AF_INITIAL(coro_) \ - ._index = 0, ._state_machine = KIT_AF_NAME(coro_), \ +#define KIT_AF_INITIAL(coro_) \ + ._index = 0, ._state_machine = (coro_), \ ._context = { .state = NULL, .execute = NULL } #define KIT_AF_CREATE(promise_, coro_, ...) \ @@ -277,7 +274,6 @@ typedef struct { # define AF_STATE_DATA KIT_AF_STATE_DATA # define AF_INTERNAL KIT_AF_INTERNAL # define AF_STATE KIT_AF_STATE -# define AF_NAME KIT_AF_NAME # define AF_DECL KIT_AF_DECL # define CORO_IMPL KIT_CORO_IMPL # define CORO_END KIT_CORO_END diff --git a/source/test/unittests/async_function.test.c b/source/test/unittests/async_function.test.c index 5816bfc..6e1bc69 100644 --- a/source/test/unittests/async_function.test.c +++ b/source/test/unittests/async_function.test.c @@ -93,7 +93,7 @@ TEST("coroutine init") { TEST("coroutine init explicit") { AF_TYPE(test_foo) promise; - AF_INIT_EXPLICIT(promise, sizeof promise, AF_NAME(test_foo)); + AF_INIT_EXPLICIT(promise, sizeof promise, test_foo); REQUIRE(!AF_FINISHED(promise)); } -- cgit v1.2.3