Closed fraguada closed 10 months ago
I've started working on this with PointCloud.Add. Overloaded methods with different argument counts work fine, but when the methods have the same argument length, then only one of them is registered. Still, this is already better than before, where no overloading worked in js. So current status is that as long as the methods have different number of arguments, it works.
My first experiment: https://github.com/mcneel/rhino3dm/blob/dev/src/bindings/bnd_pointcloud.cpp#L754-L758
I've opened an issue in the emscripten repo: https://github.com/emscripten-core/emscripten/issues/20117
pybind side of things works well.
Unfortunately this is the state of emscripten: overloads only work when the number of arguments differ, not the argument types
For example: https://github.com/mcneel/rhino3dm/blob/main/src/bindings/bnd_polycurve.cpp#L126-L128 Here there are three "append" methods with three different target methods. After compiling, only the last method
bool BND_PolyCurve::Append3(const BND_Curve& curve)
exists and we'll get an error when trying to pass an arc or a line. This behavior is also seen in xform overloads.One solution is to use
select_overload<ReturnType...>(BND_Class::BND_Method)
as documented here: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#overloaded-functions, but this would require we overload the methods (have the same method names)