diff --git a/msvc/unicorn/qapi-visit.c b/msvc/unicorn/qapi-visit.c index 6cd3b0f0..e6db06b3 100644 --- a/msvc/unicorn/qapi-visit.c +++ b/msvc/unicorn/qapi-visit.c @@ -16,7 +16,7 @@ #include "qemu-common.h" #include "qapi-visit.h" -static void visit_type_DummyForceArrays_members(Visitor *v, DummyForceArrays *obj, Error **errp) +void visit_type_DummyForceArrays_members(Visitor *v, DummyForceArrays *obj, Error **errp) { Error *err = NULL; @@ -63,7 +63,7 @@ void visit_type_QapiErrorClass(Visitor *v, const char *name, QapiErrorClass *obj *obj = value; } -static void visit_type_X86CPUFeatureWordInfo_members(Visitor *v, X86CPUFeatureWordInfo *obj, Error **errp) +void visit_type_X86CPUFeatureWordInfo_members(Visitor *v, X86CPUFeatureWordInfo *obj, Error **errp) { Error *err = NULL; diff --git a/msvc/unicorn/qapi-visit.h b/msvc/unicorn/qapi-visit.h index 798a3910..865cd2a8 100644 --- a/msvc/unicorn/qapi-visit.h +++ b/msvc/unicorn/qapi-visit.h @@ -42,8 +42,12 @@ void visit_type_uint8List(Visitor *v, const char *name, uint8List **obj, Error * #endif /* QAPI_VISIT_BUILTIN */ + +void visit_type_DummyForceArrays_members(Visitor *v, DummyForceArrays *obj, Error **errp); void visit_type_DummyForceArrays(Visitor *v, const char *name, DummyForceArrays **obj, Error **errp); void visit_type_QapiErrorClass(Visitor *v, const char *name, QapiErrorClass *obj, Error **errp); + +void visit_type_X86CPUFeatureWordInfo_members(Visitor *v, X86CPUFeatureWordInfo *obj, Error **errp); void visit_type_X86CPUFeatureWordInfo(Visitor *v, const char *name, X86CPUFeatureWordInfo **obj, Error **errp); void visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name, X86CPUFeatureWordInfoList **obj, Error **errp); void visit_type_X86CPURegister32(Visitor *v, const char *name, X86CPURegister32 *obj, Error **errp); diff --git a/qemu/scripts/qapi-visit.py b/qemu/scripts/qapi-visit.py index f036849f..726c8b5f 100644 --- a/qemu/scripts/qapi-visit.py +++ b/qemu/scripts/qapi-visit.py @@ -15,10 +15,6 @@ from qapi import * import re -# visit_type_FOO_members() is always emitted; track if a forward declaration -# or implementation has already been output. -object_members_seen = set() - def gen_visit_decl(name, scalar=False): c_type = c_name(name) + ' *' if not scalar: @@ -29,37 +25,23 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error ** c_name=c_name(name), c_type=c_type) -def gen_visit_members_decl(typ): - if typ.name in object_members_seen: - return '' - object_members_seen.add(typ.name) +def gen_visit_members_decl(name): return mcgen(''' -static void visit_type_%(c_type)s_members(Visitor *v, %(c_type)s *obj, Error **errp); +void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp); ''', - c_type=typ.c_name()) + c_name=c_name(name)) def gen_visit_object_members(name, base, members, variants): - ret = '' + ret = mcgen(''' - if base: - ret += gen_visit_members_decl(base) - if variants: - for var in variants.variants: - # Ugly special case for simple union TODO get rid of it - if not var.simple_union_type(): - ret += gen_visit_members_decl(var.type) - - object_members_seen.add(name) - ret += mcgen(''' - -static void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp) +void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp) { Error *err = NULL; ''', - c_name=c_name(name)) + c_name=c_name(name)) if base: ret += mcgen(''' @@ -174,8 +156,6 @@ def gen_visit_alternate(name, variants): for var in variants.variants: if var.type.alternate_qtype() == 'QTYPE_QINT': promote_int = 'false' - if isinstance(var.type, QAPISchemaObjectType): - ret += gen_visit_members_decl(var.type) ret += mcgen(''' @@ -324,6 +304,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): self.defn += defn def visit_object_type(self, name, info, base, members, variants): + self.decl += gen_visit_members_decl(name) self.decl += gen_visit_decl(name) self.defn += gen_visit_object(name, base, members, variants)