From nobody Tue Feb 10 16:22:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150695877508183.91805237577125; Mon, 2 Oct 2017 08:39:35 -0700 (PDT) Received: from localhost ([::1]:52871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz2oT-0001sh-Pc for importer@patchew.org; Mon, 02 Oct 2017 11:39:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz2bd-0007yO-DD for qemu-devel@nongnu.org; Mon, 02 Oct 2017 11:26:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz2ba-0007wE-P6 for qemu-devel@nongnu.org; Mon, 02 Oct 2017 11:26:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34714) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dz2ba-0007v7-DX for qemu-devel@nongnu.org; Mon, 02 Oct 2017 11:26:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86E097E425; Mon, 2 Oct 2017 15:26:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27F2C91B09; Mon, 2 Oct 2017 15:26:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B505811562E4; Mon, 2 Oct 2017 17:25:52 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 86E097E425 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 2 Oct 2017 17:25:37 +0200 Message-Id: <20171002152552.27999-18-armbru@redhat.com> In-Reply-To: <20171002152552.27999-1-armbru@redhat.com> References: <20171002152552.27999-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 02 Oct 2017 15:26:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 17/32] qapi: Fix simple union lowering with multiple schemas X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If more than one schema uses the same built-in type T for a simple union member, they all generate the same q_obj_T_wrapper into their qapi-types.h. They clash when you include more than one schema's qapi-types.h. Fix by generating them into builtin-qapi-types.h instead. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi-types.py | 12 ++++++++---- scripts/qapi.py | 2 ++ tests/qapi-schema/builtins.out | 30 ++++++++++++++++++++++++++++++ tests/qapi-schema/qapi-schema-test.json | 3 +-- tests/qapi-schema/qapi-schema-test.out | 5 ++--- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 18fd2a98c0..c058540e4d 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -53,7 +53,10 @@ def gen_struct_members(members): return ret =20 =20 -def gen_object(name, base, members, variants): +def gen_object(name, info, base, members, variants): + # TODO use something cleaner than existence of info + if not info and args.schema: + return '' # suppress built-in if name in objects_seen: return '' objects_seen.add(name) @@ -62,7 +65,7 @@ def gen_object(name, base, members, variants): if variants: for v in variants.variants: if isinstance(v.type, QAPISchemaObjectType): - ret +=3D gen_object(v.type.name, v.type.base, + ret +=3D gen_object(v.type.name, v.type.info, v.type.base, v.type.local_members, v.type.variants) =20 ret +=3D mcgen(''' @@ -200,7 +203,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): if name =3D=3D 'q_empty': return self._fwdecl +=3D gen_fwd_object_or_array(name) - self.decl +=3D gen_object(name, base, members, variants) + self.decl +=3D gen_object(name, info, base, members, variants) if base and not base.is_implicit(): self.decl +=3D gen_upcast(name, base) # TODO Worth changing the visitor signature, so we could @@ -211,7 +214,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): =20 def visit_alternate_type(self, name, info, variants): self._fwdecl +=3D gen_fwd_object_or_array(name) - self.decl +=3D gen_object(name, None, [variants.tag_member], varia= nts) + self.decl +=3D gen_object(name, info, None, + [variants.tag_member], variants) self._gen_type_cleanup(name) =20 argparser =3D common_argument_parser(builtins=3DTrue) diff --git a/scripts/qapi.py b/scripts/qapi.py index 4871eb7740..477402b7f8 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1499,6 +1499,8 @@ class QAPISchema(object): # would be to use lazy instantiation, while figuring out how to # avoid compilation issues with multiple qapi-types.h. self._make_array_type(name, None) + # TODO same for wrapper types + self._make_implicit_wrapper_type(name, None) =20 def _def_predefineds(self): for t in [('str', 'string', 'char' + pointer_suffix), diff --git a/tests/qapi-schema/builtins.out b/tests/qapi-schema/builtins.out index 40b886ddae..d289bfe919 100644 --- a/tests/qapi-schema/builtins.out +++ b/tests/qapi-schema/builtins.out @@ -1,3 +1,33 @@ enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE object q_empty +object q_obj_any-wrapper + member data: any optional=3DFalse +object q_obj_bool-wrapper + member data: bool optional=3DFalse +object q_obj_int-wrapper + member data: int optional=3DFalse +object q_obj_int16-wrapper + member data: int16 optional=3DFalse +object q_obj_int32-wrapper + member data: int32 optional=3DFalse +object q_obj_int64-wrapper + member data: int64 optional=3DFalse +object q_obj_int8-wrapper + member data: int8 optional=3DFalse +object q_obj_null-wrapper + member data: null optional=3DFalse +object q_obj_number-wrapper + member data: number optional=3DFalse +object q_obj_size-wrapper + member data: size optional=3DFalse +object q_obj_str-wrapper + member data: str optional=3DFalse +object q_obj_uint16-wrapper + member data: uint16 optional=3DFalse +object q_obj_uint32-wrapper + member data: uint32 optional=3DFalse +object q_obj_uint64-wrapper + member data: uint64 optional=3DFalse +object q_obj_uint8-wrapper + member data: uint8 optional=3DFalse diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index c091626635..ac8aefc924 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -84,8 +84,7 @@ =20 { 'union': 'UserDefSimpleUnion', 'data': { 'value1': 'UserDefA', -# FIXME generated q_obj_int_wrapper clashes with qapi-schema.json's -# 'value2': 'int', + 'value2': 'int', 'value3': 'UserDefB' } } =20 # this variant of UserDefFlatUnion defaults to a union that uses members w= ith diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 97bb02f2fd..fff25e26d0 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -112,8 +112,9 @@ object UserDefSimpleUnion member type: UserDefSimpleUnionKind optional=3DFalse tag type case value1: q_obj_UserDefA-wrapper + case value2: q_obj_int-wrapper case value3: q_obj_UserDefB-wrapper -enum UserDefSimpleUnionKind ['value1', 'value3'] +enum UserDefSimpleUnionKind ['value1', 'value2', 'value3'] object UserDefTwo member string0: str optional=3DFalse member dict1: UserDefTwoDict optional=3DFalse @@ -211,8 +212,6 @@ object q_obj_numberList-wrapper member data: numberList optional=3DFalse object q_obj_sizeList-wrapper member data: sizeList optional=3DFalse -object q_obj_str-wrapper - member data: str optional=3DFalse object q_obj_strList-wrapper member data: strList optional=3DFalse object q_obj_uint16List-wrapper --=20 2.13.6