On 10/06/20 12:03, Vladimir Sementsov-Ogievskiy wrote:
> + {struct_name} s = {{
> + .poll_state.bs = {bs},
> + .poll_state.in_progress = true,
> +
> +{ func.gen_block(' .{name} = {name},') }
> + }};
> +
> + s.poll_state.co = qemu_coroutine_create({name}_entry, &s);
> +
> + return bdrv_poll_co(&s.poll_state);
> + }}
> +}}"""
> +
> +
> +def gen_wrappers_file(input_code: str) -> str:
> + res = gen_header()
> + for func in func_decl_iter(input_code):
> + res += '\n\n\n'
> + res += gen_wrapper(func)
> +
> + return prettify(res) # prettify to wrap long lines
> +
> +
> +if __name__ == '__main__':
> + print(gen_wrappers_file(sys.stdin.read()))
> --
For Meson support, you'll have to move the "cat" inside the script. But
since func_decl_iter can work separately on each file, it's enough to do
something like
for filename in sys.argv:
with open(filename, 'r') as f:
print(gen_wrappers_file(f.read()))
Paolo