diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-12-11 14:17:06 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-12-11 14:17:06 -0800 |
commit | 73a5f983dbfbe47e2338871063f26f00adfce85c (patch) | |
tree | 4e279bd3d50f69a467b4742a323a69bf1e53a2f4 | |
parent | ed975aace68fcd8a433ee4246eb313cab1c2d503 (diff) |
thunk: fixup handling arity=0 thunks
Overlooked this, but it's also odd how the __VA_ARGS__
when empty is still being passed as a separate argument
requiring the addition of the _nil placeholders.
-rw-r--r-- | thunk.h | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -36,7 +36,7 @@ struct thunk_t { /* Macros for declaring the thunk environment struct members, we need a variant * for each supported arity. */ -#define _THUNK_GEN_STRUCT_0() +#define _THUNK_GEN_STRUCT_0(_nil) #define _THUNK_GEN_STRUCT_2(_t_a, _n_a) \ _t_a _n_a; @@ -125,7 +125,7 @@ struct thunk_t { /* Macros for populating the thunk environment struct members when instantiating the * thunk, we need a variant for each supported arity. */ -#define _THUNK_GEN_INSTANTIATE_0(_env) +#define _THUNK_GEN_INSTANTIATE_0(_env, _nil) #define _THUNK_GEN_INSTANTIATE_2(_env, _t_a, _n_a) \ _env->_n_a = _n_a; @@ -214,7 +214,8 @@ struct thunk_t { /* Macros for dispatching the embedded thunk from its associated environment, * we need a variant for each supported arity. */ -#define _THUNK_GEN_DISPATCH_0(_name, _env) +#define _THUNK_GEN_DISPATCH_0(_name, _env, _nil) \ + _name() #define _THUNK_GEN_DISPATCH_2(_name, _env, _t_a, _n_a) \ _name(_env->_n_a) @@ -258,7 +259,8 @@ struct thunk_t { /* Macros for prototyping the function being thunked, * we need a variant for each supported arity. */ -#define _THUNK_GEN_PROTO_0(_name) +#define _THUNK_GEN_PROTO_0(_name, _nil) \ + _name(void) #define _THUNK_GEN_PROTO_2(_name, _t_a, _n_a) \ _name(_t_a _n_a) |