API Reference

Base.isconstMethod
isconst(t::Union{CXType,CLType}) -> Bool

Determine whether a CXType has the "const" qualifier set, without looking through typedefs that may have added "const" at a different level. Wrapper for libclang's clang_isConstQualifiedType.

source
Base.isvalidMethod
isvalid(k::CXcursorKind) -> Bool
isvalid(c::CLCursor) -> Bool

Return true if the given cursor kind represents an valid cursor. Wrapper for libclang's clang_isInvalid.

source
Clang.address_spaceMethod
address_space(t::Union{CXType,CLType})

Returns the address space of the given type. Wrapper for libclang's clang_getAddressSpace.

source
Clang.annotateMethod
annotate(tu::TranslationUnit, tokens, token_num, cursors)

Annotate the given set of tokens by providing cursors for each token that can be mapped to a specific entity within the abstract syntax tree.

source
Clang.argnumMethod
argnum(c::Union{CXCursor,CLFunctionDecl,CLCXXMethod}) -> Int

Return the number of non-variadic arguments associated with a given cursor. Wrapper for libclang's clang_Cursor_getNumArguments.

source
Clang.argnumMethod
argnum(t::Union{CXType,CLFunctionNoProto,CLFunctionProto}) -> Int

Return the number of non-variadic parameters associated with a function type. Wrapper for libclang's clang_getNumArgTypes.

source
Clang.argtypeMethod
argtype(t::CXType, i::Unsigned) -> CXType
argtype(t::Union{CLFunctionNoProto,CLFunctionProto}, i::Integer) -> CLType

Return the type of a parameter of a function type. Wrapper for libclang's clang_getArgType.

source
Clang.argumentMethod
argument(c::CXCursor, i::Integer) -> CXCursor
argument(c::Union{CLFunctionDecl,CLCXXMethod}, i::Integer) -> CLCursor

Return the argument cursor of a function or method. Wrapper for libclang's clang_Cursor_getArgument.

source
Clang.bitwidthMethod
bitwidth(c::CLFieldDecl) -> Int

Return the bit width of a bit field declaration as an integer. Wrapper for libclang's clang_getFieldDeclBitWidth.

source
Clang.calling_convMethod
calling_conv(t::Union{CXType,CLFunctionNoProto,CLFunctionProto}) -> CXCallingConv

Return the calling convention associated with a function type. Wrapper for libclang's clang_getFunctionTypeCallingConv.

source
Clang.canonicalMethod
canonical(c::CXCursor) -> CXCursor
canonical(c::CLCursor) -> CLCursor

Return the canonical cursor corresponding to the given cursor. Wrapper for libclang's clang_getCanonicalCursor.

source
Clang.canonicalMethod
canonical(t::CXType) -> CXType
canonical(t::CLType) -> CLType

Return the canonical type for a CXType.

Clang's type system explicitly models typedefs and all the ways a specific type can be represented. The canonical type is the underlying type with all the "sugar" removed. For example, if 'T' is a typedef for 'int', the canonical type for 'T' would be 'int'. Wrapper for libclang's clang_getCanonicalType.

source
Clang.childrenMethod
children(cursor::CXCursor) -> Vector{CXCursor}
children(cursor::CLCursor) -> Vector{CLCursor}

Return a child cursor vector of the given cursor.

source
Clang.clang2juliaMethod
clang2julia(t::CLIncompleteArray)

IncompleteArrays are translated to pointers, so one need to deal with the byte offsets directly.

source
Clang.clang2juliaMethod
clang2julia(t::CLUnexposed)

Unexposed Clang types are translated to the symbol of its cursor name(if exist).

source
Clang.element_numMethod
element_num(t::Union{CXType,CLVector,CLConstantArray,CLIncompleteArray,CLVariableArray,CLDependentSizedArray}) -> Int

Return the number of elements of an array or vector type. Wrapper for libclang's clang_getNumElements.

source
Clang.element_typeMethod
element_type(t::CXType) -> CXType
element_type(t::Union{CLVector,CLConstantArray,CLIncompleteArray,CLVariableArray,CLDependentSizedArray,CLComplex}) -> CLType

Return the element type of an array, complex, or vector type. Wrapper for libclang's clang_getElementType.

source
Clang.extentMethod
extent(c::Union{CXCursor,CLCursor}) -> CXSourceRange

Return the physical extent of the source construct referenced by the given cursor.

The extent of a cursor starts with the file/line/column pointing at the first character within the source construct that the cursor refers to and ends with the last character within that source construct. For a declaration, the extent covers the declaration itself. For a reference, the extent covers the location of the reference (e.g., where the referenced entity was actually used). Wrapper for libclang's clang_getCursorExtent.

source
Clang.extentMethod
extent(tu::Union{CXTranslationUnit,TranslationUnit}, t::Union{CXToken,CLToken}) -> CXSourceRange

Return a source range that covers the given token.

source
Clang.filenameMethod
filename(c::Union{CXCursor,CLCursor}) -> String

Return the complete file and path name of the given file referenced by the input cursor.

source
Clang.function_argsMethod
function_args(cursor::CLCursor) -> Vector{CLCursor}

Return function arguments for a given cursor.

source
Clang.get_included_fileMethod
get_included_file(c::Union{CXCursor,CLCursor}) -> CXFile

Return the file that is included by the given inclusion directive cursor. Wrapper for libclang's clang_getIncludedFile.

source
Clang.get_lexical_parentMethod
get_lexical_parent(c::CXCursor) -> CXCursor
get_lexical_parent(c::CLCursor) -> CLCursor

Return the lexical parent of the given cursor. Please checkout libclang's doc to know more. Wrapper for libclang's clang_getCursorLexicalParent.

source
Clang.get_named_typeMethod
get_named_type(t::CXType) -> CXType
get_named_type(t::CLElaborated) -> CLType

Return the type named by the qualified-id. Wrapper for libclang's clang_Type_getNamedType.

source
Clang.get_semantic_parentMethod
get_semantic_parent(c::CXCursor) -> CXCursor
get_semantic_parent(c::CLCursor) -> CLCursor

Return the semantic parent of the given cursor. Please checkout libclang's doc to know more. Wrapper for libclang's clang_getCursorSemanticParent.

source
Clang.get_translation_unitMethod
get_translation_unit(c::Union{CXCursor,CLCursor}) -> CXTranslationUnit

Returns the translation unit that a cursor originated from. Wrapper for libclang's clang_Cursor_getTranslationUnit.

source
Clang.getcursorMethod
getcursor(tu::TranslationUnit) -> CLCursor
getcursor(tu::CXTranslationUnit) -> CXCursor

Return the cursor that represents the given translation unit.

source
Clang.getcursorMethod
getcursor() -> (NULL)CXCursor

Return the NULL CXCursor. Wrapper for libclang's clang_getNullCursor.

source
Clang.getdefMethod
getdef(c::CXCursor) -> CXCursor
getdef(c::CLCursor) -> CLCursor

For a cursor that is either a reference to or a declaration of some entity, retrieve a cursor that describes the definition of that entity. Wrapper for libclang's clang_getCursorDefinition.

source
Clang.getrefMethod
getref(c::CXCursor) -> CXCursor
getref(c::CLCursor) -> CLCursor

For a cursor that is a reference, retrieve a cursor representing the entity that it references. Wrapper for libclang's clang_getCursorReferenced.

source
Clang.handle_macro_exprnMethod
handle_macro_exprn(tokens::TokenList, pos::Int)

For handling of #define'd constants, allows basic expressions but bails out quickly.

source
Clang.hasattrMethod
hasattr(c::Union{CXCursor,CLCursor}) -> Bool

Determine whether the given cursor has any attributes. Wrapper for libclang's clang_Cursor_hasAttrs.

source
Clang.integer_typeMethod
integer_type(c::CLEnumDecl) -> CLType

Retrieve the integer type of an enum declaration. Wrapper for libclang's clang_getEnumDeclIntegerType.

source
Clang.is_plain_old_dataMethod
is_plain_old_data(t::Union{CXType,CLType}) -> Bool

Return true if the CXType is a plain old data type. Wrapper for libclang's clang_isPODType.

source
Clang.is_translation_unitMethod
is_translation_unit(k::CXcursorKind) -> Bool
is_translation_unit(c::CLCursor) -> Bool

Return true if the given cursor kind represents a translation unit. Wrapper for libclang's clang_isTranslationUnit.

source
Clang.is_typedef_anonMethod
is_typedef_anon(current::CLCursor, next::CLCursor) -> Bool

Return true if the current cursor is an typedef anonymous struct/enum.

