mirror of https://gitee.com/openkylin/qemu.git
qapi-visit.py: Split off generate_visit_struct_fields()
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
e2503f5e21
commit
d131c897f3
|
@ -17,34 +17,9 @@
|
|||
import getopt
|
||||
import errno
|
||||
|
||||
def generate_visit_struct_body(field_prefix, name, members):
|
||||
ret = mcgen('''
|
||||
if (!error_is_set(errp)) {
|
||||
''')
|
||||
push_indent()
|
||||
def generate_visit_struct_fields(field_prefix, members):
|
||||
ret = ''
|
||||
|
||||
if len(field_prefix):
|
||||
field_prefix = field_prefix + "."
|
||||
ret += mcgen('''
|
||||
Error **errp = &err; /* from outer scope */
|
||||
Error *err = NULL;
|
||||
visit_start_struct(m, NULL, "", "%(name)s", 0, &err);
|
||||
''',
|
||||
name=name)
|
||||
else:
|
||||
ret += mcgen('''
|
||||
Error *err = NULL;
|
||||
visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
|
||||
''',
|
||||
name=name)
|
||||
|
||||
ret += mcgen('''
|
||||
if (!err) {
|
||||
if (!obj || *obj) {
|
||||
''')
|
||||
|
||||
push_indent()
|
||||
push_indent()
|
||||
for argname, argentry, optional, structured in parse_args(members):
|
||||
if optional:
|
||||
ret += mcgen('''
|
||||
|
@ -72,9 +47,40 @@ def generate_visit_struct_body(field_prefix, name, members):
|
|||
visit_end_optional(m, &err);
|
||||
''')
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def generate_visit_struct_body(field_prefix, name, members):
|
||||
ret = mcgen('''
|
||||
if (!error_is_set(errp)) {
|
||||
''')
|
||||
push_indent()
|
||||
|
||||
if len(field_prefix):
|
||||
field_prefix = field_prefix + "."
|
||||
ret += mcgen('''
|
||||
Error **errp = &err; /* from outer scope */
|
||||
Error *err = NULL;
|
||||
visit_start_struct(m, NULL, "", "%(name)s", 0, &err);
|
||||
''',
|
||||
name=name)
|
||||
else:
|
||||
ret += mcgen('''
|
||||
Error *err = NULL;
|
||||
visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
|
||||
''',
|
||||
name=name)
|
||||
|
||||
ret += mcgen('''
|
||||
if (!err) {
|
||||
if (!obj || *obj) {
|
||||
''')
|
||||
push_indent()
|
||||
push_indent()
|
||||
|
||||
ret += generate_visit_struct_fields(field_prefix, members)
|
||||
pop_indent()
|
||||
ret += mcgen('''
|
||||
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue