Taken from D2768.
This replaces our function wrapper code with pure-template code. They would become neater come C++17 but they already work well.
Supported:
- Any number of argument, so long as they are convertible to/from JSVal (or are themselves JS::Values)
- Any return type, same criteria, including void
- Works with free functions and as object properties -> can use a custom "this" getter, so we can clean up things in a bunch of places (haven't done so yet).
- Optional arguments (aka some arguments are default-constructed no the C++ side)
Not supported:
- Functions that have overloads can't be called -> it's ambiguous. Might be solvable too with a fancy wrapper, but I'm not sure it's worth it.
There is no need to specify argument types anymore, however for the moment I'm using the ptr type and the pointer... I might find a way around that.
I think the changes mostly speak for themselves.
To check -> am I constructing the same default arguments?
----
Future improvements:
The syntax is rather awkward currently, as I must pass the pointer type and the pointer as template parameters.
If we were using C++14, I could use a single 'auto callable' argument and get it deduced, which would remove the redundancy.