Skip to content

Commit 287a9c8

Browse files
committed
Handle more cases when searching for callback reference
the tag will be searched only if its signature is void and it's not being skipped for other reasons
1 parent ec0b021 commit 287a9c8

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/arduino.cc/builder/ctags/ctags_parser.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ func parseTag(row string) *types.CTag {
236236

237237
parts = parts[2:]
238238

239-
signature := ""
240239
returntype := ""
241240
for _, part := range parts {
242241
if strings.Contains(part, ":") {
@@ -253,7 +252,7 @@ func parseTag(row string) *types.CTag {
253252
case "typeref":
254253
tag.Typeref = value
255254
case "signature":
256-
signature = value
255+
tag.Signature = value
257256
case "returntype":
258257
returntype = value
259258
case "class":
@@ -265,7 +264,7 @@ func parseTag(row string) *types.CTag {
265264
}
266265
}
267266
}
268-
tag.Prototype = returntype + " " + tag.FunctionName + signature + ";"
267+
tag.Prototype = returntype + " " + tag.FunctionName + tag.Signature + ";"
269268

270269
if strings.Contains(row, "/^") && strings.Contains(row, "$/;") {
271270
tag.Code = row[strings.Index(row, "/^")+2 : strings.Index(row, "$/;")]

src/arduino.cc/builder/ctags/ctags_to_prototypes.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,18 @@ func functionNameUsedAsFunctionPointerIn(tag *types.CTag, functionTags []*types.
7070
if tag.Line != functionTag.Line && strings.Index(tag.Code, "&"+functionTag.FunctionName) != -1 {
7171
return true
7272
}
73+
if tag.Line != functionTag.Line && strings.Index(tag.Code, functionTag.FunctionName) != -1 &&
74+
(functionTag.Signature == "(void)" || functionTag.Signature == "()") {
75+
return true
76+
}
7377
}
7478
return false
7579
}
7680

7781
func (p *CTagsParser) collectFunctions() []*types.CTag {
7882
functionTags := []*types.CTag{}
7983
for _, tag := range p.tags {
80-
if tag.Kind == KIND_FUNCTION {
84+
if tag.Kind == KIND_FUNCTION && !tag.SkipMe {
8185
functionTags = append(functionTags, tag)
8286
}
8387
}

src/arduino.cc/builder/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ type CTag struct {
252252
Filename string
253253
Typeref string
254254
SkipMe bool
255+
Signature string
255256

256257
Prototype string
257258
Function string

0 commit comments

Comments
 (0)