mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 14:51:00 +00:00
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:
parent
9b10264eea
commit
2ba3229cbb
|
@ -1074,26 +1074,26 @@ class QAPISchemaVisitor(object):
|
||||||
def visit_builtin_type(self, name, info, json_type):
|
def visit_builtin_type(self, name, info, json_type):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_enum_type(self, name, info, values, prefix):
|
def visit_enum_type(self, name, info, ifcond, values, prefix):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_array_type(self, name, info, element_type):
|
def visit_array_type(self, name, info, ifcond, element_type):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_object_type(self, name, info, base, members, variants):
|
def visit_object_type(self, name, info, ifcond, base, members, variants):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_object_type_flat(self, name, info, members, variants):
|
def visit_object_type_flat(self, name, info, ifcond, members, variants):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_alternate_type(self, name, info, variants):
|
def visit_alternate_type(self, name, info, ifcond, variants):
|
||||||
pass
|
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):
|
success_response, boxed, allow_oob, allow_preconfig):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_event(self, name, info, arg_type, boxed):
|
def visit_event(self, name, info, ifcond, arg_type, boxed):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -1203,7 +1203,7 @@ class QAPISchemaEnumType(QAPISchemaType):
|
||||||
return 'string'
|
return 'string'
|
||||||
|
|
||||||
def visit(self, visitor):
|
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)
|
self.member_names(), self.prefix)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1237,7 +1237,8 @@ class QAPISchemaArrayType(QAPISchemaType):
|
||||||
return 'array of ' + elt_doc_type
|
return 'array of ' + elt_doc_type
|
||||||
|
|
||||||
def visit(self, visitor):
|
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):
|
class QAPISchemaObjectType(QAPISchemaType):
|
||||||
|
@ -1319,9 +1320,9 @@ class QAPISchemaObjectType(QAPISchemaType):
|
||||||
return 'object'
|
return 'object'
|
||||||
|
|
||||||
def visit(self, visitor):
|
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)
|
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)
|
self.members, self.variants)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1474,7 +1475,8 @@ class QAPISchemaAlternateType(QAPISchemaType):
|
||||||
return 'value'
|
return 'value'
|
||||||
|
|
||||||
def visit(self, visitor):
|
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):
|
def is_empty(self):
|
||||||
return False
|
return False
|
||||||
|
@ -1517,7 +1519,7 @@ class QAPISchemaCommand(QAPISchemaEntity):
|
||||||
assert isinstance(self.ret_type, QAPISchemaType)
|
assert isinstance(self.ret_type, QAPISchemaType)
|
||||||
|
|
||||||
def visit(self, visitor):
|
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.arg_type, self.ret_type,
|
||||||
self.gen, self.success_response,
|
self.gen, self.success_response,
|
||||||
self.boxed, self.allow_oob,
|
self.boxed, self.allow_oob,
|
||||||
|
@ -1550,7 +1552,8 @@ class QAPISchemaEvent(QAPISchemaEntity):
|
||||||
raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
|
raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
|
||||||
|
|
||||||
def visit(self, visitor):
|
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):
|
class QAPISchema(object):
|
||||||
|
|
|
@ -184,7 +184,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor):
|
||||||
genh.add(gen_enum(self._enum_name, self._event_names))
|
genh.add(gen_enum(self._enum_name, self._event_names))
|
||||||
genc.add(gen_enum_lookup(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._genh.add(gen_event_send_decl(name, arg_type, boxed))
|
||||||
self._genc.add(gen_event_send(name, arg_type, boxed, self._enum_name))
|
self._genc.add(gen_event_send(name, arg_type, boxed, self._enum_name))
|
||||||
self._event_names.append(name)
|
self._event_names.append(name)
|
||||||
|
|
|
@ -208,16 +208,16 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
||||||
self._genh.add(gen_type_cleanup_decl(name))
|
self._genh.add(gen_type_cleanup_decl(name))
|
||||||
self._genc.add(gen_type_cleanup(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._genh.preamble_add(gen_enum(name, values, prefix))
|
||||||
self._genc.add(gen_enum_lookup(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.preamble_add(gen_fwd_object_or_array(name))
|
||||||
self._genh.add(gen_array(name, element_type))
|
self._genh.add(gen_array(name, element_type))
|
||||||
self._gen_type_cleanup(name)
|
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
|
# Nothing to do for the special empty builtin
|
||||||
if name == 'q_empty':
|
if name == 'q_empty':
|
||||||
return
|
return
|
||||||
|
@ -231,7 +231,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
||||||
# implicit types won't be directly allocated/freed
|
# implicit types won't be directly allocated/freed
|
||||||
self._gen_type_cleanup(name)
|
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.preamble_add(gen_fwd_object_or_array(name))
|
||||||
self._genh.add(gen_object(name, None,
|
self._genh.add(gen_object(name, None,
|
||||||
[variants.tag_member], variants))
|
[variants.tag_member], variants))
|
||||||
|
|
|
@ -310,15 +310,15 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
||||||
''',
|
''',
|
||||||
types=types))
|
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._genh.add(gen_visit_decl(name, scalar=True))
|
||||||
self._genc.add(gen_visit_enum(name))
|
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._genh.add(gen_visit_decl(name))
|
||||||
self._genc.add(gen_visit_list(name, element_type))
|
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
|
# Nothing to do for the special empty builtin
|
||||||
if name == 'q_empty':
|
if name == 'q_empty':
|
||||||
return
|
return
|
||||||
|
@ -331,7 +331,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
||||||
self._genh.add(gen_visit_decl(name))
|
self._genh.add(gen_visit_decl(name))
|
||||||
self._genc.add(gen_visit_object(name, base, members, variants))
|
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._genh.add(gen_visit_decl(name))
|
||||||
self._genc.add(gen_visit_alternate(name, variants))
|
self._genc.add(gen_visit_alternate(name, variants))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue