diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/BLua.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/BLua.cc b/src/BLua.cc index 48a3305..5bbdd07 100644 --- a/src/BLua.cc +++ b/src/BLua.cc @@ -804,7 +804,7 @@ void Balau::LuaObjectFactory::pushMe(Lua & L, LuaObjectBase * o, const char * ob L.push(objname); L.settable(-3, true); } - pushIt(L, "destroy", LuaStatics::destructor); + pushMethod(L, "destroy", LuaStatics::destructor); if (!m_wantsDestruct) o->detach(); } @@ -827,17 +827,29 @@ Balau::LuaObjectBase * Balau::LuaObjectFactory::getMeInternal(Lua & L, int i) { return o; } -void Balau::LuaObjectFactory::pushIt(Lua & L, const char * s, lua_CFunction f) { - L.push(s); - L.push(f); +void Balau::LuaObjectFactory::pushMethod(Lua & L, const char * s, int strSize, lua_CFunction f, int upvalues) { + if (upvalues == 0) { + L.push(s, strSize); + L.push(f); + } else { + L.push(f, upvalues); + L.push(s, strSize); + L.insert(-2); + } L.settable(-3, true); } -void Balau::LuaObjectFactory::pushMeta(Lua & L, const char * s, lua_CFunction f) { +void Balau::LuaObjectFactory::pushMeta(Lua & L, const char * s, int strSize, lua_CFunction f, int upvalues) { if (!L.getmetatable()) L.newtable(); - L.push(s); - L.push(f); + if (upvalues == 0) { + L.push(s); + L.push(f); + } else { + L.push(f, upvalues); + L.push(s, strSize); + L.insert(-2); + } L.settable(); L.setmetatable(); } |