[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 12/50] qapi-introspect: add preprocessor conditio
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v3 12/50] qapi-introspect: add preprocessor conditions to generated QLit |
Date: |
Mon, 11 Sep 2017 13:05:45 +0200 |
Add 'ifcond' condition to top-level QLit objects.
to_qlit() handles the (obj, ifcond) tuples in previous patch.
Signed-off-by: Marc-André Lureau <address@hidden>
---
scripts/qapi-introspect.py | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index dc70954e8a..69d9afc792 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -128,12 +128,12 @@ const QLitObject %(c_name)s = %(c_string)s;
return '[' + self._use_type(typ.element_type) + ']'
return self._name(typ.name)
- def _gen_qlit(self, name, mtype, obj):
+ def _gen_qlit(self, name, mtype, obj, ifcond):
if mtype not in ('command', 'event', 'builtin', 'array'):
name = self._name(name)
obj['name'] = name
obj['meta-type'] = mtype
- self._qlits.append(obj)
+ self._qlits.append((obj, ifcond))
def _gen_member(self, member):
ret = {'name': member.name, 'type': self._use_type(member.type)}
@@ -149,26 +149,27 @@ const QLitObject %(c_name)s = %(c_string)s;
return {'case': variant.name, 'type': self._use_type(variant.type)}
def visit_builtin_type(self, name, info, json_type):
- self._gen_qlit(name, 'builtin', {'json-type': json_type})
+ self._gen_qlit(name, 'builtin', {'json-type': json_type}, None)
def visit_enum_type(self, name, info, ifcond, values, prefix):
- self._gen_qlit(name, 'enum', {'values': values})
+ self._gen_qlit(name, 'enum', {'values': values}, ifcond)
def visit_array_type(self, name, info, ifcond, element_type):
element = self._use_type(element_type)
- self._gen_qlit('[' + element + ']', 'array', {'element-type': element})
+ self._gen_qlit('[' + element + ']', 'array', {'element-type': element},
+ ifcond)
def visit_object_type_flat(self, name, info, ifcond, members, variants):
obj = {'members': [self._gen_member(m) for m in members]}
if variants:
obj.update(self._gen_variants(variants.tag_member.name,
variants.variants))
- self._gen_qlit(name, 'object', obj)
+ self._gen_qlit(name, 'object', obj, ifcond)
def visit_alternate_type(self, name, info, ifcond, variants):
self._gen_qlit(name, 'alternate',
{'members': [{'type': self._use_type(m.type)}
- for m in variants.variants]})
+ for m in variants.variants]}, ifcond)
def visit_command(self, name, info, ifcond, arg_type, ret_type,
gen, success_response, boxed):
@@ -176,11 +177,12 @@ const QLitObject %(c_name)s = %(c_string)s;
ret_type = ret_type or self._schema.the_empty_object_type
self._gen_qlit(name, 'command',
{'arg-type': self._use_type(arg_type),
- 'ret-type': self._use_type(ret_type)})
+ 'ret-type': self._use_type(ret_type)}, ifcond)
def visit_event(self, name, info, ifcond, arg_type, boxed):
arg_type = arg_type or self._schema.the_empty_object_type
- self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type)})
+ self._gen_qlit(name, 'event', {'arg-type': self._use_type(arg_type)},
+ ifcond)
# Debugging aid: unmask QAPI schema's type names
# We normally mask them, because they're not QMP wire ABI
--
2.14.1.146.gd35faa819
- [Qemu-devel] [PATCH v3 02/50] qapi: generate a literal qobject for introspection, (continued)
- [Qemu-devel] [PATCH v3 02/50] qapi: generate a literal qobject for introspection, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 01/50] qlit: add qobject_from_qlit(), Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 04/50] qapi: add 'if' to top-level expressions, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 05/50] qapi: add tests for invalid 'if', Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 07/50] qapi: add 'ifcond' to visitor methods, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 06/50] qapi: pass 'if' condition into QAPISchemaEntity objects, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 08/50] qapi: mcgen() shouldn't indent # lines, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 10/50] qapi-introspect: modify to_qlit() to append ', ' on level > 0, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 11/50] qapi-introspect: modify to_qlit() to generate #if code, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 09/50] qapi: add #if/#endif helpers, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 12/50] qapi-introspect: add preprocessor conditions to generated QLit,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v3 13/50] qapi-commands: add #if conditions to commands, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 14/50] qapi-event: add #if conditions to events, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 17/50] qapi: do not define enumeration value explicitely, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 16/50] qapi-types: add #if conditions to types & visitors, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 15/50] qapi-types: refactor variants handling, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 19/50] qapi: add 'if' to enum members, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 18/50] qapi: change enum visitor to take QAPISchemaMember, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 21/50] qapi: add #if conditions on generated enum members, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 20/50] qapi-event: add 'if' condition to generated enum, Marc-André Lureau, 2017/09/11
- [Qemu-devel] [PATCH v3 23/50] qapi: add 'if' to struct members and implicit objects members, Marc-André Lureau, 2017/09/11