aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-07-04 21:24:26 +0000
committerbloodstalker <thabogre@gmail.com>2018-07-04 21:24:26 +0000
commite5ba7a8f4e4cae93da8907174edf454a35b45f47 (patch)
treef177c6541bac69ebeb37b88d6b31e955d291c117
parentupdate (diff)
downloadfaultreiber-e5ba7a8f4e4cae93da8907174edf454a35b45f47.tar.gz
faultreiber-e5ba7a8f4e4cae93da8907174edf454a35b45f47.zip
update
-rwxr-xr-xmain.py33
-rw-r--r--resources/wasm.xml41
-rwxr-xr-xrun.sh2
-rw-r--r--text.py1
4 files changed, 76 insertions, 1 deletions
diff --git a/main.py b/main.py
index 6d76678..51e1dfe 100755
--- a/main.py
+++ b/main.py
@@ -11,6 +11,7 @@ import signal
import sys
from text import text
import datetime
+import xml.etree.ElementTree
def SigHandler_SIGINT(signum, frame):
print()
@@ -27,8 +28,10 @@ class Argparser(object):
parser.add_argument("--outdir", type=str, help="path to output dir")
parser.add_argument("--structs", type=str, help="the structs json file")
parser.add_argument("--structsinclude", type=str, help="the path to the header that's going to be included by structs.h before structure declarations.")
+ parser.add_argument("--xml", type=str, help="paht to the xml file")
parser.add_argument("--dbg", action="store_true", help="debug", default=False)
parser.add_argument("--datetime", action="store_true", help="print date and time in autogen files", default=False)
+ parser.add_argument("--inline", action="store_true", help="put all reads in sequentially", default=False)
self.args = parser.parse_args()
def dupemake(path, main_name):
@@ -54,6 +57,35 @@ class CodeGen(object):
def gen_reader_funcs(self):
pass
+ def read_xml(self):
+ if self.argparser.args.xml:
+ tree = xml.etree.ElementTree.parse(self.argparser.args.xml)
+ root = tree.getroot()
+ print(root.tag)
+ print(root.attrib)
+ read_tree = xml.etree.ElementTree.Element("read")
+ def_tree = xml.etree.ElementTree.Element("def")
+ for child in root:
+ print(child.tag + "--" + repr(child.attrib))
+ if child.tag == "Read":
+ read_tree = child
+ print(type(child))
+ if child.tag == "Definition":
+ def_tree = child
+ print(type(child))
+ print(read_tree.tag)
+ print(def_tree.tag)
+ read_iter = read_tree.iter(tag=None)
+ def_iter = def_tree.iter(tag=None)
+ for child in def_iter:
+ print(child.attrib)
+ for childer in child.iter(tag=None):
+ print("\t" + childer.tag + "--" + repr(childer.attrib))
+ for child in read_iter:
+ print(child.attrib)
+ for childer in child.iter(tag=None):
+ print("\t" + childer.tag + "--" + repr(childer.attrib))
+
def gen_struct_header(self):
struct_source = open(get_full_path(self.argparser.args.outdir, "structs.h"), "w")
struct_source_c = open(get_full_path(self.argparser.args.outdir, "structs.c"), "w")
@@ -83,6 +115,7 @@ class CodeGen(object):
self.init()
self.init_hook()
self.gen_struct_header()
+ self.read_xml()
# write code here
def premain(argparser):
diff --git a/resources/wasm.xml b/resources/wasm.xml
new file mode 100644
index 0000000..f1402bb
--- /dev/null
+++ b/resources/wasm.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wasm:Structure xmlns:wasm="http://www.w3.org/2001/XMLSchema">
+ <Read>
+ <Magic_Number size="4"></Magic_Number>
+ <Version size="4"></Version>
+ <Type_Section count="1" type="" isaggregate="true"></Type_Section>
+ <Import_Section count="1" type="" isaggregate="true"></Import_Section>
+ <Function_Section count="1" type="" isaggregate="true"></Function_Section>
+ <Table_Section count="1" type="" isaggregate="true"></Table_Section>
+ <Memory_Section count="1" type="" isaggregate="true"></Memory_Section>
+ <Global_Section count="1" type="" isaggregate="true"></Global_Section>
+ <Export_Section count="1" type="" isaggregate="true"></Export_Section>
+ <Start_Section count="1" type="" isaggregate="true"></Start_Section>
+ <Element_Section count="1" type="" isaggregate="true"></Element_Section>
+ <Code_Section count="1" type="" isaggregate="true"></Code_Section>
+ <Data_Section count="1" type="" isaggregate="true"></Data_Section>
+ <Custom_Section count="1" type="" isaggregate="true"></Custom_Section>
+ </Read>
+ <Definition>
+ <Init_Expr name="init_expr_t" isaggregate="true">
+ <Size name="size" encoding="leb128u" type="varuint32" count="1"></Size>
+ <Code name="code" type="char*" coutn="1"></Code>
+ </Init_Expr>
+ <Resizable_Limit name="resizable_limit_t" isaggregate="true">
+ <Flags name="flags" encoding="leb128u" type="uint8" count="1"></Flags>
+ <Initial name="initial" encoding="leb128u" type="uint32" count="1"></Initial>
+ <Maximum name="maximum" encoding="leb128u" type="uint32" count="1"></Maximum>
+ </Resizable_Limit>
+ <Global_Type name="global_type_t" isaggregate="true">
+ <Value_Type name="value_type" type="int" count="1"></Value_Type>
+ <Mutability name="mutability" encoding="leb128u" type="uint8" count="1"></Mutability>
+ </Global_Type>
+ <Table_Type name="table_type_t" isaggregate="true">
+ <Element_Type name="element_type" encoding="leb128s" type="int8" count="1"></Element_Type>
+ <Resizable_Limit count="1"></Resizable_Limit>
+ </Table_Type>
+ <Memory_Type>
+ <Resizable_Limit count="1"></Resizable_Limit>
+ </Memory_Type>
+ </Definition>
+</wasm:Structure>
diff --git a/run.sh b/run.sh
index 4846a8e..276d2df 100755
--- a/run.sh
+++ b/run.sh
@@ -1,3 +1,3 @@
#!/bin/sh
cd $(dirname $0)
-"./faultreiber.py" --targetname autowasm --outdir ./test/ --structs ./test/struct.json --datetime --structsinclude ./resources/structsinclude.h
+"./faultreiber.py" --targetname autowasm --outdir ./test/ --structs ./test/struct.json --datetime --structsinclude ./resources/structsinclude.h --xml ./resources/wasm.xml
diff --git a/text.py b/text.py
index d71e78b..52a84b1 100644
--- a/text.py
+++ b/text.py
@@ -14,3 +14,4 @@ class text():
pragma_endif = "#endif\n"
autogen_warning = "// this file has been automatically generated by faultreiber\n"
last_comment = "// last line intentionally left blank\n\n"
+ read_func_sig = "int read_structured_file(char* path)"