From 140666204191b218b72274d8d14921c89a6631fd Mon Sep 17 00:00:00 2001 From: sanine-a Date: Sun, 29 Nov 2020 15:16:42 -0600 Subject: refactor: eliminate src subdirectories for honey files --- src/honey_lua.c | 273 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 199 insertions(+), 74 deletions(-) (limited to 'src/honey_lua.c') diff --git a/src/honey_lua.c b/src/honey_lua.c index 7730809..2469d37 100644 --- a/src/honey_lua.c +++ b/src/honey_lua.c @@ -2,14 +2,31 @@ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * Lua binding helper function definitions + * Helper structs + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +struct argument_pair { + honey_lua_type type; + void* ptr; +}; + +struct argument_list { + unsigned int length; + struct argument_pair* args; +}; + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Lua binding helper function declarations * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* string must be able to hold at least 16 characters. */ -static void type_to_string(char* string, - honey_lua_type type); +static int type_to_string(char* string, + honey_lua_type type); static bool check_argument(lua_State* L, honey_lua_type type, @@ -111,90 +128,198 @@ static void honey_lua_arg_error(lua_State* L, /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -int honey_lua_parse_arguments(lua_State* L, int n, ...) +static bool check_arg_list(lua_State* L, + struct argument_list arg_list) { - va_list args; - va_start(args, n); + struct argument_pair* args = arg_list.args; + for (int i=0; i