From nobody Thu Nov 13 23:22:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253370; cv=none; d=zohomail.com; s=zohoarc; b=ShJDNsXmugc1zT7zvlTP17FGQawKmpqdY1b4cNTab/02iZjshkk+QwtKjeRYA9ZsvtljFRV9IvLJz/y7GpcDkbhTEpFPWPR60rd+Md3HejJ/kswfxXMbayZNVSmWN0vfGUwUlTKIsKYTJ8+0oWLFVOWfRuB2vejBz37MYPOPRNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253370; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=osNV8uUZeUP5b4gAuB1lT2GZGquG+Lh6Va7VhUXUe8c=; b=C1PysiXGGOSe2WEbD+nhJos3wJr4sCBqofxrInqZ6q1o4Wzld0SZVxCfAJ9P0FuSGqE/dHo9eZL9YAgWby8GaXmHBBBxDidv5CXnovpM9OS1IW1xJEqwW77hsA8dUbuIxKiYBUONH3JgAmdFPVUiC45rtO+s5s3oZMpM1E8pGbQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158325337010513.28595315053974; Tue, 3 Mar 2020 08:36:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-426-ALRxmyMNOr2f0S8bPKUXmg-1; Tue, 03 Mar 2020 11:36:06 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 345E88010EE; Tue, 3 Mar 2020 16:35:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1AB239B; Tue, 3 Mar 2020 16:35:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 90AEB18037C8; Tue, 3 Mar 2020 16:35:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZF8X001298 for ; Tue, 3 Mar 2020 11:35:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7EE595C3FA; Tue, 3 Mar 2020 16:35:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C87405C1D8; Tue, 3 Mar 2020 16:35:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DCF561132B2C; Tue, 3 Mar 2020 17:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253368; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=osNV8uUZeUP5b4gAuB1lT2GZGquG+Lh6Va7VhUXUe8c=; b=fQlctb8gBiMrRh8MNmlklb4o9gH02wGCP29jRcu2bEnmZN88rEQfye5Wlrjb3E7JH0oIvy unx7hqiHh4gwu+oufRvLhcwvOb15HMtTVZLlPcs1RzJcGz5JIBUy2CHD7K5k6Iz9S588GH weO1w4oZpYgQdSGuDvVscN+6c3njUJY= X-MC-Unique: ALRxmyMNOr2f0S8bPKUXmg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 14/30] qapi/introspect: Rename *qlit* to reduce confusion Date: Tue, 3 Mar 2020 17:34:49 +0100 Message-Id: <20200303163505.32041-15-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We generate the value of qmp_schema_qlit from an expression tree. The function doing that is named to_qlit(), and its inputs are accumulated in QAPISchemaGenIntrospectVisitor._qlits. We call both its input and its output "qlit". This is confusing. Use "tree" for input, and "qlit" only for output: rename to_qlit() to _tree_to_qlit(), ._qlits to ._trees, ._gen_qlit() to ._gen_tree(). Signed-off-by: Markus Armbruster --- scripts/qapi/introspect.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index b54910510d..e4fc9d90f1 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -16,7 +16,7 @@ from qapi.schema import (QAPISchemaArrayType, QAPISchemaB= uiltinType, QAPISchemaType) =20 =20 -def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse): +def _tree_to_qlit(obj, level=3D0, suppress_first_indent=3DFalse): =20 def indent(level): return level * 4 * ' ' @@ -30,7 +30,7 @@ def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse= ): ret +=3D indent(level) + '/* %s */\n' % comment if ifcond: ret +=3D gen_if(ifcond) - ret +=3D to_qlit(ifobj, level) + ret +=3D _tree_to_qlit(ifobj, level) if ifcond: ret +=3D '\n' + gen_endif(ifcond) return ret @@ -43,7 +43,7 @@ def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse= ): elif isinstance(obj, str): ret +=3D 'QLIT_QSTR(' + to_c_string(obj) + ')' elif isinstance(obj, list): - elts =3D [to_qlit(elt, level + 1).strip('\n') + elts =3D [_tree_to_qlit(elt, level + 1).strip('\n') for elt in obj] elts.append(indent(level + 1) + "{}") ret +=3D 'QLIT_QLIST(((QLitObject[]) {\n' @@ -53,7 +53,8 @@ def to_qlit(obj, level=3D0, suppress_first_indent=3DFalse= ): elts =3D [] for key, value in sorted(obj.items()): elts.append(indent(level + 1) + '{ %s, %s }' % - (to_c_string(key), to_qlit(value, level + 1, True)= )) + (to_c_string(key), + _tree_to_qlit(value, level + 1, True))) elts.append(indent(level + 1) + '{}') ret +=3D 'QLIT_QDICT(((QLitDictEntry[]) {\n' ret +=3D ',\n'.join(elts) + '\n' @@ -79,7 +80,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithic= CVisitor): ' * QAPI/QMP schema introspection', __doc__) self._unmask =3D unmask self._schema =3D None - self._qlits =3D [] + self._trees =3D [] self._used_types =3D [] self._name_map =3D {} self._genc.add(mcgen(''' @@ -108,9 +109,9 @@ extern const QLitObject %(c_name)s; const QLitObject %(c_name)s =3D %(c_string)s; ''', c_name=3Dc_name(name), - c_string=3Dto_qlit(self._qlits))) + c_string=3D_tree_to_qlit(self._trees))) self._schema =3D None - self._qlits =3D [] + self._trees =3D [] self._used_types =3D [] self._name_map =3D {} =20 @@ -144,7 +145,7 @@ const QLitObject %(c_name)s =3D %(c_string)s; return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 - def _gen_qlit(self, name, mtype, obj, ifcond, features): + def _gen_tree(self, name, mtype, obj, ifcond, features): extra =3D {} if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: @@ -159,9 +160,9 @@ const QLitObject %(c_name)s =3D %(c_string)s; if ifcond: extra['if'] =3D ifcond if extra: - self._qlits.append((obj, extra)) + self._trees.append((obj, extra)) else: - self._qlits.append(obj) + self._trees.append(obj) =20 def _gen_member(self, member): ret =3D {'name': member.name, 'type': self._use_type(member.type)} @@ -180,17 +181,17 @@ const QLitObject %(c_name)s =3D %(c_string)s; {'if': variant.ifcond}) =20 def visit_builtin_type(self, name, info, json_type): - self._gen_qlit(name, 'builtin', {'json-type': json_type}, [], None) + self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) =20 def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): - self._gen_qlit(name, 'enum', + self._gen_tree(name, 'enum', {'values': [(m.name, {'if': m.ifcond}) for m in members]}, ifcond, features) =20 def visit_array_type(self, name, info, ifcond, element_type): element =3D self._use_type(element_type) - self._gen_qlit('[' + element + ']', 'array', {'element-type': elem= ent}, + self._gen_tree('[' + element + ']', 'array', {'element-type': elem= ent}, ifcond, None) =20 def visit_object_type_flat(self, name, info, ifcond, features, @@ -200,10 +201,10 @@ const QLitObject %(c_name)s =3D %(c_string)s; obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) =20 - self._gen_qlit(name, 'object', obj, ifcond, features) + self._gen_tree(name, 'object', obj, ifcond, features) =20 def visit_alternate_type(self, name, info, ifcond, features, variants): - self._gen_qlit(name, 'alternate', + self._gen_tree(name, 'alternate', {'members': [ ({'type': self._use_type(m.type)}, {'if': m.ifc= ond}) for m in variants.variants]}, @@ -218,11 +219,11 @@ const QLitObject %(c_name)s =3D %(c_string)s; 'ret-type': self._use_type(ret_type)} if allow_oob: obj['allow-oob'] =3D allow_oob - self._gen_qlit(name, 'command', obj, ifcond, features) + self._gen_tree(name, 'command', obj, ifcond, features) =20 def visit_event(self, name, info, ifcond, features, arg_type, boxed): arg_type =3D arg_type or self._schema.the_empty_object_type - self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type= )}, + self._gen_tree(name, 'event', {'arg-type': self._use_type(arg_type= )}, ifcond, features) =20 =20 --=20 2.21.1