diff options
author | Eric Blake <eblake@redhat.com> | 2016-04-28 15:45:09 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2016-05-12 09:47:54 +0200 |
commit | 983f52d4b3f86fb9dc9f8b142132feb5a8723016 (patch) | |
tree | 75fd63c51f9b3f023ad9b99379f45c9140f94d2c /include/qapi/visitor.h | |
parent | bfc766d38e1fae5767d43845c15c79ac8fa6d6af (diff) |
qapi-visit: Add visitor.type classification
We have three classes of QAPI visitors: input, output, and dealloc.
Currently, all implementations of these visitors have one thing in
common based on their visitor type: the implementation used for the
visit_type_enum() callback. But since we plan to add more such
common behavior, in relation to documenting and further refining
the semantics, it makes more sense to have the visitor
implementations advertise which class they belong to, so the common
qapi-visit-core code can use that information in multiple places.
A later patch will better document the types of visitors directly
in visitor.h.
For this patch, knowing the class of a visitor implementation lets
us make input_type_enum() and output_type_enum() become static
functions, by replacing the callback function Visitor.type_enum()
with the simpler enum member Visitor.type. Share a common
assertion in qapi-visit-core as part of the refactoring.
Move comments in opts-visitor.c to match the refactored layout.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1461879932-9020-2-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/qapi/visitor.h')
-rw-r--r-- | include/qapi/visitor.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 9a8d0105fb..690589f37d 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -78,8 +78,19 @@ void visit_end_alternate(Visitor *v); */ bool visit_optional(Visitor *v, const char *name, bool *present); +/* + * Visit an enum value. + * + * @strings expresses the mapping between C enum values and QAPI enum + * names; it should be the ENUM_lookup array from visit-types.h. + * + * May call visit_type_str() under the hood, and the enum visit may + * fail even if the corresponding string visit succeeded; this implies + * that visit_type_str() must have no unwelcome side effects. + */ void visit_type_enum(Visitor *v, const char *name, int *obj, const char *const strings[], Error **errp); + void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp); void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj, Error **errp); |