-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
Update typedefs of C-style function pointers to std::function #489
Conversation
This allows for the callback to maintain their own state (without recourse to globals). In addition, added some incidental clean up: - URICallback, passed by pointer, is now asserted to be non-null before accessing. - FSCallbacks are validated when they are set (in debug builds).
Does this change break the build(API breakage) for an existing app which uses C style function pointers? Also, please do not use |
(1) It shouldn't break the API.
|
Thanks!
In the case of this PR, I think simply check if a callback( Something like this:
|
The question is not how to determine if the callback is defined or not. The question is what to do about it. Sometimes you test, sometimes you don't. Sometimes when you test you do so in a context where you do have access to an error string and can return Specifically, I'm thinking of the functions like One option is to do nothing and wait until we try to use the functions to report that they are undefined. The other is throw an exception at the time they are setting the callbacks (at least that won't be during parsing). We could also change the return value so it returns a pair like |
Ah, I see. Ideally, such a method should have return type 'bool'(and return false when error), and also have the mechanism to report error message. (SetURICallbacks was contributed by a contributor, and at that time I accepted
I'd rather go with
This also won't break API usage in existing app code. |
Alrighty, I've removed all of the asserts (including the one from the previous PR) and updated the PRs as requested. I've confirmed this builds for my own purposes, but I don't call all of the callback functions. You might want to run it through any further testing of your own. |
Thanks! Merged!
At least CI & unit test passes. I may add some unit tester later. |
Out of curiosity, what is your policy for creating new releases? Or, to put it another way, if you had to guess how long it'll be before this latest commit ends up in a tagged commit, what would your guess be? |
Basically it follows with semvar rule.
|
And I notice you just released a new tag. :) Thanks. |
This allows for the callback to maintain their own state (without recourse to globals), making it compatible with lambdas, bindings, functors, etc.)
In addition, added some incidental clean up: