diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/honeysuckle.h | 180 |
1 files changed, 178 insertions, 2 deletions
diff --git a/src/honeysuckle.h b/src/honeysuckle.h index 584c4bd..db26562 100644 --- a/src/honeysuckle.h +++ b/src/honeysuckle.h @@ -10,7 +10,7 @@ #include "va_nargs.h" /* type constants */ -typedef enum +typedef enum { HS_BOOL, HS_INT, HS_NUM, @@ -62,7 +62,7 @@ void hs_parse_args_(lua_State *L, int n_args, struct hs_arg *arguments); #define hs_parse_args(L, ...) \ hs_parse_args_(L, VA_NARGS(__VA_ARGS__)/2, (struct hs_arg[]) { __VA_ARGS__ }) - + #define hs_overload(...) VA_NARGS(__VA_ARGS__)/2, (struct hs_arg[]) { __VA_ARGS__ } @@ -78,6 +78,182 @@ int hs_parse_overloaded_(lua_State *L, ...); * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +struct hs_tbl_entry { + hs_type key_type; + union { + bool boolean; + lua_Integer integer; + lua_Number number; + char *string; + int stack_index; + lua_CFunction function; + void *userdata; + } key; + hs_type value_type; + union { + bool boolean; + lua_Integer integer; + lua_Number number; + char *string; + int stack_index; + lua_CFunction function; + void *userdata; + } value; +} + +#define hs_bool_bool(key, value) \ + { HS_BOOL, .key.boolean=key, HS_BOOL, .value.boolean=value } +#define hs_bool_int(key, value) \ + { HS_BOOL, .key.boolean=key, HS_INT, .value.integer=value } +#define hs_bool_num(key, value) \ + { HS_BOOL, .key.boolean=key, HS_NUM, .value.number=value } +#define hs_bool_str(key, value) \ + { HS_BOOL, .key.boolean=key, HS_STR, .value.string=value } +#define hs_bool_tbl(key, value) \ + { HS_BOOL, .key.boolean=key, HS_TBL, .value.stack_index=value } +#define hs_bool_func(key, value) \ + { HS_BOOL, .key.boolean=key, HS_FUNC, .value.stack_index=value } +#define hs_bool_cfunc(key, value) \ + { HS_BOOL, .key.boolean=key, HS_CFUNC, .value.function=value } +#define hs_bool_user(key, value) \ + { HS_BOOL, .key.boolean=key, HS_USER, .value.stack_index=value } +#define hs_bool_light(key, value) \ + { HS_BOOL, .key.boolean=key, HS_LIGHT, .value.userdata=value } + +#define hs_int_bool(key, value) \ + { HS_INT, .key.integer=key, HS_BOOL, .value.boolean=value } +#define hs_int_int(key, value) \ + { HS_INT, .key.integer=key, HS_INT, .value.integer=value } +#define hs_int_num(key, value) \ + { HS_INT, .key.integer=key, HS_NUM, .value.number=value } +#define hs_int_str(key, value) \ + { HS_INT, .key.integer=key, HS_STR, .value.string=value } +#define hs_int_tbl(key, value) \ + { HS_INT, .key.integer=key, HS_TBL, .value.stack_index=value } +#define hs_int_func(key, value) \ + { HS_INT, .key.integer=key, HS_FUNC, .value.stack_index=value } +#define hs_int_cfunc(key, value) \ + { HS_INT, .key.integer=key, HS_CFUNC, .value.function=value } +#define hs_int_user(key, value) \ + { HS_INT, .key.integer=key, HS_USER, .value.stack_index=value } +#define hs_int_light(key, value) \ + { HS_INT, .key.integer=key, HS_LIGHT, .value.userdata=value } + +#define hs_num_bool(key, value) \ + { HS_NUM, .key.number=key, HS_BOOL, .value.boolean=value } +#define hs_num_int(key, value) \ + { HS_NUM, .key.number=key, HS_INT, .value.integer=value } +#define hs_num_num(key, value) \ + { HS_NUM, .key.number=key, HS_NUM, .value.number=value } +#define hs_num_str(key, value) \ + { HS_NUM, .key.number=key, HS_STR, .value.string=value } +#define hs_num_tbl(key, value) \ + { HS_NUM, .key.number=key, HS_TBL, .value.stack_index=value } +#define hs_num_func(key, value) \ + { HS_NUM, .key.number=key, HS_FUNC, .value.stack_index=value } +#define hs_num_cfunc(key, value) \ + { HS_NUM, .key.number=key, HS_CFUNC, .value.function=value } +#define hs_num_user(key, value) \ + { HS_NUM, .key.number=key, HS_USER, .value.stack_index=value } +#define hs_num_light(key, value) \ + { HS_NUM, .key.number=key, HS_LIGHT, .value.userdata=value } + +#define hs_tbl_bool(key, value) \ + { HS_TBL, .key.stack_index=key, HS_BOOL, .value.boolean=value } +#define hs_tbl_int(key, value) \ + { HS_TBL, .key.stack_index=key, HS_INT, .value.integer=value } +#define hs_tbl_num(key, value) \ + { HS_TBL, .key.stack_index=key, HS_NUM, .value.number=value } +#define hs_tbl_str(key, value) \ + { HS_TBL, .key.stack_index=key, HS_STR, .value.string=value } +#define hs_tbl_tbl(key, value) \ + { HS_TBL, .key.stack_index=key, HS_TBL, .value.stack_index=value } +#define hs_tbl_func(key, value) \ + { HS_TBL, .key.stack_index=key, HS_FUNC, .value.stack_index=value } +#define hs_tbl_cfunc(key, value) \ + { HS_TBL, .key.stack_index=key, HS_CFUNC, .value.function=value } +#define hs_tbl_user(key, value) \ + { HS_TBL, .key.stack_index=key, HS_USER, .value.stack_index=value } +#define hs_tbl_light(key, value) \ + { HS_TBL, .key.stack_index=key, HS_LIGHT, .value.userdata=value } + +#define hs_func_bool(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_BOOL, .value.boolean=value } +#define hs_func_int(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_INT, .value.integer=value } +#define hs_func_num(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_NUM, .value.number=value } +#define hs_func_str(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_STR, .value.string=value } +#define hs_func_tbl(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_TBL, .value.stack_index=value } +#define hs_func_func(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_FUNC, .value.stack_index=value } +#define hs_func_cfunc(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_CFUNC, .value.function=value } +#define hs_func_user(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_USER, .value.stack_index=value } +#define hs_func_light(key, value) \ + { HS_FUNC, .key.stack_index=key, HS_LIGHT, .value.userdata=value } + +#define hs_cfunc_bool(key, value) \ + { HS_CFUNC, .key.function=key, HS_BOOL, .value.boolean=value } +#define hs_cfunc_int(key, value) \ + { HS_CFUNC, .key.function=key, HS_INT, .value.integer=value } +#define hs_cfunc_num(key, value) \ + { HS_CFUNC, .key.function=key, HS_NUM, .value.number=value } +#define hs_cfunc_str(key, value) \ + { HS_CFUNC, .key.function=key, HS_STR, .value.string=value } +#define hs_cfunc_tbl(key, value) \ + { HS_CFUNC, .key.function=key, HS_TBL, .value.stack_index=value } +#define hs_cfunc_func(key, value) \ + { HS_CFUNC, .key.function=key, HS_FUNC, .value.stack_index=value } +#define hs_cfunc_cfunc(key, value) \ + { HS_CFUNC, .key.function=key, HS_CFUNC, .value.function=value } +#define hs_cfunc_user(key, value) \ + { HS_CFUNC, .key.function=key, HS_USER, .value.stack_index=value } +#define hs_cfunc_light(key, value) \ + { HS_CFUNC, .key.function=key, HS_LIGHT, .value.userdata=value } + +#define hs_user_bool(key, value) \ + { HS_USER, .key.stack_index=key, HS_BOOL, .value.boolean=value } +#define hs_user_int(key, value) \ + { HS_USER, .key.stack_index=key, HS_INT, .value.integer=value } +#define hs_user_num(key, value) \ + { HS_USER, .key.stack_index=key, HS_NUM, .value.number=value } +#define hs_user_str(key, value) \ + { HS_USER, .key.stack_index=key, HS_STR, .value.string=value } +#define hs_user_tbl(key, value) \ + { HS_USER, .key.stack_index=key, HS_TBL, .value.stack_index=value } +#define hs_user_func(key, value) \ + { HS_USER, .key.stack_index=key, HS_FUNC, .value.stack_index=value } +#define hs_user_cfunc(key, value) \ + { HS_USER, .key.stack_index=key, HS_CFUNC, .value.function=value } +#define hs_user_user(key, value) \ + { HS_USER, .key.stack_index=key, HS_USER, .value.stack_index=value } +#define hs_user_light(key, value) \ + { HS_USER, .key.stack_index=key, HS_LIGHT, .value.userdata=value } + +#define hs_light_bool(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_BOOL, .value.boolean=value } +#define hs_light_int(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_INT, .value.integer=value } +#define hs_light_num(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_NUM, .value.number=value } +#define hs_light_str(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_STR, .value.string=value } +#define hs_light_tbl(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_TBL, .value.stack_index=value } +#define hs_light_func(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_FUNC, .value.stack_index=value } +#define hs_light_cfunc(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_CFUNC, .value.function=value } +#define hs_light_user(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_USER, .value.stack_index=value } +#define hs_light_light(key, value) \ + { HS_LIGHT, .key.userdata=key, HS_LIGHT, .value.userdata=value } + + int hs_create_table(lua_State *L, ...); void hs_process_table(lua_State *L, int table_index, void *data, ...); |