Пример #1
0
bool
REL_matchS(REL_t rT, REL_t rM1)
{
    bool match = false;
    if (rM1 == REL_any_ or /* any relation (short-circuit) */
        rT == rM1) {	/* a specific type of relation */
        match = true;
    } else {
        switch (rM1) {
        case REL_TEXT: if (REL_is_TEXT(rT)) { match = true; } break;
        case REL_LETTER: if (REL_is_LETTER(rT)) { match = true; } break;
        case REL_LETTER_EOL: if (REL_is_LETTER_EOL(rT)) { match = true; } break;
        case REL_LETTER_WS: if (REL_is_LETTER_WS(rT)) { match = true; } break;

        case REL_PARENT: if (REL_is_PARENT(rT)) { match = true; } break;
        case REL_CHILD: if (REL_is_CHILD(rT)) { match = true; } break;

        case REL_MASTER: if (REL_is_MASTER(rT)) { match = true; } break;
        case REL_SLAVE: if (REL_is_SLAVE(rT)) { match = true; } break;
        case REL_SLAVE_AXTICK: if (REL_is_SLAVE_AXTICK(rT)) { match = true; } break;
        case REL_SLAVE_LAYHINT: if (REL_is_SLAVE_LAYHINT(rT)) { match = true; } break;
        case REL_SLAVE_LAYHINT_CADJ: if (REL_is_SLAVE_CADJ(rT)) { match = true; } break;
        case REL_SIBLING: if (REL_is_SIBLING(rT)) { match = true; } break;

        case REL_PRODUCER: if (REL_is_PRODUCER(rT)) { match = true; } break;
        case REL_CONSUMER: if (REL_is_CONSUMER(rT)) { match = true; } break;

        case REL_ALIGNER: if (REL_is_ALIGNER(rT)) { match = true; } break;
        case REL_ALIGNEE: if (REL_is_ALIGNEE(rT)) { match = true; } break;
        default: break;
        }
    }
    return match;
}
Пример #2
0
static bool
REL_dualsOrdered(REL_t relA, REL_t relB)
{
    if (REL_getDual(relA) == relB) { return true; }
    if (REL_is_PARENT(relA) and
        REL_is_CHILD(relB)) { return true; }
    if (REL_is_MASTER(relA) and
        REL_is_SLAVE(relB)) { return true; }
    if (REL_is_PRODUCER(relA) and
        REL_is_CONSUMER(relB)) { return true; }
    if (REL_is_TEXT(relA) and
        REL_is_LETTER(relB)) { return true; }
    if (REL_is_TEXT(relA) and
        REL_is_CURSOR(relB)) { return true; }
    return false;
}
Пример #3
0
REL_t REL_getDual(REL_t rel)
{
    REL_t dual = REL_undefined_;

    const auto hit = g_duals.left.find(rel);
    if (hit != g_duals.left.end()) {
        dual = hit->second;
    }

    else if (REL_is_PARENT(rel)) { dual = REL_CHILD; }
    else if (REL_is_CHILD(rel)) { dual = REL_PARENT; }

    else if (REL_is_MASTER(rel)) { dual = REL_SLAVE; }
    else if (REL_is_SLAVE(rel)) { dual = REL_MASTER; }

    else if (REL_is_PRODUCER(rel)) { dual = REL_CONSUMER; }
    else if (REL_is_CONSUMER(rel)) { dual = REL_PRODUCER; }

    else if (REL_is_TEXT(rel)) { dual = REL_LETTER; }
    else if (REL_is_LETTER(rel)) { dual = REL_TEXT; }
    else if (REL_is_CURSOR(rel)) { dual = REL_TEXT; }

    return dual;
}
Пример #4
0
/*!
 * Return non-zero if \p rel belongs to the group of relations that
 * upon deletion of its related objects should be deleted as welll
 * (to the grave).
 */
inline bool
REL_followsDelete(REL_t rel)
{
    return (REL_is_SLAVE(rel) or
            REL_is_LETTER(rel));
}