aboutsummaryrefslogtreecommitdiffstats
path: root/extra-tools
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-06-24 06:16:22 +0000
committerbloodstalker <thabogre@gmail.com>2018-06-24 06:16:22 +0000
commit045e4e775c5d0ee2e7fd489cc3c236861fa5f004 (patch)
tree17a24b4f1d29e48f7c5b6db28927700d4e3bf186 /extra-tools
parentfixes #43. the auto-gen source files by luatablegen dont look like source fil... (diff)
downloadmutator-045e4e775c5d0ee2e7fd489cc3c236861fa5f004.tar.gz
mutator-045e4e775c5d0ee2e7fd489cc3c236861fa5f004.zip
fixes 42, fixes 44
Diffstat (limited to 'extra-tools')
-rwxr-xr-xextra-tools/luatablegen.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/extra-tools/luatablegen.py b/extra-tools/luatablegen.py
index dbf7435..aca41d3 100755
--- a/extra-tools/luatablegen.py
+++ b/extra-tools/luatablegen.py
@@ -205,7 +205,7 @@ class TbgParser(object):
c_source.write(SETTER_GEN[0].replace("XXX", struct_name).replace("YYY", field_name))
c_source.write(SETTER_GEN[1].replace("XXX", struct_name))
if lua_type == "integer": dummy = "\tdummy->" + field_name + " = " + "luaL_checkinteger(__ls, 2);\n"
- elif lua_type == "lightuserdata": dummy ="\tdummy->" + field_name + " = " + "luaL_checkudata(__ls, 2, "+'"'+struct_name+'"'+");\n"
+ elif lua_type == "lightuserdata": dummy ="\tdummy->" + field_name + " = " + "luaL_checkudata(__ls, 2, "+'"'+field_name+"_t"+'"'+");\n"
elif lua_type == "number": dummy ="\tdummy->" + field_name + " = " + "luaL_checknumber(__ls, 2);\n"
elif lua_type == "string": dummy ="\tdummy->" + field_name + " = " + "luaL_checkstring(__ls, 2);\n"
elif lua_type == "boolean": pass
@@ -255,13 +255,28 @@ class TbgParser(object):
c_source.write("\n")
def docgen_md(self, d_source, struct_name, field_names, field_types, lua_types):
- d_source.write("## wasm tables method list:\n")
+ d_source.write("## " + "__" + struct_name + "__" + ":\n")
+ d_source.write("\n")
+ d_source.write("### " + "_" + "getter fields" + "_" + ":\n")
for field_name,lua_type in zip(field_names, lua_types):
d_source.write(struct_name + ":" + field_name + "()" + " -- ")
- d_source.write(lua_type + "<br/>" + "\n")
+ if lua_type == "lightuserdata":
+ d_source.write("return type: " + field_name + "_t" + "<br/>" + "\n")
+ else:
+ d_source.write("return type: " + lua_type + "<br/>" + "\n")
+ d_source.write("\n")
+ d_source.write("### " + "_" + "setter fields" + "_" + ":\n")
for field_name,lua_type in zip(field_names, lua_types):
d_source.write("set_" + struct_name + ":" + field_name + "()" + " -- ")
- d_source.write(lua_type + "<br/>" + "\n")
+ if lua_type == "lightuserdata":
+ d_source.write("arg type: " + field_name + "_t" + "<br/>" + "\n")
+ else:
+ d_source.write("arg type: " + lua_type + "<br/>" + "\n")
+ d_source.write("\n")
+ d_source.write("### " + "_" + "constructors" + "_" + ":\n")
+ d_source.write(struct_name + ":new() -- needs all the args<br/>\n")
+ d_source.write(struct_name + "() -- lazy constructor<br/>\n")
+ d_source.write("\n")
d_source.write("\n")
def luagen(self):
@@ -293,6 +308,8 @@ class TbgParser(object):
c_source = open(self.argparser.args.outfile, "w")
if self.argparser.args.docpath:
d_source = open(self.argparser.args.docpath, "w")
+ d_source.write("The lazy constructors are inside wasm.lua.\n")
+ d_source.write("```lua\nlocal wasm = require(\"wasm\")\n```\n")
for k, v in self.tbg_file.items():
struct_name = k
field_names = v['field_name']
@@ -373,6 +390,8 @@ class TbgParser(object):
m_source = open(self.argparser.args.out + "/" + "tablegen.mk", "w")
# generate lua module
self.luagen()
+ if self.argparser.args.docpath:
+ d_source.write("_automatically generated by luatablegen._<br/>\n")
# write code here
def premain(argparser):