Exemplo n.º 1
0
 inline type_id_t get_type_id() const {
     if (is_builtin_type()) {
         return get_builtin_type_id();
     } else {
         return m_type->get_type_id();
     }
 }
Exemplo n.º 2
0
/**
 * Returns the alignment for the given type.
 *
 * \param bt  Pointer to a base_type object, or a builtin type id.
 */
inline size_t get_base_type_alignment(const base_type *bt)
{
    if (is_builtin_type(bt)) {
        return static_cast<size_t>(
            detail::builtin_data_alignments[reinterpret_cast<uintptr_t>(bt)]);
    } else {
        return bt->get_data_alignment();
    }
}
Exemplo n.º 3
0
/**
 * Returns the kind for the given type.
 *
 * \param bt  Pointer to a base_type object, or a builtin type id.
 */
inline type_kind_t get_base_type_kind(const base_type *bt)
{
    if (is_builtin_type(bt)) {
        return static_cast<type_kind_t>(
            detail::builtin_kinds[reinterpret_cast<uintptr_t>(bt)]);
    } else {
        return bt->get_kind();
    }
}
Exemplo n.º 4
0
void struct_attribute_foreach(FcitxConfiguration* config, const char* path, void* userData)
{
    FcitxDescription* desc = userData;
    if (desc->error) {
        return;
    }

    const char* type = fcitx_configuration_get_value_by_path(config, "Type");
    if (!type) {
        asprintf(&desc->errorMessage, "%s misses Type.", path);
        desc->error = true;
        return;
    }

    if (!is_builtin_type(type)) {
        asprintf(&desc->errorMessage, "Invalide Type.");
        desc->error = true;
        return;
    }

    if (strcmp(type, "List") == 0) {
        const char* subType = fcitx_configuration_get_value_by_path(config, "SubType");
        if (!subType) {
            asprintf(&desc->errorMessage, "%s misses SubType.", path);
            desc->error = true;
            return;
        }

        if (strcmp(subType, "List") == 0) {
            asprintf(&desc->errorMessage, "Recursive List is not allowed.");
            desc->error = true;
            return;
        }

        if (!is_builtin_type(subType) && !fcitx_string_hashset_contains(desc->structs, subType)) {
            asprintf(&desc->errorMessage, "Invalide SubType.");
            desc->error = true;
            return;
        }

        fcitx_string_hashset_remove(desc->topLevelStructs, subType);
    }
}
Exemplo n.º 5
0
/**
 * Checks if the type is builtin or not, and if not,
 * decrements the reference count of the type,
 * freeing it if the count reaches zero.
 */
inline void base_type_xdecref(const base_type *bd)
{
    if (!is_builtin_type(bd)) {
        base_type_decref(bd);
    }
}