Use method indices as LuaLuna thunk upvalues
Rather than member function pointers, which are not necessarily simple pointers and are not necessarily convertible to void * sensibly. This also gets rid of the last instance of lua_pushlightuserdata, which apparently isn't super well-supported by luajit, and which thus often crash on android.
This commit is contained in:
parent
b5d40a49f8
commit
d56510b1ac
@ -57,7 +57,7 @@ public:
|
||||
{
|
||||
/* edited by Snaily: shouldn't it be const RegType *l ... ? */
|
||||
lua_pushstring(L, l->name);
|
||||
lua_pushlightuserdata(L, (void*)l);
|
||||
lua_pushinteger(L, l - T::methods);
|
||||
lua_pushcclosure(L, thunk, 1);
|
||||
lua_settable(L, methods);
|
||||
}
|
||||
@ -116,7 +116,7 @@ private:
|
||||
T *obj = check(L, 1); // get 'self', or if you prefer, 'this'
|
||||
lua_remove(L, 1); // remove self so member function args start at index 1
|
||||
// get member function from upvalue
|
||||
RegType *l = static_cast<RegType*>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
RegType *l = T::methods + lua_tointeger(L, lua_upvalueindex(1));
|
||||
return (obj->*(l->mfunc))(L); // call member function
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user