mirror of
https://github.com/love2d/love.git
synced 2026-08-13 17:10:54 +02:00
Added __tostring for all types.
This commit is contained in:
@@ -44,6 +44,12 @@ namespace love
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int w__tostring(lua_State * L)
|
||||
{
|
||||
lua_pushvalue(L, lua_upvalueindex(1));
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference * luax_refif(lua_State * L, int type)
|
||||
{
|
||||
Reference * r = 0;
|
||||
@@ -177,6 +183,11 @@ namespace love
|
||||
lua_pushcfunction(L, w__gc);
|
||||
lua_setfield(L, -2, "__gc");
|
||||
|
||||
// Add tostring function.
|
||||
lua_pushstring(L, tname);
|
||||
lua_pushcclosure(L, w__tostring, 1);
|
||||
lua_setfield(L, -2, "__tostring");
|
||||
|
||||
if(f != 0)
|
||||
luaL_register(L, 0, f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user