Skip to content

Commit 0801711

Browse files
author
Federico Fissore
committedOct 8, 2015
Refactored functions in ctags parser
Signed-off-by: Federico Fissore <f.fissore@arduino.cc>
1 parent 5d3922e commit 0801711

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed
 

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

+13-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (s *CTagsParser) Run(context map[string]interface{}) error {
7171
tags = filterOutUnknownTags(tags)
7272
tags = filterOutTagsWithField(tags, FIELD_CLASS)
7373
tags = filterOutTagsWithField(tags, FIELD_STRUCT)
74-
tags = markTagsWithFunctionWithDefaultArgs(tags)
74+
tags = skipTagsWhere(tags, signatureContainsDefaultArg)
7575
tags = addPrototypes(tags)
7676
tags = removeDefinedProtypes(tags)
7777
tags = removeDuplicate(tags)
@@ -153,13 +153,23 @@ func removeDuplicate(tags []map[string]string) []map[string]string {
153153
return newTags
154154
}
155155

156-
func markTagsWithFunctionWithDefaultArgs(tags []map[string]string) []map[string]string {
156+
type skipFuncType func(tag map[string]string) bool
157+
158+
func skipTagsWhere(tags []map[string]string, skipFuncs ...skipFuncType) []map[string]string {
157159
for _, tag := range tags {
158-
tag[FIELD_SKIP] = strconv.FormatBool(strings.Contains(tag[FIELD_SIGNATURE], "="))
160+
skip := skipFuncs[0](tag)
161+
for _, skipFunc := range skipFuncs[1:] {
162+
skip = skip || skipFunc(tag)
163+
}
164+
tag[FIELD_SKIP] = strconv.FormatBool(skip)
159165
}
160166
return tags
161167
}
162168

169+
func signatureContainsDefaultArg(tag map[string]string) bool {
170+
return strings.Contains(tag[FIELD_SIGNATURE], "=")
171+
}
172+
163173
func filterOutTagsWithField(tags []map[string]string, field string) []map[string]string {
164174
var newTags []map[string]string
165175
for _, tag := range tags {

‎src/arduino.cc/builder/test/sketch_with_function_pointer/sketch.ino

-9
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.