当前位置: 首页>>代码示例>>C++>>正文


C++ QOBJECT函数代码示例

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


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

示例1: 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

示例2: blkverify_refresh_filename

static void blkverify_refresh_filename(BlockDriverState *bs)
{
    BDRVBlkverifyState *s = bs->opaque;

    /* bs->file has already been refreshed */
    bdrv_refresh_filename(s->test_file);

    if (bs->file->full_open_options && s->test_file->full_open_options) {
        QDict *opts = qdict_new();
        qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify")));

        QINCREF(bs->file->full_open_options);
        qdict_put_obj(opts, "raw", QOBJECT(bs->file->full_open_options));
        QINCREF(s->test_file->full_open_options);
        qdict_put_obj(opts, "test", QOBJECT(s->test_file->full_open_options));

        bs->full_open_options = opts;
    }

    if (bs->file->exact_filename[0] && s->test_file->exact_filename[0]) {
        snprintf(bs->exact_filename, sizeof(bs->exact_filename),
                 "blkverify:%s:%s",
                 bs->file->exact_filename, s->test_file->exact_filename);
    }
}
开发者ID:AgathaYang,项目名称:qemu_stm32,代码行数:25,代码来源:blkverify.c

示例3: test_dealloc_partial

/* test generated deallocation on an object whose construction was prematurely
 * terminated due to an error */
static void test_dealloc_partial(void)
{
    static const char text[] = "don't leak me";

    UserDefTwo *ud2 = NULL;
    Error *err = NULL;

    /* create partial object */
    {
        QDict *ud2_dict;
        Visitor *v;

        ud2_dict = qdict_new();
        qdict_put_obj(ud2_dict, "string0", QOBJECT(qstring_from_str(text)));

        v = qobject_input_visitor_new(QOBJECT(ud2_dict));
        visit_type_UserDefTwo(v, NULL, &ud2, &err);
        visit_free(v);
        QDECREF(ud2_dict);
    }

    /* verify that visit_type_XXX() cleans up properly on error */
    error_free_or_abort(&err);
    assert(!ud2);

    /* Manually create a partial object, leaving ud2->dict1 at NULL */
    ud2 = g_new0(UserDefTwo, 1);
    ud2->string0 = g_strdup(text);

    /* tear down partial object */
    qapi_free_UserDefTwo(ud2);
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:34,代码来源:test-qmp-commands.c

示例4: test_dealloc_partial

/* test generated deallocation on an object whose construction was prematurely
 * terminated due to an error */
static void test_dealloc_partial(void)
{
    static const char text[] = "don't leak me";

    UserDefTwo *ud2 = NULL;
    Error *err = NULL;

    /* create partial object */
    {
        QDict *ud2_dict;
        QmpInputVisitor *qiv;

        ud2_dict = qdict_new();
        qdict_put_obj(ud2_dict, "string0", QOBJECT(qstring_from_str(text)));

        qiv = qmp_input_visitor_new(QOBJECT(ud2_dict));
        visit_type_UserDefTwo(qmp_input_get_visitor(qiv), &ud2, NULL, &err);
        qmp_input_visitor_cleanup(qiv);
        QDECREF(ud2_dict);
    }

    /* verify partial success */
    assert(ud2 != NULL);
    assert(ud2->string0 != NULL);
    assert(strcmp(ud2->string0, text) == 0);
    assert(ud2->dict1 == NULL);

    /* confirm & release construction error */
    assert(err != NULL);
    error_free(err);

    /* tear down partial object */
    qapi_free_UserDefTwo(ud2);
}
开发者ID:kevinzhang1986,项目名称:qemu,代码行数:36,代码来源:test-qmp-commands.c

示例5: 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

示例6: qobject_is_equal_num_test

static void qobject_is_equal_num_test(void)
{
    QNum *u0, *i0, *d0, *dnan, *um42, *im42, *dm42;

    u0 = qnum_from_uint(0u);
    i0 = qnum_from_int(0);
    d0 = qnum_from_double(0.0);
    dnan = qnum_from_double(NAN);
    um42 = qnum_from_uint((uint64_t)-42);
    im42 = qnum_from_int(-42);
    dm42 = qnum_from_double(-42.0);

    /* Integers representing a mathematically equal number should
     * compare equal */
    check_equal(u0, i0);
    /* Doubles, however, are always unequal to integers */
    check_unequal(u0, d0);
    check_unequal(i0, d0);

    /* Do not assume any object is equal to itself -- note however
     * that NaN cannot occur in a JSON object anyway. */
    g_assert(qobject_is_equal(QOBJECT(dnan), QOBJECT(dnan)) == false);

    /* No unsigned overflow */
    check_unequal(um42, im42);
    check_unequal(um42, dm42);
    check_unequal(im42, dm42);

    free_all(u0, i0, d0, dnan, um42, im42, dm42);
}
开发者ID:CRYP706URU,项目名称:pyrebox,代码行数:30,代码来源:check-qobject.c

示例7: 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();
    QDict *resp;

    qdict_put_str(req, "execute", "user_def_cmd2");

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

    qobject_unref(resp);
    qobject_unref(req);

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

    qdict_put_str(req, "execute", "user_def_cmd");

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

    qobject_unref(resp);
    qobject_unref(req);
}
开发者ID:JayFoxRox,项目名称:xqemu,代码行数:30,代码来源:test-qmp-cmds.c

