Skip to content

Fix prototype callback generation if direct reference is used #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

facchinm
Copy link
Member

@facchinm facchinm commented Nov 18, 2016

Fixes #180
Should be refactored when merging #190

@ArduinoBot
Copy link
Contributor

✅ Build completed.

⬇️ Build URL: http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-191.zip

ℹ️ To test this build:

  1. Replace arduino-builder binary (you can find it where you installed the IDE) with the provided one

@matthijskooijman
Copy link
Collaborator

From the commit messages and testcase it is not entirely clear to me what kind of code this is actually catering for. Could you perhaps expand on that (and probably update the commit message as well for future reference)?

@facchinm
Copy link
Member Author

This is actually a fix for the forward declaration generator; when guessing where to insert the declarations, it searches for function pointers in the form &function, while the preferred Arduino style for FP is function as in attachInterrupt.
With this PR it also searches for function only if the function signature is () (to avoid too many false positives, since it's only searching for a string ignoring the semantics)

Recalling arduino/arduino-cli#1944, we can't even diagnostic these kind of problems because the prototype is generated, but too late.

facchinm added a commit to facchinm/arduino-builder that referenced this pull request Jan 20, 2017
Fixes arduino#206

The sample code from the issue provided a smart way to cheat the dumb FP parser.
In fact, the & is referred to the return type (correct) but the comparator doesn't know about semantics and simply prepends the ampersand before searching for the match.
So the code matches itself, which makes absolutely no sense.
Avoiding this occurrence fixes the issue, however the entire code for prototype line insertion should be refactored in a saner way (see arduino#180 and arduino#191 for another problem)
@facchinm facchinm force-pushed the prototype_callback_generation branch from b73c990 to 99a0fa5 Compare March 17, 2017 11:16
the tag will be searched only if its signature is void and it's not being skipped for other reasons
@facchinm facchinm force-pushed the prototype_callback_generation branch from 99a0fa5 to 4a7df6b Compare March 17, 2017 11:19
@ArduinoBot
Copy link
Contributor

✅ Build completed.

⬇️ Build URL: http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-191.zip

ℹ️ To test this build:

  1. Replace arduino-builder binary (you can find it where you installed the IDE) with the provided one

@facchinm facchinm closed this Jun 14, 2017
@cmaglie cmaglie deleted the prototype_callback_generation branch January 11, 2018 10:42
@per1234 per1234 added the conclusion: duplicate Has already been submitted label Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto generated function declarations no longer works for callbacks assigned at variable declaration
5 participants