summaryrefslogtreecommitdiff
path: root/src/cat/LuaLuna.h
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-01 19:13:51 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-01 19:13:51 (GMT)
commit6d991c10d7800859a39e447ec7f95b861d5fb69f (patch)
tree8244e80d38182a527248235340a634db923e88cd /src/cat/LuaLuna.h
parent9bc06a2fc4d7d4ce82da7323a567402d7688d3d3 (diff)
downloadpowder-6d991c10d7800859a39e447ec7f95b861d5fb69f.zip
powder-6d991c10d7800859a39e447ec7f95b861d5fb69f.tar.gz
Logging for UI component events, tr
Diffstat (limited to 'src/cat/LuaLuna.h')
-rw-r--r--src/cat/LuaLuna.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cat/LuaLuna.h b/src/cat/LuaLuna.h
index 591dad2..1d5d937 100644
--- a/src/cat/LuaLuna.h
+++ b/src/cat/LuaLuna.h
@@ -126,9 +126,14 @@ private:
static int new_T(lua_State * L)
{
lua_remove(L, 1); // use classname:new(), instead of classname.new()
+
T *obj = new T(L); // call constructor for T objects
userdataType *ud = static_cast<userdataType*>(lua_newuserdata(L, sizeof(userdataType)));
ud->pT = obj; // store pointer to object in userdata
+
+ obj->UserData = luaL_ref(L, LUA_REGISTRYINDEX);
+ lua_rawgeti(L, LUA_REGISTRYINDEX, obj->UserData);
+
luaL_getmetatable(L, T::className); // lookup metatable in Lua registry
lua_setmetatable(L, -2);
return 1; // userdata containing pointer to T object