Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ctags/ctags_to_prototypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ func functionNameUsedAsFunctionPointerIn(tag *types.CTag, functionTags []*types.
if tag.Line != functionTag.Line && strings.Index(tag.Code, "&"+functionTag.FunctionName) != -1 {
return true
}
if tag.Line != functionTag.Line && strings.Index(tag.Code, functionTag.FunctionName) != -1 &&
(functionTag.Signature == "(void)" || functionTag.Signature == "()") {
if tag.Line != functionTag.Line && strings.Index(strings.TrimSpace(tag.Code), "("+functionTag.FunctionName+")") != -1 {
return true
}
}
Expand Down
51 changes: 47 additions & 4 deletions test/prototypes_adder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
package test

import (
"github.com/arduino/arduino-builder"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
"github.com/stretchr/testify/require"
"os"
"path/filepath"
"strings"
"testing"

"github.com/arduino/arduino-builder"
"github.com/arduino/arduino-builder/types"
"github.com/arduino/arduino-builder/utils"
"github.com/stretchr/testify/require"
)

func TestPrototypesAdderBridgeExample(t *testing.T) {
Expand Down Expand Up @@ -906,3 +907,45 @@ func TestPrototypesAdderSketchWithDosEol(t *testing.T) {
}
// only requires no error as result
}

func TestPrototypesAdderSketchWithSubstringFunctionMember(t *testing.T) {
DownloadCoresAndToolsAndLibraries(t)

sketchLocation := filepath.Join("sketch_with_class_and_method_substring", "sketch_with_class_and_method_substring.ino")
quotedSketchLocation := utils.QuoteCppString(Abs(t, sketchLocation))

ctx := &types.Context{
HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"},
ToolsFolders: []string{"downloaded_tools"},
BuiltInLibrariesFolders: []string{"downloaded_libraries"},
OtherLibrariesFolders: []string{"libraries"},
SketchLocation: sketchLocation,
FQBN: "arduino:avr:uno",
ArduinoAPIVersion: "10600",
Verbose: true,
}

buildPath := SetupBuildPath(t, ctx)
defer os.RemoveAll(buildPath)

commands := []types.Command{

&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},

&builder.ContainerMergeCopySketchFiles{},

&builder.ContainerFindIncludes{},

&builder.PrintUsedLibrariesIfVerbose{},
&builder.WarnAboutArchIncompatibleLibraries{},

&builder.ContainerAddPrototypes{},
}

for _, command := range commands {
err := command.Run(ctx)
NoError(t, err)
}

require.Contains(t, ctx.Source, "class Foo {\nint blooper(int x) { return x+1; }\n};\n\nFoo foo;\n\n#line 7 "+quotedSketchLocation+"\nvoid setup();")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Foo {
int blooper(int x) { return x+1; }
};

Foo foo;

void setup() {
foo.setup();
}

void loop() {
foo.loop();
}