/
index.jl
34 lines (31 loc) · 1.03 KB
/
index.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
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.
"""
mutable struct Index
ptr::CXIndex
exclude_decls_from_PCH::Cint
display_diagnostics::Cint
function Index(exclude_decls_from_PCH, display_diagnostics)
ptr = clang_createIndex(exclude_decls_from_PCH, display_diagnostics)
@assert ptr != C_NULL
obj = new(ptr, exclude_decls_from_PCH, display_diagnostics)
finalizer(obj) do x
if x.ptr != C_NULL
clang_disposeIndex(x)
x.ptr = C_NULL
end
end
return obj
end
end
Index(diagnostic::Bool) = Index(false, diagnostic)
Index() = Index(true)
Base.unsafe_convert(::Type{CXIndex}, x::Index) = x.ptr
## TODO:
# clang_CXIndex_setGlobalOptions
# clang_CXIndex_getGlobalOptions
# clang_CXIndex_setInvocationEmissionPathOption