From patchwork Tue Feb 2 17:46:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RIeSZhtL; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXMr21C9z9tlG for ; Wed, 3 Feb 2021 04:47:50 +1100 (AEDT) Received: from localhost ([::1]:46870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zmF-0004kl-Pw for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:47:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlW-0004j3-9G for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlU-0008AS-Cu for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288018; h=from:from: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; bh=XWr0AcRlsQez5Aq3NxYWxDa4M/wcTgndy6zggib5YUk=; b=RIeSZhtLMYmmQQ+jLSDSvwSftwg9kYRMopsWaEjsgn+5oRvHIfx26H4jEbYsv3gqiAAp4A NZhXhjwbPGseBzwGQJZivm5ia1JOInoIVpH6jEuwoA+BqDF+YknBB4qZkJ3CFqA9DnzQMG 5i0RxN9TvHAYp5yNYhqEtbMMlZ47rvE= 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-384-S5AIT4FVMK6rNaXOXqz8ZA-1; Tue, 02 Feb 2021 12:46:56 -0500 X-MC-Unique: S5AIT4FVMK6rNaXOXqz8ZA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2062835E21; Tue, 2 Feb 2021 17:46:53 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 278F85C1CF; Tue, 2 Feb 2021 17:46:53 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 01/14] qapi/introspect.py: assert schema is not None Date: Tue, 2 Feb 2021 12:46:38 -0500 Message-Id: <20210202174651.2274166-2-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The introspect visitor is stateful, but expects that it will have a schema to refer to. Add assertions that state this. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index fafec94e022..43ab4be1f77 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -147,6 +147,8 @@ def _name(self, name): return self._name_map[name] def _use_type(self, typ): + assert self._schema is not None + # Map the various integer types to plain int if typ.json_type() == 'int': typ = self._schema.lookup_type('int') @@ -225,6 +227,8 @@ def visit_alternate_type(self, name, info, ifcond, features, variants): def visit_command(self, name, info, ifcond, features, arg_type, ret_type, gen, success_response, boxed, allow_oob, allow_preconfig, coroutine): + assert self._schema is not None + arg_type = arg_type or self._schema.the_empty_object_type ret_type = ret_type or self._schema.the_empty_object_type obj = {'arg-type': self._use_type(arg_type), @@ -234,6 +238,7 @@ def visit_command(self, name, info, ifcond, features, self._gen_tree(name, 'command', obj, ifcond, features) def visit_event(self, name, info, ifcond, features, arg_type, boxed): + assert self._schema is not None arg_type = arg_type or self._schema.the_empty_object_type self._gen_tree(name, 'event', {'arg-type': self._use_type(arg_type)}, ifcond, features) From patchwork Tue Feb 2 17:46:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ja+Na7IA; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXRp1tR2z9tlG for ; Wed, 3 Feb 2021 04:51:18 +1100 (AEDT) Received: from localhost ([::1]:55230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zpc-0008K9-6W for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:51:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlX-0004jz-2j for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:28068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlV-0008BG-GI for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288020; h=from:from: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; bh=8DOXV3YUlb956rFhumyfuqnFObM1oyNO6UcyQdM6/4Q=; b=Ja+Na7IALTtUg3AI4y3pWcyFx1hxkRMPvMql6vTyBEVsWcdw113RWiYfu6COfthoq6EjhK I4p2xhzig7Snm86dtOm+B31XaKOJplqU+zLLlTI5cKb29CwXVQqgq6Q2l4SFhqFLiDE0P2 pmDKafT8OzUewF6zLlo0EHVVko6xCC0= 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-480-egD_HxESPRObyIV1JFpysg-1; Tue, 02 Feb 2021 12:46:56 -0500 X-MC-Unique: egD_HxESPRObyIV1JFpysg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 11614106BAE8; Tue, 2 Feb 2021 17:46:55 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 344CA5C5FC; Tue, 2 Feb 2021 17:46:53 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 02/14] qapi/introspect.py: use _make_tree for features nodes Date: Tue, 2 Feb 2021 12:46:39 -0500 Message-Id: <20210202174651.2274166-3-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" At present, we open-code this in _make_tree itself; but if the structure of the tree changes, this is brittle. Use an explicit recursive call to _make_tree when appropriate to help keep the interior node typing consistent. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 43ab4be1f77..3295a15c98e 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -30,7 +30,9 @@ def _make_tree(obj, ifcond, features, extra=None): if ifcond: extra['if'] = ifcond if features: - obj['features'] = [(f.name, {'if': f.ifcond}) for f in features] + obj['features'] = [ + _make_tree(f.name, f.ifcond, None) for f in features + ] if extra: return (obj, extra) return obj From patchwork Tue Feb 2 17:46:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hzc1ukhx; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXNm63dQz9tlM for ; Wed, 3 Feb 2021 04:48:40 +1100 (AEDT) Received: from localhost ([::1]:48880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zn4-0005ei-OG for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:48:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlY-0004m7-3b for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlW-0008BU-9v for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288021; h=from:from: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; bh=acrxd18H7FqKyFi0v69UbUmTdPkZgFPrjuidbeAGGhQ=; b=hzc1ukhxaUgAAc12Iiuf2XHBpkoiczfndPVoEIzYMuLUqsFO/pALvoKHawQJO5eGRhXSVX b21fnIa7BzAl69UqtUwrj0ksNzmHcnctoirLWdARS7Ry6WKANzwFRxcGnEksnkmmrjnxwd Ybvi4KvW8gxkXqkr+0QBcAzn5h1i1UM= 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-444-J30PkeZ2O7i1QlfI2fmJzA-1; Tue, 02 Feb 2021 12:46:57 -0500 X-MC-Unique: J30PkeZ2O7i1QlfI2fmJzA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED744107ACE8; Tue, 2 Feb 2021 17:46:55 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 391F45C1CF; Tue, 2 Feb 2021 17:46:55 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 03/14] qapi/introspect.py: add _gen_features helper Date: Tue, 2 Feb 2021 12:46:40 -0500 Message-Id: <20210202174651.2274166-4-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" _make_tree might receive a dict (a SchemaInfo object) or some other type (usually, a string) for its obj parameter. Adding features information should arguably be performed by the caller at such a time when we know the type of the object and don't have to re-interrogate it. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 3295a15c98e..4749f65ea3c 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -24,15 +24,11 @@ ) -def _make_tree(obj, ifcond, features, extra=None): +def _make_tree(obj, ifcond, extra=None): if extra is None: extra = {} if ifcond: extra['if'] = ifcond - if features: - obj['features'] = [ - _make_tree(f.name, f.ifcond, None) for f in features - ] if extra: return (obj, extra) return obj @@ -169,6 +165,10 @@ def _use_type(self, typ): return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) + @staticmethod + def _gen_features(features): + return [_make_tree(f.name, f.ifcond) for f in features] + def _gen_tree(self, name, mtype, obj, ifcond, features): extra = None if mtype not in ('command', 'event', 'builtin', 'array'): @@ -179,13 +179,17 @@ def _gen_tree(self, name, mtype, obj, ifcond, features): name = self._name(name) obj['name'] = name obj['meta-type'] = mtype - self._trees.append(_make_tree(obj, ifcond, features, extra)) + if features: + obj['features'] = self._gen_features(features) + self._trees.append(_make_tree(obj, ifcond, extra)) def _gen_member(self, member): obj = {'name': member.name, 'type': self._use_type(member.type)} if member.optional: obj['default'] = None - return _make_tree(obj, member.ifcond, member.features) + if member.features: + obj['features'] = self._gen_features(member.features) + return _make_tree(obj, member.ifcond) def _gen_variants(self, tag_name, variants): return {'tag': tag_name, @@ -193,7 +197,7 @@ def _gen_variants(self, tag_name, variants): def _gen_variant(self, variant): obj = {'case': variant.name, 'type': self._use_type(variant.type)} - return _make_tree(obj, variant.ifcond, None) + return _make_tree(obj, variant.ifcond) def visit_builtin_type(self, name, info, json_type): self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) From patchwork Tue Feb 2 17:46:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c/mk9QPS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXWQ0xRGz9tlG for ; Wed, 3 Feb 2021 04:54:26 +1100 (AEDT) Received: from localhost ([::1]:35284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zse-0003gv-2U for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:54:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlX-0004ky-Ow for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlU-0008At-Ak for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288019; h=from:from: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; bh=vAvdidcxAG70q1T89fjw/Ce4mvUGyQrT1MKRfSG98VM=; b=c/mk9QPSYqxGZ0bT9TVmJkAVj+hQC+n7mDGXYp1T8tiuRvd+QFn0tUB2yXWAOjcdZyX3IK wsQZ60phzBZsBBOKomCzIYeTXrjz49nwVGlcFkLt1LGauoo/kr9qF64R8wHf7kCqk5WTR0 W4eiD7qTzCqHedNk2h7pN0ra9ssmRng= 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-204-MGjz74EMNHmtfuMZuOEhBA-1; Tue, 02 Feb 2021 12:46:57 -0500 X-MC-Unique: MGjz74EMNHmtfuMZuOEhBA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D515E1934100; Tue, 2 Feb 2021 17:46:56 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2328B5C22B; Tue, 2 Feb 2021 17:46:56 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 04/14] qapi/introspect.py: guard against ifcond/comment misuse Date: Tue, 2 Feb 2021 12:46:41 -0500 Message-Id: <20210202174651.2274166-5-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" _tree_to_qlit is called recursively on dict values alone; at such a point in generating output it is too late to apply an ifcond. Similarly, comments do not necessarily have a "tidy" place they can be printed in such a circumstance. Forbid this usage. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 4749f65ea3c..ccdf4f1c0d0 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -43,6 +43,12 @@ def indent(level): ifobj, extra = obj ifcond = extra.get('if') comment = extra.get('comment') + + # NB: _tree_to_qlit is called recursively on the values of a key:value + # pair; those values can't be decorated with comments or conditionals. + msg = "dict values cannot have attached comments or if-conditionals." + assert not suppress_first_indent, msg + ret = '' if comment: ret += indent(level) + '/* %s */\n' % comment From patchwork Tue Feb 2 17:46:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X5hNOi3W; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXRy3Jd2z9tlG for ; Wed, 3 Feb 2021 04:51:26 +1100 (AEDT) Received: from localhost ([::1]:55350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zpj-0008NJ-QW for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:51:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlY-0004n8-IT for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43187) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlW-0008BS-CA for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288021; h=from:from: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; bh=ldeAmiIKnAEFKCFQiHI4++OADpvPK+E3kx7sPHnd2IU=; b=X5hNOi3Wvq/JGt38d01KzMI3HcPhVARflTPk5sMtluzvtm0TPNYoPElsK+ZtEZ9jshadPY SQ03T50KQQB11ZzXiXG72Qc84PipJUCWF8hZ+Vtk4plGOIFu+a0QqZ/icqE346MLPp789g qGp9XPojtYjfdLUlvXYrvKx1s6NJuJI= 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-469-qyPyJnk5PRWBzudEnoRWLg-1; Tue, 02 Feb 2021 12:46:58 -0500 X-MC-Unique: qyPyJnk5PRWBzudEnoRWLg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C05DA1800D50; Tue, 2 Feb 2021 17:46:57 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0948E5C1CF; Tue, 2 Feb 2021 17:46:56 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 05/14] qapi/introspect.py: Unify return type of _make_tree() Date: Tue, 2 Feb 2021 12:46:42 -0500 Message-Id: <20210202174651.2274166-6-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Returning two different types conditionally can be complicated to type. Return one type for consistency. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index ccdf4f1c0d0..d3fbf694ad2 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -29,9 +29,7 @@ def _make_tree(obj, ifcond, extra=None): extra = {} if ifcond: extra['if'] = ifcond - if extra: - return (obj, extra) - return obj + return (obj, extra) def _tree_to_qlit(obj, level=0, suppress_first_indent=False): From patchwork Tue Feb 2 17:46:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RmhVdaQl; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXMs67nrz9tlG for ; Wed, 3 Feb 2021 04:47:53 +1100 (AEDT) Received: from localhost ([::1]:47178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zmJ-0004u0-Qz for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:47:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zla-0004qR-7h for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlY-0008Cs-B0 for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288023; h=from:from: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; bh=Qz/o09IKu9KjjNwsj6ta2xekFpM0AVQ8ov8SHgO3d34=; b=RmhVdaQlWcapk/BtgZYYwWk0pyp1qSsvpUbs2mwNb2LV/LG15uIoTwdZGwVtj63VRbY6V/ VQgdR2iJmXApzacgGmD5ijidXwGeng0Z0qwEsaZzQXz0rNvHmy6MMhO78T+E0LtYgSLclo fW3DkoyuLABTqLP/JSJYZ5z62BRE2xk= 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-408-5SGYpHA9Pi-ePS6omsvE2w-1; Tue, 02 Feb 2021 12:47:00 -0500 X-MC-Unique: 5SGYpHA9Pi-ePS6omsvE2w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC6F91934100; Tue, 2 Feb 2021 17:46:58 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6AEA5C22B; Tue, 2 Feb 2021 17:46:57 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 06/14] qapi/introspect.py: replace 'extra' dict with 'comment' argument Date: Tue, 2 Feb 2021 12:46:43 -0500 Message-Id: <20210202174651.2274166-7-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is only used to pass in a dictionary with a comment already set, so skip the runaround and just accept the comment. This works because _tree_to_qlit() treats 'if': None; 'comment': None exactly like absent 'if'; 'comment'. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index d3fbf694ad2..0aa3b77109f 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -10,6 +10,8 @@ See the COPYING file in the top-level directory. """ +from typing import Optional + from .common import ( c_name, gen_endif, @@ -24,11 +26,11 @@ ) -def _make_tree(obj, ifcond, extra=None): - if extra is None: - extra = {} - if ifcond: - extra['if'] = ifcond +def _make_tree(obj, ifcond, comment=None): + extra = { + 'if': ifcond, + 'comment': comment, + } return (obj, extra) @@ -174,18 +176,18 @@ def _gen_features(features): return [_make_tree(f.name, f.ifcond) for f in features] def _gen_tree(self, name, mtype, obj, ifcond, features): - extra = None + comment: Optional[str] = None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: # Output a comment to make it easy to map masked names # back to the source when reading the generated output. - extra = {'comment': '"%s" = %s' % (self._name(name), name)} + comment = f'"{self._name(name)}" = {name}' name = self._name(name) obj['name'] = name obj['meta-type'] = mtype if features: obj['features'] = self._gen_features(features) - self._trees.append(_make_tree(obj, ifcond, extra)) + self._trees.append(_make_tree(obj, ifcond, comment)) def _gen_member(self, member): obj = {'name': member.name, 'type': self._use_type(member.type)} From patchwork Tue Feb 2 17:46:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JVqPdAo1; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXdF6LPwz9tlJ for ; Wed, 3 Feb 2021 04:59:29 +1100 (AEDT) Received: from localhost ([::1]:43928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zxW-00081T-I0 for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:59:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlZ-0004p5-Kq for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34088) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlX-0008Cg-Ub for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288023; h=from:from: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; bh=HFDyOxoGjdw/M6uGtxwmb9fdlj1TAK7OqU/iyC4IfjE=; b=JVqPdAo1Nti8ldi5PpWOUnTXjL4Wmg9lvg1qL8C+yCoyhbDcfjeS7ByMOIQiLk1uB09kDy Z4pBaT0GgF0veaYXcitTqppDuEMIEchA1Yr6051YRpAy20GXLueTzyFEDkIW1+qgNqKyM7 4e2xDo9DRMiyjipdSeuam2TGY5+FFeM= 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-55-u_6yA9MoMCq3oNaXwsaYMg-1; Tue, 02 Feb 2021 12:47:00 -0500 X-MC-Unique: u_6yA9MoMCq3oNaXwsaYMg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93AAF835E22; Tue, 2 Feb 2021 17:46:59 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id D314E5C1CF; Tue, 2 Feb 2021 17:46:58 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 07/14] qapi/introspect.py: Introduce preliminary tree typing Date: Tue, 2 Feb 2021 12:46:44 -0500 Message-Id: <20210202174651.2274166-8-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The types will be used in forthcoming patches to add typing. These types describe the layout and structure of the objects passed to _tree_to_qlit, but lack the power to describe annotations until the next commit. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 0aa3b77109f..b82efe16f6e 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -10,7 +10,13 @@ See the COPYING file in the top-level directory. """ -from typing import Optional +from typing import ( + Any, + Dict, + List, + Optional, + Union, +) from .common import ( c_name, @@ -26,6 +32,28 @@ ) +# This module constructs a tree data structure that is used to +# generate the introspection information for QEMU. It behaves similarly +# to a JSON value. +# +# A complexity over JSON is that our values may or may not be annotated. +# +# Un-annotated values may be: +# Scalar: str, bool, None. +# Non-scalar: List, Dict +# _value = Union[str, bool, None, Dict[str, TreeValue], List[TreeValue]] +# +# With optional annotations, the type of all values is: +# TreeValue = Union[_value, Annotated[_value]] +# +# Sadly, mypy does not support recursive types, so we must approximate this. +_stub = Any +_scalar = Union[str, bool, None] +_nonscalar = Union[Dict[str, _stub], List[_stub]] +_value = Union[_scalar, _nonscalar] +# TreeValue = Union[_value, 'Annotated[_value]'] + + def _make_tree(obj, ifcond, comment=None): extra = { 'if': ifcond, From patchwork Tue Feb 2 17:46:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=B6CnyJw8; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXT75GJCz9tlG for ; Wed, 3 Feb 2021 04:52:27 +1100 (AEDT) Received: from localhost ([::1]:57250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zqj-0000ni-MP for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:52:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlb-0004sk-Cn for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlY-0008D2-S1 for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288024; h=from:from: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; bh=YH/r0keMcLdV84njaSdaWHfrPxmjV8hvfdDHSpdMn8A=; b=B6CnyJw8i96eRMT2pZQnAtFd5MCQ7/bZEizEXlKeMnN0jPDQ3EHYdmTPsiaDUY8VtQnhbT aCFnbJVNlMOVq25FBupKHrq4bL8p4xGGQm0I8ApQK0q3Ca9aYhtne00uw19P2ExzmUHSe6 SQvT5VWNNC/Q8OIoJbN8wfCv93M6xBY= 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-462-AOVPclDqN1yW1fhQUiWjgA-1; Tue, 02 Feb 2021 12:47:01 -0500 X-MC-Unique: AOVPclDqN1yW1fhQUiWjgA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7AA5C106BAE4; Tue, 2 Feb 2021 17:47:00 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB0CE5C1CF; Tue, 2 Feb 2021 17:46:59 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 08/14] qapi/introspect.py: create a typed 'Annotated' data strutcure Date: Tue, 2 Feb 2021 12:46:45 -0500 Message-Id: <20210202174651.2274166-9-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Presently, we use a tuple to attach a dict containing annotations (comments and compile-time conditionals) to a tree node. This is undesirable because dicts are difficult to strongly type; promoting it to a real class allows us to name the values and types of the annotations we are expecting. In terms of typing, the Annotated type serves as a generic container where the annotated node's type is preserved, allowing for greater specificity than we'd be able to provide without a generic. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 77 ++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index b82efe16f6e..2b90a52f016 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -13,8 +13,12 @@ from typing import ( Any, Dict, + Generic, + Iterable, List, Optional, + Tuple, + TypeVar, Union, ) @@ -51,15 +55,25 @@ _scalar = Union[str, bool, None] _nonscalar = Union[Dict[str, _stub], List[_stub]] _value = Union[_scalar, _nonscalar] -# TreeValue = Union[_value, 'Annotated[_value]'] +TreeValue = Union[_value, 'Annotated[_value]'] -def _make_tree(obj, ifcond, comment=None): - extra = { - 'if': ifcond, - 'comment': comment, - } - return (obj, extra) +_NodeT = TypeVar('_NodeT', bound=TreeValue) + + +class Annotated(Generic[_NodeT]): + """ + Annotated generally contains a SchemaInfo-like type (as a dict), + But it also used to wrap comments/ifconds around scalar leaf values, + for the benefit of features and enums. + """ + # Remove after 3.7 adds @dataclass: + # pylint: disable=too-few-public-methods + def __init__(self, value: _NodeT, ifcond: Iterable[str], + comment: Optional[str] = None): + self.value = value + self.comment: Optional[str] = comment + self.ifcond: Tuple[str, ...] = tuple(ifcond) def _tree_to_qlit(obj, level=0, suppress_first_indent=False): @@ -67,24 +81,20 @@ def _tree_to_qlit(obj, level=0, suppress_first_indent=False): def indent(level): return level * 4 * ' ' - if isinstance(obj, tuple): - ifobj, extra = obj - ifcond = extra.get('if') - comment = extra.get('comment') - + if isinstance(obj, Annotated): # NB: _tree_to_qlit is called recursively on the values of a key:value # pair; those values can't be decorated with comments or conditionals. msg = "dict values cannot have attached comments or if-conditionals." assert not suppress_first_indent, msg ret = '' - if comment: - ret += indent(level) + '/* %s */\n' % comment - if ifcond: - ret += gen_if(ifcond) - ret += _tree_to_qlit(ifobj, level) - if ifcond: - ret += '\n' + gen_endif(ifcond) + if obj.comment: + ret += indent(level) + '/* %s */\n' % obj.comment + if obj.ifcond: + ret += gen_if(obj.ifcond) + ret += _tree_to_qlit(obj.value, level, suppress_first_indent) + if obj.ifcond: + ret += '\n' + gen_endif(obj.ifcond) return ret ret = '' @@ -201,7 +211,7 @@ def _use_type(self, typ): @staticmethod def _gen_features(features): - return [_make_tree(f.name, f.ifcond) for f in features] + return [Annotated(f.name, f.ifcond) for f in features] def _gen_tree(self, name, mtype, obj, ifcond, features): comment: Optional[str] = None @@ -215,7 +225,7 @@ def _gen_tree(self, name, mtype, obj, ifcond, features): obj['meta-type'] = mtype if features: obj['features'] = self._gen_features(features) - self._trees.append(_make_tree(obj, ifcond, comment)) + self._trees.append(Annotated(obj, ifcond, comment)) def _gen_member(self, member): obj = {'name': member.name, 'type': self._use_type(member.type)} @@ -223,7 +233,7 @@ def _gen_member(self, member): obj['default'] = None if member.features: obj['features'] = self._gen_features(member.features) - return _make_tree(obj, member.ifcond) + return Annotated(obj, member.ifcond) def _gen_variants(self, tag_name, variants): return {'tag': tag_name, @@ -231,16 +241,17 @@ def _gen_variants(self, tag_name, variants): def _gen_variant(self, variant): obj = {'case': variant.name, 'type': self._use_type(variant.type)} - return _make_tree(obj, variant.ifcond) + return Annotated(obj, variant.ifcond) def visit_builtin_type(self, name, info, json_type): self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) def visit_enum_type(self, name, info, ifcond, features, members, prefix): - self._gen_tree(name, 'enum', - {'values': [_make_tree(m.name, m.ifcond, None) - for m in members]}, - ifcond, features) + self._gen_tree( + name, 'enum', + {'values': [Annotated(m.name, m.ifcond) for m in members]}, + ifcond, features + ) def visit_array_type(self, name, info, ifcond, element_type): element = self._use_type(element_type) @@ -257,12 +268,12 @@ def visit_object_type_flat(self, name, info, ifcond, features, self._gen_tree(name, 'object', obj, ifcond, features) def visit_alternate_type(self, name, info, ifcond, features, variants): - self._gen_tree(name, 'alternate', - {'members': [ - _make_tree({'type': self._use_type(m.type)}, - m.ifcond, None) - for m in variants.variants]}, - ifcond, features) + self._gen_tree(name, 'alternate', {'members': [ + Annotated({'type': self._use_type(m.type)}, m.ifcond) + for m in variants.variants + ]}, + ifcond, features + ) def visit_command(self, name, info, ifcond, features, arg_type, ret_type, gen, success_response, boxed, From patchwork Tue Feb 2 17:46:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DcIVq7Ni; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXSD4GxHz9tlP for ; Wed, 3 Feb 2021 04:51:40 +1100 (AEDT) Received: from localhost ([::1]:55698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zpy-0008W8-HJ for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:51:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlc-0004vx-O7 for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlY-0008Cy-Hx for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288023; h=from:from: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; bh=JIIHBaH5jer7KgMFZCSjC6Gf07YQuTK0ZAzFHouzS0s=; b=DcIVq7NiNKwcs+yYW1CiLBURD6lHik2YoWKWIkzGQW9Vg5TJRriJ40gAOh5hbNPAahyJvP FEbNAihk01vI81PTLWwuDXY6AeThWMn4ZLVfhR6P4F/t4zh030/n1mXsU9oxlxuOL2x+p+ 09b4cqcEaqbG1f4nSiK9Ae7YZ4deyPo= 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-174-KhTk3VFsNLiENT5k7n7aGw-1; Tue, 02 Feb 2021 12:47:02 -0500 X-MC-Unique: KhTk3VFsNLiENT5k7n7aGw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A8E31800D50; Tue, 2 Feb 2021 17:47:01 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F30F5C1CF; Tue, 2 Feb 2021 17:47:00 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 09/14] qapi/introspect.py: improve _tree_to_qlit error message Date: Tue, 2 Feb 2021 12:46:46 -0500 Message-Id: <20210202174651.2274166-10-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Trivial; make the error message just a pinch more explicit in case we trip this by accident in the future. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 2b90a52f016..c72beeeed27 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -124,7 +124,9 @@ def indent(level): elif isinstance(obj, bool): ret += 'QLIT_QBOOL(%s)' % ('true' if obj else 'false') else: - assert False # not implemented + raise NotImplementedError( + f"type '{type(obj).__name__}' not implemented" + ) if level > 0: ret += ',' return ret From patchwork Tue Feb 2 17:46:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434872 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EWERNjDP; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXYZ5FBzz9tlG for ; Wed, 3 Feb 2021 04:56:18 +1100 (AEDT) Received: from localhost ([::1]:37468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zuS-0004iB-JQ for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:56:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlb-0004tQ-O5 for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlZ-0008DQ-Jt for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288024; h=from:from: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; bh=96PaxVN1+MOOFep/lXNZxqncK3TVoXRtBdD76kel934=; b=EWERNjDPLJTyxA3lzF2SqbuY+iZT/sHG1dbYdGBfKHhNF6GSRtIPWCufjHTxuL5ohmS+dK +FULDiG7XUl5hPqjyDTgybH90fdKXm7x6fr49YkPqiBiORH9SWFQIcXzcLwFgMC72Xtrw0 gkTmvkXJlGhDuUbc1Sp80IIvZXj3+AQ= 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-497-ZK7X56dtPNKlHbK56pwOug-1; Tue, 02 Feb 2021 12:47:03 -0500 X-MC-Unique: ZK7X56dtPNKlHbK56pwOug-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F000107ACE3; Tue, 2 Feb 2021 17:47:02 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 822D65C1CF; Tue, 2 Feb 2021 17:47:01 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 10/14] qapi/introspect.py: improve readability of _tree_to_qlit Date: Tue, 2 Feb 2021 12:46:47 -0500 Message-Id: <20210202174651.2274166-11-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Subjective, but I find getting rid of the comprehensions helps. Also, divide the sections into scalar and non-scalar sections, and remove old-style string formatting. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index c72beeeed27..60ec326d2c7 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -89,7 +89,7 @@ def indent(level): ret = '' if obj.comment: - ret += indent(level) + '/* %s */\n' % obj.comment + ret += indent(level) + f"/* {obj.comment} */\n" if obj.ifcond: ret += gen_if(obj.ifcond) ret += _tree_to_qlit(obj.value, level, suppress_first_indent) @@ -100,33 +100,36 @@ def indent(level): ret = '' if not suppress_first_indent: ret += indent(level) + + # Scalars: if obj is None: ret += 'QLIT_QNULL' elif isinstance(obj, str): - ret += 'QLIT_QSTR(' + to_c_string(obj) + ')' + ret += f"QLIT_QSTR({to_c_string(obj)})" + elif isinstance(obj, bool): + ret += f"QLIT_QBOOL({str(obj).lower()})" + + # Non-scalars: elif isinstance(obj, list): - elts = [_tree_to_qlit(elt, level + 1).strip('\n') - for elt in obj] - elts.append(indent(level + 1) + "{}") ret += 'QLIT_QLIST(((QLitObject[]) {\n' - ret += '\n'.join(elts) + '\n' + for value in obj: + ret += _tree_to_qlit(value, level + 1).strip('\n') + '\n' + ret += indent(level + 1) + '{}\n' ret += indent(level) + '}))' elif isinstance(obj, dict): - elts = [] - for key, value in sorted(obj.items()): - elts.append(indent(level + 1) + '{ %s, %s }' % - (to_c_string(key), - _tree_to_qlit(value, level + 1, True))) - elts.append(indent(level + 1) + '{}') ret += 'QLIT_QDICT(((QLitDictEntry[]) {\n' - ret += ',\n'.join(elts) + '\n' + for key, value in sorted(obj.items()): + ret += indent(level + 1) + "{{ {:s}, {:s} }},\n".format( + to_c_string(key), + _tree_to_qlit(value, level + 1, suppress_first_indent=True) + ) + ret += indent(level + 1) + '{}\n' ret += indent(level) + '}))' - elif isinstance(obj, bool): - ret += 'QLIT_QBOOL(%s)' % ('true' if obj else 'false') else: raise NotImplementedError( f"type '{type(obj).__name__}' not implemented" ) + if level > 0: ret += ',' return ret From patchwork Tue Feb 2 17:46:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SZqV/zn8; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXXB1hPkz9tlG for ; Wed, 3 Feb 2021 04:55:06 +1100 (AEDT) Received: from localhost ([::1]:35752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6ztI-0003tH-67 for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:55:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zle-0004zq-5V for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlb-0008EW-Jk for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288026; h=from:from: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; bh=Ba6lItiflmZcaPCPB5SEdKY07Sr3A9ytgApkZOKRKnE=; b=SZqV/zn8qRb1RJKemZgIRhCJ/3Ry3bMKfC5jnCkRIPafnaDlourbyM+lkBh4R8uhChm8K9 LTWjrnckuz/OFGkFWqR63ihu5bWUYQ/AyUH36kkhg3/s9PZB9GrT/lR51sV3Qa9zJID6j5 uzZbKi51sNEBOPE5JXG+N3H+//hAOsU= 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-220-7MGDTRFQNkKgkJz4wzudyQ-1; Tue, 02 Feb 2021 12:47:04 -0500 X-MC-Unique: 7MGDTRFQNkKgkJz4wzudyQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 246DB1800D50; Tue, 2 Feb 2021 17:47:03 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6640C5C22B; Tue, 2 Feb 2021 17:47:02 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 11/14] qapi/introspect.py: add type hint annotations Date: Tue, 2 Feb 2021 12:46:48 -0500 Message-Id: <20210202174651.2274166-12-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- scripts/qapi/introspect.py | 115 ++++++++++++++++++++++++++----------- scripts/qapi/mypy.ini | 5 -- scripts/qapi/schema.py | 2 +- 3 files changed, 82 insertions(+), 40 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 60ec326d2c7..b7f2a6cf260 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -30,10 +30,19 @@ ) from .gen import QAPISchemaMonolithicCVisitor from .schema import ( + QAPISchema, QAPISchemaArrayType, QAPISchemaBuiltinType, + QAPISchemaEntity, + QAPISchemaEnumMember, + QAPISchemaFeature, + QAPISchemaObjectType, + QAPISchemaObjectTypeMember, QAPISchemaType, + QAPISchemaVariant, + QAPISchemaVariants, ) +from .source import QAPISourceInfo # This module constructs a tree data structure that is used to @@ -57,6 +66,8 @@ _value = Union[_scalar, _nonscalar] TreeValue = Union[_value, 'Annotated[_value]'] +# This is a (strict) alias for an arbitrary object non-scalar, as above: +_DObject = Dict[str, object] _NodeT = TypeVar('_NodeT', bound=TreeValue) @@ -76,9 +87,11 @@ def __init__(self, value: _NodeT, ifcond: Iterable[str], self.ifcond: Tuple[str, ...] = tuple(ifcond) -def _tree_to_qlit(obj, level=0, suppress_first_indent=False): +def _tree_to_qlit(obj: TreeValue, + level: int = 0, + suppress_first_indent: bool = False) -> str: - def indent(level): + def indent(level: int) -> str: return level * 4 * ' ' if isinstance(obj, Annotated): @@ -135,21 +148,21 @@ def indent(level): return ret -def to_c_string(string): +def to_c_string(string: str) -> str: return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"' class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithicCVisitor): - def __init__(self, prefix, unmask): + def __init__(self, prefix: str, unmask: bool): super().__init__( prefix, 'qapi-introspect', ' * QAPI/QMP schema introspection', __doc__) self._unmask = unmask - self._schema = None - self._trees = [] - self._used_types = [] - self._name_map = {} + self._schema: Optional[QAPISchema] = None + self._trees: List[Annotated[_DObject]] = [] + self._used_types: List[QAPISchemaType] = [] + self._name_map: Dict[str, str] = {} self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "%(prefix)sqapi-introspect.h" @@ -157,10 +170,10 @@ def __init__(self, prefix, unmask): ''', prefix=prefix)) - def visit_begin(self, schema): + def visit_begin(self, schema: QAPISchema) -> None: self._schema = schema - def visit_end(self): + def visit_end(self) -> None: # visit the types that are actually used for typ in self._used_types: typ.visit(self) @@ -182,18 +195,18 @@ def visit_end(self): self._used_types = [] self._name_map = {} - def visit_needed(self, entity): + def visit_needed(self, entity: QAPISchemaEntity) -> bool: # Ignore types on first pass; visit_end() will pick up used types return not isinstance(entity, QAPISchemaType) - def _name(self, name): + def _name(self, name: str) -> str: if self._unmask: return name if name not in self._name_map: self._name_map[name] = '%d' % len(self._name_map) return self._name_map[name] - def _use_type(self, typ): + def _use_type(self, typ: QAPISchemaType) -> str: assert self._schema is not None # Map the various integer types to plain int @@ -215,10 +228,13 @@ def _use_type(self, typ): return self._name(typ.name) @staticmethod - def _gen_features(features): + def _gen_features(features: List[QAPISchemaFeature] + ) -> List[Annotated[str]]: return [Annotated(f.name, f.ifcond) for f in features] - def _gen_tree(self, name, mtype, obj, ifcond, features): + def _gen_tree(self, name: str, mtype: str, obj: _DObject, + ifcond: List[str], + features: Optional[List[QAPISchemaFeature]]) -> None: comment: Optional[str] = None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: @@ -232,47 +248,67 @@ def _gen_tree(self, name, mtype, obj, ifcond, features): obj['features'] = self._gen_features(features) self._trees.append(Annotated(obj, ifcond, comment)) - def _gen_member(self, member): - obj = {'name': member.name, 'type': self._use_type(member.type)} + def _gen_member(self, member: QAPISchemaObjectTypeMember + ) -> Annotated[_DObject]: + obj: _DObject = { + 'name': member.name, + 'type': self._use_type(member.type) + } if member.optional: obj['default'] = None if member.features: obj['features'] = self._gen_features(member.features) return Annotated(obj, member.ifcond) - def _gen_variants(self, tag_name, variants): + def _gen_variants(self, tag_name: str, + variants: List[QAPISchemaVariant]) -> _DObject: return {'tag': tag_name, 'variants': [self._gen_variant(v) for v in variants]} - def _gen_variant(self, variant): - obj = {'case': variant.name, 'type': self._use_type(variant.type)} + def _gen_variant(self, variant: QAPISchemaVariant) -> Annotated[_DObject]: + obj: _DObject = { + 'case': variant.name, + 'type': self._use_type(variant.type) + } return Annotated(obj, variant.ifcond) - def visit_builtin_type(self, name, info, json_type): + def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo], + json_type: str) -> None: self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) - def visit_enum_type(self, name, info, ifcond, features, members, prefix): + def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], features: List[QAPISchemaFeature], + members: List[QAPISchemaEnumMember], + prefix: Optional[str]) -> None: self._gen_tree( name, 'enum', {'values': [Annotated(m.name, m.ifcond) for m in members]}, ifcond, features ) - def visit_array_type(self, name, info, ifcond, element_type): + def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], + element_type: QAPISchemaType) -> None: element = self._use_type(element_type) self._gen_tree('[' + element + ']', 'array', {'element-type': element}, ifcond, None) - def visit_object_type_flat(self, name, info, ifcond, features, - members, variants): - obj = {'members': [self._gen_member(m) for m in members]} + def visit_object_type_flat(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + members: List[QAPISchemaObjectTypeMember], + variants: Optional[QAPISchemaVariants]) -> None: + obj: _DObject = {'members': [self._gen_member(m) for m in members]} if variants: obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) self._gen_tree(name, 'object', obj, ifcond, features) - def visit_alternate_type(self, name, info, ifcond, features, variants): + def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + variants: QAPISchemaVariants) -> None: self._gen_tree(name, 'alternate', {'members': [ Annotated({'type': self._use_type(m.type)}, m.ifcond) for m in variants.variants @@ -280,27 +316,38 @@ def visit_alternate_type(self, name, info, ifcond, features, variants): ifcond, features ) - def visit_command(self, name, info, ifcond, features, - arg_type, ret_type, gen, success_response, boxed, - allow_oob, allow_preconfig, coroutine): + def visit_command(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + arg_type: Optional[QAPISchemaObjectType], + ret_type: Optional[QAPISchemaType], gen: bool, + success_response: bool, boxed: bool, allow_oob: bool, + allow_preconfig: bool, coroutine: bool) -> None: assert self._schema is not None arg_type = arg_type or self._schema.the_empty_object_type ret_type = ret_type or self._schema.the_empty_object_type - obj = {'arg-type': self._use_type(arg_type), - 'ret-type': self._use_type(ret_type)} + obj: _DObject = { + 'arg-type': self._use_type(arg_type), + 'ret-type': self._use_type(ret_type) + } if allow_oob: obj['allow-oob'] = allow_oob self._gen_tree(name, 'command', obj, ifcond, features) - def visit_event(self, name, info, ifcond, features, arg_type, boxed): + def visit_event(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], features: List[QAPISchemaFeature], + arg_type: Optional[QAPISchemaObjectType], + boxed: bool) -> None: assert self._schema is not None + arg_type = arg_type or self._schema.the_empty_object_type self._gen_tree(name, 'event', {'arg-type': self._use_type(arg_type)}, ifcond, features) -def gen_introspect(schema, output_dir, prefix, opt_unmask): +def gen_introspect(schema: QAPISchema, output_dir: str, prefix: str, + opt_unmask: bool) -> None: vis = QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) schema.visit(vis) vis.write(output_dir) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 04bd5db5278..0a000d58b37 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -13,11 +13,6 @@ disallow_untyped_defs = False disallow_incomplete_defs = False check_untyped_defs = False -[mypy-qapi.introspect] -disallow_untyped_defs = False -disallow_incomplete_defs = False -check_untyped_defs = False - [mypy-qapi.parser] disallow_untyped_defs = False disallow_incomplete_defs = False diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 353e8020a27..ff16578f6de 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -28,7 +28,7 @@ class QAPISchemaEntity: meta: Optional[str] = None - def __init__(self, name, info, doc, ifcond=None, features=None): + def __init__(self, name: str, info, doc, ifcond=None, features=None): assert name is None or isinstance(name, str) for f in features or []: assert isinstance(f, QAPISchemaFeature) From patchwork Tue Feb 2 17:46:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VRJHWMit; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXWR5MHwz9tlG for ; Wed, 3 Feb 2021 04:54:27 +1100 (AEDT) Received: from localhost ([::1]:35430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zsf-0003kl-LO for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:54:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zle-00051U-O0 for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zlc-0008El-Kl for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288028; h=from:from: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; bh=igXdpddoN154z3gheiDaIM2pkxAGZEJVxhZzCsNwTjc=; b=VRJHWMitfxGE+eV00yoCAuyWwgw95OGQbmGlYik4VA2x40ajRNY509mMl8l6iBRkuOoXp7 lWQHO1utmeETTW7qncMD5azXj5KticNBUdf85T3KogfgpZQYm0BYmZW0gK4m4ph4hhJDJz ElVQo31ZmUFdPg63Q9iPJkDTQi4Ncgg= 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-563-ZaCI4Ga2P5KuNzYMJVPAcQ-1; Tue, 02 Feb 2021 12:47:05 -0500 X-MC-Unique: ZaCI4Ga2P5KuNzYMJVPAcQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A3AC106BAED; Tue, 2 Feb 2021 17:47:04 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4ECA65C1CF; Tue, 2 Feb 2021 17:47:03 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 12/14] qapi/introspect.py: add introspect.json dummy types Date: Tue, 2 Feb 2021 12:46:49 -0500 Message-Id: <20210202174651.2274166-13-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add some aliases that declare intent for some of the "dictly-typed" objects we pass around in introspect.py. Signed-off-by: John Snow --- This patch is optional, it can be dropped if desired. It is purely for the sake of demonstrating what the _DObject was meant to convey: a Python Dict that represents some JSON Object. It does not add any type safety in and of itself, but does have some (light) annotational benefit. In this case, it's usually a specific data structure from the QAPI Schema we are referencing, but do not have "compile-time" access to in Python. These are loosely typed and don't bother reproducing the exact structure of the real types. Python 3.6 does not have support for TypedDict structures, so this is as good as we can do without involving a third-party library (e.g. Pydantic), in which we might be able to say: class SchemaMetaType(str, enum.Enum): BUILTIN = "builtin" ENUM = "enum" ARRAY = "array" OBJECT = "object" ALTERNATE = "alternate" COMMAND = "command" EVENT = "event" class SchemaInfo(pydantic.BaseModel): name: str meta-type: SchemaMetaType features: Optional[List[str]] data: Union[SchemaInfoBuiltin, SchemaInfoEnum, SchemaInfoArray, SchemaInfoObject, SchemaInfoAlternate, SchemaInfoCommand, SchemaInfoEvent] However, the cost of reproducing and keeping these structure definitions in-sync between the user-defined portion of the schema and the code generator is likely not worth doing any such thing. However, it does illustrate an interesting dependency the generator has on the user-defined schema itself in terms of types. So, I settled on using some light types that suggest the form of the object instead of enforcing the form. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 49 ++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index b7f2a6cf260..eb5d34cdb42 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -66,8 +66,15 @@ _value = Union[_scalar, _nonscalar] TreeValue = Union[_value, 'Annotated[_value]'] -# This is a (strict) alias for an arbitrary object non-scalar, as above: -_DObject = Dict[str, object] +# These types are based on structures defined in QEMU's schema, so we lack +# precise types for them here. Python 3.6 does not offer TypedDict constructs, +# so they are loosely typed here as simple python Dicts. +SchemaInfo = Dict[str, object] +SchemaInfoObject = Dict[str, object] +SchemaInfoObjectVariant = Dict[str, object] +SchemaInfoObjectMember = Dict[str, object] +SchemaInfoCommand = Dict[str, object] + _NodeT = TypeVar('_NodeT', bound=TreeValue) @@ -160,7 +167,7 @@ def __init__(self, prefix: str, unmask: bool): ' * QAPI/QMP schema introspection', __doc__) self._unmask = unmask self._schema: Optional[QAPISchema] = None - self._trees: List[Annotated[_DObject]] = [] + self._trees: List[Annotated[SchemaInfo]] = [] self._used_types: List[QAPISchemaType] = [] self._name_map: Dict[str, str] = {} self._genc.add(mcgen(''' @@ -232,9 +239,18 @@ def _gen_features(features: List[QAPISchemaFeature] ) -> List[Annotated[str]]: return [Annotated(f.name, f.ifcond) for f in features] - def _gen_tree(self, name: str, mtype: str, obj: _DObject, + def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object], ifcond: List[str], features: Optional[List[QAPISchemaFeature]]) -> None: + """ + Build and append a SchemaInfo object to self._trees. + + :param name: The entity's name. + :param mtype: The entity's meta-type. + :param obj: Additional entity fields, as appropriate for the meta-type. + :param ifcond: List of conditionals that apply to this entire entity. + :param features: Optional features field for SchemaInfo. + """ comment: Optional[str] = None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: @@ -249,8 +265,8 @@ def _gen_tree(self, name: str, mtype: str, obj: _DObject, self._trees.append(Annotated(obj, ifcond, comment)) def _gen_member(self, member: QAPISchemaObjectTypeMember - ) -> Annotated[_DObject]: - obj: _DObject = { + ) -> Annotated[SchemaInfoObjectMember]: + obj: SchemaInfoObjectMember = { 'name': member.name, 'type': self._use_type(member.type) } @@ -260,13 +276,9 @@ def _gen_member(self, member: QAPISchemaObjectTypeMember obj['features'] = self._gen_features(member.features) return Annotated(obj, member.ifcond) - def _gen_variants(self, tag_name: str, - variants: List[QAPISchemaVariant]) -> _DObject: - return {'tag': tag_name, - 'variants': [self._gen_variant(v) for v in variants]} - - def _gen_variant(self, variant: QAPISchemaVariant) -> Annotated[_DObject]: - obj: _DObject = { + def _gen_variant(self, variant: QAPISchemaVariant + ) -> Annotated[SchemaInfoObjectVariant]: + obj: SchemaInfoObjectVariant = { 'case': variant.name, 'type': self._use_type(variant.type) } @@ -298,11 +310,12 @@ def visit_object_type_flat(self, name: str, info: Optional[QAPISourceInfo], features: List[QAPISchemaFeature], members: List[QAPISchemaObjectTypeMember], variants: Optional[QAPISchemaVariants]) -> None: - obj: _DObject = {'members': [self._gen_member(m) for m in members]} + obj: SchemaInfoObject = { + 'members': [self._gen_member(m) for m in members] + } if variants: - obj.update(self._gen_variants(variants.tag_member.name, - variants.variants)) - + obj['tag'] = variants.tag_member.name + obj['variants'] = [self._gen_variant(v) for v in variants.variants] self._gen_tree(name, 'object', obj, ifcond, features) def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo], @@ -327,7 +340,7 @@ def visit_command(self, name: str, info: Optional[QAPISourceInfo], arg_type = arg_type or self._schema.the_empty_object_type ret_type = ret_type or self._schema.the_empty_object_type - obj: _DObject = { + obj: SchemaInfoCommand = { 'arg-type': self._use_type(arg_type), 'ret-type': self._use_type(ret_type) } From patchwork Tue Feb 2 17:46:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bpUwPVNv; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXdG50YCz9tlM for ; Wed, 3 Feb 2021 04:59:30 +1100 (AEDT) Received: from localhost ([::1]:44058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zxY-00086K-LW for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 12:59:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlf-00053t-Ml for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zle-0008Fp-0Y for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288029; h=from:from: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; bh=GftNvl9QqS+qriNjqxWY8yBmQfUNiK84j48aT3ZfqnI=; b=bpUwPVNvGIjZBrvjqkd7mp2+mpT/oUkGZG3X01fbyLr25wEEGdJ77nXRl0SWMGHmNlLES7 9UaO8iwDAhAUo+iNr5o5flUUIHUfLTV40sKW6n/8+5wlcaUg/PjVCqMi1wW+6Lqc87aOYd ffI6iTB07XDn7GfwzhcLbWoGBOL03Es= 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-372-RkRTVukKPcSMV6d-RYSrKg-1; Tue, 02 Feb 2021 12:47:06 -0500 X-MC-Unique: RkRTVukKPcSMV6d-RYSrKg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1374107ACE3; Tue, 2 Feb 2021 17:47:04 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 312A75C1CF; Tue, 2 Feb 2021 17:47:04 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 13/14] qapi/introspect.py: Add docstring to _tree_to_qlit Date: Tue, 2 Feb 2021 12:46:50 -0500 Message-Id: <20210202174651.2274166-14-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- scripts/qapi/introspect.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index eb5d34cdb42..3e59caf7d4d 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -97,6 +97,13 @@ def __init__(self, value: _NodeT, ifcond: Iterable[str], def _tree_to_qlit(obj: TreeValue, level: int = 0, suppress_first_indent: bool = False) -> str: + """ + Convert the type tree into a QLIT C string, recursively. + + :param obj: The value to convert. + :param level: The indentation level for this particular value. + :param suppress_first_indent: True for dict value children. + """ def indent(level: int) -> str: return level * 4 * ' ' From patchwork Tue Feb 2 17:46:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 1434878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z30LGmFm; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVXfb29bLz9sVF for ; Wed, 3 Feb 2021 05:00:39 +1100 (AEDT) Received: from localhost ([::1]:46154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6zyf-0000bj-74 for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2021 13:00:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6zlf-00052n-8V for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6zld-0008FO-I6 for qemu-devel@nongnu.org; Tue, 02 Feb 2021 12:47:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612288028; h=from:from: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; bh=Wc+/HVD+JUT3BB8ApyOe2tjoujvknFEE3Ny6WjFYXjw=; b=Z30LGmFm0U/1EyJcdkZj0GIMq9GOhqvbeYqURq2ph9zY+hg2v+HgvTV7QnmyEX19TRISJZ /oN44tYfQ7/2mObkhgybfpsWJKRmWrfq2WMJs645vTQfJblp0hlDQF8WqP8zeFtCibeeqy m6Q/r9kp3da2qWqVFVStvRQyAbO5FGc= 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-222-CD_LTG1dN1KHfyJklr_FYw-1; Tue, 02 Feb 2021 12:47:07 -0500 X-MC-Unique: CD_LTG1dN1KHfyJklr_FYw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47915107ACFC; Tue, 2 Feb 2021 17:47:06 +0000 (UTC) Received: from scv.redhat.com (ovpn-112-247.rdu2.redhat.com [10.10.112.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1454A5C1CF; Tue, 2 Feb 2021 17:47:04 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH v4 14/14] qapi/introspect.py: Update copyright and authors list Date: Tue, 2 Feb 2021 12:46:51 -0500 Message-Id: <20210202174651.2274166-15-jsnow@redhat.com> In-Reply-To: <20210202174651.2274166-1-jsnow@redhat.com> References: <20210202174651.2274166-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.386, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , John Snow , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: John Snow --- scripts/qapi/introspect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 3e59caf7d4d..df2bb50df32 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -1,10 +1,11 @@ """ QAPI introspection generator -Copyright (C) 2015-2018 Red Hat, Inc. +Copyright (C) 2015-2020 Red Hat, Inc. Authors: Markus Armbruster + John Snow This work is licensed under the terms of the GNU GPL, version 2. See the COPYING file in the top-level directory.