#include #include "honeysuckle.h" static bool check_parse(lua_State *L, int index, struct hs_arg *expected) { switch(expected->type) { case HS_BOOL: if (!lua_isboolean(L, index)) return false; *(expected->ptr.boolean) = lua_toboolean(L, index); return true; case HS_INT: if (!lua_isnumber(L, index)) return false; *(expected->ptr.integer) = lua_tointeger(L, index); return true; case HS_NUM: if (!lua_isnumber(L, index)) return false; *(expected->ptr.number) = lua_tonumber(L, index); return true; case HS_STR: if (!lua_isstring(L, index)) return false; *(expected->ptr.string) = (char *) lua_tostring(L, index); return true; case HS_TBL: if (!lua_istable(L, index)) return false; *(expected->ptr.stack_index) = index; return true; case HS_FUNC: if (!lua_isfunction(L, index)) return false; *(expected->ptr.stack_index) = index; return true; case HS_CFUNC: if (!lua_iscfunction(L, index)) return false; *(expected->ptr.function) = lua_tocfunction(L, index); return true; case HS_USER: if (!lua_isuserdata(L, index)) return false; *(expected->ptr.userdata) = lua_touserdata(L, index); return true; case HS_LIGHT: if (!lua_islightuserdata(L, index)) return false; *(expected->ptr.userdata) = lua_touserdata(L, index); return true; case HS_NIL: if (!lua_isnil(L, index)) return false; *(expected->ptr.stack_index) = index; case HS_ANY: *(expected->ptr.stack_index) = index; return true; default: return false; } } static bool try_parse_args(lua_State *L, int n_args, struct hs_arg *arguments) { int args_provided = lua_gettop(L); if (args_provided != n_args) return false; for (int i=0; i