From e6003c0ecfd7e76803bac7d98feca814997e8a86 Mon Sep 17 00:00:00 2001 From: tylov Date: Sun, 30 Jul 2023 22:46:33 +0200 Subject: Added cco_generator(Name, ...) macro to simplify defining the iterator struct. Updated example generator.c --- include/stc/coroutine.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/stc/coroutine.h b/include/stc/coroutine.h index 9f55dddf..7917878a 100644 --- a/include/stc/coroutine.h +++ b/include/stc/coroutine.h @@ -132,7 +132,19 @@ typedef enum { (void)((co)->cco_state = 0) /* - * Tasks (optional) + * Generators + */ + +#define cco_generator(Name, ...) \ + typedef Name Name##_value; \ + typedef struct { \ + Name##_value* ref; \ + int cco_state; \ + __VA_ARGS__ \ + } Name##_iter + +/* + * Tasks */ struct cco_runtime; -- cgit v1.2.3