source
Clang.isanonymousMethod
isanonymous(c::Union{CXCursor,CLCursor}) -> Bool

Return true if the given cursor represents an anonymous record declaration(C++). Wrapper for libclang's clang_Cursor_isAnonymous.

source
Clang.isattrMethod
isattr(k::CXcursorKind) -> Bool
isattr(c::CLCursor) -> Bool

Return true if the given cursor kind represents an attribute. Wrapper for libclang's clang_isAttribute.

source
Clang.isbitMethod
isbit(c::Union{CXCursor,CLCursor}) -> Bool

Return true if the cursor specifies a Record member that is a bitfield. Wrapper for libclang's clang_Cursor_isBitField.

source
Clang.isbuiltinMethod
isbuiltin(c::Union{CXCursor,CLCursor}) -> Bool

Determine whether a CXCursor that is a macro, is a builtin one. Wrapper for libclang's clang_Cursor_isMacroBuiltin.

source
Clang.isdeclMethod
isdecl(k::CXcursorKind) -> Bool
isdecl(c::CLCursor) -> Bool

Return true if the given cursor kind represents a declaration. Wrapper for libclang's clang_isDeclaration.

source
Clang.isdefMethod
isdef(c::Union{CXCursor,CLCursor}) -> Bool

Return true if the declaration pointed to by this cursor is also a definition of that entity. Wrapper for libclang's clang_isCursorDefinition.

source
Clang.isexprMethod
isexpr(k::CXcursorKind) -> Bool
isexpr(c::CLCursor) -> Bool

Return true if the given cursor kind represents an expression. Wrapper for libclang's clang_isExpression.

source
Clang.isfunctionlikeMethod
isfunctionlike(c::Union{CXCursor,CLCursor}) -> Bool

Determine whether a CXCursor that is a macro, is function like. Wrapper for libclang's clang_Cursor_isMacroFunctionLike.

source
Clang.isinlinedMethod
isinlined(c::Union{CXCursor,CLCursor}) -> Bool

Determine whether a CXCursor that is a function declaration, is an inline declaration. Wrapper for libclang's clang_Cursor_isFunctionInlined.

source
Clang.isnullMethod
isnull(c::Union{CXCursor,CLCursor}) -> Bool

Return true if cursor is null. Wrapper for libclang's clang_Cursor_isNull.

source
Clang.ispreprocessingMethod
ispreprocessing(k::CXcursorKind) -> Bool
ispreprocessing(c::CLCursor) -> Bool

Return true if the given cursor kind represents a preprocessing element, such as a preprocessor directive or macro instantiation. Wrapper for libclang's clang_isPreprocessing.

source
Clang.isrefMethod
isref(k::CXcursorKind) -> Bool
isref(c::CLCursor) -> Bool

Return true if the given cursor kind represents a simple reference. Note that other kinds of cursors (such as expressions) can also refer to other cursors. Use getref to determine whether a particular cursor refers to another entity. Wrapper for libclang's clang_isReference.

source
Clang.isrestrictMethod
isrestrict(t::Union{CXType,CLType}) -> Bool

Determine whether a CXType has the "restrict" qualifier set, without looking through typedefs that may have added "restrict" at a different level. Wrapper for libclang's clang_isRestrictQualifiedType.

source
Clang.isstmtMethod
isstmt(k::CXcursorKind) -> Bool
isstmt(c::CLCursor) -> Bool

Return true if the given cursor kind represents a statement. Wrapper for libclang's clang_isStatement.

source
Clang.isunexposedMethod
isunexposed(k::CXcursorKind) -> Bool

Return true if the given cursor kind represents a currently unexposed piece of the AST (e.g., CXCursorUnexposedStmt). Wrapper for libclang's `clangisUnexposed`.

source
Clang.isvalidMethod
isvalid(t::CXType) -> Bool
isvalid(t::CLType) -> Bool

Return true if the type is a valid type.

source
Clang.isvariadicMethod
isvariadic(c::Union{CXCursor,CLCursor}) -> Bool

Return true if the given cursor is a variadic function or method. Wrapper for libclang's clang_Cursor_isVariadic.

source
Clang.isvariadicMethod
isvariadic(t::Union{CXType,CLType}) -> Bool

Return true if the CXType is a variadic function type. Wrapper for libclang's clang_isFunctionTypeVariadic.

