Exemple #1
0
static String typeString(const CXType &type)
{
    const char *builtIn = builtinTypeName(type.kind);
    if (builtIn)
        return builtIn;

    if (char pointer = (type.kind == CXType_Pointer ? '*' : (type.kind == CXType_LValueReference ? '&' : 0))) {
        const CXType pointee = clang_getPointeeType(type);
        String ret = typeString(pointee);
        if (ret.endsWith('*') || ret.endsWith('&')) {
            ret += pointer;
        } else {
            ret += ' ';
            ret += pointer;
        }
        return ret;
    }

    if (type.kind == CXType_ConstantArray) {
        String arrayType = typeString(clang_getArrayElementType(type));
        const long long count = clang_getNumElements(type);
        arrayType += '[';
        if (count >= 0)
            arrayType += String::number(count);
        arrayType += ']';
        return arrayType;
    }
    String ret = IndexerJob::typeName(clang_getTypeDeclaration(type));
    if (ret.endsWith(' '))
        ret.chop(1);
    return ret;
}
Exemple #2
0
long long cursor::type::num_elements()
{
    return clang_getNumElements(ctype);
}