[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC v5 31/32] qapi-introspect: Map all integer types
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH RFC v5 31/32] qapi-introspect: Map all integer types to 'int' |
Date: |
Mon, 7 Sep 2015 12:16:42 +0200 |
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
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 893a6f6..458b217 100644
--- a/docs/qapi-code-gen.txt
+++ b/docs/qapi-code-gen.txt
@@ -668,14 +668,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 754f263..1bc26f0 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -77,6 +77,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
- [Qemu-devel] [PATCH RFC v5 13/32] qapi: De-duplicate enum code generation, (continued)
- [Qemu-devel] [PATCH RFC v5 13/32] qapi: De-duplicate enum code generation, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 08/32] Revert "qapi: Generate comments to simplify splitting for review", Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 12/32] qapi-commands: Convert to QAPISchemaVisitor, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 05/32] tests/qapi-schema: Convert test harness to QAPISchemaVisitor, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 18/32] qapi: Replace dirty is_c_ptr() by method c_null(), Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 02/32] qapi: New QAPISchema intermediate reperesentation, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 15/32] qapi-event: Convert to QAPISchemaVisitor, fixing data with base, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 11/32] qapi-visit: Convert to QAPISchemaVisitor, fixing bugs, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 20/32] qapi-visit: Rearrange code a bit, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 25/32] qapi: Improve built-in type documentation, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 31/32] qapi-introspect: Map all integer types to 'int',
Markus Armbruster <=
- [Qemu-devel] [PATCH RFC v5 23/32] qapi: De-duplicate parameter list generation, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 16/32] qapi: Generate comments to simplify splitting for review, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 28/32] qapi-schema: Fix up misleading specification of netdev_add, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 17/32] Revert "qapi: Generate comments to simplify splitting for review", Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 24/32] qapi-commands: De-duplicate output marshaling functions, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 32/32] qapi-introspect: Hide type names, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 27/32] qom: Don't use 'gen': false for qom-get, qom-set, object-add, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 26/32] qapi: Introduce a first class 'any' type, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 29/32] qapi: Pseudo-type '**' is now unused, drop it, Markus Armbruster, 2015/09/07
- [Qemu-devel] [PATCH RFC v5 21/32] qapi-commands: Rearrange code, Markus Armbruster, 2015/09/07