summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-11-04 02:17:12 -0800
committerVito Caputo <vcaputo@pengaru.com>2020-11-04 02:17:12 -0800
commitf73822a6b74690dd8189d048b67a83eb863c4083 (patch)
tree9a93da3441a14faad01d5a9ea6d249d75df65cf1
parente6a866286cbc9442ae466e335023b37943956e27 (diff)
thunk: expand max number of thunk parameters to 12
Just bumping this limit a bit
-rw-r--r--thunk.h80
1 files changed, 73 insertions, 7 deletions
diff --git a/thunk.h b/thunk.h
index c388140..cc07868 100644
--- a/thunk.h
+++ b/thunk.h
@@ -32,11 +32,11 @@ struct thunk_t {
#define _C99_NARGS(...) \
_C99_NARGS1( , ##__VA_ARGS__)
#define _C99_NARGS1(...) \
- _C99_NARGS2(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
-#define _C99_NARGS2(_, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, _n, ...) \
+ _C99_NARGS2(__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+#define _C99_NARGS2(_, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, _n, ...) \
_n
-/* Macros for declaring the thunk environment struct members, we need a variant
+/* Macros for declaring the thunk environment struct members, we need a variant
* for each supported arity. */
#define _THUNK_GEN_STRUCT_0(_nil)
@@ -115,11 +115,38 @@ struct thunk_t {
_t_i _n_i; \
_t_j _n_j;
+#define _THUNK_GEN_STRUCT_22(_t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j, _t_k, _n_k)\
+ _t_a _n_a; \
+ _t_b _n_b; \
+ _t_c _n_c; \
+ _t_d _n_d; \
+ _t_e _n_e; \
+ _t_f _n_f; \
+ _t_g _n_g; \
+ _t_h _n_h; \
+ _t_i _n_i; \
+ _t_j _n_j; \
+ _t_k _n_k;
+
+#define _THUNK_GEN_STRUCT_24(_t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j, _t_k, _n_k, _t_l, _n_l)\
+ _t_a _n_a; \
+ _t_b _n_b; \
+ _t_c _n_c; \
+ _t_d _n_d; \
+ _t_e _n_e; \
+ _t_f _n_f; \
+ _t_g _n_g; \
+ _t_h _n_h; \
+ _t_i _n_i; \
+ _t_j _n_j; \
+ _t_k _n_k; \
+ _t_l _n_l;
+
#define _THUNK_GEN_STRUCT__(_count, ...) \
_THUNK_GEN_STRUCT_##_count(__VA_ARGS__)
#define _THUNK_GEN_STRUCT_(_count, ...) \
- _THUNK_GEN_STRUCT__(_count, __VA_ARGS__)
+ _THUNK_GEN_STRUCT__(_count, __VA_ARGS__)
#define _THUNK_GEN_STRUCT(...) \
_THUNK_GEN_STRUCT_(_C99_NARGS(__VA_ARGS__), __VA_ARGS__)
@@ -204,11 +231,38 @@ struct thunk_t {
_env->_n_i = _n_i; \
_env->_n_j = _n_j;
+#define _THUNK_GEN_INSTANTIATE_22(_env, _t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j, _t_k, _n_k)\
+ _env->_n_a = _n_a; \
+ _env->_n_b = _n_b; \
+ _env->_n_c = _n_c; \
+ _env->_n_d = _n_d; \
+ _env->_n_e = _n_e; \
+ _env->_n_f = _n_f; \
+ _env->_n_g = _n_g; \
+ _env->_n_h = _n_h; \
+ _env->_n_i = _n_i; \
+ _env->_n_j = _n_j; \
+ _env->_n_k = _n_k;
+
+#define _THUNK_GEN_INSTANTIATE_24(_env, _t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j, _t_k, _n_k, _t_l, _n_l)\
+ _env->_n_a = _n_a; \
+ _env->_n_b = _n_b; \
+ _env->_n_c = _n_c; \
+ _env->_n_d = _n_d; \
+ _env->_n_e = _n_e; \
+ _env->_n_f = _n_f; \
+ _env->_n_g = _n_g; \
+ _env->_n_h = _n_h; \
+ _env->_n_i = _n_i; \
+ _env->_n_j = _n_j; \
+ _env->_n_k = _n_k; \
+ _env->_n_l = _n_l;
+
#define _THUNK_GEN_INSTANTIATE__(_env, _count, ...) \
_THUNK_GEN_INSTANTIATE_##_count(_env, __VA_ARGS__)
#define _THUNK_GEN_INSTANTIATE_(_env, _count, ...) \
- _THUNK_GEN_INSTANTIATE__(_env, _count, __VA_ARGS__)
+ _THUNK_GEN_INSTANTIATE__(_env, _count, __VA_ARGS__)
#define _THUNK_GEN_INSTANTIATE(_env, ...) \
_THUNK_GEN_INSTANTIATE_(_env, _C99_NARGS(__VA_ARGS__), __VA_ARGS__)
@@ -249,11 +303,17 @@ struct thunk_t {
#define _THUNK_GEN_DISPATCH_20(_name, _env, _t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j)\
_name(_env->_n_a, _env->_n_b, _env->_n_c, _env->_n_d, _env->_n_e, _env->_n_f, _env->_n_g, _env->_n_h, _env->_n_i, _env->_n_j)
+#define _THUNK_GEN_DISPATCH_22(_name, _env, _t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j, _t_k, _n_k)\
+ _name(_env->_n_a, _env->_n_b, _env->_n_c, _env->_n_d, _env->_n_e, _env->_n_f, _env->_n_g, _env->_n_h, _env->_n_i, _env->_n_j, _env->n_k)
+
+#define _THUNK_GEN_DISPATCH_24(_name, _env, _t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j, _t_k, _n_k, _t_l, _n_l)\
+ _name(_env->_n_a, _env->_n_b, _env->_n_c, _env->_n_d, _env->_n_e, _env->_n_f, _env->_n_g, _env->_n_h, _env->_n_i, _env->_n_j, _env->n_k, _env->n_l)
+
#define _THUNK_GEN_DISPATCH__(_name, _env, _count, ...) \
_THUNK_GEN_DISPATCH_##_count(_name, _env, __VA_ARGS__)
#define _THUNK_GEN_DISPATCH_(_name, _env, _count, ...) \
- _THUNK_GEN_DISPATCH__(_name, _env, _count, __VA_ARGS__)
+ _THUNK_GEN_DISPATCH__(_name, _env, _count, __VA_ARGS__)
#define _THUNK_GEN_DISPATCH(_name, _env, ...) \
_THUNK_GEN_DISPATCH_(_name, _env, _C99_NARGS(__VA_ARGS__), __VA_ARGS__)
@@ -294,11 +354,17 @@ struct thunk_t {
#define _THUNK_GEN_PROTO_20(_name, _t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j)\
_name(_t_a _n_a, _t_b _n_b, _t_c _n_c, _t_d _n_d, _t_e _n_e, _t_f _n_f, _t_g _n_g, _t_h _n_h, _t_i _n_i, _t_j _n_j)
+#define _THUNK_GEN_PROTO_22(_name, _t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j, _t_k, _n_k)\
+ _name(_t_a _n_a, _t_b _n_b, _t_c _n_c, _t_d _n_d, _t_e _n_e, _t_f _n_f, _t_g _n_g, _t_h _n_h, _t_i _n_i, _t_j _n_j, _t_k _n_k)
+
+#define _THUNK_GEN_PROTO_24(_name, _t_a, _n_a, _t_b, _n_b, _t_c, _n_c, _t_d, _n_d, _t_e, _n_e, _t_f, _n_f, _t_g, _n_g, _t_h, _n_h, _t_i, _n_i, _t_j, _n_j, _t_k, _n_k, _t_l, _n_l)\
+ _name(_t_a _n_a, _t_b _n_b, _t_c _n_c, _t_d _n_d, _t_e _n_e, _t_f _n_f, _t_g _n_g, _t_h _n_h, _t_i _n_i, _t_j _n_j, _t_k _n_k, _t_l _n_l)
+
#define _THUNK_GEN_PROTO__(_name, _count, ...) \
_THUNK_GEN_PROTO_##_count(_name, __VA_ARGS__)
#define _THUNK_GEN_PROTO_(_name, _count, ...) \
- _THUNK_GEN_PROTO__(_name, _count, __VA_ARGS__)
+ _THUNK_GEN_PROTO__(_name, _count, __VA_ARGS__)
#define _THUNK_GEN_PROTO(_name, ...) \
_THUNK_GEN_PROTO_(_name, _C99_NARGS(__VA_ARGS__), __VA_ARGS__)
© 2021 All Rights Reserved