From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXVXC-0004QR-Ms for qemu-devel@nongnu.org; Thu, 03 Sep 2015 10:30:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXVXB-0005hG-A0 for qemu-devel@nongnu.org; Thu, 03 Sep 2015 10:30:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXVXA-0005gm-Vc for qemu-devel@nongnu.org; Thu, 03 Sep 2015 10:30:37 -0400 From: Markus Armbruster Date: Thu, 3 Sep 2015 16:30:22 +0200 Message-Id: <1441290623-13631-32-git-send-email-armbru@redhat.com> In-Reply-To: <1441290623-13631-1-git-send-email-armbru@redhat.com> References: <1441290623-13631-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH RFC v4 31/32] qapi-introspect: Map all integer types to 'int' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com How many bits we use internally is an implementation detail. It could be pressed into external interface service as very approximate range information, but that's probably a bad idea. If we need range information, we better do it properly. Reduces output of query-schema by a negligible 0.5 out of 85KiB. Signed-off-by: Markus Armbruster --- docs/qapi-code-gen.txt | 11 ++++++++--- scripts/qapi-introspect.py | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index 1f8f891..a079b51 100644 --- a/docs/qapi-code-gen.txt +++ b/docs/qapi-code-gen.txt @@ -662,14 +662,19 @@ Example: the SchemaInfo for MyEnum from section Enumeration types "values": [ "value1", "value2", "value3" ] } The SchemaInfo for a built-in type has the same name as the type in -the QAPI schema (see section Built-in Types). It has variant member -"json-type" that shows how values of this type are encoded on the -wire. +the QAPI schema (see section Built-in Types), with one exception +detailed below. It has variant member "json-type" that shows how +values of this type are encoded on the wire. Example: the SchemaInfo for str { "name": "str", "meta-type": "builtin", "json-type": "string" } +The QAPI schema supports a number of integer types that only differ in +how they map to C. They are identical as far as SchemaInfo is +concerned. Therefore, they get all mapped to a single type "int" in +SchemaInfo. + As explained above, type names are not part of the wire ABI. Not even the names of built-in types. Clients should examine member "json-type" instead of hard-coding names of built-in types. diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 4bcffc4..2f6a4c6 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -74,6 +74,13 @@ const char %(c_name)s[] = %(c_string)s; self.used_types = None def _use_type(self, typ): + # Map the various integer types to plain int + if typ.json_type() == 'int': + typ = self.schema.lookup_type('int') + elif isinstance(typ, QAPISchemaArrayType) \ + and typ.element_type.json_type() == 'int': + typ = self.schema.lookup_type('intList') + # Add type to work queue if new if typ not in self.used_types: self.used_types.append(typ) return typ.name -- 2.4.3