From 9ca06ce6baaa38010af869096cd498ffbf24de94 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sun, 16 Sep 2018 04:40:42 +0430 Subject: update --- luatablegen.py | 5 +++-- out/lua.c | 2 +- out/main.c | 2 +- out/makefile | 2 +- out/test.lua | 3 ++- run.sh | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/luatablegen.py b/luatablegen.py index a50fa1f..8bd3dfb 100755 --- a/luatablegen.py +++ b/luatablegen.py @@ -287,6 +287,7 @@ class Argparser(object): def __init__(self): parser = argparse.ArgumentParser() parser.add_argument("--out", type=str, help="output directory") + parser.add_argument("--name", type=str, help="will be used to generate some custom names") parser.add_argument("--tbg", type=str, help="the table gen file") parser.add_argument("--pre", type=str, help="path to source code file to add after header guard/extern c") parser.add_argument("--post", type=str, help="path to source code file to add before header guard/extern c end") @@ -842,8 +843,8 @@ class TbgParser(object): aggr_header_h.write("#include " + '"' + item + '"\n') aggr_header.write("#include " + '".' + dummy + '"\n') aggr_header.write("\n") - aggr_header.write("void reg_tablegen_tables(lua_State* __ls) {\n") - aggr_header_h.write("void reg_tablegen_tables(lua_State* __ls);\n") + aggr_header.write("void reg_tablegen_tables_"+self.argparser.args.name+"(lua_State* __ls) {\n") + aggr_header_h.write("void reg_tablegen_tables_"+self.argparser.args.name+"(lua_State* __ls);\n") for func_sig in table_reg_list: aggr_header.write("\t" + func_sig) if self.argparser.args.anon: diff --git a/out/lua.c b/out/lua.c index b204e4b..2e2da3f 100644 --- a/out/lua.c +++ b/out/lua.c @@ -578,7 +578,7 @@ int main(int argc, char **argv) { l_message(argv[0], "cannot create state: not enough memory"); return EXIT_FAILURE; } - reg_tablegen_tables(L); + reg_tablegen_tables_wasm(L); lua_pushcfunction(L, &pmain); /* to call 'pmain' in protected mode */ lua_pushinteger(L, argc); /* 1st argument */ lua_pushlightuserdata(L, argv); /* 2nd argument */ diff --git a/out/main.c b/out/main.c index be01f97..2573bad 100644 --- a/out/main.c +++ b/out/main.c @@ -9,5 +9,5 @@ int main(int argc, char **argv) { lua_State *ls = luaL_newstate(); luaL_openlibs(ls); - reg_tablegen_tables(ls); + reg_tablegen_tables_wasm(ls); } diff --git a/out/makefile b/out/makefile index 9723b0c..88a066a 100644 --- a/out/makefile +++ b/out/makefile @@ -3,7 +3,7 @@ SHELL=bash SHELL?=bash CC=clang CC?=clang -CC_FLAGS= +CC_FLAGS= -fPIC CC_EXTRA?= CTAGS_I_PATH?=./ LD_FLAGS= diff --git a/out/test.lua b/out/test.lua index 0ada3a3..8b82bea 100644 --- a/out/test.lua +++ b/out/test.lua @@ -2,9 +2,10 @@ print("Start of REPL test\n") --global_type_t = require("global_type_t") +print(type(global_type_t)) for k,v in pairs(global_type_t) do if type(v) == "function" then - print(i, v) + print(k, v) end end diff --git a/run.sh b/run.sh index 1c46b75..9ff5bab 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,7 @@ #!/usr/bin/bash cd $(dirname $0) if [[ -d ./out ]]; then :;else mkdir ./out;fi -./luatablegen.py --tbg ./test/wasmtablegen.json --out ./out --luaheader /home/bloodstalker/devi/hell2/bruiser/lua-5.3.4/src --pre ./test/wasmheader.txt --headeraggr ./out/wasm_tables.h --lualibpath ./out/wasm.lua --docpath ./out/wasm.md --xml ./test/wasm.xml --tbldefs ./out/ --anon +./luatablegen.py --tbg ./test/wasmtablegen.json --out ./out --luaheader /home/bloodstalker/devi/hell2/bruiser/lua-5.3.4/src --pre ./test/wasmheader.txt --headeraggr ./out/wasm_tables.h --lualibpath ./out/wasm.lua --docpath ./out/wasm.md --xml ./test/wasm.xml --tbldefs ./out/ --anon --name wasm clang-format ./out/*.c ./out/*.h -i for filename in ./out/*.c; do gcc -c $filename > /dev/null 2>&1 -- cgit v1.2.3