diff options
author | Anthony Liguori <aliguori@amazon.com> | 2013-10-11 09:29:58 -0700 |
---|---|---|
committer | Anthony Liguori <aliguori@amazon.com> | 2013-10-11 09:29:58 -0700 |
commit | 33c6cae44eccea5e627c2dc5cbf31456db90fc38 (patch) | |
tree | 26f994c9f78144b2a6f12da686a2235d0df1dd21 /scripts | |
parent | 39c153b80f890dc5f02465dc59992e195abd5f40 (diff) | |
parent | 34eeb82de65ce9f83081a3357b0afe80a6a1d86a (diff) |
Merge remote-tracking branch 'kwolf/for-anthony' into staging
# By Max Reitz (30) and others
# Via Kevin Wolf
* kwolf/for-anthony: (61 commits)
qemu-iotests: Add test for inactive L2 overlap
qemu-io: Let "open" pass options to block driver
vmdk: Fix vmdk_parse_extents
blockdev: blockdev_init() error conversion
blockdev: Don't disable COR automatically with blockdev-add
blockdev: Remove 'media' parameter from blockdev_init()
qemu-iotests: Check autodel behaviour for device_del
blockdev: Remove IF_* check for read-only blockdev_init
blockdev: Move virtio-blk device creation to drive_init
blockdev: Move bus/unit/index processing to drive_init
blockdev: Move parsing of 'boot' option to drive_init
blockdev: Moving parsing of geometry options to drive_init
blockdev: Move parsing of 'if' option to drive_init
blockdev: Move parsing of 'media' option to drive_init
blockdev: Pass QDict to blockdev_init()
blockdev: Separate ID generation from DriveInfo creation
blockdev: 'blockdev-add' QMP command
blockdev: Introduce DriveInfo.enable_auto_del
qapi-types/visit.py: Inheritance for structs
qapi-types/visit.py: Pass whole expr dict for structs
...
Message-id: 1381503951-27985-1-git-send-email-kwolf@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi-types.py | 15 | ||||
-rw-r--r-- | scripts/qapi-visit.py | 26 |
2 files changed, 34 insertions, 7 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 5222463893..4a1652b56f 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -71,7 +71,7 @@ def generate_struct_fields(members): c_name=c_var(argname)) if structured: push_indent() - ret += generate_struct("", argname, argentry) + ret += generate_struct({ "field": argname, "data": argentry}) pop_indent() else: ret += mcgen(''' @@ -81,13 +81,22 @@ def generate_struct_fields(members): return ret -def generate_struct(structname, fieldname, members): +def generate_struct(expr): + + structname = expr.get('type', "") + fieldname = expr.get('field', "") + members = expr['data'] + base = expr.get('base') + ret = mcgen(''' struct %(name)s { ''', name=structname) + if base: + ret += generate_struct_fields({'base': base}) + ret += generate_struct_fields(members) if len(fieldname): @@ -417,7 +426,7 @@ if do_builtins: for expr in exprs: ret = "\n" if expr.has_key('type'): - ret += generate_struct(expr['type'], "", expr['data']) + "\n" + ret += generate_struct(expr) + "\n" ret += generate_type_cleanup_decl(expr['type'] + "List") fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n") ret += generate_type_cleanup_decl(expr['type']) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 597cca4b66..c39e6284b8 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -17,7 +17,7 @@ import os import getopt import errno -def generate_visit_struct_fields(name, field_prefix, fn_prefix, members): +def generate_visit_struct_fields(name, field_prefix, fn_prefix, members, base = None): substructs = [] ret = '' full_name = name if not fn_prefix else "%s_%s" % (name, fn_prefix) @@ -42,6 +42,19 @@ static void visit_type_%(full_name)s_fields(Visitor *m, %(name)s ** obj, Error * name=name, full_name=full_name) push_indent() + if base: + ret += mcgen(''' +visit_start_implicit_struct(m, obj ? (void**) &(*obj)->%(c_name)s : NULL, sizeof(%(type)s), &err); +if (!err) { + visit_type_%(type)s_fields(m, obj ? &(*obj)->%(c_prefix)s%(c_name)s : NULL, &err); + error_propagate(errp, err); + err = NULL; + visit_end_implicit_struct(m, &err); +} +''', + c_prefix=c_var(field_prefix), + type=type_name(base), c_name=c_var('base')) + for argname, argentry, optional, structured in parse_args(members): if optional: ret += mcgen(''' @@ -120,8 +133,13 @@ if (!err) { ''') return ret -def generate_visit_struct(name, members): - ret = generate_visit_struct_fields(name, "", "", members) +def generate_visit_struct(expr): + + name = expr['type'] + members = expr['data'] + base = expr.get('base') + + ret = generate_visit_struct_fields(name, "", "", members, base) ret += mcgen(''' @@ -472,7 +490,7 @@ if do_builtins: for expr in exprs: if expr.has_key('type'): - ret = generate_visit_struct(expr['type'], expr['data']) + ret = generate_visit_struct(expr) ret += generate_visit_list(expr['type'], expr['data']) fdef.write(ret) |