From 468866b816f13c8141b692ac0280706c16b30185 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 7 May 2014 09:53:47 +0200 Subject: qapi-visit.py: Clean up confusing push_indent() / pop_indent() use Changing implicit indentation in the middle of generating a block makes following the code being generated unnecessarily hard. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- scripts/qapi-visit.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 9f22eee873..28176ba734 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -128,12 +128,14 @@ if (!err) { ''', name=full_name) + ret += mcgen(''' + /* Always call end_struct if start_struct succeeded. */ + visit_end_struct(m, &err); +} +error_propagate(errp, err); +''') pop_indent() ret += mcgen(''' - /* Always call end_struct if start_struct succeeded. */ - visit_end_struct(m, &err); - } - error_propagate(errp, err); } ''') return ret @@ -289,19 +291,15 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** ''', name=name) - - push_indent() push_indent() push_indent() if base: ret += mcgen(''' - visit_type_%(name)s_fields(m, obj, &err); + visit_type_%(name)s_fields(m, obj, &err); ''', name=name) - pop_indent() - if not discriminator: disc_key = "type" else: @@ -343,19 +341,17 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** } error_propagate(errp, err); err = NULL; - } ''') pop_indent() - ret += mcgen(''' - /* Always call end_struct if start_struct succeeded. */ - visit_end_struct(m, &err); - } - error_propagate(errp, err); -} -''') + pop_indent() - pop_indent(); ret += mcgen(''' + } + /* Always call end_struct if start_struct succeeded. */ + visit_end_struct(m, &err); + } + error_propagate(errp, err); + } } ''') -- cgit v1.2.3