qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH v6 14/26] qapi-visit: Rearrange code a bit
Date: Fri, 11 Sep 2015 21:17:57 +0200	[thread overview]
Message-ID: <1441999089-28960-15-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1441999089-28960-1-git-send-email-armbru@redhat.com>

Move gen_visit_decl() to a better place.  Inline
generate_visit_struct_body().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 scripts/qapi-visit.py | 50 ++++++++++++++++++++------------------------------
 1 file changed, 20 insertions(+), 30 deletions(-)

diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 2ac244b..d776948 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -19,6 +19,16 @@ implicit_structs_seen = set()
 struct_fields_seen = set()
 
 
+def gen_visit_decl(name, scalar=False):
+    c_type = c_name(name) + ' *'
+    if not scalar:
+        c_type += '*'
+    return mcgen('''
+void visit_type_%(c_name)s(Visitor *m, %(c_type)sobj, const char *name, Error **errp);
+''',
+                 c_name=c_name(name), c_type=c_type)
+
+
 def gen_visit_implicit_struct(typ):
     if typ in implicit_structs_seen:
         return ''
@@ -117,12 +127,17 @@ out:
     return ret
 
 
-def gen_visit_struct_body(name):
+def gen_visit_struct(name, base, members):
+    ret = gen_visit_struct_fields(name, base, members)
+
     # FIXME: if *obj is NULL on entry, and visit_start_struct() assigns to
     # *obj, but then visit_type_FOO_fields() fails, we should clean up *obj
     # rather than leaving it non-NULL. As currently written, the caller must
     # call qapi_free_FOO() to avoid a memory leak of the partial FOO.
-    ret = mcgen('''
+    ret += mcgen('''
+
+void visit_type_%(c_name)s(Visitor *m, %(c_name)s **obj, const char *name, Error **errp)
+{
     Error *err = NULL;
 
     visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(c_name)s), &err);
@@ -133,25 +148,10 @@ def gen_visit_struct_body(name):
         visit_end_struct(m, &err);
     }
     error_propagate(errp, err);
-''',
-                name=name, c_name=c_name(name))
-    return ret
-
-
-def gen_visit_struct(name, base, members):
-    ret = gen_visit_struct_fields(name, base, members)
-    ret += mcgen('''
-
-void visit_type_%(c_name)s(Visitor *m, %(c_name)s **obj, const char *name, Error **errp)
-{
-''',
-                 c_name=c_name(name))
-
-    ret += gen_visit_struct_body(name)
-
-    ret += mcgen('''
 }
-''')
+''',
+                 name=name, c_name=c_name(name))
+
     return ret
 
 
@@ -342,16 +342,6 @@ out:
     return ret
 
 
-def gen_visit_decl(name, scalar=False):
-    c_type = c_name(name) + ' *'
-    if not scalar:
-        c_type += '*'
-    return mcgen('''
-void visit_type_%(c_name)s(Visitor *m, %(c_type)sobj, const char *name, Error **errp);
-''',
-                 c_name=c_name(name), c_type=c_type)
-
-
 class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
     def __init__(self):
         self.decl = None
-- 
2.4.3

  parent reply	other threads:[~2015-09-11 19:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 19:17 [Qemu-devel] [PATCH v6 00/26] qapi: QMP introspection Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 01/26] qapi: Rename class QAPISchema to QAPISchemaParser Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 02/26] qapi: New QAPISchema intermediate reperesentation Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 03/26] qapi: QAPISchema code generation helper methods Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 04/26] qapi: New QAPISchemaVisitor Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 05/26] tests/qapi-schema: Convert test harness to QAPISchemaVisitor Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 06/26] qapi-types: Convert to QAPISchemaVisitor, fixing flat unions Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 07/26] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 08/26] qapi-commands: Convert to QAPISchemaVisitor Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 09/26] qapi: De-duplicate enum code generation Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 10/26] qapi-event: Eliminate global variable event_enum_value Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 11/26] qapi-event: Convert to QAPISchemaVisitor, fixing data with base Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 12/26] qapi: Replace dirty is_c_ptr() by method c_null() Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 13/26] qapi: Clean up after recent conversions to QAPISchemaVisitor Markus Armbruster
2015-09-11 19:17 ` Markus Armbruster [this message]
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 15/26] qapi-commands: Rearrange code Markus Armbruster
2015-09-11 19:17 ` [Qemu-devel] [PATCH v6 16/26] qapi: Rename qmp_marshal_input_FOO() to qmp_marshal_FOO() Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 17/26] qapi: De-duplicate parameter list generation Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 18/26] qapi-commands: De-duplicate output marshaling functions Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 19/26] qapi: Improve built-in type documentation Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 20/26] qapi: Fix output visitor to return qnull() instead of NULL Markus Armbruster
2015-09-11 20:43   ` Eric Blake
2015-09-11 21:01     ` Eric Blake
2015-09-12  8:10       ` Markus Armbruster
2015-09-12 12:16         ` Eric Blake
2015-09-12 13:42           ` Eric Blake
2015-09-12 13:55             ` Eric Blake
2015-09-12 14:11           ` Markus Armbruster
2015-09-12 14:17             ` Eric Blake
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 21/26] qapi: Introduce a first class 'any' type Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 22/26] qom: Don't use 'gen': false for qom-get, qom-set, object-add Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 23/26] qapi-schema: Fix up misleading specification of netdev_add Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 24/26] qapi: Pseudo-type '**' is now unused, drop it Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 25/26] qapi: New QMP command query-qmp-schema for QMP introspection Markus Armbruster
2015-09-11 19:18 ` [Qemu-devel] [PATCH v6 26/26] qapi-introspect: Hide type names Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1441999089-28960-15-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).