Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Constructors supported. #24

Open
xemjeff opened this issue Apr 19, 2020 · 1 comment
Open

Multiple Constructors supported. #24

xemjeff opened this issue Apr 19, 2020 · 1 comment

Comments

@xemjeff
Copy link

xemjeff commented Apr 19, 2020

If I try to register multiple constructors for a class, only one of them is used:

class Vector3
{
public:
	Vector3();
	Vector3(double x_, double y_, double z_);

I register both constructors:

	dukglue_register_constructor<Vector3, double, double, double>(ctx, "Vector3");
	dukglue_register_constructor<Vector3>(ctx, "Vector3");

but now I can't use the first constructor.

@totalgee
Copy link

Agreed, this would be nice... I don't think function overloading is supported in JavaScript, but maybe something could be done with a "dispatching" dukglue-bound constructor method that takes variable args and calls the best constructor depending on the number/type of args?

Or having a way to set default arguments for dukglue-bound functions...? For example, in your example, maybe there's a way the x_, y_ and z_ arguments could be defaulted to 0, which would support a constructor with 0, 1, 2 or 3 arguments...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants