make safe usertypes safer (nw)

This commit is contained in:
cracyc 2016-11-06 13:31:37 -06:00
parent 55b5777824
commit 6fd9586a89

View File

@ -276,6 +276,9 @@ namespace sol {
static int call(lua_State* L, Fx&& f) { static int call(lua_State* L, Fx&& f) {
typedef std::conditional_t<std::is_void<T>::value, object_type, T> Ta; typedef std::conditional_t<std::is_void<T>::value, object_type, T> Ta;
#ifdef SOL_SAFE_USERTYPE #ifdef SOL_SAFE_USERTYPE
if(type_of(L, 1) != sol::type::userdata) {
return luaL_error(L, "sol: received null for 'self' argument (use ':' for accessing member functions, make sure member variables are preceeded by the actual object with '.' syntax)");
}
object_type* o = static_cast<object_type*>(stack::get<Ta*>(L, 1)); object_type* o = static_cast<object_type*>(stack::get<Ta*>(L, 1));
if (o == nullptr) { if (o == nullptr) {
return luaL_error(L, "sol: received null for 'self' argument (use ':' for accessing member functions, make sure member variables are preceeded by the actual object with '.' syntax)"); return luaL_error(L, "sol: received null for 'self' argument (use ':' for accessing member functions, make sure member variables are preceeded by the actual object with '.' syntax)");