qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 4/7] scripts: add coroutine-wrapper.py


From: Paolo Bonzini
Subject: Re: [PATCH v7 4/7] scripts: add coroutine-wrapper.py
Date: Thu, 20 Aug 2020 09:38:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]