From 6da5fe4317627903ec50cd7841b8c35204d6caa4 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Mon, 5 Aug 2024 19:26:59 +0800 Subject: [PATCH] c/clang:marco content --- c/clang/_demo/symboldump/symboldump.go | 1 + c/clang/clang.go | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/c/clang/_demo/symboldump/symboldump.go b/c/clang/_demo/symboldump/symboldump.go index e5a74a4b..ab44ffbc 100644 --- a/c/clang/_demo/symboldump/symboldump.go +++ b/c/clang/_demo/symboldump/symboldump.go @@ -59,6 +59,7 @@ func printMarcoInfo(cursor clang.Cursor) { for _, tok := range tokensSlice { tokStr := context.unit.Token(tok) c.Printf(c.Str("%s "), tokStr.CStr()) + tokStr.Dispose() } c.Printf(c.Str("\n")) diff --git a/c/clang/clang.go b/c/clang/clang.go index dfbe6824..14a195c6 100644 --- a/c/clang/clang.go +++ b/c/clang/clang.go @@ -1360,7 +1360,6 @@ type SourceRange struct { /** * Describes a kind of token. */ - type TokenKind c.Int const ( @@ -1471,6 +1470,16 @@ func (c Cursor) Argument(index c.Uint) (arg Cursor) { return } +/** + * Retrieve the physical location of the source constructor referenced + * by the given cursor. + * + * The location of a declaration is typically the location of the name of that + * declaration, where the name of that declaration would occur if it is + * unnamed, or some keyword that introduces that particular declaration. + * The location of a reference is where that reference occurs within the + * source code. + */ // llgo:link (*Cursor).wrapLocation C.wrap_clang_getCursorLocation func (c *Cursor) wrapLocation(loc *SourceLocation) {} @@ -1518,7 +1527,7 @@ func (c Cursor) Extent() (loc SourceRange) { // llgo:link (*TranslationUnit).wrapTokenize C.wrap_clang_tokenize func (t *TranslationUnit) wrapTokenize(ran *SourceRange, tokens **Token, numTokens *c.Uint) {} -func (t TranslationUnit) Tokenize(ran SourceRange, tokens **Token, numTokens *c.Uint) { +func (t *TranslationUnit) Tokenize(ran SourceRange, tokens **Token, numTokens *c.Uint) { t.wrapTokenize(&ran, tokens, numTokens) } @@ -1533,7 +1542,7 @@ func (*TranslationUnit) wrapToken(token *Token) (ret String) { return } -func (c TranslationUnit) Token(token Token) (ret String) { +func (c *TranslationUnit) Token(token Token) (ret String) { return c.wrapToken(&token) }