Mercurial > hg > CbC > old > CbC_scripts
changeset 25:9a1cce532f29
fix meta connection bugs
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 01 Nov 2015 18:00:20 +0900 |
parents | 569b28c699d9 |
children | b9f88346cecd |
files | meta_connector/meta_connector.py |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/meta_connector/meta_connector.py Sun Nov 01 04:33:51 2015 +0900 +++ b/meta_connector/meta_connector.py Sun Nov 01 18:00:20 2015 +0900 @@ -10,7 +10,7 @@ parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description="""\ -Parse meta connect syntax. Default output is stdout. +Parse meta connect syntax and create stub. Default output is stdout. sample) __code code0(struct Data data1, ...){ @@ -64,11 +64,12 @@ if callee_name == 'start_code' or re.match('meta_|meta$',callee_name): file.write(l) elif re.search(r"\(context", l) is None: - file.write("/*-- connected by script */\n") - file.write('// '+l) - meta_name = 'meta_'+caller_name if cs_search(lines, 'meta_'+callee_name) else 'meta' - file.write("goto {0:s}(context{1:s}, {2:s});\n".format(meta_name, args,\ - callee_name.capitalize())) + connect_meta(file, lines, l, caller_name, callee_name) + # file.write("/*-- connected by script */\n") + # file.write('// '+l) + # meta_name = 'meta_'+caller_name if cs_search(lines, 'meta_'+callee_name) else 'meta' + # file.write("goto {0:s}(context{1:s}, {2:s});\n".format(meta_name, args,\ + # callee_name.capitalize())) else: file.write(l) else: @@ -96,13 +97,23 @@ file.write(', &context->data['+arg.capitalize()+']->'+arg) file.write(');\n}\n') +def connect_meta(file, lines, l, caller_name, callee_name): + meta_name = 'meta_'+caller_name if cs_search(lines, 'meta_'+callee_name) else 'meta' + args = get_args_from_line(l) + file.write("/*-- connected by script */\n") + file.write('// '+l) + file.write("goto {0:s}(context".format(meta_name)) + for arg in args_str2args_list(args): + file.write(', '+arg) + file.write(', '+callee_name.capitalize()+');\n') + def args_str2args_list(args_str): args_list = [] temporary_list = args_str.split() for i,arg in enumerate(temporary_list): if re.search(r"context,*", arg) is not None: continue - if arg.endswith(',') or i == len(temporary_list)-1: + if re.search(r"[a-zA-Z0-9_] *,$", arg) is not None or i == len(temporary_list)-1: args_list.append(arg.strip(',')) return args_list