/
clang.go
51 lines (44 loc) · 898 Bytes
/
clang.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package clang
// #cgo LDFLAGS: -L/usr/lib/llvm -lclang
// #include <clang-c/Index.h>
import "C"
type Index struct {
ptr C.CXIndex
}
func CreateIndex(exclude_decl_from_pch, display_diags bool) Index {
var arg1, arg2 C.int
if exclude_decl_from_pch {
arg1 = 1
} else {
arg1 = 0
}
if display_diags {
arg2 = 1
} else {
arg1 = 0
}
p := C.clang_createIndex(arg1, arg2)
return Index{p}
}
func (index *Index) Dispose() {
if index != nil && index.ptr != nil {
C.clang_disposeIndex(index.ptr)
index.ptr = nil
}
}
type TranslationUnit struct {
ptr C.CXTranslationUnit
}
func ParseTranslationUnit(idx Index,
filename string,
cmdline_args []string,
unsaved_files []UnsavedFile,
options TUOptions) TranslationUnit {
return TranslationUnit{}
}
func (tu *TranslationUnit) Dispose() {
if tu != nil && tu.ptr != nil {
C.clang_disposeTranslationUnit(tu.ptr)
tu.ptr = nil
}
}