示例8: qdict_destroy_simple_test

static void qdict_destroy_simple_test(void)
{
    QDict *qdict;

    qdict = qdict_new();
    qdict_put_obj(qdict, "num", QOBJECT(qint_from_int(0)));
    qdict_put_obj(qdict, "str", QOBJECT(qstring_from_str("foo")));

    QDECREF(qdict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:10,代码来源:check-qdict.c

示例9: 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

示例10: 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

示例11: 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

示例12: test_dispatch_cmd_error

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

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

    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,代码行数:16,代码来源:test-qmp-commands.c

示例13: send_response

static int send_response(GAState *s, QDict *payload)
{
    const char *buf;
    QString *payload_qstr, *response_qstr;
    GIOStatus status;

    g_assert(payload && s->channel);

    payload_qstr = qobject_to_json(QOBJECT(payload));
    if (!payload_qstr) {
        return -EINVAL;
    }

    if (s->delimit_response) {
        s->delimit_response = false;
        response_qstr = qstring_new();
        qstring_append_chr(response_qstr, QGA_SENTINEL_BYTE);
        qstring_append(response_qstr, qstring_get_str(payload_qstr));
        qobject_unref(payload_qstr);
    } else {
        response_qstr = payload_qstr;
    }

    qstring_append_chr(response_qstr, '\n');
    buf = qstring_get_str(response_qstr);
    status = ga_channel_write_all(s->channel, buf, strlen(buf));
    qobject_unref(response_qstr);
    if (status != G_IO_STATUS_NORMAL) {
        return -EIO;
    }

    return 0;
}
开发者ID:JayFoxRox,项目名称:xqemu,代码行数:33,代码来源:main.c

示例14: 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

示例15: do_info_migrate

void do_info_migrate(Monitor *mon, QObject **ret_data)
{
    QDict *qdict;
    MigrationState *s = current_migration;

    if (s) {
        switch (s->get_status(s)) {
        case MIG_STATE_ACTIVE:
            qdict = qdict_new();
            qdict_put(qdict, "status", qstring_from_str("active"));

            migrate_put_status(qdict, "ram", ram_bytes_transferred(),
                               ram_bytes_remaining(), ram_bytes_total());

            if (blk_mig_active()) {
                migrate_put_status(qdict, "disk", blk_mig_bytes_transferred(),
                                   blk_mig_bytes_remaining(),
                                   blk_mig_bytes_total());
            }

            *ret_data = QOBJECT(qdict);
            break;
        case MIG_STATE_COMPLETED:
            *ret_data = qobject_from_jsonf("{ 'status': 'completed' }");
            break;
        case MIG_STATE_ERROR:
            *ret_data = qobject_from_jsonf("{ 'status': 'failed' }");
            break;
        case MIG_STATE_CANCELLED:
            *ret_data = qobject_from_jsonf("{ 'status': 'cancelled' }");
            break;
        }
    }
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:34,代码来源:migration.c


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