Commit 28770e05 authored by Markus Armbruster's avatar Markus Armbruster
Browse files

qapi: Introduce a first class 'any' type



It's first class, because unlike '**', it actually works, i.e. doesn't
require 'gen': false.

'**' will go away next.

Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent 6c2f9a15
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ The following types are predefined, and map to C as follows:
  size      uint64_t   like uint64_t, except StringInputVisitor
                       accepts size suffixes
  bool      bool       JSON true or false
  any       QObject *  any JSON value


=== Includes ===
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ struct Visitor
    void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp);
    void (*type_number)(Visitor *v, double *obj, const char *name,
                        Error **errp);
    void (*type_any)(Visitor *v, QObject **obj, const char *name,
                     Error **errp);

    /* May be NULL */
    void (*optional)(Visitor *v, bool *present, const char *name,
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp);
void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp);
void visit_type_any(Visitor *v, QObject **obj, const char *name, Error **errp);
bool visit_start_union(Visitor *v, bool data_present, Error **errp);
void visit_end_union(Visitor *v, bool data_present, Error **errp);

+9 −0
Original line number Diff line number Diff line
@@ -151,6 +151,14 @@ static void qapi_dealloc_type_number(Visitor *v, double *obj, const char *name,
{
}

static void qapi_dealloc_type_anything(Visitor *v, QObject **obj,
                                       const char *name, Error **errp)
{
    if (obj) {
        qobject_decref(*obj);
    }
}

static void qapi_dealloc_type_size(Visitor *v, uint64_t *obj, const char *name,
                                   Error **errp)
{
@@ -216,6 +224,7 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
    v->visitor.type_bool = qapi_dealloc_type_bool;
    v->visitor.type_str = qapi_dealloc_type_str;
    v->visitor.type_number = qapi_dealloc_type_number;
    v->visitor.type_any = qapi_dealloc_type_anything;
    v->visitor.type_size = qapi_dealloc_type_size;
    v->visitor.start_union = qapi_dealloc_start_union;

+6 −0
Original line number Diff line number Diff line
@@ -260,6 +260,12 @@ void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp)
    v->type_number(v, obj, name, errp);
}

void visit_type_any(Visitor *v, QObject **obj, const char *name,
                    Error **errp)
{
    v->type_any(v, obj, name, errp);
}

void output_type_enum(Visitor *v, int *obj, const char * const strings[],
                      const char *kind, const char *name,
                      Error **errp)
Loading