Add the option to 'return' the bound argument via pass-by-reference. #867
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.