c/clang:location to cursor

This commit is contained in:
luoliwoshang
2024-11-04 15:50:05 +08:00
parent d0217e62f0
commit 8bef0ede1b
2 changed files with 28 additions and 0 deletions

View File

@@ -33,6 +33,10 @@ void wrap_clang_getOverriddenCursors(CXCursor *cursor, CXCursor **overridden, un
clang_getOverriddenCursors(*cursor, overridden, num_overridden); clang_getOverriddenCursors(*cursor, overridden, num_overridden);
} }
void wrap_clang_getCursor(CXTranslationUnit uint, CXSourceLocation *loc, CXCursor *cur) {
*cur = clang_getCursor(uint, *loc);
}
void wrap_clang_getCursorLocation(CXCursor *cur, CXSourceLocation *loc) { *loc = clang_getCursorLocation(*cur); } void wrap_clang_getCursorLocation(CXCursor *cur, CXSourceLocation *loc) { *loc = clang_getCursorLocation(*cur); }
void wrap_clang_getCursorExtent(CXCursor *cur, CXSourceRange *range) { *range = clang_getCursorExtent(*cur); } void wrap_clang_getCursorExtent(CXCursor *cur, CXSourceRange *range) { *range = clang_getCursorExtent(*cur); }

View File

@@ -1710,6 +1710,30 @@ func (c Cursor) OverriddenCursors(overridden **Cursor, numOverridden *c.Uint) {
// llgo:link (*Cursor).DisposeOverriddenCursors C.clang_disposeOverriddenCursors // llgo:link (*Cursor).DisposeOverriddenCursors C.clang_disposeOverriddenCursors
func (c *Cursor) DisposeOverriddenCursors() {} func (c *Cursor) DisposeOverriddenCursors() {}
/**
* Map a source location to the cursor that describes the entity at that
* location in the source code.
*
* clang_getCursor() maps an arbitrary source location within a translation
* unit down to the most specific cursor that describes the entity at that
* location. For example, given an expression \c x + y, invoking
* clang_getCursor() with a source location pointing to "x" will return the
* cursor for "x"; similarly for "y". If the cursor points anywhere between
* "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
* will return a cursor referring to the "+" expression.
*
* \returns a cursor representing the entity at the given source location, or
* a NULL cursor if no such entity can be found.
*/
// llgo:link (*TranslationUnit).wrapGetCursor C.wrap_clang_getCursor
func (l *TranslationUnit) wrapGetCursor(loc *SourceLocation, cur *Cursor) {}
func (l *TranslationUnit) GetCursor(loc *SourceLocation) (cur Cursor) {
l.wrapGetCursor(loc, &cur)
return
}
/** /**
* Retrieve the physical location of the source constructor referenced * Retrieve the physical location of the source constructor referenced
* by the given cursor. * by the given cursor.