• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ qobject_decref函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中qobject_decref函数的典型用法代码示例。如果您正苦于以下问题:C++ qobject_decref函数的具体用法?C++ qobject_decref怎么用?C++ qobject_decref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了qobject_decref函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_dispatch_cmd_failure

/* test commands that return an error due to invalid parameters */
static void test_dispatch_cmd_failure(void)
{
    QDict *req = qdict_new();
    QDict *args = qdict_new();
    QObject *resp;

    qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));

    resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
    assert(resp != NULL);
    assert(qdict_haskey(qobject_to_qdict(resp), "error"));

    qobject_decref(resp);
    QDECREF(req);

    /* check that with extra arguments it throws an error */
    req = qdict_new();
    qdict_put(args, "a", qint_from_int(66));
    qdict_put(req, "arguments", args);

    qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd")));

    resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
    assert(resp != NULL);
    assert(qdict_haskey(qobject_to_qdict(resp), "error"));

    qobject_decref(resp);
    QDECREF(req);
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:30,代码来源:test-qmp-commands.c


示例2: qnull_visit_test

static void qnull_visit_test(void)
{
    QObject *obj;
    Visitor *v;
    QNull *null;

    /*
     * Most tests of interactions between QObject and visitors are in
     * test-qmp-*-visitor; but these tests live here because they
     * depend on layering violations to check qnull_ refcnt.
     */

    g_assert(qnull_.base.refcnt == 1);
    obj = QOBJECT(qnull());
    v = qobject_input_visitor_new(obj);
    qobject_decref(obj);
    visit_type_null(v, NULL, &null, &error_abort);
    g_assert(obj == QOBJECT(&qnull_));
    QDECREF(null);
    visit_free(v);

    null = NULL;
    v = qobject_output_visitor_new(&obj);
    visit_type_null(v, NULL, &null, &error_abort);
    visit_complete(v, &obj);
    g_assert(obj == QOBJECT(&qnull_));
    QDECREF(null);
    qobject_decref(obj);
    visit_free(v);

    g_assert(qnull_.base.refcnt == 1);
}
开发者ID:8tab,项目名称:qemu,代码行数:32,代码来源:check-qnull.c


示例3: qnull_visit_test

static void qnull_visit_test(void)
{
    QObject *obj;
    QmpOutputVisitor *qov;
    QmpInputVisitor *qiv;

    /*
     * Most tests of interactions between QObject and visitors are in
     * test-qmp-*-visitor; but these tests live here because they
     * depend on layering violations to check qnull_ refcnt.
     */

    g_assert(qnull_.refcnt == 1);
    obj = qnull();
    qiv = qmp_input_visitor_new(obj, true);
    qobject_decref(obj);
    visit_type_null(qmp_input_get_visitor(qiv), NULL, &error_abort);
    qmp_input_visitor_cleanup(qiv);

    qov = qmp_output_visitor_new();
    visit_type_null(qmp_output_get_visitor(qov), NULL, &error_abort);
    obj = qmp_output_get_qobject(qov);
    g_assert(obj == &qnull_);
    qobject_decref(obj);
    qmp_output_visitor_cleanup(qov);

    g_assert(qnull_.refcnt == 1);
}
开发者ID:Jameshzc,项目名称:qemu,代码行数:28,代码来源:check-qnull.c


示例4: test_dispatch_cmd_io

/* test commands that involve both input parameters and return values */
static void test_dispatch_cmd_io(void)
{
    QDict *req = qdict_new();
    QDict *args = qdict_new();
    QDict *ud1a = qdict_new();
    QDict *ud1b = qdict_new();
    QObject *resp;

    qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42)));
    qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello")));
    qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422)));
    qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2")));
    qdict_put_obj(args, "ud1a", QOBJECT(ud1a));
    qdict_put_obj(args, "ud1b", QOBJECT(ud1b));
    qdict_put_obj(req, "arguments", QOBJECT(args));

    qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));

    /* TODO: put in full payload and check for errors */
    resp = qmp_dispatch(QOBJECT(req));
    assert(resp != NULL);
    assert(!qdict_haskey(qobject_to_qdict(resp), "error"));
    g_print("\nresp: %s\n", qstring_get_str(qobject_to_json_pretty(resp)));

    qobject_decref(resp);
    QDECREF(req);
}
开发者ID:B-Rich,项目名称:serialice,代码行数:28,代码来源:test-qmp-commands.c


