Prerequisites

As referred to below, Index.h is the libclang API header, available within the Clang source tree at include/clang-c/Index.h (suggested download location).

The following definitions should be adjusted to match the appropriate paths on your system, if libclang is installed separately from Julia.


In [1]:
indexh         = joinpath(JULIA_HOME, "../include/clang-c/Index.h")
clang_includes = [joinpath(JULIA_HOME, "../lib/clang/3.3/include"), joinpath(dirname(indexh), "..")]


Out[1]:
2-element Array{ASCIIString,1}:
 "/cmn/julia/usr/bin/../lib/clang/3.3/include"                          
 "/cmn/julia/usr/bin/../../deps/llvm-3.3/tools/clang/include/clang-c/.."

Printing Enums


In [3]:
using Clang.cindex

top = parse_header(indexh; includes=clang_includes, diagnostics=true)

function print_enums(enumdef::EnumDecl)
    for enum in children(enumdef)
        println("  const ", name(enum), " = ", value(enum))
    end
end

for cursor in children(top)
    # Skip cursors not in target file
    if (basename(cu_file(cursor)) != basename(indexh)) continue end
    
    got_enum = false
    if isa(cursor, EnumDecl)
        #if (name(cursor) == "") continue end
        println("# Enum: ", name(cursor))
        print_enums(cursor)
        got_enum = true
    elseif isa(cursor, TypedefDecl)
        td_children = children(cursor)
        td_children.size == 0 && continue
        
        td_cursor = td_children[1]
        if isa(td_cursor, EnumDecl)
            println("# Typedef Enum: ", name(td_cursor))
            print_enums(td_cursor)
            got_enum = true
        end
    end
end


# Enum: CXAvailabilityKind
  const CXAvailability_Available = 0
  const CXAvailability_Deprecated = 1
  const CXAvailability_NotAvailable = 2
  const CXAvailability_NotAccessible = 3
# Enum: 
  const CXGlobalOpt_None = 0
  const CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 1
  const CXGlobalOpt_ThreadBackgroundPriorityForEditing = 2
  const CXGlobalOpt_ThreadBackgroundPriorityForAll = 3
# Typedef Enum: 
  const CXGlobalOpt_None = 0
  const CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 1
  const CXGlobalOpt_ThreadBackgroundPriorityForEditing = 2
  const CXGlobalOpt_ThreadBackgroundPriorityForAll = 3
# Enum: CXDiagnosticSeverity
  const CXDiagnostic_Ignored = 0
  const CXDiagnostic_Note = 1
  const CXDiagnostic_Warning = 2
  const CXDiagnostic_Error = 3
  const CXDiagnostic_Fatal = 4
# Enum: CXLoadDiag_Error
  const CXLoadDiag_None = 0
  const CXLoadDiag_Unknown = 1
  const CXLoadDiag_CannotLoad = 2
  const CXLoadDiag_InvalidFile = 3
# Enum: CXDiagnosticDisplayOptions
  const CXDiagnostic_DisplaySourceLocation = 1
  const CXDiagnostic_DisplayColumn = 2
  const CXDiagnostic_DisplaySourceRanges = 4
  const CXDiagnostic_DisplayOption = 8
  const CXDiagnostic_DisplayCategoryId = 16
  const CXDiagnostic_DisplayCategoryName = 32
# Enum: CXTranslationUnit_Flags
  const CXTranslationUnit_None = 0
  const CXTranslationUnit_DetailedPreprocessingRecord = 1
  const CXTranslationUnit_Incomplete = 2
  const CXTranslationUnit_PrecompiledPreamble = 4
  const CXTranslationUnit_CacheCompletionResults = 8
  const CXTranslationUnit_ForSerialization = 16
  const CXTranslationUnit_CXXChainedPCH = 32
  const CXTranslationUnit_SkipFunctionBodies = 64
  const CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 128
# Enum: CXSaveTranslationUnit_Flags
  const CXSaveTranslationUnit_None = 0
# Enum: CXSaveError
  const CXSaveError_None = 0
  const CXSaveError_Unknown = 1
  const CXSaveError_TranslationErrors = 2
  const CXSaveError_InvalidTU = 3
# Enum: CXReparse_Flags
  const CXReparse_None = 0
# Enum: CXTUResourceUsageKind
  const CXTUResourceUsage_AST = 1
  const CXTUResourceUsage_Identifiers = 2
  const CXTUResourceUsage_Selectors = 3
  const CXTUResourceUsage_GlobalCompletionResults = 4
  const CXTUResourceUsage_SourceManagerContentCache = 5
  const CXTUResourceUsage_AST_SideTables = 6
  const CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7
  const CXTUResourceUsage_SourceManager_Membuffer_MMap = 8
  const CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9
  const CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10
  const CXTUResourceUsage_Preprocessor = 11
  const CXTUResourceUsage_PreprocessingRecord = 12
  const CXTUResourceUsage_SourceManager_DataStructures = 13
  const CXTUResourceUsage_Preprocessor_HeaderSearch = 14
  const CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = 1
  const CXTUResourceUsage_MEMORY_IN_BYTES_END = 14
  const CXTUResourceUsage_First = 1
  const CXTUResourceUsage_Last = 14
