diff options
author | bloodstalker <thabogre@gmail.com> | 2019-01-07 11:43:46 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2019-01-07 11:43:46 +0000 |
commit | d805bfd40e9e985f4ca9e0ddfe643743052fad6c (patch) | |
tree | a6b4ae6eda8939663f7d3225f8eac8b8bd818f85 | |
parent | fix (diff) | |
download | luatablegen-d805bfd40e9e985f4ca9e0ddfe643743052fad6c.tar.gz luatablegen-d805bfd40e9e985f4ca9e0ddfe643743052fad6c.zip |
update
Diffstat (limited to '')
-rwxr-xr-x | luatablegen.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/luatablegen.py b/luatablegen.py index e5d9b31..c160347 100755 --- a/luatablegen.py +++ b/luatablegen.py @@ -33,10 +33,13 @@ CHECK = ['static XXX* check_XXX(lua_State* __ls, int index) {\n', # '\tif (dummy == NULL) printf("XXX:bad user data type.\\n");\n', # '\treturn dummy;\n}\n'] PUSH_SELF = [ 'XXX* push_XXX(lua_State* __ls) {\n', - '\tlua_checkstack(__ls, 1);\n', + '\tlua_checkstack(__ls, 3);\n', '\tXXX* dummy = lua_newuserdata(__ls, sizeof(XXX));\n', '\tluaL_getmetatable(__ls, "XXX");\n', '\tlua_setmetatable(__ls, -2);\n', + '\tlua_pushlightuserdata(__ls, dummy);\n', + '\tlua_pushvalue(__ls, -2);\n', + '\tlua_settable(__ls, LUA_REGISTRYINDEX);\n', '\treturn dummy;\n}\n'] PUSH_ARGS = ['int XXX_push_args(lua_State* __ls, XXX* _st) {\n', '\tlua_checkstack(__ls, NNN);\n', '\treturn NNN;\n}\n'] @@ -737,8 +740,9 @@ class TbgParser(object): elif lua_type == "lightuserdata": if count == 1: dummy = "lua_pushlightuserdata(__ls, dummy->"+child.attrib["name"]+");\n" - dummy += 'luaL_getmetatable(__ls, "'+ref_node_type.attrib["name"]+'");\n' - dummy += "lua_setmetatable(__ls, -2);\n" + dummy += "lua_gettable(__ls, LUA_REGISTRYINDEX);\n" + #dummy += 'luaL_getmetatable(__ls, "'+ref_node_type.attrib["name"]+'");\n' + #dummy += "lua_setmetatable(__ls, -2);\n" #dummy = ref_node_type.attrib["name"]+ "_push_args(__ls, dummy->"+field_name+");\nnew_" + ref_node_type.attrib["name"] + "(__ls);\n" #FIXME else: @@ -786,8 +790,9 @@ class TbgParser(object): #push = type_node.attrib["name"]+"_push_args(__ls, dummy->"+child.attrib["name"]+");\n" #push += "new_" + type_node.attrib["name"] + "(__ls);\n" push = "lua_pushlightuserdata(__ls, dummy->"+child.attrib["name"]+");\n" - push += 'luaL_getmetatable(__ls, "'+type_node.attrib["name"]+'");\n' - push += "lua_setmetatable(__ls, -2);\n" + push += "lua_gettable(__ls, LUA_REGISTRYINDEX);\n" + #push += 'luaL_getmetatable(__ls, "'+type_node.attrib["name"]+'");\n' + #push += "lua_setmetatable(__ls, -2);\n" else: print("this was not supposed to happen...") dummy += "if (dummy->" + cond_node.attrib["name"] + " ==" + kind.text+ ") {"+push+"}\n" else: |