diff options
author | Mitya Selivanov <0x7fffff@guattari.ru> | 2022-08-15 04:25:53 +0400 |
---|---|---|
committer | Mitya Selivanov <0x7fffff@guattari.ru> | 2022-08-15 04:25:53 +0400 |
commit | d01d6adafc655895f23023057a0cb0a3be648af3 (patch) | |
tree | fc308a72610a7994b83c677697d00a25b265aa4c | |
parent | b0811b24d400aaab3629440c0da9fd792b22f55b (diff) | |
download | kit-d01d6adafc655895f23023057a0cb0a3be648af3.zip |
Refactor
-rw-r--r-- | source/kit/async_function.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/source/kit/async_function.h b/source/kit/async_function.h index d23998a..55e9c0c 100644 --- a/source/kit/async_function.h +++ b/source/kit/async_function.h @@ -26,21 +26,24 @@ typedef struct { kit_af_execute execute; } kit_af_execution_context; +#define KIT_AF_STATE_DATA \ + struct { \ + int _index; \ + kit_af_state_machine _state_machine; \ + kit_af_execution_context _context; \ + } + typedef struct { - int _index; - kit_af_state_machine _state_machine; - kit_af_execution_context _context; + KIT_AF_STATE_DATA; } kit_af_type_void; #define KIT_AF_INTERNAL(coro_) (*((kit_af_type_void *) (coro_))) -#define KIT_AF_STATE(ret_type_, name_, ...) \ - struct name_##_coro_state_ { \ - int _index; \ - kit_af_state_machine _state_machine; \ - kit_af_execution_context _context; \ - ret_type_ return_value; \ - __VA_ARGS__ \ +#define KIT_AF_STATE(ret_type_, name_, ...) \ + struct name_##_coro_state_ { \ + KIT_AF_STATE_DATA; \ + ret_type_ return_value; \ + __VA_ARGS__ \ } #define KIT_AF_DECL(name_) \ @@ -254,6 +257,7 @@ typedef struct { # define af_execution_context kit_af_execution_context # define af_type_void kit_af_type_void +# define AF_STATE_DATA KIT_AF_STATE_DATA # define AF_INTERNAL KIT_AF_INTERNAL # define AF_STATE KIT_AF_STATE # define AF_DECL KIT_AF_DECL |