示例5: qapi_dealloc_type_anything

static void qapi_dealloc_type_anything(Visitor *v, QObject **obj,
                                       const char *name, Error **errp)
{
    if (obj) {
        qobject_decref(*obj);
    }
}
开发者ID:32bitmicro,项目名称:riscv-qemu,代码行数:7,代码来源:qapi-dealloc-visitor.c


示例6: qapi_copy_SocketAddress

void qapi_copy_SocketAddress(SocketAddress **p_dest,
                             SocketAddress *src)
{
    QmpOutputVisitor *qov;
    QmpInputVisitor *qiv;
    Visitor *ov, *iv;
    QObject *obj;

    *p_dest = NULL;

    qov = qmp_output_visitor_new();
    ov = qmp_output_get_visitor(qov);
    visit_type_SocketAddress(ov, NULL, &src, &error_abort);
    obj = qmp_output_get_qobject(qov);
    qmp_output_visitor_cleanup(qov);
    if (!obj) {
        return;
    }

    qiv = qmp_input_visitor_new(obj);
    iv = qmp_input_get_visitor(qiv);
    visit_type_SocketAddress(iv, NULL, p_dest, &error_abort);
    qmp_input_visitor_cleanup(qiv);
    qobject_decref(obj);
}
开发者ID:01org,项目名称:qemu-lite,代码行数:25,代码来源:qemu-sockets.c


示例7: qjson_finalizefn

static void qjson_finalizefn(Object *obj)
{
    QJSON *json = (QJSON *)object_dynamic_cast(obj, TYPE_QJSON);

    assert(json);
    qobject_decref(QOBJECT(json->str));
}
开发者ID:AdrianHuang,项目名称:qemu,代码行数:7,代码来源:qjson.c


示例8: panicked_mon_event

static void panicked_mon_event(const char *action)
{
    QObject *data;

    data = qobject_from_jsonf("{ 'action': %s }", action);
    monitor_protocol_event(QEVENT_GUEST_PANICKED, data);
    qobject_decref(data);
}
开发者ID:ZhuZhengyi,项目名称:qemu,代码行数:8,代码来源:pvpanic.c


示例9: visitor_output_teardown

static void visitor_output_teardown(TestOutputVisitorData *data,
                                    const void *unused)
{
    visit_free(data->ov);
    data->ov = NULL;
    qobject_decref(data->obj);
    data->obj = NULL;
}
开发者ID:mdroth,项目名称:qemu,代码行数:8,代码来源:test-qobject-output-visitor.c


示例10: qentry_destroy

