mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
qapi: Generalize struct member policy checking
The generated visitor functions call visit_deprecated_accept() and visit_deprecated() when visiting a struct member with special feature flag 'deprecated'. This makes the feature flag visible to the actual visitors. I want to make feature flag 'unstable' visible there as well, so I can add policy for it. To let me make it visible, replace these functions by visit_policy_reject() and visit_policy_skip(), which take the member's special features as an argument. Note that the new functions have the opposite sense, i.e. the return value flips. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20211028102520.747396-6-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> [Unbreak forward visitor]
This commit is contained in:
parent
c67db1ed16
commit
a130728554
8 changed files with 65 additions and 42 deletions
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/compat-policy.h"
|
||||
#include "qapi/qobject-output-visitor.h"
|
||||
#include "qapi/visitor-impl.h"
|
||||
#include "qemu/queue.h"
|
||||
|
@ -208,9 +209,11 @@ static bool qobject_output_type_null(Visitor *v, const char *name,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool qobject_output_deprecated(Visitor *v, const char *name)
|
||||
static bool qobject_output_policy_skip(Visitor *v, const char *name,
|
||||
unsigned special_features)
|
||||
{
|
||||
return v->compat_policy.deprecated_output != COMPAT_POLICY_OUTPUT_HIDE;
|
||||
return !(special_features & 1u << QAPI_DEPRECATED)
|
||||
|| v->compat_policy.deprecated_output == COMPAT_POLICY_OUTPUT_HIDE;
|
||||
}
|
||||
|
||||
/* Finish building, and return the root object.
|
||||
|
@ -262,7 +265,7 @@ Visitor *qobject_output_visitor_new(QObject **result)
|
|||
v->visitor.type_number = qobject_output_type_number;
|
||||
v->visitor.type_any = qobject_output_type_any;
|
||||
v->visitor.type_null = qobject_output_type_null;
|
||||
v->visitor.deprecated = qobject_output_deprecated;
|
||||
v->visitor.policy_skip = qobject_output_policy_skip;
|
||||
v->visitor.complete = qobject_output_complete;
|
||||
v->visitor.free = qobject_output_free;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue