示例#1
0
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);
}
示例#2
0
文件: check-qnull.c 项目: 8tab/qemu
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);
}
示例#3
0
static void qobject_is_equal_conversion_test(void)
{
    QNum *u0, *i0, *d0;
    QString *s0, *s_empty;
    QBool *bfalse;

    u0 = qnum_from_uint(0u);
    i0 = qnum_from_int(0);
    d0 = qnum_from_double(0.0);
    s0 = qstring_from_str("0");
    s_empty = qstring_new();
    bfalse = qbool_from_bool(false);

    /* No automatic type conversion */
    check_unequal(u0, s0, s_empty, bfalse, qnull(), NULL);
    check_unequal(i0, s0, s_empty, bfalse, qnull(), NULL);
    check_unequal(d0, s0, s_empty, bfalse, qnull(), NULL);

    free_all(u0, i0, d0, s0, s_empty, bfalse);
}
示例#4
0
文件: check-qnull.c 项目: 8tab/qemu
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);
}
示例#5
0
/**
 * Set the amount of unfolding of the globe.
 *
 * \param f Ranges from 0 (sphere/icosahedron) to 1 (entirely unfolded flat)
 */
void vtIcoGlobe::SetUnfolding(float f)
{
    // only possible on unfoldable globes
    if (m_style != DYMAX_UNFOLD)
        return;

    m_bUnfolded = (f != 0.0f);
    int i;

    m_SurfaceGroup->SetEnabled(!m_bUnfolded);
    for (i = 0; i < 22; i++)
        m_mface[i].surfgroup->SetEnabled(f == 1.0f);

    float dih = (float) DihedralAngle();
    for (i = 1; i < 22; i++)
    {
        FPoint3 pos = m_mface[i].xform->GetTrans();
        m_mface[i].xform->Identity();
        m_mface[i].xform->SetTrans(pos);
        m_mface[i].xform->RotateLocal(m_mface[i].axis, -f * dih);
    }

    // gradually undo the current top rotation
    FQuat qnull(0,0,0,1);
    FQuat q1, q2;
    FMatrix3 m3;
    FMatrix4 m4;

    q1.Slerp(qnull, m_Rotation, 1-f);
    q1.GetMatrix(m3);
    m4 = m3;
    m_top->SetTransform1(m3);

    // interpolate from No rotation to the desired rotation
    q2.Slerp(qnull, m_diff, f);
    q2.GetMatrix(m3);
    m4 = m3;
    m_mface[0].xform->SetTransform1(m3);
}
示例#6
0
static void qobject_is_equal_null_test(void)
{
    check_unequal(qnull(), NULL);
}
static void qobject_output_type_null(Visitor *v, const char *name,
                                     QNull **obj, Error **errp)
{
    QObjectOutputVisitor *qov = to_qov(v);
    qobject_output_add(qov, name, qnull());
}