diff options
-rwxr-xr-x | luatablegen.py | 15 | ||||
-rw-r--r-- | out/main.c | 13 | ||||
-rw-r--r-- | out/makefile | 14 |
3 files changed, 24 insertions, 18 deletions
diff --git a/luatablegen.py b/luatablegen.py index 02b15f2..bae7435 100755 --- a/luatablegen.py +++ b/luatablegen.py @@ -80,7 +80,8 @@ int pushluatable_YYY(lua_State* ls, XXX array) { i++; } return 0; -}""" +} +""" LUA_PUSH_TABLE_SIG = "int pushluatable_YYY(lua_State* ls, XXX array);\n" LUA_PUSH_TABLE_CALL = "pushluatable_YYY(lua_State* ls, WWW, XXX array);\n" @@ -295,7 +296,8 @@ class TbgParser(object): def gen_luato_generic(self, struct_name, field_name, arg_pos): parent = get_def_node(struct_name, self.elems) child = get_def_node(field_name, self.elems) - return LUA_TO_GENERIC.replace("YYY", struct_name + "_" + field_name).replace("ZZZ", repr(arg_pos)) + #return LUA_TO_GENERIC.replace("YYY", struct_name + "_" + field_name).replace("ZZZ", repr(arg_pos)) + return "check_" + struct_name + "(__ls," + repr(arg_pos) + ");\n" def struct(self, c_source, field_names, field_types, struct_name): c_source.write("typedef struct {\n") @@ -593,8 +595,9 @@ class TbgParser(object): count_replacement = "" type_name = type_resolver(node, self.def_elems+self.read_elems) type_ref_node = get_def_node(type_name, self.def_elems+self.read_elems) - if type_ref_node and node.tag not in tbl_tag_list: - tbl_tag_list.append(node.tag) + if type_ref_node and type_ref_node.tag not in tbl_tag_list: + tbl_tag_list.append(type_ref_node.tag) + print(type_ref_node.tag) count = get_elem_count(node) pointer = "" if count == -1: @@ -602,7 +605,7 @@ class TbgParser(object): if node2.tag == node.attrib["count"][6:]: count_replacement = node2.attrib["name"] if count == 1: - pointer = "" + pointer = "*" else: pointer += "*" yyy = node.attrib["name"] @@ -613,7 +616,7 @@ class TbgParser(object): else: xxx = node.attrib["name"] zzz = "lua_push" + node.attrib["luatype"] - if pointer == "*": continue + #if pointer == "*": continue tbl_source.write(LUA_PUSH_TABLE.replace("XXX", xxx+pointer).replace("YYY", xxx).replace("WWW", xxx)) tbl_header.write(LUA_PUSH_TABLE_SIG.replace("XXX", xxx+pointer).replace("YYY", xxx)) #end of tadldef @@ -1,10 +1,13 @@ +#include "../lua5/lauxlib.h" +#include "../lua5/lua.h" +#include "../lua5/lualib.h" #include "./wasm_tables.h" -#include <stdio.h> #include <inttypes.h> -#include "/home/bloodstalker/devi/hell2/bruiser/lua-5.3.4/src/lauxlib.h" -#include "/home/bloodstalker/devi/hell2/bruiser/lua-5.3.4/src/lua.h" -#include "/home/bloodstalker/devi/hell2/bruiser/lua-5.3.4/src/lualib.h" +#include <stdio.h> #pragma weak main -int main (int argc, char** argv) { +int main(int argc, char **argv) { + lua_State *ls = luaL_newstate(); + luaL_openlibs(ls); + reg_tablegen_tables(ls); } diff --git a/out/makefile b/out/makefile index f3a0757..86b90b3 100644 --- a/out/makefile +++ b/out/makefile @@ -8,7 +8,7 @@ CC_EXTRA?= CTAGS_I_PATH?=./ LD_FLAGS= LIB_LUA=../lua5/liblua.a -EXTRA_LD_FLAGS?=-L ../lua5 +EXTRA_LD_FLAGS?=-lm -ldl -llua ADD_SANITIZERS_CC= -g -fsanitize=address -fno-omit-frame-pointer ADD_SANITIZERS_LD= -g -fsanitize=address MEM_SANITIZERS_CC= -g -fsanitize=memory -fno-omit-frame-pointer @@ -80,16 +80,16 @@ depend:.depend $(LIB_LUA): $(MAKE) -C ../lua5 a -$(TARGET): $(TARGET).o $(LIB_LUA) +$(TARGET): $(TARGET).o $(LIB_LUA) $(OBJ_LIST) $(CC) $^ $(LD_FLAGS) -o $@ -$(TARGET)-static: $(TARGET).o $(LIB_LUA) +$(TARGET)-static: $(TARGET).o $(LIB_LUA) $(OBJ_LIST) $(CC) $^ $(LD_FLAGS) -static -o $@ -$(TARGET)-dbg: $(TARGET).odbg $(LIB_LUA) +$(TARGET)-dbg: $(TARGET).odbg $(LIB_LUA) $(OBJ_LIST) $(CC) $^ $(LD_FLAGS) -g -o $@ -$(TARGET)-cov: $(TARGET).ocov $(LIB_LUA) +$(TARGET)-cov: $(TARGET).ocov $(LIB_LUA) $(OBJ_LIST) $(CC) $^ $(LD_FLAGS) $(COV_LD) -o $@ cov: @@ -116,10 +116,10 @@ tags:$(SRCS) %.dis: %.o objdump -r -d -M intel -S $< > $@ -$(TARGET).so: $(TARGET).o $(LIB_LUA) +$(TARGET).so: $(TARGET).o $(LIB_LUA) $(OBJ_LIST) $(CC) $^ $(LD_FLAGS) -shared -o $@ -$(TARGET).a: $(TARGET).o $(LIB_LUA) +$(TARGET).a: $(TARGET).o $(LIB_LUA) $(OBJ_LIST) ar rcs $(TARGET).a $(TARGET).o runcov: $(TARGET)-cov |