13
0

Extend Lua binding for static methods

This add support for Lua bindings for static member
functions in weak/share ptr class bindings.
This commit is contained in:
Robin Gareus 2020-01-31 12:28:34 +01:00
parent ee43db8b54
commit fbacb13d2d
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -1304,6 +1304,22 @@ private:
return addConstructor <void (*) ()> ();
}
template <class FP>
WSPtrClass <T>& addStaticFunction (char const* name, FP const fp)
{
FUNDOC ("Static Member Function", name, FP)
set_shared_class ();
new (lua_newuserdata (L, sizeof (fp))) FP (fp);
lua_pushcclosure (L, &CFunc::Call <FP>::f, 1);
rawsetfield (L, -2, name);
set_weak_class ();
new (lua_newuserdata (L, sizeof (fp))) FP (fp);
lua_pushcclosure (L, &CFunc::Call <FP>::f, 1);
rawsetfield (L, -2, name);
return *this;
}
WSPtrClass <T>& addNilPtrConstructor ()
{
FUNDOC ("Weak/Shared Pointer NIL Constructor", "", void (*) ())