Add the option to 'return' the bound argument via pass-by-reference.#867
Open
dandeto wants to merge 2 commits into
Open
Add the option to 'return' the bound argument via pass-by-reference.#867dandeto wants to merge 2 commits into
dandeto wants to merge 2 commits into
Conversation
Collaborator
Author
|
Built just fine on my machine. I'll look into it later. |
Collaborator
|
You'll need Since this PR adds a new function, why not just add a |
Collaborator
Author
|
C++ could default the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will resolve #730 and also maintains backwards-compatibility.
void webview::unbind(const std::string &name)works as before.void webview::unbind(const std::string &name, void *&arg)implements the new desired behavior of "returning" the bound argument via pass-by-reference.void webview_unbind_return(webview_t w, const char *name, void *&arg);is the new C function. I had to change the name since overloading does not exist in C.Unbind without returning the arg:
Unbind, use the arg, and free:
The correct way to do this in C++ would be to use a template like so:
template<typename T> void unbind(const std::string &name, T *& arg). Unfortunately, I could not figure out how to get C to call a C++ template function. Maybe you guys know more about that. This continues the pattern of usingvoid*to accept an argument of any type, but usingvoid*&is a little unsafe.