From patchwork Fri Oct 23 05:09:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 534777 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1C351141324 for ; Fri, 23 Oct 2015 16:12:43 +1100 (AEDT) Received: from localhost ([::1]:36037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpUee-0002zS-VZ for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2015 01:12:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpUcA-0006tU-Ab for qemu-devel@nongnu.org; Fri, 23 Oct 2015 01:10:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpUc9-0003Er-AE for qemu-devel@nongnu.org; Fri, 23 Oct 2015 01:10:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58651) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpUc9-0003Dw-5v for qemu-devel@nongnu.org; Fri, 23 Oct 2015 01:10:05 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id C164D8C1D6; Fri, 23 Oct 2015 05:10:04 +0000 (UTC) Received: from red.redhat.com (ovpn-113-176.phx2.redhat.com [10.3.113.176]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9N59xE9026589; Fri, 23 Oct 2015 01:10:04 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 22 Oct 2015 23:09:41 -0600 Message-Id: <1445576998-2921-9-git-send-email-eblake@redhat.com> In-Reply-To: <1445576998-2921-1-git-send-email-eblake@redhat.com> References: <1445576998-2921-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, Michael Roth Subject: [Qemu-devel] [PATCH v10 08/25] qapi-types: Refactor base fields output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Move code from gen_union() into gen_struct_fields() in order for a later patch to share code when enumerating inherited fields for struct types. No change to generated code. Signed-off-by: Eric Blake --- v10: new patch, split off of 5/17 --- scripts/qapi-types.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 4fe618e..a97cc10 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -51,9 +51,19 @@ def gen_struct_field(name, typ, optional): return ret -def gen_struct_fields(members): +def gen_struct_fields(members, base=None): ret = '' + if base: + ret += mcgen(''' + /* Members inherited from %(c_name)s: */ +''', + c_name=base.c_name()) + ret += gen_struct_fields(base.members) + ret += mcgen(''' + /* Own members: */ +''') + for memb in members: ret += gen_struct_field(memb.name, memb.type, memb.optional) return ret @@ -126,14 +136,7 @@ struct %(c_name)s { ''', c_name=c_name(name)) if base: - ret += mcgen(''' - /* Members inherited from %(c_name)s: */ -''', - c_name=c_name(base.name)) - ret += gen_struct_fields(base.members) - ret += mcgen(''' - /* Own members: */ -''') + ret += gen_struct_fields([], base) else: ret += mcgen(''' %(c_type)s kind;