From 761d524dbcc5bb41213dd0f238f43c273bc2b077 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 3 Jul 2013 15:52:42 +0200 Subject: qapi: Add visitor for implicit structs These can be used when an embedded struct is parsed and members not belonging to the struct may be present in the input (e.g. parsing a flat namespace QMP union, where fields from both the base and one of the alternative types are mixed in the JSON object) Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- qapi/qapi-visit-core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'qapi/qapi-visit-core.c') diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 401ee6e597..9b4d51bc0a 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -45,6 +45,22 @@ void visit_end_struct(Visitor *v, Error **errp) v->end_struct(v, errp); } +void visit_start_implicit_struct(Visitor *v, void **obj, size_t size, + Error **errp) +{ + if (!error_is_set(errp) && v->start_implicit_struct) { + v->start_implicit_struct(v, obj, size, errp); + } +} + +void visit_end_implicit_struct(Visitor *v, Error **errp) +{ + assert(!error_is_set(errp)); + if (v->end_implicit_struct) { + v->end_implicit_struct(v, errp); + } +} + void visit_start_list(Visitor *v, const char *name, Error **errp) { if (!error_is_set(errp)) { -- cgit 1.4.1