From patchwork Fri Mar 4 16:45:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8506281 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DCF9DC0553 for ; Fri, 4 Mar 2016 16:49:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E60CF20125 for ; Fri, 4 Mar 2016 16:49:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE17E201BC for ; Fri, 4 Mar 2016 16:49:50 +0000 (UTC) Received: from localhost ([::1]:42293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1absvG-000899-7Y for patchwork-qemu-devel@patchwork.kernel.org; Fri, 04 Mar 2016 11:49:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1absr9-000188-Ip for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:45:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1absr6-0005Z9-Ba for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:45:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1absr6-0005Yr-27 for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:45:32 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id AC0F319CB82 for ; Fri, 4 Mar 2016 16:45:31 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-56.ams2.redhat.com [10.36.116.56]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u24GjTjC018462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 4 Mar 2016 11:45:30 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 265BC303E3F3; Fri, 4 Mar 2016 17:45:29 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 4 Mar 2016 17:45:19 +0100 Message-Id: <1457109928-4881-4-git-send-email-armbru@redhat.com> In-Reply-To: <1457109928-4881-1-git-send-email-armbru@redhat.com> References: <1457109928-4881-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/12] qapi: Rename 'fields' to 'members' in generator 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Blake C types and JSON objects don't have fields, but members. We shouldn't gratuitously invent terminology. This patch is a strict renaming of generator code internals (including testsuite comments), before later patches rename C interfaces. No change to generated code with this patch. Suggested-by: Markus Armbruster Signed-off-by: Eric Blake Message-Id: <1457021813-10704-2-git-send-email-eblake@redhat.com> --- scripts/qapi-commands.py | 4 ++-- scripts/qapi-event.py | 4 ++-- scripts/qapi-types.py | 8 ++++---- scripts/qapi-visit.py | 28 ++++++++++++++-------------- scripts/qapi.py | 20 ++++++++++---------- tests/qapi-schema/qapi-schema-test.json | 2 +- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index f831621..f44e01f 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -111,7 +111,7 @@ def gen_marshal_input_visit(arg_type, dealloc=False): v = qmp_input_get_visitor(qiv); ''') - ret += gen_visit_fields(arg_type.members, skiperr=dealloc) + ret += gen_visit_members(arg_type.members, skiperr=dealloc) if dealloc: ret += mcgen(''' @@ -175,7 +175,7 @@ def gen_marshal(name, arg_type, ret_type): ret += gen_marshal_input_visit(arg_type) ret += gen_call(name, arg_type, ret_type) - # 'goto out' produced by gen_marshal_input_visit->gen_visit_fields() + # 'goto out' produced by gen_marshal_input_visit->gen_visit_members() # for each arg_type member, and by gen_call() for ret_type if (arg_type and arg_type.members) or ret_type: ret += mcgen(''' diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index 544ae12..fb579dd 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -67,8 +67,8 @@ def gen_event_send(name, arg_type): ''', name=name) ret += gen_err_check() - ret += gen_visit_fields(arg_type.members, need_cast=True, - label='out_obj') + ret += gen_visit_members(arg_type.members, need_cast=True, + label='out_obj') ret += mcgen(''' out_obj: visit_end_struct(v, err ? NULL : &err); diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index eac90d2..8858d29 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -38,7 +38,7 @@ struct %(c_name)s { c_name=c_name(name), c_type=element_type.c_type()) -def gen_struct_fields(members): +def gen_struct_members(members): ret = '' for memb in members: if memb.optional: @@ -77,16 +77,16 @@ struct %(c_name)s { /* Members inherited from %(c_name)s: */ ''', c_name=base.c_name()) - ret += gen_struct_fields(base.members) + ret += gen_struct_members(base.members) ret += mcgen(''' /* Own members: */ ''') - ret += gen_struct_fields(members) + ret += gen_struct_members(members) if variants: ret += gen_variants(variants) - # Make sure that all structs have at least one field; this avoids + # Make sure that all structs have at least one member; this avoids # potential issues with attempting to malloc space for zero-length # structs in C, and also incompatibility with C++ (where an empty # struct is size 1). diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 2308268..b21d3ef 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -15,9 +15,9 @@ from qapi import * import re -# visit_type_FOO_fields() is always emitted; track if a forward declaration +# visit_type_FOO_members() is always emitted; track if a forward declaration # or implementation has already been output. -struct_fields_seen = set() +object_members_seen = set() def gen_visit_decl(name, scalar=False): @@ -30,10 +30,10 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error ** c_name=c_name(name), c_type=c_type) -def gen_visit_fields_decl(typ): - if typ.name in struct_fields_seen: +def gen_visit_members_decl(typ): + if typ.name in object_members_seen: return '' - struct_fields_seen.add(typ.name) + object_members_seen.add(typ.name) return mcgen(''' static void visit_type_%(c_type)s_fields(Visitor *v, %(c_type)s *obj, Error **errp); @@ -41,18 +41,18 @@ static void visit_type_%(c_type)s_fields(Visitor *v, %(c_type)s *obj, Error **er c_type=typ.c_name()) -def gen_visit_struct_fields(name, base, members, variants): +def gen_visit_object_members(name, base, members, variants): ret = '' if base: - ret += gen_visit_fields_decl(base) + ret += gen_visit_members_decl(base) if variants: for var in variants.variants: # Ugly special case for simple union TODO get rid of it if not var.simple_union_type(): - ret += gen_visit_fields_decl(var.type) + ret += gen_visit_members_decl(var.type) - struct_fields_seen.add(name) + object_members_seen.add(name) ret += mcgen(''' static void visit_type_%(c_name)s_fields(Visitor *v, %(c_name)s *obj, Error **errp) @@ -69,7 +69,7 @@ static void visit_type_%(c_name)s_fields(Visitor *v, %(c_name)s *obj, Error **er c_type=base.c_name()) ret += gen_err_check() - ret += gen_visit_fields(members, prefix='obj->') + ret += gen_visit_members(members, prefix='obj->') if variants: ret += mcgen(''' @@ -108,7 +108,7 @@ static void visit_type_%(c_name)s_fields(Visitor *v, %(c_name)s *obj, Error **er } ''') - # 'goto out' produced for base, by gen_visit_fields() for each member, + # 'goto out' produced for base, by gen_visit_members() for each member, # and if variants were present if base or members or variants: ret += mcgen(''' @@ -174,7 +174,7 @@ def gen_visit_alternate(name, variants): if var.type.alternate_qtype() == 'QTYPE_QINT': promote_int = 'false' if isinstance(var.type, QAPISchemaObjectType): - ret += gen_visit_fields_decl(var.type) + ret += gen_visit_members_decl(var.type) ret += mcgen(''' @@ -235,10 +235,10 @@ out: def gen_visit_object(name, base, members, variants): - ret = gen_visit_struct_fields(name, base, members, variants) + ret = gen_visit_object_members(name, base, members, variants) # 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 + # *obj, but then visit_type_FOO_members() 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(''' diff --git a/scripts/qapi.py b/scripts/qapi.py index 18adca7..6b2aa6e 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -326,7 +326,7 @@ class QAPISchemaParser(object): # -def find_base_fields(base): +def find_base_members(base): base_struct_define = find_struct(base) if not base_struct_define: return None @@ -355,11 +355,11 @@ def discriminator_find_enum_define(expr): if not (discriminator and base): return None - base_fields = find_base_fields(base) - if not base_fields: + base_members = find_base_members(base) + if not base_members: return None - discriminator_type = base_fields.get(discriminator) + discriminator_type = base_members.get(discriminator) if not discriminator_type: return None @@ -567,14 +567,14 @@ def check_union(expr, expr_info): raise QAPIExprError(expr_info, "Flat union '%s' must have a base" % name) - base_fields = find_base_fields(base) - assert base_fields + base_members = find_base_members(base) + assert base_members # The value of member 'discriminator' must name a non-optional # member of the base struct. check_name(expr_info, "Discriminator of flat union '%s'" % name, discriminator) - discriminator_type = base_fields.get(discriminator) + discriminator_type = base_members.get(discriminator) if not discriminator_type: raise QAPIExprError(expr_info, "Discriminator '%s' is not a member of base " @@ -969,7 +969,7 @@ class QAPISchemaObjectType(QAPISchemaType): assert self.variants.tag_member in self.members self.variants.check_clash(schema, self.info, seen) - # Check that the members of this type do not cause duplicate JSON fields, + # Check that the members of this type do not cause duplicate JSON members, # and update seen to track the members seen so far. Report any errors # on behalf of info, which is not necessarily self.info def check_clash(self, schema, info, seen): @@ -1647,8 +1647,8 @@ def gen_err_check(label='out', skiperr=False): label=label) -def gen_visit_fields(members, prefix='', need_cast=False, skiperr=False, - label='out'): +def gen_visit_members(members, prefix='', need_cast=False, skiperr=False, + label='out'): ret = '' if skiperr: errparg = 'NULL' diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index 632964a..728659e 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -77,7 +77,7 @@ 'base': 'UserDefZero', 'data': { 'string': 'str', 'enum1': 'QEnumTwo' } } -# this variant of UserDefFlatUnion defaults to a union that uses fields with +# this variant of UserDefFlatUnion defaults to a union that uses members with # allocated types to test corner cases in the cleanup/dealloc visitor { 'union': 'UserDefFlatUnion2', 'base': 'UserDefUnionBase2',