source
Clang.isvirtualMethod
isvirtual(c::Union{CXCursor,CLCursor}) -> Bool

Return true if the base class specified by the cursor with kind CXCXXBaseSpecifier is virtual. Wrapper for libclang's `clangisVirtualBase`.

source
Clang.isvolatileMethod
isvolatile(t::Union{CXType,CLType}) -> Bool

Determine whether a CXType has the "volatile" qualifier set, without looking through typedefs that may have added "volatile" at a different level. Wrapper for libclang's clang_isVolatileQualifiedType.

source
Clang.kindMethod
kind(c::CLCursor) -> CXCursorKind

Return the kind of the given cursor. Note this method directly reads CXCursor's kind field, which won't invoke additional clang_getCursorKind function calls.

source
Clang.kindMethod
kind(c::CXCursor) -> CXCursorKind

Return the kind of the given cursor. Wrapper for libclang's clang_getCursorKind.

source
Clang.kindMethod
kind(t::CXToken) -> CXTokenKind
kind(t::CLToken) -> CXTokenKind

Return the kind of the given token.

source
Clang.kindMethod
kind(t::CXType) -> CXTypeKind
kind(t::CLType) -> CXTypeKind

Return the kind of the given type.

source
Clang.linkageMethod
linkage(c::Union{CXCursor,CLCursor}) -> CXLinkageKind

Return the linkage of the entity referred to by a given cursor. Wrapper for libclang's clang_getCursorLinkage.

source
Clang.locationMethod
location(c::Union{CXCursor,CLCursor}) -> CXSourceLocation

Return the physical location of the source constructor referenced by the given cursor. Wrapper for libclang's clang_getCursorLocation.

source
Clang.locationMethod
location(tu::Union{CXTranslationUnit,TranslationUnit}, t::Union{CXToken,CLToken}) -> CXSourceLocation

Return the source location of the given token.

source
Clang.nameMethod
name(c::Union{CXCursor,CLCursor}) -> String

Return the display name for the entity referenced by this cursor.

source
Clang.name_safeMethod
name_safe(name::AbstractString)

Return a valid Julia variable name, prefixed with "_" if the name is conflict with Julia's reserved words.

source
Clang.parse_headerMethod
parse_header(header::AbstractString; index::Index=Index(), args::Vector{String}=String[],
             includes::Vector{String}=String[], flags=CXTranslationUnit_None) -> TranslationUnit

Return the TranslationUnit for a given header. This is the main entry point for parsing. See also parse_headers.

Arguments

  • header::AbstractString: the header file to parse.
  • index::Index: CXIndex pointer (pass to avoid re-allocation).
  • args::Vector{String}: compiler switches as string array, eg: ["-x", "c++", "-fno-elide-type"].
  • includes::Vector{String}: vector of extra include directories to search.
  • flags: bitwise OR of CXTranslationUnit_Flags.
source
Clang.parse_headersMethod
parse_headers(headers::Vector{String}; index::Index=Index(), args::Vector{String}=String[], includes::Vector{String}=String[],
    flags = CXTranslationUnit_DetailedPreprocessingRecord | CXTranslationUnit_SkipFunctionBodies) -> Vector{TranslationUnit}

Return a TranslationUnit vector for the given headers. See also parse_header.

source
Clang.pointee_typeMethod
pointee_type(t::CXType) -> CXType
pointee_type(t::CLType) -> CLType

Return the type of the pointee for pointer types. Wrapper for libclang's clang_getPointeeType.

source
Clang.print_bufferMethod

Pretty-print a buffer of expressions (and comments) to an output stream Adds blank lines at appropriate places for readability

source
Clang.resolve_typeMethod
resolve_type(t::CLType) -> CLType

This function attempts to work around some limitations of the current libclang API.

source
Clang.result_typeMethod
result_type(c::CXCursor) -> CXType
result_type(c::Union{CLFunctionDecl,CLCXXMethod}) -> CLType

Return the return type associated with a given cursor. This only returns a valid type if the cursor refers to a function or method. Wrapper for libclang's clang_getCursorResultType.

source
Clang.result_typeMethod
result_type(t::CXType) -> CXType
result_type(t::Union{CLFunctionNoProto,CLFunctionProto}) -> CLType

Return the return type associated with a function type. Wrapper for libclang's clang_getResultType.

