Merge pull request #893 from tsingbx/clang

add clang.GoString, clang.File functions for helper of llcppsymg struct_methodname
This commit is contained in:
xushiwei
2024-12-02 13:45:55 +08:00
committed by GitHub
3 changed files with 39 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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
}

View File

@@ -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.