aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2012-09-10 15:04:36 +0200
committerAurelien Jarno <aurelien@aurel32.net>2012-09-10 15:04:36 +0200
commite22b1e9907833d72f4a959b34c5eefc3533c7711 (patch)
tree662cf685e04726bb68d8eeee94a06d694f35f95a /scripts
parenta32354e206895400d17c3de9a8df1de96d3df289 (diff)
parent0ab6b63655ba59d7c05089017acb721a44979526 (diff)
Merge branch 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstable
* 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstable: tcx: tcx_screen_dump(): add error handling tcx: tcx24_screen_dump(): add error handling g364fb: g364fb_screen_dump(): add error handling omap_lcdc: omap_ppm_save(): add error handling omap_lcdc: rename ppm_save() to omap_ppm_save() vga: ppm_save(): add error handling qapi: convert screendump console: vga_hw_screen_dump_ptr: take Error argument error: add error_setg() json-parser: Fix potential NULL pointer segfault qapi: Fix potential NULL pointer segfault qapi: convert sendkey monitor: move key_defs[] table and introduce two help functions qapi: add the QKeyCode enum qapi: generate list struct and visit_list for enum hmp: rename arguments monitor: rename keyname '<' to 'less' fix doc of using raw values with sendkey Add support for pretty-printing response in qmp-shell
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi-types.py16
-rw-r--r--scripts/qapi-visit.py16
2 files changed, 29 insertions, 3 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index cf601ae2d2..49ef569a2f 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -28,6 +28,16 @@ typedef struct %(name)sList
''',
name=name)
+def generate_fwd_enum_struct(name, members):
+ return mcgen('''
+typedef struct %(name)sList
+{
+ %(name)s value;
+ struct %(name)sList *next;
+} %(name)sList;
+''',
+ name=name)
+
def generate_struct(structname, fieldname, members):
ret = mcgen('''
struct %(name)s
@@ -276,7 +286,8 @@ for expr in exprs:
if expr.has_key('type'):
ret += generate_fwd_struct(expr['type'], expr['data'])
elif expr.has_key('enum'):
- ret += generate_enum(expr['enum'], expr['data'])
+ ret += generate_enum(expr['enum'], expr['data']) + "\n"
+ ret += generate_fwd_enum_struct(expr['enum'], expr['data'])
fdef.write(generate_enum_lookup(expr['enum'], expr['data']))
elif expr.has_key('union'):
ret += generate_fwd_struct(expr['union'], expr['data']) + "\n"
@@ -300,6 +311,9 @@ for expr in exprs:
fdef.write(generate_type_cleanup(expr['union'] + "List") + "\n")
ret += generate_type_cleanup_decl(expr['union'])
fdef.write(generate_type_cleanup(expr['union']) + "\n")
+ elif expr.has_key('enum'):
+ ret += generate_type_cleanup_decl(expr['enum'] + "List")
+ fdef.write(generate_type_cleanup(expr['enum'] + "List") + "\n")
else:
continue
fdecl.write(ret)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 04ef7c41ab..e2093e8947 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -157,7 +157,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
if (!error_is_set(errp)) {
visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
if (!err) {
- if (!obj || *obj) {
+ if (obj && *obj) {
visit_type_%(name)sKind(m, &(*obj)->kind, "type", &err);
if (!err) {
switch ((*obj)->kind) {
@@ -217,6 +217,16 @@ void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name,
return ret
+def generate_enum_declaration(name, members, genlist=True):
+ ret = ""
+ if genlist:
+ ret += mcgen('''
+void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp);
+''',
+ name=name)
+
+ return ret
+
def generate_decl_enum(name, members, genlist=True):
return mcgen('''
@@ -335,10 +345,12 @@ for expr in exprs:
ret += generate_declaration(expr['union'], expr['data'])
fdecl.write(ret)
elif expr.has_key('enum'):
- ret = generate_visit_enum(expr['enum'], expr['data'])
+ ret = generate_visit_list(expr['enum'], expr['data'])
+ ret += generate_visit_enum(expr['enum'], expr['data'])
fdef.write(ret)
ret = generate_decl_enum(expr['enum'], expr['data'])
+ ret += generate_enum_declaration(expr['enum'], expr['data'])
fdecl.write(ret)
fdecl.write('''