From 4d586e42f94a8a93368f311edaec8d81d46f7055 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Thu, 20 Sep 2018 16:44:40 +0430 Subject: update --- luatablegen.py | 17 +++++- run.sh | 2 +- test/luwasm.xml | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 test/luwasm.xml diff --git a/luatablegen.py b/luatablegen.py index 93d92d3..a1531f2 100755 --- a/luatablegen.py +++ b/luatablegen.py @@ -533,7 +533,7 @@ class TbgParser(object): count_node = get_count_node(child, parent) #print("parent:" + parent.attrib["name"]) #print("child:" + child.attrib["name"]) - if count_node != None: print("count node:" + count_node.attrib["name"]) + #if count_node != None: print("count node:" + count_node.attrib["name"]) if count_node != None: count_node_name = count_node.attrib["name"] if count == 1: dummy = "\tpush_" + type_resolver(child, self.elems) +"(__ls, _st->"+field_name+");\n" @@ -579,7 +579,20 @@ class TbgParser(object): for kid in parent: if kid.attrib["name"] == field_name: child = kid if lua_type == "integer": dummy = "\t"+simple_type_resovler(field_type) +" "+field_name+" = "+"luaL_optinteger(__ls,"+repr(rev_counter)+",0);\n" - elif lua_type == "lightuserdata": dummy = "\t"+field_type +" "+field_name+" = "+"lua_touserdata(__ls,"+repr(rev_counter)+");\n" + elif lua_type == "lightuserdata": + if field_type.find("self::") == 0: + parent_node = get_def_node(struct_name, self.elems) + self_node = get_def_node(field_name, parent_node) + count = get_elem_count(self_node) + ptr = "" + if count != 1: ptr = "*" + child_node = get_def_node_tag(field_type[6:], self.elems) + print("parent node:" + parent_node.attrib["name"]) + print("field type:" + field_type[6:]) + if child_node != None: print("child_node:" + child_node.attrib["name"]) + dummy = "\t"+child_node.attrib["name"] + ptr +"* "+field_name+" = "+"lua_touserdata(__ls,"+repr(rev_counter)+");\n" + else: + dummy = "\t"+field_type +" "+field_name+" = "+"lua_touserdata(__ls,"+repr(rev_counter)+");\n" elif lua_type == "number": pass elif lua_type == "string":dummy = "\t"+simple_type_resovler(field_type) +" "+field_name+" = "+"lua_tostring(__ls,"+repr(rev_counter)+");\n" elif lua_type == "boolean": pass diff --git a/run.sh b/run.sh index 9ff5bab..7dcc5a1 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 --name wasm +./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/luwasm.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 diff --git a/test/luwasm.xml b/test/luwasm.xml new file mode 100644 index 0000000..3e10a40 --- /dev/null +++ b/test/luwasm.xml @@ -0,0 +1,174 @@ + + + + + + + 1 + + + + + + + + 2 + + + + + + + + 3 + + + + + + + + 4 + + + + + + + + 5 + + + + + + + + 6 + + + + + + + + 7 + + + + + + + + 8 + + + + + + + 9 + + + + + + + + 10 + + + + + + + + 11 + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + 0 + 1 + 2 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3