@@ -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.
@@ -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