示例#1
0
QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
{
    QmpInputVisitor *v;

    v = g_malloc0(sizeof(*v));

    v->visitor.start_struct = qmp_input_start_struct;
    v->visitor.end_struct = qmp_input_end_struct;
    v->visitor.start_implicit_struct = qmp_input_start_implicit_struct;
    v->visitor.end_implicit_struct = qmp_input_end_implicit_struct;
    v->visitor.start_list = qmp_input_start_list;
    v->visitor.next_list = qmp_input_next_list;
    v->visitor.end_list = qmp_input_end_list;
    v->visitor.type_enum = input_type_enum;
    v->visitor.type_int = qmp_input_type_int;
    v->visitor.type_bool = qmp_input_type_bool;
    v->visitor.type_str = qmp_input_type_str;
    v->visitor.type_number = qmp_input_type_number;
    v->visitor.start_optional = qmp_input_start_optional;
    v->visitor.get_next_type = qmp_input_get_next_type;

    qmp_input_push(v, obj, NULL);
    qobject_incref(obj);

    return v;
}
static void qobject_output_type_any(Visitor *v, const char *name,
                                    QObject **obj, Error **errp)
{
    QObjectOutputVisitor *qov = to_qov(v);
    qobject_incref(*obj);
    qobject_output_add_obj(qov, name, *obj);
}
示例#3
0
文件: error.c 项目: aliguori/qemu
void error_set_qobject(Error **errp, QObject *obj)
{
    Error *err;
    if (errp == NULL) {
        return;
    }
    err = g_malloc0(sizeof(*err));
    err->obj = qobject_to_qdict(obj);
    qobject_incref(obj);

    *errp = err;
}
/* Finish building, and return the root object.
 * The root object is never null. The caller becomes the object's
 * owner, and should use qobject_decref() when done with it.  */
static void qobject_output_complete(Visitor *v, void *opaque)
{
    QObjectOutputVisitor *qov = to_qov(v);

    /* A visit must have occurred, with each start paired with end.  */
    assert(qov->root && QSLIST_EMPTY(&qov->stack));
    assert(opaque == qov->result);

    qobject_incref(qov->root);
    *qov->result = qov->root;
    qov->result = NULL;
}
示例#5
0
static QObject *test_qmp_dispatch(QDict *req)
{
    QObject *resp_obj;
    QDict *resp;
    QObject *ret;

    resp_obj = qmp_dispatch(&qmp_commands, QOBJECT(req));
    assert(resp_obj);
    resp = qobject_to_qdict(resp_obj);
    assert(resp && !qdict_haskey(resp, "error"));
    ret = qdict_get(resp, "return");
    assert(ret);
    qobject_incref(ret);
    qobject_decref(resp_obj);
    return ret;
}
示例#6
0
QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
{
    QmpInputVisitor *v;

    v = qemu_mallocz(sizeof(*v));

    v->visitor.start_struct = qmp_input_start_struct;
    v->visitor.end_struct = qmp_input_end_struct;
    v->visitor.start_list = qmp_input_start_list;
    v->visitor.next_list = qmp_input_next_list;
    v->visitor.end_list = qmp_input_end_list;
    v->visitor.type_enum = qmp_input_type_enum;
    v->visitor.type_int = qmp_input_type_int;
    v->visitor.type_bool = qmp_input_type_bool;
    v->visitor.type_str = qmp_input_type_str;
    v->visitor.type_number = qmp_input_type_number;
    v->visitor.start_optional = qmp_input_start_optional;
    v->visitor.end_optional = qmp_input_end_optional;

    v->obj = obj;
    qobject_incref(v->obj);

    return v;
}