Esempio n. 1
0
    public ClangExplorerNode(
        CKind kind,
        ClangLocation location,
        ClangExplorerNode?parent,
        CXCursor cursor,
        CXType type,
        CXType originalType,
        string?name,
        string?typeName)
    {
        Kind = kind;

        if (string.IsNullOrEmpty(location.FileName))
        {
            if (type.IsPrimitive())
            {
                // Primitives don't have a location
                Location = new ClangLocation
                {
                    FilePath   = string.Empty,
                    FileName   = "Builtin",
                    LineColumn = 0,
                    LineNumber = 0,
                    IsBuiltin  = true
                };
            }
            else
            {
                throw new NotImplementedException();
            }
        }
        else
        {
            Location = location;
        }

        Parent       = parent;
        Cursor       = cursor;
        Type         = type;
        OriginalType = originalType;
        Name         = name;
        TypeName     = typeName;
    }
Esempio n. 2
0
    public static bool IsSystem(this CXType type)
    {
        var kind = type.kind;

        if (type.IsPrimitive())
        {
            return(true);
        }

        switch (kind)
        {
        case CXTypeKind.CXType_Pointer:
            var pointeeType = clang_getPointeeType(type);
            return(IsSystem(pointeeType));

        case CXTypeKind.CXType_ConstantArray:
        case CXTypeKind.CXType_IncompleteArray:
            var elementType = clang_getElementType(type);
            return(IsSystem(elementType));

        case CXTypeKind.CXType_Typedef:
        case CXTypeKind.CXType_Elaborated:
        case CXTypeKind.CXType_Record:
        case CXTypeKind.CXType_Enum:
        case CXTypeKind.CXType_FunctionProto:
            var declaration = clang_getTypeDeclaration(type);
            return(IsSystem(declaration));

        case CXTypeKind.CXType_FunctionNoProto:
            return(false);

        case CXTypeKind.CXType_Attributed:
            var modifiedType = clang_Type_getModifiedType(type);
            return(IsSystem(modifiedType));

        default:
            throw new NotImplementedException();
        }
    }