# Enum: CXCursorKind
  const CXCursor_UnexposedDecl = 1
  const CXCursor_StructDecl = 2
  const CXCursor_UnionDecl = 3
  const CXCursor_ClassDecl = 4
  const CXCursor_EnumDecl = 5
  const CXCursor_FieldDecl = 6
  const CXCursor_EnumConstantDecl = 7
  const CXCursor_FunctionDecl = 8
  const CXCursor_VarDecl = 9
  const CXCursor_ParmDecl = 10
  const CXCursor_ObjCInterfaceDecl = 11
  const CXCursor_ObjCCategoryDecl = 12
  const CXCursor_ObjCProtocolDecl = 13
  const CXCursor_ObjCPropertyDecl = 14
  const CXCursor_ObjCIvarDecl = 15
  const CXCursor_ObjCInstanceMethodDecl = 16
  const CXCursor_ObjCClassMethodDecl = 17
  const CXCursor_ObjCImplementationDecl = 18
  const CXCursor_ObjCCategoryImplDecl = 19
  const CXCursor_TypedefDecl = 20
  const CXCursor_CXXMethod = 21
  const CXCursor_Namespace = 22
  const CXCursor_LinkageSpec = 23
  const CXCursor_Constructor = 24
  const CXCursor_Destructor = 25
  const CXCursor_ConversionFunction = 26
  const CXCursor_TemplateTypeParameter = 27
  const CXCursor_NonTypeTemplateParameter = 28
  const CXCursor_TemplateTemplateParameter = 29
  const CXCursor_FunctionTemplate = 30
  const CXCursor_ClassTemplate = 31
  const CXCursor_ClassTemplatePartialSpecialization = 32
  const CXCursor_NamespaceAlias = 33
  const CXCursor_UsingDirective = 34
  const CXCursor_UsingDeclaration = 35
  const CXCursor_TypeAliasDecl = 36
  const CXCursor_ObjCSynthesizeDecl = 37
  const CXCursor_ObjCDynamicDecl = 38
  const CXCursor_CXXAccessSpecifier = 39
  const CXCursor_FirstDecl = 1
  const CXCursor_LastDecl = 39
  const CXCursor_FirstRef = 40
  const CXCursor_ObjCSuperClassRef = 40
  const CXCursor_ObjCProtocolRef = 41
  const CXCursor_ObjCClassRef = 42
  const CXCursor_TypeRef = 43
  const CXCursor_CXXBaseSpecifier = 44
  const CXCursor_TemplateRef = 45
  const CXCursor_NamespaceRef = 46
  const CXCursor_MemberRef = 47
  const CXCursor_LabelRef = 48
  const CXCursor_OverloadedDeclRef = 49
  const CXCursor_VariableRef = 50
  const CXCursor_LastRef = 50
  const CXCursor_FirstInvalid = 70
  const CXCursor_InvalidFile = 70
  const CXCursor_NoDeclFound = 71
  const CXCursor_NotImplemented = 72
  const CXCursor_InvalidCode = 73
  const CXCursor_LastInvalid = 73
  const CXCursor_FirstExpr = 100
  const CXCursor_UnexposedExpr = 100
  const CXCursor_DeclRefExpr = 101
  const CXCursor_MemberRefExpr = 102
  const CXCursor_CallExpr = 103
  const CXCursor_ObjCMessageExpr = 104
  const CXCursor_BlockExpr = 105
  const CXCursor_IntegerLiteral = 106
  const CXCursor_FloatingLiteral = 107
  const CXCursor_ImaginaryLiteral = 108
  const CXCursor_StringLiteral = 109
  const CXCursor_CharacterLiteral = 110
  const CXCursor_ParenExpr = 111
  const CXCursor_UnaryOperator = 112
  const CXCursor_ArraySubscriptExpr = 113
  const CXCursor_BinaryOperator = 114
  const CXCursor_CompoundAssignOperator = 115
  const CXCursor_ConditionalOperator = 116
  const CXCursor_CStyleCastExpr = 117
  const CXCursor_CompoundLiteralExpr = 118
  const CXCursor_InitListExpr = 119
  const CXCursor_AddrLabelExpr = 120
  const CXCursor_StmtExpr = 121
  const CXCursor_GenericSelectionExpr = 122
  const CXCursor_GNUNullExpr = 123
  const CXCursor_CXXStaticCastExpr = 124
  const CXCursor_CXXDynamicCastExpr = 125
  const CXCursor_CXXReinterpretCastExpr = 126
  const CXCursor_CXXConstCastExpr = 127
  const CXCursor_CXXFunctionalCastExpr = 128
  const CXCursor_CXXTypeidExpr = 129
  const CXCursor_CXXBoolLiteralExpr = 130
  const CXCursor_CXXNullPtrLiteralExpr = 131
  const CXCursor_CXXThisExpr = 132
  const CXCursor_CXXThrowExpr = 133
  const CXCursor_CXXNewExpr = 134
  const CXCursor_CXXDeleteExpr = 135
  const CXCursor_UnaryExpr = 136
  const CXCursor_ObjCStringLiteral = 137
  const CXCursor_ObjCEncodeExpr = 138
  const CXCursor_ObjCSelectorExpr = 139
  const CXCursor_ObjCProtocolExpr = 140
  const CXCursor_ObjCBridgedCastExpr = 141
  const CXCursor_PackExpansionExpr = 142
  const CXCursor_SizeOfPackExpr = 143
  const CXCursor_LambdaExpr = 144
  const CXCursor_ObjCBoolLiteralExpr = 145
  const CXCursor_ObjCSelfExpr = 146
  const CXCursor_LastExpr = 146
  const CXCursor_FirstStmt = 200
  const CXCursor_UnexposedStmt = 200
  const CXCursor_LabelStmt = 201
  const CXCursor_CompoundStmt = 202
  const CXCursor_CaseStmt = 203
  const CXCursor_DefaultStmt = 204
  const CXCursor_IfStmt = 205
  const CXCursor_SwitchStmt = 206
  const CXCursor_WhileStmt = 207
  const CXCursor_DoStmt = 208
  const CXCursor_ForStmt = 209
  const CXCursor_GotoStmt = 210
  const CXCursor_IndirectGotoStmt = 211
  const CXCursor_ContinueStmt = 212
  const CXCursor_BreakStmt = 213
  const CXCursor_ReturnStmt = 214
  const CXCursor_GCCAsmStmt = 215
  const CXCursor_AsmStmt = 215
  const CXCursor_ObjCAtTryStmt = 216
  const CXCursor_ObjCAtCatchStmt = 217
  const CXCursor_ObjCAtFinallyStmt = 218
  const CXCursor_ObjCAtThrowStmt = 219
  const CXCursor_ObjCAtSynchronizedStmt = 220
  const CXCursor_ObjCAutoreleasePoolStmt = 221
  const CXCursor_ObjCForCollectionStmt = 222
  const CXCursor_CXXCatchStmt = 223
  const CXCursor_CXXTryStmt = 224
  const CXCursor_CXXForRangeStmt = 225
  const CXCursor_SEHTryStmt = 226
  const CXCursor_SEHExceptStmt = 227
  const CXCursor_SEHFinallyStmt = 228
  const CXCursor_MSAsmStmt = 229
  const CXCursor_NullStmt = 230
  const CXCursor_DeclStmt = 231
  const CXCursor_LastStmt = 231
  const CXCursor_TranslationUnit = 300
  const CXCursor_FirstAttr = 400
  const CXCursor_UnexposedAttr = 400
  const CXCursor_IBActionAttr = 401
  const CXCursor_IBOutletAttr = 402
  const CXCursor_IBOutletCollectionAttr = 403
  const CXCursor_CXXFinalAttr = 404
  const CXCursor_CXXOverrideAttr = 405
  const CXCursor_AnnotateAttr = 406
  const CXCursor_AsmLabelAttr = 407
  const CXCursor_LastAttr = 407
  const CXCursor_PreprocessingDirective = 500
  const CXCursor_MacroDefinition = 501
  const CXCursor_MacroExpansion = 502
  const CXCursor_MacroInstantiation = 502
  const CXCursor_InclusionDirective = 503
  const CXCursor_FirstPreprocessing = 500
  const CXCursor_LastPreprocessing = 503
  const CXCursor_ModuleImportDecl = 600
  const CXCursor_FirstExtraDecl = 600
  const CXCursor_LastExtraDecl = 600
# Enum: CXLinkageKind
  const CXLinkage_Invalid = 0
  const CXLinkage_NoLinkage = 1
  const CXLinkage_Internal = 2
  const CXLinkage_UniqueExternal = 3
  const CXLinkage_External = 4
# Enum: CXLanguageKind
  const CXLanguage_Invalid = 0
  const CXLanguage_C = 1
  const CXLanguage_ObjC = 2
  const CXLanguage_CPlusPlus = 3
# Enum: CXTypeKind
  const CXType_Invalid = 0
  const CXType_Unexposed = 1
  const CXType_Void = 2
  const CXType_Bool = 3
  const CXType_Char_U = 4
  const CXType_UChar = 5
  const CXType_Char16 = 6
  const CXType_Char32 = 7
  const CXType_UShort = 8
  const CXType_UInt = 9
  const CXType_ULong = 10
  const CXType_ULongLong = 11
  const CXType_UInt128 = 12
  const CXType_Char_S = 13
  const CXType_SChar = 14
  const CXType_WChar = 15
  const CXType_Short = 16
  const CXType_Int = 17
  const CXType_Long = 18
  const CXType_LongLong = 19
  const CXType_Int128 = 20
  const CXType_Float = 21
  const CXType_Double = 22
  const CXType_LongDouble = 23
  const CXType_NullPtr = 24
  const CXType_Overload = 25
  const CXType_Dependent = 26
  const CXType_ObjCId = 27
  const CXType_ObjCClass = 28
  const CXType_ObjCSel = 29
  const CXType_FirstBuiltin = 2
  const CXType_LastBuiltin = 29
  const CXType_Complex = 100
  const CXType_Pointer = 101
  const CXType_BlockPointer = 102
  const CXType_LValueReference = 103
  const CXType_RValueReference = 104
  const CXType_Record = 105
  const CXType_Enum = 106
  const CXType_Typedef = 107
  const CXType_ObjCInterface = 108
  const CXType_ObjCObjectPointer = 109
  const CXType_FunctionNoProto = 110
  const CXType_FunctionProto = 111
  const CXType_ConstantArray = 112
  const CXType_Vector = 113
# Enum: CXCallingConv
  const CXCallingConv_Default = 0
  const CXCallingConv_C = 1
  const CXCallingConv_X86StdCall = 2
  const CXCallingConv_X86FastCall = 3
  const CXCallingConv_X86ThisCall = 4
  const CXCallingConv_X86Pascal = 5
  const CXCallingConv_AAPCS = 6
  const CXCallingConv_AAPCS_VFP = 7
  const CXCallingConv_PnaclCall = 8
  const CXCallingConv_IntelOclBicc = 9
  const CXCallingConv_Invalid = 100
  const CXCallingConv_Unexposed = 200
# Enum: CXTypeLayoutError
  const CXTypeLayoutError_Invalid = -1
  const CXTypeLayoutError_Incomplete = -2
  const CXTypeLayoutError_Dependent = -3
  const CXTypeLayoutError_NotConstantSize = -4
  const CXTypeLayoutError_InvalidFieldName = -5
# Enum: CX_CXXAccessSpecifier
  const CX_CXXInvalidAccessSpecifier = 0
  const CX_CXXPublic = 1
  const CX_CXXProtected = 2
  const CX_CXXPrivate = 3
# Enum: CXChildVisitResult
  const CXChildVisit_Break = 0
  const CXChildVisit_Continue = 1
  const CXChildVisit_Recurse = 2
# Enum: 
  const CXObjCPropertyAttr_noattr = 0
  const CXObjCPropertyAttr_readonly = 1
  const CXObjCPropertyAttr_getter = 2
  const CXObjCPropertyAttr_assign = 4
  const CXObjCPropertyAttr_readwrite = 8
  const CXObjCPropertyAttr_retain = 16
  const CXObjCPropertyAttr_copy = 32
  const CXObjCPropertyAttr_nonatomic = 64
  const CXObjCPropertyAttr_setter = 128
  const CXObjCPropertyAttr_atomic = 256
  const CXObjCPropertyAttr_weak = 512
  const CXObjCPropertyAttr_strong = 1024
  const CXObjCPropertyAttr_unsafe_unretained = 2048
# Typedef Enum: 
  const CXObjCPropertyAttr_noattr = 0
  const CXObjCPropertyAttr_readonly = 1
  const CXObjCPropertyAttr_getter = 2
  const CXObjCPropertyAttr_assign = 4
  const CXObjCPropertyAttr_readwrite = 8
  const CXObjCPropertyAttr_retain = 16
  const CXObjCPropertyAttr_copy = 32
  const CXObjCPropertyAttr_nonatomic = 64
  const CXObjCPropertyAttr_setter = 128
  const CXObjCPropertyAttr_atomic = 256
  const CXObjCPropertyAttr_weak = 512
  const CXObjCPropertyAttr_strong = 1024
  const CXObjCPropertyAttr_unsafe_unretained = 2048
# Enum: 
  const CXObjCDeclQualifier_None = 0
  const CXObjCDeclQualifier_In = 1
  const CXObjCDeclQualifier_Inout = 2
  const CXObjCDeclQualifier_Out = 4
  const CXObjCDeclQualifier_Bycopy = 8
  const CXObjCDeclQualifier_Byref = 16
  const CXObjCDeclQualifier_Oneway = 32
# Typedef Enum: 
  const CXObjCDeclQualifier_None = 0
  const CXObjCDeclQualifier_In = 1
  const CXObjCDeclQualifier_Inout = 2
  const CXObjCDeclQualifier_Out = 4
  const CXObjCDeclQualifier_Bycopy = 8
  const CXObjCDeclQualifier_Byref = 16
  const CXObjCDeclQualifier_Oneway = 32
# Enum: CXCommentKind
  const CXComment_Null = 0
  const CXComment_Text = 1
  const CXComment_InlineCommand = 2
  const CXComment_HTMLStartTag = 3
  const CXComment_HTMLEndTag = 4
  const CXComment_Paragraph = 5
  const CXComment_BlockCommand = 6
  const CXComment_ParamCommand = 7
  const CXComment_TParamCommand = 8
  const CXComment_VerbatimBlockCommand = 9
  const CXComment_VerbatimBlockLine = 10
  const CXComment_VerbatimLine = 11
  const CXComment_FullComment = 12
# Enum: CXCommentInlineCommandRenderKind
  const CXCommentInlineCommandRenderKind_Normal = 0
  const CXCommentInlineCommandRenderKind_Bold = 1
  const CXCommentInlineCommandRenderKind_Monospaced = 2
  const CXCommentInlineCommandRenderKind_Emphasized = 3
# Enum: CXCommentParamPassDirection
  const CXCommentParamPassDirection_In = 0
  const CXCommentParamPassDirection_Out = 1
  const CXCommentParamPassDirection_InOut = 2
# Enum: CXNameRefFlags
  const CXNameRange_WantQualifier = 1
  const CXNameRange_WantTemplateArgs = 2
  const CXNameRange_WantSinglePiece = 4
# Enum: CXTokenKind
  const CXToken_Punctuation = 0
  const CXToken_Keyword = 1
  const CXToken_Identifier = 2
  const CXToken_Literal = 3
  const CXToken_Comment = 4
# Typedef Enum: CXTokenKind
  const CXToken_Punctuation = 0
  const CXToken_Keyword = 1
  const CXToken_Identifier = 2
  const CXToken_Literal = 3
  const CXToken_Comment = 4
# Enum: CXCompletionChunkKind
  const CXCompletionChunk_Optional = 0
  const CXCompletionChunk_TypedText = 1
  const CXCompletionChunk_Text = 2
  const CXCompletionChunk_Placeholder = 3
  const CXCompletionChunk_Informative = 4
  const CXCompletionChunk_CurrentParameter = 5
  const CXCompletionChunk_LeftParen = 6
  const CXCompletionChunk_RightParen = 7
  const CXCompletionChunk_LeftBracket = 8
  const CXCompletionChunk_RightBracket = 9
  const CXCompletionChunk_LeftBrace = 10
  const CXCompletionChunk_RightBrace = 11
  const CXCompletionChunk_LeftAngle = 12
  const CXCompletionChunk_RightAngle = 13
  const CXCompletionChunk_Comma = 14
  const CXCompletionChunk_ResultType = 15
  const CXCompletionChunk_Colon = 16
  const CXCompletionChunk_SemiColon = 17
  const CXCompletionChunk_Equal = 18
  const CXCompletionChunk_HorizontalSpace = 19
  const CXCompletionChunk_VerticalSpace = 20
# Enum: CXCodeComplete_Flags
  const CXCodeComplete_IncludeMacros = 1
  const CXCodeComplete_IncludeCodePatterns = 2
  const CXCodeComplete_IncludeBriefComments = 4
# Enum: CXCompletionContext
  const CXCompletionContext_Unexposed = 0
  const CXCompletionContext_AnyType = 1
  const CXCompletionContext_AnyValue = 2
  const CXCompletionContext_ObjCObjectValue = 4
  const CXCompletionContext_ObjCSelectorValue = 8
  const CXCompletionContext_CXXClassTypeValue = 16
  const CXCompletionContext_DotMemberAccess = 32
  const CXCompletionContext_ArrowMemberAccess = 64
  const CXCompletionContext_ObjCPropertyAccess = 128
  const CXCompletionContext_EnumTag = 256
  const CXCompletionContext_UnionTag = 512
  const CXCompletionContext_StructTag = 1024
  const CXCompletionContext_ClassTag = 2048
  const CXCompletionContext_Namespace = 4096
  const CXCompletionContext_NestedNameSpecifier = 8192
  const CXCompletionContext_ObjCInterface = 16384
  const CXCompletionContext_ObjCProtocol = 32768
  const CXCompletionContext_ObjCCategory = 65536
  const CXCompletionContext_ObjCInstanceMessage = 131072
  const CXCompletionContext_ObjCClassMessage = 262144
  const CXCompletionContext_ObjCSelectorName = 524288
  const CXCompletionContext_MacroName = 1048576
  const CXCompletionContext_NaturalLanguage = 2097152
  const CXCompletionContext_Unknown = 4194303
# Enum: CXVisitorResult
  const CXVisit_Break = 0
  const CXVisit_Continue = 1
# Enum: 
  const CXResult_Success = 0
  const CXResult_Invalid = 1
  const CXResult_VisitBreak = 2
# Typedef Enum: 
  const CXResult_Success = 0
  const CXResult_Invalid = 1
  const CXResult_VisitBreak = 2
# Enum: 
  const CXIdxEntity_Unexposed = 0
  const CXIdxEntity_Typedef = 1
  const CXIdxEntity_Function = 2
  const CXIdxEntity_Variable = 3
  const CXIdxEntity_Field = 4
  const CXIdxEntity_EnumConstant = 5
  const CXIdxEntity_ObjCClass = 6
  const CXIdxEntity_ObjCProtocol = 7
  const CXIdxEntity_ObjCCategory = 8
  const CXIdxEntity_ObjCInstanceMethod = 9
  const CXIdxEntity_ObjCClassMethod = 10
  const CXIdxEntity_ObjCProperty = 11
  const CXIdxEntity_ObjCIvar = 12
  const CXIdxEntity_Enum = 13
  const CXIdxEntity_Struct = 14
  const CXIdxEntity_Union = 15
  const CXIdxEntity_CXXClass = 16
  const CXIdxEntity_CXXNamespace = 17
  const CXIdxEntity_CXXNamespaceAlias = 18
  const CXIdxEntity_CXXStaticVariable = 19
  const CXIdxEntity_CXXStaticMethod = 20
  const CXIdxEntity_CXXInstanceMethod = 21
  const CXIdxEntity_CXXConstructor = 22
  const CXIdxEntity_CXXDestructor = 23
  const CXIdxEntity_CXXConversionFunction = 24
  const CXIdxEntity_CXXTypeAlias = 25
  const CXIdxEntity_CXXInterface = 26
# Typedef Enum: 
  const CXIdxEntity_Unexposed = 0
  const CXIdxEntity_Typedef = 1
  const CXIdxEntity_Function = 2
  const CXIdxEntity_Variable = 3
  const CXIdxEntity_Field = 4
  const CXIdxEntity_EnumConstant = 5
  const CXIdxEntity_ObjCClass = 6
  const CXIdxEntity_ObjCProtocol = 7
  const CXIdxEntity_ObjCCategory = 8
  const CXIdxEntity_ObjCInstanceMethod = 9
  const CXIdxEntity_ObjCClassMethod = 10
  const CXIdxEntity_ObjCProperty = 11
  const CXIdxEntity_ObjCIvar = 12
  const CXIdxEntity_Enum = 13
  const CXIdxEntity_Struct = 14
  const CXIdxEntity_Union = 15
  const CXIdxEntity_CXXClass = 16
  const CXIdxEntity_CXXNamespace = 17
  const CXIdxEntity_CXXNamespaceAlias = 18
  const CXIdxEntity_CXXStaticVariable = 19
  const CXIdxEntity_CXXStaticMethod = 20
  const CXIdxEntity_CXXInstanceMethod = 21
  const CXIdxEntity_CXXConstructor = 22
  const CXIdxEntity_CXXDestructor = 23
  const CXIdxEntity_CXXConversionFunction = 24
  const CXIdxEntity_CXXTypeAlias = 25
  const CXIdxEntity_CXXInterface = 26
# Enum: 
  const CXIdxEntityLang_None = 0
  const CXIdxEntityLang_C = 1
  const CXIdxEntityLang_ObjC = 2
  const CXIdxEntityLang_CXX = 3
# Typedef Enum: 
  const CXIdxEntityLang_None = 0
  const CXIdxEntityLang_C = 1
  const CXIdxEntityLang_ObjC = 2
  const CXIdxEntityLang_CXX = 3
# Enum: 
  const CXIdxEntity_NonTemplate = 0
  const CXIdxEntity_Template = 1
  const CXIdxEntity_TemplatePartialSpecialization = 2
  const CXIdxEntity_TemplateSpecialization = 3
# Typedef Enum: 
  const CXIdxEntity_NonTemplate = 0
  const CXIdxEntity_Template = 1
  const CXIdxEntity_TemplatePartialSpecialization = 2
  const CXIdxEntity_TemplateSpecialization = 3
# Enum: 
  const CXIdxAttr_Unexposed = 0
  const CXIdxAttr_IBAction = 1
  const CXIdxAttr_IBOutlet = 2
  const CXIdxAttr_IBOutletCollection = 3
# Typedef Enum: 
  const CXIdxAttr_Unexposed = 0
  const CXIdxAttr_IBAction = 1
  const CXIdxAttr_IBOutlet = 2
  const CXIdxAttr_IBOutletCollection = 3
# Enum: 
  const CXIdxDeclFlag_Skipped = 1
# Typedef Enum: 
  const CXIdxDeclFlag_Skipped = 1
# Enum: 
  const CXIdxObjCContainer_ForwardRef = 0
  const CXIdxObjCContainer_Interface = 1
  const CXIdxObjCContainer_Implementation = 2
# Typedef Enum: 
  const CXIdxObjCContainer_ForwardRef = 0
  const CXIdxObjCContainer_Interface = 1
  const CXIdxObjCContainer_Implementation = 2
# Enum: 
  const CXIdxEntityRef_Direct = 1
  const CXIdxEntityRef_Implicit = 2
# Typedef Enum: 
  const CXIdxEntityRef_Direct = 1
  const CXIdxEntityRef_Implicit = 2
# Enum: 
  const CXIndexOpt_None = 0
  const CXIndexOpt_SuppressRedundantRefs = 1
  const CXIndexOpt_IndexFunctionLocalSymbols = 2
  const CXIndexOpt_IndexImplicitTemplateInstantiations = 4
  const CXIndexOpt_SuppressWarnings = 8
  const CXIndexOpt_SkipParsedBodiesInSession = 16
# Typedef Enum: 
  const CXIndexOpt_None = 0
  const CXIndexOpt_SuppressRedundantRefs = 1
  const CXIndexOpt_IndexFunctionLocalSymbols = 2
  const CXIndexOpt_IndexImplicitTemplateInstantiations = 4
  const CXIndexOpt_SuppressWarnings = 8
  const CXIndexOpt_SkipParsedBodiesInSession = 16

Print Functions

Expected output:

Number of cursors in TranslationUnit: 679
Functions:
  clang_createIndex(CXIndex,Int,Int,)
  clang_disposeIndex(Typedef,)
  clang_CXIndex_setGlobalOptions(Typedef,UInt,)
  clang_CXIndex_getGlobalOptions(Typedef,)
  clang_getFileName(CXString,Typedef,)
  clang_getFileTime(time_t,Typedef,)
  ...

Note: number of cursors may vary depending on the definitions activated in previous includes based on system type and configuration.


In [7]:
using Clang.cindex

get_it(t::TypedefDecl) = get_it(cindex.getTypedefDeclUnderlyingType(t))
get_it(d::ParmDecl)    = get_it(cu_type(d))
get_it(t::TypeRef)     = spelling(t)
get_it(t::Pointer) = string("Ptr{", get_it(cindex.getPointeeType(t)), "}")
get_it(t::CLType)  = spelling(t)

get_it(c::CLCursor) = get_it(cindex.getCursorType(c))
get_it(f::FunctionDecl) = spelling(f)

function print_function(f::FunctionDecl)
    rt = return_type(f)
    print("  ", get_it(f))
    print("(")
    for a in children(f)
        if !(isa(a, TypeRef) || isa(a, ParmDecl)) break end
        print(get_it(a))
        print(",")
    end
    print(")\n")
end

function dump_functions(header::String)
    tu = parse_header(header; includes=clang_includes)
    tu_children = children(tu)
    
    println("Number of cursors in TranslationUnit: ", length(tu_children))
    println("Functions:")
    for node in children(tu)
        # Skip anything outside of the TU
        if (basename(cu_file(node)) != basename(header))
            continue
        end
        if isa(node, FunctionDecl)
            print_function(node)
        end
    end
end

dump_functions(indexh)


Number of cursors in TranslationUnit: 679
Functions:
  clang_createIndex(CXIndex,Int,Int,)
  clang_disposeIndex(Typedef,)
  clang_CXIndex_setGlobalOptions(Typedef,UInt,)
  clang_CXIndex_getGlobalOptions(Typedef,)
  clang_getFileName(CXString,Typedef,)
  clang_getFileTime(time_t,Typedef,)
  clang_getFileUniqueID(Typedef,Ptr{Typedef},)
  clang_isFileMultipleIncludeGuarded(Typedef,Typedef,)
  clang_getFile(CXFile,Typedef,Ptr{Char_S},)
  clang_getNullLocation(CXSourceLocation,)
  clang_equalLocations(Typedef,Typedef,)
  clang_getLocation(CXSourceLocation,Typedef,Typedef,UInt,UInt,)
  clang_getLocationForOffset(CXSourceLocation,Typedef,Typedef,UInt,)
  clang_Location_isInSystemHeader(Typedef,)
  clang_getNullRange(CXSourceRange,)
  clang_getRange(CXSourceRange,Typedef,Typedef,)
  clang_equalRanges(Typedef,Typedef,)
  clang_Range_isNull(Typedef,)
  clang_getExpansionLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)
  clang_getPresumedLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},)
  clang_getInstantiationLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)
  clang_getSpellingLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)
  clang_getFileLocation(Typedef,Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)
  clang_getRangeStart(CXSourceLocation,Typedef,)
  clang_getRangeEnd(CXSourceLocation,Typedef,)
  clang_getNumDiagnosticsInSet(Typedef,)
  clang_getDiagnosticInSet(CXDiagnostic,Typedef,UInt,)
  clang_loadDiagnostics(CXDiagnosticSet,Ptr{Char_S},Ptr{Unexposed},Ptr{Typedef},)
  clang_disposeDiagnosticSet(Typedef,)
  clang_getChildDiagnostics(CXDiagnosticSet,Typedef,)
  clang_getNumDiagnostics(Typedef,)
  clang_getDiagnostic(CXDiagnostic,Typedef,UInt,)
  clang_getDiagnosticSetFromTU(CXDiagnosticSet,Typedef,)
  clang_disposeDiagnostic(Typedef,)
  clang_formatDiagnostic(CXString,Typedef,UInt,)
  clang_defaultDiagnosticDisplayOptions()
  clang_getDiagnosticSeverity(enum CXDiagnosticSeverity,Typedef,)
  clang_getDiagnosticLocation(CXSourceLocation,Typedef,)
  clang_getDiagnosticSpelling(CXString,Typedef,)
  clang_getDiagnosticOption(CXString,Typedef,Ptr{Typedef},)
  clang_getDiagnosticCategory(Typedef,)
  clang_getDiagnosticCategoryName()
  clang_getDiagnosticCategoryText(CXString,Typedef,)
  clang_getDiagnosticNumRanges(Typedef,)
  clang_getDiagnosticRange(CXSourceRange,Typedef,UInt,)
  clang_getDiagnosticNumFixIts(Typedef,)
  clang_getDiagnosticFixIt(CXString,Typedef,UInt,Ptr{Typedef},)
  clang_getTranslationUnitSpelling(CXString,Typedef,)
  clang_createTranslationUnitFromSourceFile(CXTranslationUnit,Typedef,Ptr{Char_S},Int,Ptr{Ptr{Char_S}},UInt,Ptr{Unexposed},)
  clang_createTranslationUnit(CXTranslationUnit,Typedef,Ptr{Char_S},)
  clang_defaultEditingTranslationUnitOptions()
  clang_parseTranslationUnit(CXTranslationUnit,Typedef,Ptr{Char_S},Ptr{Ptr{Char_S}},Int,Ptr{Unexposed},UInt,UInt,)
  clang_defaultSaveOptions(Typedef,)
  clang_saveTranslationUnit(Typedef,Ptr{Char_S},UInt,)
  clang_disposeTranslationUnit(Typedef,)
  clang_defaultReparseOptions(Typedef,)
  clang_reparseTranslationUnit(Typedef,UInt,Ptr{Unexposed},UInt,)
  clang_getTUResourceUsageName(Unexposed,)
  clang_getCXTUResourceUsage(CXTUResourceUsage,Typedef,)
  clang_disposeCXTUResourceUsage(Typedef,)
  clang_getNullCursor(CXCursor,)
  clang_getTranslationUnitCursor(CXCursor,Typedef,)
  clang_equalCursors(Typedef,Typedef,)
  clang_Cursor_isNull(Typedef,)
  clang_hashCursor(Typedef,)
  clang_getCursorKind(enum CXCursorKind,Typedef,)
  clang_isDeclaration(Unexposed,)
  clang_isReference(Unexposed,)
  clang_isExpression(Unexposed,)
  clang_isStatement(Unexposed,)
  clang_isAttribute(Unexposed,)
  clang_isInvalid(Unexposed,)
  clang_isTranslationUnit(Unexposed,)
  clang_isPreprocessing(Unexposed,)
  clang_isUnexposed(Unexposed,)
  clang_getCursorLinkage(enum CXLinkageKind,Typedef,)
  clang_getCursorAvailability(enum CXAvailabilityKind,Typedef,)
  clang_getCursorPlatformAvailability(Typedef,Ptr{Int},Ptr{Typedef},Ptr{Int},Ptr{Typedef},Ptr{Typedef},Int,)
  clang_disposeCXPlatformAvailability(Ptr{Typedef},)
  clang_getCursorLanguage(enum CXLanguageKind,Typedef,)
  clang_Cursor_getTranslationUnit(CXTranslationUnit,Typedef,)
  clang_createCXCursorSet(CXCursorSet,)
  clang_disposeCXCursorSet(Typedef,)
  clang_CXCursorSet_contains(Typedef,Typedef,)
  clang_CXCursorSet_insert(Typedef,Typedef,)
  clang_getCursorSemanticParent(CXCursor,Typedef,)
  clang_getCursorLexicalParent(CXCursor,Typedef,)
  clang_getOverriddenCursors(Typedef,Ptr{Ptr{Typedef}},Ptr{UInt},)
  clang_disposeOverriddenCursors(Ptr{Typedef},)
  clang_getIncludedFile(CXFile,Typedef,)
  clang_getCursor(CXCursor,Typedef,Typedef,)
  clang_getCursorLocation(CXSourceLocation,Typedef,)
  clang_getCursorExtent(CXSourceRange,Typedef,)
  clang_getCursorType(CXType,Typedef,)
  clang_getTypeSpelling(CXString,Typedef,)
  clang_getTypedefDeclUnderlyingType(CXType,Typedef,)
  clang_getEnumDeclIntegerType(CXType,Typedef,)
  clang_getEnumConstantDeclValue(Typedef,)
  clang_getEnumConstantDeclUnsignedValue(Typedef,)
  clang_getFieldDeclBitWidth(Typedef,)
  clang_Cursor_getNumArguments(Typedef,)
  clang_Cursor_getArgument(CXCursor,Typedef,UInt,)
  clang_equalTypes(Typedef,Typedef,)
  clang_getCanonicalType(CXType,Typedef,)
  clang_isConstQualifiedType(Typedef,)
  clang_isVolatileQualifiedType(Typedef,)
  clang_isRestrictQualifiedType(Typedef,)
  clang_getPointeeType(CXType,Typedef,)
  clang_getTypeDeclaration(CXCursor,Typedef,)
  clang_getDeclObjCTypeEncoding(CXString,Typedef,)
  clang_getTypeKindSpelling(CXString,Unexposed,)
  clang_getFunctionTypeCallingConv(enum CXCallingConv,Typedef,)
  clang_getResultType(CXType,Typedef,)
  clang_getNumArgTypes(Typedef,)
  clang_getArgType(CXType,Typedef,UInt,)
  clang_isFunctionTypeVariadic(Typedef,)
  clang_getCursorResultType(CXType,Typedef,)
  clang_isPODType(Typedef,)
  clang_getElementType(CXType,Typedef,)
  clang_getNumElements(Typedef,)
  clang_getArrayElementType(CXType,Typedef,)
  clang_getArraySize(Typedef,)
  clang_Type_getAlignOf(Typedef,)
  clang_Type_getSizeOf(Typedef,)
  clang_Type_getOffsetOf(Typedef,Ptr{Char_S},)
  clang_Cursor_isBitField(Typedef,)
  clang_isVirtualBase(Typedef,)
  clang_getCXXAccessSpecifier(enum CX_CXXAccessSpecifier,Typedef,)
  clang_getNumOverloadedDecls(Typedef,)
  clang_getOverloadedDecl(CXCursor,Typedef,UInt,)
  clang_getIBOutletCollectionType(CXType,Typedef,)
  clang_visitChildren(Typedef,Typedef,Typedef,)
  clang_getCursorUSR(CXString,Typedef,)
  clang_constructUSR_ObjCClass(CXString,Ptr{Char_S},)
  clang_constructUSR_ObjCCategory(CXString,Ptr{Char_S},Ptr{Char_S},)
  clang_constructUSR_ObjCProtocol(CXString,Ptr{Char_S},)
  clang_constructUSR_ObjCIvar(CXString,Ptr{Char_S},Typedef,)
  clang_constructUSR_ObjCMethod(CXString,Ptr{Char_S},UInt,Typedef,)
  clang_constructUSR_ObjCProperty(CXString,Ptr{Char_S},Typedef,)
  clang_getCursorSpelling(CXString,Typedef,)
  clang_Cursor_getSpellingNameRange(CXSourceRange,Typedef,UInt,UInt,)
  clang_getCursorDisplayName(CXString,Typedef,)
  clang_getCursorReferenced(CXCursor,Typedef,)
  clang_getCursorDefinition(CXCursor,Typedef,)
  clang_isCursorDefinition(Typedef,)
  clang_getCanonicalCursor(CXCursor,Typedef,)
  clang_Cursor_getObjCSelectorIndex(Typedef,)
  clang_Cursor_isDynamicCall(Typedef,)
  clang_Cursor_getReceiverType(CXType,Typedef,)
  clang_Cursor_getObjCPropertyAttributes(Typedef,UInt,)
  clang_Cursor_getObjCDeclQualifiers(Typedef,)
  clang_Cursor_isVariadic(Typedef,)
  clang_Cursor_getCommentRange(CXSourceRange,Typedef,)
  clang_Cursor_getRawCommentText(CXString,Typedef,)
  clang_Cursor_getBriefCommentText(CXString,Typedef,)
  clang_Cursor_getParsedComment(CXComment,Typedef,)
  clang_Cursor_getModule(CXModule,Typedef,)
  clang_Module_getASTFile(CXFile,Typedef,)
  clang_Module_getParent(CXModule,Typedef,)
  clang_Module_getName(CXString,Typedef,)
  clang_Module_getFullName(CXString,Typedef,)
  clang_Module_getNumTopLevelHeaders(Typedef,Typedef,)
  clang_Module_getTopLevelHeader(CXFile,Typedef,Typedef,UInt,)
  clang_Comment_getKind(enum CXCommentKind,Typedef,)
  clang_Comment_getNumChildren(Typedef,)
  clang_Comment_getChild(CXComment,Typedef,UInt,)
  clang_Comment_isWhitespace(Typedef,)
  clang_InlineContentComment_hasTrailingNewline(Typedef,)
  clang_TextComment_getText(CXString,Typedef,)
  clang_InlineCommandComment_getCommandName(CXString,Typedef,)
  clang_InlineCommandComment_getRenderKind(enum CXCommentInlineCommandRenderKind,Typedef,)
  clang_InlineCommandComment_getNumArgs(Typedef,)
  clang_InlineCommandComment_getArgText(CXString,Typedef,UInt,)
  clang_HTMLTagComment_getTagName(CXString,Typedef,)
  clang_HTMLStartTagComment_isSelfClosing(Typedef,)
  clang_HTMLStartTag_getNumAttrs(Typedef,)
  clang_HTMLStartTag_getAttrName(CXString,Typedef,UInt,)
  clang_HTMLStartTag_getAttrValue(CXString,Typedef,UInt,)
  clang_BlockCommandComment_getCommandName(CXString,Typedef,)
  clang_BlockCommandComment_getNumArgs(Typedef,)
  clang_BlockCommandComment_getArgText(CXString,Typedef,UInt,)
  clang_BlockCommandComment_getParagraph(CXComment,Typedef,)
  clang_ParamCommandComment_getParamName(CXString,Typedef,)
  clang_ParamCommandComment_isParamIndexValid(Typedef,)
  clang_ParamCommandComment_getParamIndex(Typedef,)
  clang_ParamCommandComment_isDirectionExplicit(Typedef,)
  clang_ParamCommandComment_getDirection(enum CXCommentParamPassDirection,Typedef,)
  clang_TParamCommandComment_getParamName(CXString,Typedef,)
  clang_TParamCommandComment_isParamPositionValid(Typedef,)
  clang_TParamCommandComment_getDepth(Typedef,)
  clang_TParamCommandComment_getIndex(Typedef,UInt,)
  clang_VerbatimBlockLineComment_getText(CXString,Typedef,)
  clang_VerbatimLineComment_getText(CXString,Typedef,)
  clang_HTMLTagComment_getAsString(CXString,Typedef,)
  clang_FullComment_getAsHTML(CXString,Typedef,)
  clang_FullComment_getAsXML(CXString,Typedef,)
  clang_CXXMethod_isStatic(Typedef,)
  clang_CXXMethod_isVirtual(Typedef,)
  clang_getTemplateCursorKind(enum CXCursorKind,Typedef,)
  clang_getSpecializedCursorTemplate(CXCursor,Typedef,)
  clang_getCursorReferenceNameRange(CXSourceRange,Typedef,UInt,UInt,)
  clang_getTokenKind(CXTokenKind,Typedef,)
  clang_getTokenSpelling(CXString,Typedef,Typedef,)
  clang_getTokenLocation(CXSourceLocation,Typedef,Typedef,)
  clang_getTokenExtent(CXSourceRange,Typedef,Typedef,)
  clang_tokenize(Typedef,Typedef,Ptr{Ptr{Typedef}},Ptr{UInt},)
  clang_annotateTokens(Typedef,Ptr{Typedef},UInt,Ptr{Typedef},)
  clang_disposeTokens(Typedef,Ptr{Typedef},UInt,)
  clang_getCursorKindSpelling(CXString,Unexposed,)
  clang_getDefinitionSpellingAndExtent(Typedef,Ptr{Ptr{Char_S}},Ptr{Ptr{Char_S}},Ptr{UInt},Ptr{UInt},Ptr{UInt},Ptr{UInt},)
  clang_enableStackTraces()
  clang_executeOnThread(Ptr{Unexposed},Ptr{Void},UInt,)
  clang_getCompletionChunkKind(enum CXCompletionChunkKind,Typedef,UInt,)
  clang_getCompletionChunkText(CXString,Typedef,UInt,)
  clang_getCompletionChunkCompletionString(CXCompletionString,Typedef,UInt,)
  clang_getNumCompletionChunks(Typedef,)
  clang_getCompletionPriority(Typedef,)
  clang_getCompletionAvailability(enum CXAvailabilityKind,Typedef,)
  clang_getCompletionNumAnnotations(Typedef,)
  clang_getCompletionAnnotation(CXString,Typedef,UInt,)
  clang_getCompletionParent(CXString,Typedef,Ptr{Unexposed},)
  clang_getCompletionBriefComment(CXString,Typedef,)
  clang_getCursorCompletionString(CXCompletionString,Typedef,)
  clang_defaultCodeCompleteOptions()
  clang_codeCompleteAt(CXCodeCompleteResults,Typedef,Ptr{Char_S},UInt,UInt,Ptr{Unexposed},UInt,UInt,)
  clang_sortCodeCompletionResults(Ptr{Typedef},UInt,)
  clang_disposeCodeCompleteResults(Ptr{Typedef},)
  clang_codeCompleteGetNumDiagnostics(Ptr{Typedef},)
  clang_codeCompleteGetDiagnostic(CXDiagnostic,Ptr{Typedef},UInt,)
  clang_codeCompleteGetContexts(Ptr{Typedef},)
  clang_codeCompleteGetContainerKind(enum CXCursorKind,Ptr{Typedef},Ptr{UInt},)
  clang_codeCompleteGetContainerUSR(CXString,Ptr{Typedef},)
  clang_codeCompleteGetObjCSelector(CXString,Ptr{Typedef},)
  clang_getClangVersion(CXString,)
  clang_toggleCrashRecovery(UInt,)
  clang_getInclusions(Typedef,Typedef,Typedef,)
  clang_getRemappings(CXRemapping,Ptr{Char_S},)
  clang_getRemappingsFromFileList(CXRemapping,Ptr{Ptr{Char_S}},UInt,)
  clang_remap_getNumFiles(Typedef,)
  clang_remap_getFilenames(Typedef,UInt,Ptr{Typedef},Ptr{Typedef},)
  clang_remap_dispose(Typedef,)
  clang_findReferencesInFile(CXResult,Typedef,Typedef,Typedef,)
  clang_findIncludesInFile(CXResult,Typedef,Typedef,Typedef,)
  clang_index_isEntityObjCContainerKind(Typedef,)
  clang_index_getObjCContainerDeclInfo(CXIdxObjCContainerDeclInfo,Ptr{Typedef},)
  clang_index_getObjCInterfaceDeclInfo(CXIdxObjCInterfaceDeclInfo,Ptr{Typedef},)
  clang_index_getObjCCategoryDeclInfo(CXIdxObjCCategoryDeclInfo,Ptr{Typedef},)
  clang_index_getObjCProtocolRefListInfo(CXIdxObjCProtocolRefListInfo,Ptr{Typedef},)
  clang_index_getObjCPropertyDeclInfo(CXIdxObjCPropertyDeclInfo,Ptr{Typedef},)
  clang_index_getIBOutletCollectionAttrInfo(CXIdxIBOutletCollectionAttrInfo,Ptr{Typedef},)
  clang_index_getCXXClassDeclInfo(CXIdxCXXClassDeclInfo,Ptr{Typedef},)
  clang_index_getClientContainer(CXIdxClientContainer,Ptr{Typedef},)
  clang_index_setClientContainer(Ptr{Typedef},Typedef,)
  clang_index_getClientEntity(CXIdxClientEntity,Ptr{Typedef},)
  clang_index_setClientEntity(Ptr{Typedef},Typedef,)
  clang_IndexAction_create(CXIndexAction,Typedef,)
  clang_IndexAction_dispose(Typedef,)
  clang_indexSourceFile(Typedef,Typedef,Ptr{Typedef},UInt,UInt,Ptr{Char_S},Ptr{Ptr{Char_S}},Int,Ptr{Unexposed},UInt,Ptr{Typedef},UInt,)
  clang_indexTranslationUnit(Typedef,Typedef,Ptr{Typedef},UInt,UInt,Typedef,)
  clang_indexLoc_getFileLocation(Typedef,Ptr{Typedef},Ptr{Typedef},Ptr{UInt},Ptr{UInt},Ptr{UInt},)
  clang_indexLoc_getCXSourceLocation(CXSourceLocation,Typedef,)

