From dfc42106eb8a74422d04f877c2954c8e3fcbd1aa Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Mon, 10 Sep 2018 08:38:09 +0430 Subject: update --- main.py | 6 ++++-- run.sh | 2 +- test/autowasm.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 6985132..cd8abca 100755 --- a/main.py +++ b/main.py @@ -171,6 +171,7 @@ class Argparser(object): 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("--name", type=str, help="will be used to create some names in the source code") 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="inlines reader funcs", default=False) @@ -517,7 +518,7 @@ class CodeGen(object): count_int = 0 count_void = 0 void_source.write("}\n") - void_source.write("void read_aggr(int _fd) {\n") + void_source.write("void read_aggr_"+self.argparser.args.name+"(int _fd) {\n") for elem in self.read_elems: if "isaggregate" in elem.attrib: for child in elem: @@ -530,7 +531,8 @@ class CodeGen(object): def gen_aggregate_read(self): agg_source = open(self.aggregate_source, "a") agg_source_h = open(self.aggregate_source_h, "a") - agg_source_h.write("void read_aggr(int _fd);\n") + print(self.argparser.args.name) + agg_source_h.write("void read_aggr_"+self.argparser.args.name+"(int _fd);\n") agg_source.write("uint8_t eof = 0U;") for elem in self.read_elems: if "unorderedbegin" in elem.attrib: diff --git a/run.sh b/run.sh index 82d7cf0..66e117f 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,5 @@ #!/bin/sh cd $(dirname $0) #"./faultreiber.py" --targetname autowasm --outdir ./test/ --structs ./test/struct.json --datetime --structsinclude ./resources/structsinclude.h --xml ./resources/wasm.xml -"./faultreiber.py" --targetname autowasm --outdir ./test/ --structs ./test/struct.json --xml ./resources/wasm.xml +"./faultreiber.py" --targetname autowasm --outdir ./test/ --structs ./test/struct.json --xml ./resources/wasm.xml --name wasm "clang-format" -i ./test/read.c ./test/structs.c ./test/structs.h ./test/aggregate.c ./test/aggregate.h ./test/read.h diff --git a/test/autowasm.c b/test/autowasm.c index 0f81225..02b034c 100644 --- a/test/autowasm.c +++ b/test/autowasm.c @@ -12,7 +12,7 @@ #pragma weak main int main (int argc, char** argv) { int wasm = open("./test.wasm", O_RDONLY); - read_aggr(wasm); + read_aggr_wasm(wasm); printf("magic_number:%x\n", magic_number_container->magic_number); printf("version:%x\n", version_container->version); -- cgit v1.2.3