-
Notifications
You must be signed in to change notification settings - Fork 71
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
Global function as member function. #29
Comments
Yes. state["A"].setClass(kaguya::UserdataMetatable<A>()
.setConstructors<A()>()
.addStaticFunction("lambdafn", [](A* self,int v){self->setValue(v);})
); local a = ABC.new()
a:lambdafn(3) --equal setValue(3)
a.lambdafn(a,3) --equal to above |
addStaticFunction may not the best name for it situation. I prefer to addMemberFunction. |
If implement addMemberFunction for global function, need first argument type check. |
Yes, another question:
|
Can not now. Try to make because it is easy. |
Thinks, but as convention, it is better make getter as first argumention.
|
It's changed. |
Great!, but
First template arguments is SetType, It is misleading. |
When a global function with first argument is Object& or Object*, Can I treat is as a member function for usertype. e.g.
In Lua:
Now I can register it as a static function for usertype.
The text was updated successfully, but these errors were encountered: