-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursor.go
53 lines (41 loc) · 1.23 KB
/
cursor.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
52
53
package libclang
// #include <clang-c/Index.h>
import "C"
type Cursor C.CXCursor
func (c Cursor) c() C.CXCursor {
return C.CXCursor(c)
}
func (c Cursor) Spelling() string {
return cxString(C.clang_getCursorSpelling(c.c()))
}
func (c Cursor) Kind() CursorKind {
kind := C.clang_getCursorKind(c.c())
return CursorKind(kind)
}
func (c Cursor) Type() Type {
return Type(C.clang_getCursorType(c.c()))
}
func (c Cursor) IsStatic() bool {
return C.clang_Cursor_getStorageClass(c.c()) == C.CX_SC_Static
}
func (c Cursor) Location() (string, int, int) {
loc := C.clang_getCursorLocation(c.c())
var file C.CXFile
var line C.unsigned
var column C.unsigned
C.clang_getSpellingLocation(loc, &file, &line, &column, nil)
filename := C.clang_getFileName(file)
return cxString(filename), int(line), int(column)
}
func (c Cursor) EnumConstantDeclValue() int64 {
return int64(C.clang_getEnumConstantDeclValue(c.c()))
}
func (c Cursor) EnumConstantDeclUnsignedValue() uint64 {
return uint64(C.clang_getEnumConstantDeclUnsignedValue(c.c()))
}
func (c Cursor) Availability() AvailabilityKind {
return AvailabilityKind(C.clang_getCursorAvailability(c.c()))
}
func (c Cursor) IsDeprecated() bool {
return c.Availability() == Availability_Deprecated
}