Closed frericp closed 3 years ago
That's funny, because I explicitly renamed it from BIND_FUNC
to BIND_CLASS_FUNC
before, since it only works on class member functions (i.e. you have to provide a class parameter to the macro). But I wasn't aware of the emscripten::class_function
. Will change it back...
This PR introduces a way to conveniently create bindings for functions with optional parameters. The following compares the old with the new approach:
Old: Create a single binding that expects all parameters, including optional ones (due to a limitation of Emscripten). Allow to not provide optional parameters by adding additional logic on the JavaScript side, which essentially fills in all non-provided optional parameters.
New: Use macros to automatically register multiple bindings for a function, each taking a different number of parameters. This has several advantages:
All functions of the
Document
class that had default parameters defined in the JS boilerplate code have been redefined for illustration purposes.Furthermore, this PR fixes an issue with the JS boilerplate code, which broke the function overloading capabilities of Emscripten.
FYI @sdunkel @kohakukun