API Reference

API Reference

address_space(t::CXType)
address_space(t::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(tu::CXTranslationUnit, 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::CXCursor) -> Int
argnum(c::CLCXXMethod) -> Int
argnum(c::CLFunctionDecl) -> 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::CXType) -> Int
argnum(t::CLFunctionProto) -> Int
argnum(t::CLFunctionNoProto) -> 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::CLFunctionProto, i::Integer) -> CLType
argtype(t::CLFunctionNoProto, 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::Unsigned) -> CXCursor
argument(c::CLFunctionDecl, i::Integer) -> CLCursor
argument(c::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.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::CLConstantArray)

ConstantArrays are translated to NTuples.

source
Clang.clang2juliaMethod.
clang2julia(c::CLCursor) -> Symbol/Expr

Convert libclang cursor/type to Julia.

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::CLPointer)

Pointers are translated to Ptrs.

source
Clang.clang2juliaMethod.
clang2julia(t::CLType) -> Symbol/Expr

Convert libclang cursor/type to Julia.

source
Clang.clang2juliaMethod.
clang2julia(t::CLUnexposed)

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

source
Clang.copydepsMethod.
copydeps(dst)

Copy dependencies to dst.

source
Clang.element_numMethod.
element_num(t::CXType) -> Int
element_num(t::CLVector) -> Int
element_num(t::CLConstantArray) -> Int
element_num(t::CLIncompleteArray) -> Int
element_num(t::CLVariableArray) -> Int
element_num(t::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::CLVector) -> CLType
element_type(t::CLConstantArray) -> CLType
element_type(t::CLIncompleteArray) -> CLType
element_type(t::CLVariableArray) -> CLType
element_type(t::CLDependentSizedArray) -> CLType
element_type(t::CLComplex) -> CLType

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

source
Clang.extentMethod.
extent(c::CXCursor) -> CXSourceRange
extent(c::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::TranslationUnit, t::CLToken) -> CXSourceRange
extent(tu::TranslationUnit, t::CXToken) -> CXSourceRange
extent(tu::CXTranslationUnit, t::CXToken) -> CXSourceRange

Return a source range that covers the given token.

source
Clang.filenameMethod.
filename(c::CXCursor) -> String
filename(c::CLCursor) -> String

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

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

Return function arguments for a given cursor.

source
get_included_file(c::CXCursor) -> CXFile
get_included_file(c::CLCursor) -> CXFile

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

source
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
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
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
get_translation_unit(c::CXCursor) -> CXTranslationUnit
get_translation_unit(c::CLCursor) -> CXTranslationUnit

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

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

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.hasattrMethod.
hasattr(c::CXCursor) -> Bool
hasattr(c::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
is_plain_old_data(t::CXType) -> Bool
is_plain_old_data(t::CLType) -> Bool

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

source
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
is_typedef_anon(current::CLCursor, next::CLCursor) -> Bool

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

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::CXCursor) -> Bool
isbit(c::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::CXCursor) -> Bool
isbuiltin(c::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::CXCursor) -> Bool
isdef(c::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
isfunctionlike(c::CXCursor) -> Bool
isfunctionlike(c::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::CXCursor) -> Bool
isinlined(c::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::CXCursor) -> Bool
isnull(c::CLCursor) -> Bool

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

source
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::CXType) -> Bool
isrestrict(t::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.isvariadicMethod.
isvariadic(c::CXCursor) -> Bool
isvariadic(c::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::CXType) -> Bool
isvariadic(t::CLType) -> Bool

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

source
Clang.isvolatileMethod.
isvolatile(t::CXType) -> Bool
isvolatile(t::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.locationMethod.
location(c::CXCursor) -> CXSourceLocation
location(c::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::TranslationUnit, t::CLToken) -> CXSourceLocation
location(tu::TranslationUnit, t::CXToken) -> CXSourceLocation
location(tu::CXTranslationUnit, t::CXToken) -> CXSourceLocation

Return the source location of the given token.

source
Clang.nameMethod.
name(c::CXCursor) -> String
name(c::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
parse_headers(headers::Vector{String}; index::Index=Index(), args::Vector{String}=String[], includes::Vector{String}=String[],
    flags = CXTranslationUnit_DetailedPreprocessingRecord | CXTranslationUnit_SkipFunctionBodies) -> Dict

Return a TranslationUnit Dict 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::CLFunctionDecl) -> CLType
result_type(c::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::CLFunctionProto) -> CLType
result_type(t::CLFunctionNoProto) -> 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(c::CXCursor) -> String
spelling(c::CLCursor) -> String

Return a name for the entity referenced by this cursor.

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

Return the spelling of a given CXTypeKind.

source
Clang.spellingMethod.
spelling(t::CXType) -> String
spelling(t::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.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.symbol_safeMethod.
symbol_safe(name::AbstractString)

Same as name_safe, but return a Symbol.

source
Clang.tokenizeMethod.
tokenize(c::CXCursor) -> TokenList
tokenize(c::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::CXType) -> String
typedef_name(t::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
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.TokenListType.

Tokenizer access

source
TranslationUnit(idx, source, args)
TranslationUnit(idx, source, args, unsavedFiles, options)

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

source
WrapContext

Store shared information about the wrapping session.

source

Mapping from libclang types to Julia types

source

Unsupported argument types

source
Clang.RESERVED_WORDSConstant.

Reserved Julia identifiers will be prepended with "_"

source
Base.isconstMethod.
isconst(t::CXType) -> Bool
isconst(t::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.calling_convMethod.
calling_conv(t::CXType) -> CXCallingConv
calling_conv(t::CLFunctionProto) -> CXCallingConv
calling_conv(t::CLFunctionNoProto) -> CXCallingConv

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

source
handle_macro_exprn(tokens::TokenList, pos::Int)

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

source
Clang.isanonymousMethod.
isanonymous(c::CXCursor) -> Bool
isanonymous(c::CLCursor) -> Bool

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

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

Return true if the type is a valid type.

source
Clang.isvirtualMethod.
isvirtual(c::CXCursor) -> Bool
isvirtual(c::CLCursor) -> Bool

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

source
Clang.linkageMethod.
linkage(c::CXCursor) -> CXLinkageKind
linkage(c::CLCursor) -> CXLinkageKind

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

source