Printing Structs

Expected output:

Struct: CXTranslationUnitImpl
Struct: CXUnsavedFile
Struct: CXVersion
Struct: CXVersion
Struct: 
Struct:

Note: it takes a little bit more work to get the name of typedef'd structs. See Clang.jl/src/wrap_c.jl for a full implementation.


In [11]:
using Clang.cindex

get_struct(t::TypedefDecl) = get_struct(cindex.getTypeDeclaration(cindex.getTypedefDeclUnderlyingType(t)))
get_struct(d::StructDecl)  = d
get_struct(d::CLCursor)    = Union{}

function dump_structs(hdr::String)
    topcu = parse_header(hdr; includes = clang_includes)
    for cu in children(topcu)
        # Skip includes
        if (basename(cu_file(cu)) != basename(hdr)) continue end
        cur = get_struct(cu)
        if (cur != Union{})
            println("Struct: ", name(cur))
        end
    end
end

dump_structs(indexh)


Struct: CXTranslationUnitImpl
Struct: CXUnsavedFile
Struct: CXVersion
Struct: CXVersion
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: CXTUResourceUsageEntry
Struct: CXTUResourceUsageEntry
Struct: CXTUResourceUsage
Struct: CXTUResourceUsage
Struct: 
Struct: 
Struct: 
Struct: 
Struct: CXPlatformAvailability
Struct: CXPlatformAvailability
Struct: CXCursorSetImpl
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 
Struct: 

In [ ]: