From 41ac253f743e464194587c3ecc0f2547c95d924d Mon Sep 17 00:00:00 2001 From: sanine-a Date: Sat, 24 Oct 2020 21:35:14 -0500 Subject: add window module and fullscreen toggle --- src/honey_lua.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/honey_lua.c') diff --git a/src/honey_lua.c b/src/honey_lua.c index ded2a91..4dd0667 100644 --- a/src/honey_lua.c +++ b/src/honey_lua.c @@ -132,6 +132,36 @@ bool honey_lua_validate_types(lua_State* L, } break; + case HONEY_USERDATA: + if (!lua_isuserdata(L, i+1)) { + result = honey_format_string(&error_message, + "Expected userdata in position %d", + i); + if (result != HONEY_OK) + lua_pushstring(L, "Expected userdata; allocation error occurred for more detailed message."); + else { + lua_pushstring(L, error_message); + free(error_message); + } + return false; + } + break; + + case HONEY_LIGHTUSERDATA: + if (!lua_islightuserdata(L, i+1)) { + result = honey_format_string(&error_message, + "Expected C pointer in position %d", + i); + if (result != HONEY_OK) + lua_pushstring(L, "Expected C pointer; allocation error occurred for more detailed message."); + else { + lua_pushstring(L, error_message); + free(error_message); + } + return false; + } + break; + case HONEY_ANY: break; @@ -185,6 +215,19 @@ void honey_lua_push_element(lua_State* L, honey_lua_element element) element.data.table.n_elements); break; + case HONEY_NIL: + lua_pushnil(L); + break; + + case HONEY_USERDATA: + /* cannot push userdata, push nil */ + lua_pushnil(L); + break; + + case HONEY_LIGHTUSERDATA: + lua_pushlightuserdata(L, element.data.pointer); + break; + default: // this should never happen break; -- cgit v1.2.1