From efae8398853d1494a17351f855e261867922ba44 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Mon, 4 Jun 2018 04:43:03 +0430 Subject: fixes #40 --- bruiser/wasm.c | 15 ++++++++++++++- bruiser/wasm.h | 20 ++++++++++---------- bruiser/wasm.sh | 4 ++-- 3 files changed, 26 insertions(+), 13 deletions(-) (limited to 'bruiser') diff --git a/bruiser/wasm.c b/bruiser/wasm.c index ac5143c..c517269 100644 --- a/bruiser/wasm.c +++ b/bruiser/wasm.c @@ -21,8 +21,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.* #include "./lua-5.3.4/src/lua.h" #include "./lua-5.3.4/src/lauxlib.h" #include "./lua-5.3.4/src/lualib.h" -#include "wasm.h" +#include "./wasm.h" /**********************************************************************************************************************/ +static Wasm_Module* convert_wasm_module(lua_State* ls, int index) { + Wasm_Module* dummy = lua_touserdata(ls, index); + if (dummy == NULL) {printf("convert_wasm_module: bad userdata.\n");} + return dummy; +} + +static Wasm_Module* check_wasm_module(lua_State* ls, int index) { + Wasm_Module* dummy; + luaL_checktype(ls, index, LUA_TUSERDATA); + dummy = (Wasm_Module*)luaL_checkudata(ls, index, "wasm_module"); + if (dummy == NULL) {printf("check_wasm_module: bad userdata.\n");} + return dummy; +} #pragma weak main int main(int argc, char** argv) { diff --git a/bruiser/wasm.h b/bruiser/wasm.h index af02a20..ec68553 100644 --- a/bruiser/wasm.h +++ b/bruiser/wasm.h @@ -192,16 +192,16 @@ typedef int32_t varuint32; #endif typedef struct Wasm_Module { - W_Import_Section import_section; - W_Function_Section function_section; - W_Table_Section table_section; - W_Memory_Section memory_section; - W_Global_Section global_section; - W_Export_Section export_section; - W_Start_Section start_section; - W_Element_Section element_section; - W_Code_Section code_section; - W_Data_Section data_section; + W_Import_Section* import_section; + W_Function_Section* function_section; + W_Table_Section* table_section; + W_Memory_Section* memory_section; + W_Global_Section* global_section; + W_Export_Section* export_section; + W_Start_Section* start_section; + W_Element_Section* element_section; + W_Code_Section* code_section; + W_Data_Section* data_section; void** W_Custom_Sections; char* name; }Wasm_Module; diff --git a/bruiser/wasm.sh b/bruiser/wasm.sh index d8d4990..4863b9b 100755 --- a/bruiser/wasm.sh +++ b/bruiser/wasm.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -gcc wasm.c -o wasme -./wasme +gcc wasm.c -o wasme -L ./lua-5.3.4/src/ -llua -lm -ldl +./wasme || exit $? rm ./wasme -- cgit v1.2.3