static void qentry_destroy(QDictEntry *e)
{
    assert(e != NULL);
    assert(e->key != NULL);
    assert(e->value != NULL);

    qobject_decref(e->value);
    qemu_free(e->key);
    qemu_free(e);
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:10,代码来源:qdict.c


示例11: do_free_all

static void do_free_all(int _, ...)
{
    va_list ap;
    QObject *obj;

    va_start(ap, _);
    while ((obj = va_arg(ap, QObject *)) != NULL) {
        qobject_decref(obj);
    }
    va_end(ap);
}
开发者ID:CRYP706URU,项目名称:pyrebox,代码行数:11,代码来源:check-qobject.c


示例12: validate_teardown

static void validate_teardown(TestInputVisitorData *data,
                               const void *unused)
{
    qobject_decref(data->obj);
    data->obj = NULL;

    if (data->qiv) {
        visit_free(data->qiv);
        data->qiv = NULL;
    }
}
开发者ID:heiher,项目名称:qemu,代码行数:11,代码来源:test-qmp-input-strict.c


示例13: visitor_input_teardown

static void visitor_input_teardown(TestInputVisitorData *data,
                                   const void *unused)
{
    qobject_decref(data->obj);
    data->obj = NULL;

    if (data->qiv) {
        qmp_input_visitor_cleanup(data->qiv);
        data->qiv = NULL;
    }
}
开发者ID:32bitmicro,项目名称:riscv-qemu,代码行数:11,代码来源:test-qmp-input-visitor.c


示例14: complete_stats_request

static void complete_stats_request(VirtIOBalloon *vb)
{
    QObject *stats;

    if (!vb->stats_opaque_callback_data)
        return;

    stats = get_stats_qobject(vb);
    vb->stats_callback(vb->stats_opaque_callback_data, stats);
    qobject_decref(stats);
    vb->stats_opaque_callback_data = NULL;
    vb->stats_callback = NULL;
}
开发者ID:16aug,项目名称:nvmeqemu,代码行数:13,代码来源:virtio-balloon.c


示例15: qnull_ref_test

static void qnull_ref_test(void)
{
    QObject *obj;

    g_assert(qnull_.base.refcnt == 1);
    obj = QOBJECT(qnull());
    g_assert(obj);
    g_assert(obj == QOBJECT(&qnull_));
    g_assert(qnull_.base.refcnt == 2);
    g_assert(qobject_type(obj) == QTYPE_QNULL);
    qobject_decref(obj);
    g_assert(qnull_.base.refcnt == 1);
}
开发者ID:8tab,项目名称:qemu,代码行数:13,代码来源:check-qnull.c


示例16: test_visitor_in_any

static void test_visitor_in_any(TestInputVisitorData *data,
                                const void *unused)
{
    QObject *res = NULL;
    Visitor *v;
    QInt *qint;
    QBool *qbool;
    QString *qstring;
    QDict *qdict;
    QObject *qobj;

    v = visitor_input_test_init(data, "-42");
    visit_type_any(v, &res, NULL, &error_abort);
    qint = qobject_to_qint(res);
    g_assert(qint);
    g_assert_cmpint(qint_get_int(qint), ==, -42);
    qobject_decref(res);

    v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
    visit_type_any(v, &res, NULL, &error_abort);
    qdict = qobject_to_qdict(res);
    g_assert(qdict && qdict_size(qdict) == 3);
    qobj = qdict_get(qdict, "integer");
    g_assert(qobj);
    qint = qobject_to_qint(qobj);
    g_assert(qint);
    g_assert_cmpint(qint_get_int(qint), ==, -42);
    qobj = qdict_get(qdict, "boolean");
    g_assert(qobj);
    qbool = qobject_to_qbool(qobj);
    g_assert(qbool);
    g_assert(qbool_get_bool(qbool) == true);
    qobj = qdict_get(qdict, "string");
    g_assert(qobj);
    qstring = qobject_to_qstring(qobj);
    g_assert(qstring);
    g_assert_cmpstr(qstring_get_str(qstring), ==, "foo");
    qobject_decref(res);
}
开发者ID:32bitmicro,项目名称:riscv-qemu,代码行数:39,代码来源:test-qmp-input-visitor.c


示例17: qobject_output_free

static void qobject_output_free(Visitor *v)
{
    QObjectOutputVisitor *qov = to_qov(v);
    QStackEntry *e;

    while (!QSLIST_EMPTY(&qov->stack)) {
        e = QSLIST_FIRST(&qov->stack);
        QSLIST_REMOVE_HEAD(&qov->stack, node);
        g_free(e);
    }

    qobject_decref(qov->root);
    g_free(qov);
}
开发者ID:CRYP706URU,项目名称:pyrebox,代码行数:14,代码来源:qobject-output-visitor.c


示例18: test_dispatch_cmd

/* test commands with no input and no return value */
static void test_dispatch_cmd(void)
{
    QDict *req = qdict_new();
    QObject *resp;

    qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd")));

    resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
    assert(resp != NULL);
    assert(!qdict_haskey(qobject_to_qdict(resp), "error"));

    qobject_decref(resp);
    QDECREF(req);
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:15,代码来源:test-qmp-commands.c


示例19: process_event

/* handle requests/control events coming in over the channel */
static void process_event(JSONMessageParser *parser, QList *tokens)
{
    GAState *s = container_of(parser, GAState, parser);
    QObject *obj;
    QDict *qdict;
    Error *err = NULL;
    int ret;

    g_assert(s && parser);

    g_debug("process_event: called");
    obj = json_parser_parse_err(tokens, NULL, &err);
    if (err || !obj || qobject_type(obj) != QTYPE_QDICT) {
        qobject_decref(obj);
        qdict = qdict_new();
        if (!err) {
            g_warning("failed to parse event: unknown error");
            error_set(&err, QERR_JSON_PARSING);
        } else {
            g_warning("failed to parse event: %s", error_get_pretty(err));
        }
        qdict_put_obj(qdict, "error", error_get_qobject(err));
        error_free(err);
    } else {
        qdict = qobject_to_qdict(obj);
    }

    g_assert(qdict);

    /* handle host->guest commands */
    if (qdict_haskey(qdict, "execute")) {
        process_command(s, qdict);
    } else {
        if (!qdict_haskey(qdict, "error")) {
            QDECREF(qdict);
            qdict = qdict_new();
            g_warning("unrecognized payload format");
            error_set(&err, QERR_UNSUPPORTED);
            qdict_put_obj(qdict, "error", error_get_qobject(err));
            error_free(err);
        }
        ret = conn_channel_send_payload(s->conn_channel, QOBJECT(qdict));
        if (ret) {
            g_warning("error sending payload: %s", strerror(ret));
        }
    }

    QDECREF(qdict);
}
开发者ID:AsherBond,项目名称:qemu-kvm,代码行数:50,代码来源:qemu-ga.c


示例20: test_nested_enums

/* test enum values nested in schema-defined structs */
static void test_nested_enums(void)
{
    QmpOutputVisitor *mo;
    QmpInputVisitor *mi;
    Visitor *v;
    NestedEnumsOne *nested_enums, *nested_enums_cpy = NULL;
    Error *err = NULL;
    QObject *obj;
    QString *str;

    nested_enums = qemu_mallocz(sizeof(NestedEnumsOne));
    nested_enums->enum1 = ENUM_ONE_VALUE1;
    nested_enums->enum2 = ENUM_ONE_VALUE2;
    nested_enums->enum3 = ENUM_ONE_VALUE3;
    nested_enums->enum4 = ENUM_ONE_VALUE3;
    nested_enums->has_enum2 = false;
    nested_enums->has_enum4 = true;

    /* C type -> QObject */
    mo = qmp_output_visitor_new();
    v = qmp_output_get_visitor(mo);
    visit_type_NestedEnumsOne(v, &nested_enums, NULL, &err);
    if (err) {
        g_error("%s", error_get_pretty(err));
    }
    obj = qmp_output_get_qobject(mo);
    g_assert(obj);
    str = qobject_to_json_pretty(obj);
    g_print("%s\n", qstring_get_str(str));
    QDECREF(str);

    /* QObject -> C type */
    mi = qmp_input_visitor_new(obj);
    v = qmp_input_get_visitor(mi);
    visit_type_NestedEnumsOne(v, &nested_enums_cpy, NULL, &err);
    if (err) {
        g_error("%s", error_get_pretty(err));
    }
    g_assert(nested_enums_cpy);
    g_assert(nested_enums_cpy->enum1 == nested_enums->enum1);
    g_assert(nested_enums_cpy->enum3 == nested_enums->enum3);
    g_assert(nested_enums_cpy->enum4 == nested_enums->enum4);
    g_assert(nested_enums_cpy->has_enum2 == false);
    g_assert(nested_enums_cpy->has_enum4 == true);

    qobject_decref(obj);
    qapi_free_NestedEnumsOne(nested_enums);
    qapi_free_NestedEnumsOne(nested_enums_cpy);
}
开发者ID:B-Rich,项目名称:serialice,代码行数:50,代码来源:test-visitor.c



注:本文中的qobject_decref函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ qobject_to_qdict函数代码示例发布时间:2022-05-30
下一篇:
C++ qnumber函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap