diff options
Diffstat (limited to 'include/qapi')
| -rw-r--r-- | include/qapi/error.h | 3 | ||||
| -rw-r--r-- | include/qapi/qmp-event.h | 1 | ||||
| -rw-r--r-- | include/qapi/qmp/dispatch.h | 1 | ||||
| -rw-r--r-- | include/qapi/qmp/json-lexer.h | 1 | ||||
| -rw-r--r-- | include/qapi/qmp/json-parser.h | 1 | ||||
| -rw-r--r-- | include/qapi/qmp/json-streamer.h | 2 | ||||
| -rw-r--r-- | include/qapi/qmp/qbool.h | 1 | ||||
| -rw-r--r-- | include/qapi/qmp/qdict.h | 2 | ||||
| -rw-r--r-- | include/qapi/qmp/qfloat.h | 1 | ||||
| -rw-r--r-- | include/qapi/qmp/qint.h | 1 | ||||
| -rw-r--r-- | include/qapi/qmp/qjson.h | 2 | ||||
| -rw-r--r-- | include/qapi/qmp/qobject.h | 2 | ||||
| -rw-r--r-- | include/qapi/qmp/qstring.h | 1 | ||||
| -rw-r--r-- | include/qapi/visitor-impl.h | 22 | ||||
| -rw-r--r-- | include/qapi/visitor.h | 65 |
15 files changed, 54 insertions, 52 deletions
diff --git a/include/qapi/error.h b/include/qapi/error.h index e64fe54cf9..02e9dd20a7 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -115,9 +115,6 @@ #ifndef ERROR_H #define ERROR_H -#include <stdarg.h> -#include <stdbool.h> -#include "qemu/compiler.h" #include "qapi-types.h" /* diff --git a/include/qapi/qmp-event.h b/include/qapi/qmp-event.h index 8a8ffb5718..40fe3cbc12 100644 --- a/include/qapi/qmp-event.h +++ b/include/qapi/qmp-event.h @@ -14,7 +14,6 @@ #ifndef QMP_EVENT_H #define QMP_EVENT_H -#include "qapi/error.h" #include "qapi/qmp/qdict.h" typedef void (*QMPEventFuncEmit)(unsigned event, QDict *dict, Error **errp); diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index e389697f19..495520994c 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -16,7 +16,6 @@ #include "qapi/qmp/qobject.h" #include "qapi/qmp/qdict.h" -#include "qapi/error.h" typedef void (QmpCommandFunc)(QDict *, QObject **, Error **); diff --git a/include/qapi/qmp/json-lexer.h b/include/qapi/qmp/json-lexer.h index cb456d53e5..afee7828cd 100644 --- a/include/qapi/qmp/json-lexer.h +++ b/include/qapi/qmp/json-lexer.h @@ -14,7 +14,6 @@ #ifndef QEMU_JSON_LEXER_H #define QEMU_JSON_LEXER_H -#include "glib-compat.h" typedef enum json_token_type { JSON_MIN = 100, diff --git a/include/qapi/qmp/json-parser.h b/include/qapi/qmp/json-parser.h index fea89f873a..9987f8ca85 100644 --- a/include/qapi/qmp/json-parser.h +++ b/include/qapi/qmp/json-parser.h @@ -16,7 +16,6 @@ #include "qemu-common.h" #include "qapi/qmp/qlist.h" -#include "qapi/error.h" QObject *json_parser_parse(GQueue *tokens, va_list *ap); QObject *json_parser_parse_err(GQueue *tokens, va_list *ap, Error **errp); diff --git a/include/qapi/qmp/json-streamer.h b/include/qapi/qmp/json-streamer.h index 09b3d3ec15..00d8a23af8 100644 --- a/include/qapi/qmp/json-streamer.h +++ b/include/qapi/qmp/json-streamer.h @@ -14,8 +14,6 @@ #ifndef QEMU_JSON_STREAMER_H #define QEMU_JSON_STREAMER_H -#include <stdint.h> -#include "glib-compat.h" #include "qapi/qmp/json-lexer.h" typedef struct JSONToken { diff --git a/include/qapi/qmp/qbool.h b/include/qapi/qmp/qbool.h index 836d078866..a41111c309 100644 --- a/include/qapi/qmp/qbool.h +++ b/include/qapi/qmp/qbool.h @@ -14,7 +14,6 @@ #ifndef QBOOL_H #define QBOOL_H -#include <stdbool.h> #include "qapi/qmp/qobject.h" typedef struct QBool { diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 6c2a0e501e..71b8eb0416 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -16,8 +16,6 @@ #include "qapi/qmp/qobject.h" #include "qapi/qmp/qlist.h" #include "qemu/queue.h" -#include <stdbool.h> -#include <stdint.h> #define QDICT_BUCKET_MAX 512 diff --git a/include/qapi/qmp/qfloat.h b/include/qapi/qmp/qfloat.h index a8af2a89b2..b5d15836b5 100644 --- a/include/qapi/qmp/qfloat.h +++ b/include/qapi/qmp/qfloat.h @@ -14,7 +14,6 @@ #ifndef QFLOAT_H #define QFLOAT_H -#include <stdint.h> #include "qapi/qmp/qobject.h" typedef struct QFloat { diff --git a/include/qapi/qmp/qint.h b/include/qapi/qmp/qint.h index 049e528079..3aaff768dd 100644 --- a/include/qapi/qmp/qint.h +++ b/include/qapi/qmp/qint.h @@ -13,7 +13,6 @@ #ifndef QINT_H #define QINT_H -#include <stdint.h> #include "qapi/qmp/qobject.h" typedef struct QInt { diff --git a/include/qapi/qmp/qjson.h b/include/qapi/qmp/qjson.h index ee4d31a46a..02b1f2ce31 100644 --- a/include/qapi/qmp/qjson.h +++ b/include/qapi/qmp/qjson.h @@ -14,8 +14,6 @@ #ifndef QJSON_H #define QJSON_H -#include <stdarg.h> -#include "qemu/compiler.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index 74459ae14b..b8ddbca405 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -32,8 +32,6 @@ #ifndef QOBJECT_H #define QOBJECT_H -#include <stddef.h> -#include <assert.h> #include "qapi-types.h" struct QObject { diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h index df7df558b2..10076b7c8c 100644 --- a/include/qapi/qmp/qstring.h +++ b/include/qapi/qmp/qstring.h @@ -13,7 +13,6 @@ #ifndef QSTRING_H #define QSTRING_H -#include <stdint.h> #include "qapi/qmp/qobject.h" typedef struct QString { diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index ea252f8e3a..2bd8f292b2 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -12,7 +12,6 @@ #ifndef QAPI_VISITOR_IMPL_H #define QAPI_VISITOR_IMPL_H -#include "qapi/error.h" #include "qapi/visitor.h" struct Visitor @@ -22,22 +21,23 @@ struct Visitor size_t size, Error **errp); void (*end_struct)(Visitor *v, Error **errp); - void (*start_implicit_struct)(Visitor *v, void **obj, size_t size, - Error **errp); - /* May be NULL */ - void (*end_implicit_struct)(Visitor *v); - void (*start_list)(Visitor *v, const char *name, Error **errp); /* Must be set */ - GenericList *(*next_list)(Visitor *v, GenericList **list); + GenericList *(*next_list)(Visitor *v, GenericList **list, size_t size); /* Must be set */ void (*end_list)(Visitor *v); + /* Optional, needed for input and dealloc visitors. */ + void (*start_alternate)(Visitor *v, const char *name, + GenericAlternate **obj, size_t size, + bool promote_int, Error **errp); + + /* Optional, needed for dealloc visitor. */ + void (*end_alternate)(Visitor *v); + + /* Must be set. */ void (*type_enum)(Visitor *v, const char *name, int *obj, const char *const strings[], Error **errp); - /* May be NULL; only needed for input visitors. */ - void (*get_next_type)(Visitor *v, const char *name, QType *type, - bool promote_int, Error **errp); /* Must be set. */ void (*type_int64)(Visitor *v, const char *name, int64_t *obj, @@ -58,8 +58,6 @@ struct Visitor /* May be NULL; most useful for input visitors. */ void (*optional)(Visitor *v, const char *name, bool *present); - - bool (*start_union)(Visitor *v, bool data_present, Error **errp); }; void input_type_enum(Visitor *v, const char *name, int *obj, diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 5e581dcf7e..1000da2bda 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -16,29 +16,61 @@ #include "qemu/typedefs.h" #include "qapi/qmp/qobject.h" -#include "qapi/error.h" -#include <stdlib.h> -typedef struct GenericList -{ - union { - void *value; - uint64_t padding; - }; +/* This struct is layout-compatible with all other *List structs + * created by the qapi generator. It is used as a typical + * singly-linked list. */ +typedef struct GenericList { struct GenericList *next; + char padding[]; } GenericList; +/* This struct is layout-compatible with all Alternate types + * created by the qapi generator. */ +typedef struct GenericAlternate { + QType type; + char padding[]; +} GenericAlternate; + void visit_start_struct(Visitor *v, const char *name, void **obj, size_t size, Error **errp); void visit_end_struct(Visitor *v, Error **errp); -void visit_start_implicit_struct(Visitor *v, void **obj, size_t size, - Error **errp); -void visit_end_implicit_struct(Visitor *v); void visit_start_list(Visitor *v, const char *name, Error **errp); -GenericList *visit_next_list(Visitor *v, GenericList **list); +GenericList *visit_next_list(Visitor *v, GenericList **list, size_t size); void visit_end_list(Visitor *v); +/* + * Start the visit of an alternate @obj with the given @size. + * + * @name specifies the relationship to the containing struct (ignored + * for a top level visit, the name of the key if this alternate is + * part of an object, or NULL if this alternate is part of a list). + * + * @obj must not be NULL. Input visitors will allocate @obj and + * determine the qtype of the next thing to be visited, stored in + * (*@obj)->type. Other visitors will leave @obj unchanged. + * + * If @promote_int, treat integers as QTYPE_FLOAT. + * + * If successful, this must be paired with visit_end_alternate(), even + * if visiting the contents of the alternate fails. + */ +void visit_start_alternate(Visitor *v, const char *name, + GenericAlternate **obj, size_t size, + bool promote_int, Error **errp); + +/* + * Finish visiting an alternate type. + * + * Must be called after a successful visit_start_alternate(), even if + * an error occurred in the meantime. + * + * TODO: Should all the visit_end_* interfaces take obj parameter, so + * that dealloc visitor need not track what was passed in visit_start? + */ +void visit_end_alternate(Visitor *v); + /** * Check if an optional member @name of an object needs visiting. * For input visitors, set *@present according to whether the @@ -47,14 +79,6 @@ void visit_end_list(Visitor *v); */ bool visit_optional(Visitor *v, const char *name, bool *present); -/** - * Determine the qtype of the item @name in the current object visit. - * For input visitors, set *@type to the correct qtype of a qapi - * alternate type; for other visitors, leave *@type unchanged. - * If @promote_int, treat integers as QTYPE_FLOAT. - */ -void visit_get_next_type(Visitor *v, const char *name, QType *type, - bool promote_int, Error **errp); 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); @@ -80,6 +104,5 @@ void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp); void visit_type_number(Visitor *v, const char *name, double *obj, Error **errp); void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp); -bool visit_start_union(Visitor *v, bool data_present, Error **errp); #endif |