diff --git a/c/clang/_wrap/cursor.cpp b/c/clang/_wrap/cursor.cpp index 2952a0d2..db550aae 100644 --- a/c/clang/_wrap/cursor.cpp +++ b/c/clang/_wrap/cursor.cpp @@ -35,6 +35,8 @@ int wrap_clang_Cursor_isNull(CXCursor *cursor) { return clang_Cursor_isNull(*cur void wrap_clang_getCursorSemanticParent(CXCursor *C, CXCursor *parent) { *parent = clang_getCursorSemanticParent(*C); } +void wrap_clang_getCursorDefinition(CXCursor *C, CXCursor *def) { *def = clang_getCursorDefinition(*C); } + void wrap_clang_getCursorLexicalParent(CXCursor *C, CXCursor *parent) { *parent = clang_getCursorLexicalParent(*C); } void wrap_clang_getOverriddenCursors(CXCursor *cursor, CXCursor **overridden, unsigned *num_overridden) { diff --git a/c/clang/basic.go b/c/clang/basic.go index 078bb3f2..5130803c 100644 --- a/c/clang/basic.go +++ b/c/clang/basic.go @@ -57,3 +57,12 @@ type StringSet struct { */ // llgo:link (*StringSet).Dispose C.clang_disposeStringSet func (*StringSet) Dispose() {} + +func GoString(clangStr String) (str string) { + defer clangStr.Dispose() + cstr := clangStr.CStr() + if cstr != nil { + str = c.GoString(cstr) + } + return +} diff --git a/c/clang/clang.go b/c/clang/clang.go index 8f2faf9b..0f3e25f0 100644 --- a/c/clang/clang.go +++ b/c/clang/clang.go @@ -1635,6 +1635,14 @@ func (c Cursor) SemanticParent() (parent Cursor) { return } +// llgo:link (*Cursor).wrapDefinition C.wrap_clang_getCursorDefinition +func (*Cursor) wrapDefinition(def *Cursor) {} + +func (c Cursor) Definition() (def Cursor) { + c.wrapDefinition(&def) + return +} + /** * Determine the lexical parent of the given cursor. * @@ -2795,6 +2803,26 @@ func (l SourceLocation) SpellingLocation(file *File, line, column, offset *c.Uin l.wrapSpellingLocation(file, line, column, offset) } +func (l SourceLocation) File() (ret File) { + l.wrapSpellingLocation(&ret, nil, nil, nil) + return +} + +func (l SourceLocation) Line() (ret c.Uint) { + l.wrapSpellingLocation(nil, &ret, nil, nil) + return +} + +func (l SourceLocation) Column() (ret c.Uint) { + l.wrapSpellingLocation(nil, nil, &ret, nil) + return +} + +func (l SourceLocation) Offset() (ret c.Uint) { + l.wrapSpellingLocation(nil, nil, nil, &ret) + return +} + /** * Retrieve a source location representing the first character within a * source range.