qapi: add 'ifcond' to visitor methods

Modify the test visitor to check correct passing of values.

Backports commit fbf09a2fa4d9460033023e56cc1b195be053b353 from qemu
This commit is contained in:
Marc-André Lureau 2018-07-05 12:04:06 -04:00 committed by Lioncash
parent 9b10264eea
commit 2ba3229cbb
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
4 changed files with 26 additions and 23 deletions

View file

@ -1074,26 +1074,26 @@ class QAPISchemaVisitor(object):
def visit_builtin_type(self, name, info, json_type):
pass
def visit_enum_type(self, name, info, values, prefix):
def visit_enum_type(self, name, info, ifcond, values, prefix):
pass
def visit_array_type(self, name, info, element_type):
def visit_array_type(self, name, info, ifcond, element_type):
pass
def visit_object_type(self, name, info, base, members, variants):
def visit_object_type(self, name, info, ifcond, base, members, variants):
pass
def visit_object_type_flat(self, name, info, members, variants):
def visit_object_type_flat(self, name, info, ifcond, members, variants):
pass
def visit_alternate_type(self, name, info, variants):
def visit_alternate_type(self, name, info, ifcond, variants):
pass
def visit_command(self, name, info, arg_type, ret_type, gen,
def visit_command(self, name, info, ifcond, arg_type, ret_type, gen,
success_response, boxed, allow_oob, allow_preconfig):
pass
def visit_event(self, name, info, arg_type, boxed):
def visit_event(self, name, info, ifcond, arg_type, boxed):
pass
@ -1203,7 +1203,7 @@ class QAPISchemaEnumType(QAPISchemaType):
return 'string'
def visit(self, visitor):
visitor.visit_enum_type(self.name, self.info,
visitor.visit_enum_type(self.name, self.info, self.ifcond,
self.member_names(), self.prefix)
@ -1237,7 +1237,8 @@ class QAPISchemaArrayType(QAPISchemaType):
return 'array of ' + elt_doc_type
def visit(self, visitor):
visitor.visit_array_type(self.name, self.info, self.element_type)
visitor.visit_array_type(self.name, self.info, self.ifcond,
self.element_type)
class QAPISchemaObjectType(QAPISchemaType):
@ -1319,9 +1320,9 @@ class QAPISchemaObjectType(QAPISchemaType):
return 'object'
def visit(self, visitor):
visitor.visit_object_type(self.name, self.info,
visitor.visit_object_type(self.name, self.info, self.ifcond,
self.base, self.local_members, self.variants)
visitor.visit_object_type_flat(self.name, self.info,
visitor.visit_object_type_flat(self.name, self.info, self.ifcond,
self.members, self.variants)
@ -1474,7 +1475,8 @@ class QAPISchemaAlternateType(QAPISchemaType):
return 'value'
def visit(self, visitor):
visitor.visit_alternate_type(self.name, self.info, self.variants)
visitor.visit_alternate_type(self.name, self.info, self.ifcond,
self.variants)
def is_empty(self):
return False
@ -1517,7 +1519,7 @@ class QAPISchemaCommand(QAPISchemaEntity):
assert isinstance(self.ret_type, QAPISchemaType)
def visit(self, visitor):
visitor.visit_command(self.name, self.info,
visitor.visit_command(self.name, self.info, self.ifcond,
self.arg_type, self.ret_type,
self.gen, self.success_response,
self.boxed, self.allow_oob,
@ -1550,7 +1552,8 @@ class QAPISchemaEvent(QAPISchemaEntity):
raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
def visit(self, visitor):
visitor.visit_event(self.name, self.info, self.arg_type, self.boxed)
visitor.visit_event(self.name, self.info, self.ifcond,
self.arg_type, self.boxed)
class QAPISchema(object):

View file

@ -184,7 +184,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor):
genh.add(gen_enum(self._enum_name, self._event_names))
genc.add(gen_enum_lookup(self._enum_name, self._event_names))
def visit_event(self, name, info, arg_type, boxed):
def visit_event(self, name, info, ifcond, arg_type, boxed):
self._genh.add(gen_event_send_decl(name, arg_type, boxed))
self._genc.add(gen_event_send(name, arg_type, boxed, self._enum_name))
self._event_names.append(name)

View file

@ -208,16 +208,16 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
self._genh.add(gen_type_cleanup_decl(name))
self._genc.add(gen_type_cleanup(name))
def visit_enum_type(self, name, info, values, prefix):
def visit_enum_type(self, name, info, ifcond, values, prefix):
self._genh.preamble_add(gen_enum(name, values, prefix))
self._genc.add(gen_enum_lookup(name, values, prefix))
def visit_array_type(self, name, info, element_type):
def visit_array_type(self, name, info, ifcond, element_type):
self._genh.preamble_add(gen_fwd_object_or_array(name))
self._genh.add(gen_array(name, element_type))
self._gen_type_cleanup(name)
def visit_object_type(self, name, info, base, members, variants):
def visit_object_type(self, name, info, ifcond, base, members, variants):
# Nothing to do for the special empty builtin
if name == 'q_empty':
return
@ -231,7 +231,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
# implicit types won't be directly allocated/freed
self._gen_type_cleanup(name)
def visit_alternate_type(self, name, info, variants):
def visit_alternate_type(self, name, info, ifcond, variants):
self._genh.preamble_add(gen_fwd_object_or_array(name))
self._genh.add(gen_object(name, None,
[variants.tag_member], variants))

View file

@ -310,15 +310,15 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
''',
types=types))
def visit_enum_type(self, name, info, values, prefix):
def visit_enum_type(self, name, info, ifcond, values, prefix):
self._genh.add(gen_visit_decl(name, scalar=True))
self._genc.add(gen_visit_enum(name))
def visit_array_type(self, name, info, element_type):
def visit_array_type(self, name, info, ifcond, element_type):
self._genh.add(gen_visit_decl(name))
self._genc.add(gen_visit_list(name, element_type))
def visit_object_type(self, name, info, base, members, variants):
def visit_object_type(self, name, info, ifcond, base, members, variants):
# Nothing to do for the special empty builtin
if name == 'q_empty':
return
@ -331,7 +331,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
self._genh.add(gen_visit_decl(name))
self._genc.add(gen_visit_object(name, base, members, variants))
def visit_alternate_type(self, name, info, variants):
def visit_alternate_type(self, name, info, ifcond, variants):
self._genh.add(gen_visit_decl(name))
self._genc.add(gen_visit_alternate(name, variants))