source
Clang.return_typeFunction
return_type(c::CLCursor, resolve::Bool=true) -> CXtype

Return the return type associated with a function/method cursor.

source
Clang.searchMethod
search(cursors::Vector{CLCursor}, ismatch::Function) -> Vector{CLCursor}

Return vector of CLCursors that match predicate. ismatch is a function that accepts a CLCursor argument.

source
Clang.spellingMethod
spelling(kind::CXTypeKind) -> String

Return the spelling of a given CXTypeKind.

source
Clang.spellingMethod
spelling(tu::TranslationUnit, t::CLToken) -> String
spelling(tu::TranslationUnit, t::CXToken) -> String
spelling(tu::CXTranslationUnit, t::CXToken) -> String

Return the spelling of the given token. The spelling of a token is the textual representation of that token, e.g., the text of an identifier or keyword.

source
Clang.spellingMethod
spelling(tu::TranslationUnit) -> String

Return the original translation unit source file name.

source
Clang.spellingMethod
spelling(c::Union{CXCursor,CLCursor}) -> String

Return a name for the entity referenced by this cursor.

source
Clang.spellingMethod
spelling(t::Union{CXType,CLType}) -> String

Pretty-print the underlying type using the rules of the language of the translation unit from which it came. If the type is invalid, an empty string is returned. Wrapper for libclang's clang_getTypeSpelling.

source
Clang.tokenizeMethod
tokenize(c::Union{CXCursor,CLCursor}) -> TokenList

Return a TokenList from the given cursor.

source
Clang.typeMethod
type(c::CXCursor) -> CXType
type(c::CLCursor) -> CLType

Return the type of a CXCursor (if any). To get the cursor from a type, see typedecl. Wrapper for libclang's clang_getCursorType.

source
Clang.typedeclMethod
typedecl(t::CXType) -> CXCursor
typedecl(t::CLType) -> CLCursor

Return the cursor for the declaration of the given type. To get the type of the cursor, see type. Wrapper for libclang's clang_getTypeDeclaration.

source
Clang.typedef_nameMethod
typedef_name(t::Union{CXType,CLType}) -> String

Return the typedef name of the given type. Wrapper for libclang's clang_getTypedefName.

source
Clang.typedef_typeMethod
typedef_type(c::CLCursor) -> CXType

Return the underlying type of a typedef declaration.

source
Clang.typesizeMethod
typesize(t::CLType) -> Int
typesize(c::CLCursor) -> Int

Return field declaration size.

source
Clang.underlying_typeMethod
underlying_type(c::CLTypedefDecl) -> CLType

Return the underlying type of a typedef declaration. Wrapper for libclang's clang_getTypedefDeclUnderlyingType.

source
Clang.valueMethod
value(c::CLCursor) -> Int

Return the integer value of an enum constant declaration.

source
Clang.wrap!Method
wrap!(ctx::AbstractContext, cursor::CLEnumDecl)

Subroutine for handling enum declarations.

source
Clang.wrap!Method
wrap!(ctx::AbstractContext, cursor::CLFunctionDecl)

Subroutine for handling function declarations. Note that VarArg functions are not supported.

source
Clang.wrap!Method
wrap!(ctx::AbstractContext, cursor::CLMacroDefinition)

Subroutine for handling macro declarations.

source
Clang.wrap!Method
wrap!(ctx::AbstractContext, cursor::CLStructDecl)

Subroutine for handling struct declarations.

source
Clang.wrap!Method
wrap!(ctx::AbstractContext, cursor::CLTypeRef)

For now, we just skip CXCursor_TypeRef cursors.

source
Clang.wrap!Method
wrap!(ctx::AbstractContext, cursor::CLTypedefDecl)

Subroutine for handling typedef declarations.

source
Clang.wrap!Method
wrap!(ctx::AbstractContext, cursor::CLUnionDecl)

Subroutine for handling union declarations.

source
Clang.IndexType
Index(exclude_decls_from_PCH, display_diagnostics)

Provide a shared context for creating translation units.

Arguments

  • exclude_decls_from_PCH: whether to allow enumeration of "local" declarations.
  • display_diagnostics: whether to display diagnostics.
source
Clang.TranslationUnitType
TranslationUnit(idx, source, args)
TranslationUnit(idx, source, args, unsavedFiles, options)

Parse the given source file and the translation unit corresponding to that file.

source