qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC v3 32/32] qapi-introspect: Hide type names


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH RFC v3 32/32] qapi-introspect: Hide type names
Date: Wed, 5 Aug 2015 15:50:42 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

On 08/05/2015 03:06 PM, Eric Blake wrote:
> On 08/04/2015 09:58 AM, Markus Armbruster wrote:
>> To eliminate the temptation for clients to look up types by name
>> (which are not ABI), replace all type names by meaningless strings.
>>
>> Reduces output of query-schema by 13 out of 85KiB.
> 
> I'm starting to be more in favor of this patch, both for ABI reasons and
> for size shavings.  It definitely looks better than in v2, where munged
> names are just an arbitrary number, and where builtins are not munged.
> 
>>
>> TODO Either generate comments with the true type names, or provide an
>> option to generate without type name hiding.
> 
> See also my comments on 30/32 about whether we should mask array types
> differently (and yes, the lack of comments made it a bit harder to chase
> down types for my commentary in that mail).

In fact, squashing this in was all the more I needed to implement the
proposal there:

diff --git i/scripts/qapi-introspect.py w/scripts/qapi-introspect.py
index 5e99d4b..d723ef1 100644
--- i/scripts/qapi-introspect.py
+++ w/scripts/qapi-introspect.py
@@ -97,10 +97,12 @@ const char %(c_name)s[] = %(c_string)s;
         # characters.
         if isinstance(typ, QAPISchemaBuiltinType):
             return typ.name
+        if isinstance(typ, QAPISchemaArrayType):
+            return '[' + self._use_type(typ.element_type) + ']'
         return self._name(typ.name)

     def _gen_json(self, name, mtype, obj={}):
-        if mtype != 'command' and mtype != 'event' and mtype != 'builtin':
+        if mtype not in ('command', 'event', 'builtin', 'array'):
             name = self._name(name)
         obj['name'] = name
         obj['meta-type'] = mtype
@@ -126,8 +128,9 @@ const char %(c_name)s[] = %(c_string)s;
         self._gen_json(name, 'enum', { 'values': values })

     def visit_array_type(self, name, info, element_type):
-        self._gen_json(name, 'array',
-                       { 'element-type': self._use_type(element_type) })
+        element = self._use_type(element_type)
+        self._gen_json('[' + element + ']', 'array',
+                       { 'element-type': element })

     def visit_object_type_flat(self, name, info, members, variants):
         obj = { 'members': [self._gen_member(m) for m in members] }

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]