int tLuaObject::garbagecollect(lua_State *L) { tLuaObject* lua_obj = (tLuaObject*) luaCompat_getTypedObject(L, -1); delete lua_obj; return 0; }
int LuaBeans::gc(lua_State* L) { LuaBeans *beans = (LuaBeans*) luaCompat_getTypedObject(L, -1); CHECKPRECOND(beans); delete beans; return 0; }
int tLuaCOMEnumerator::garbagecollect(lua_State *L) { LUASTACK_SET(L); // gets the enumerator tLuaCOMEnumerator* enumerator = (tLuaCOMEnumerator*) luaCompat_getTypedObject(L, -1); delete enumerator; LUASTACK_CLEAN(L, 0); return 0; }
int tLuaCOMEnumerator::call_method(lua_State *L) { /// positions of parameters // self param (not used, but explicited to ensure // consistency) const int self_param = 1; // first user param const int user_first_param = 2; // last user param, excluding upvalues const int user_last_param = luaCompat_getNumParams(L, 2); // upvalues const int enumerator_param = luaCompat_upvalueIndex(L, 1, 2); const int method_param = luaCompat_upvalueIndex(L, 2, 2); int num_params = 0; if(user_last_param < user_first_param) num_params = 0; else num_params = user_last_param - user_first_param + 1; // gets the enumerator tLuaCOMEnumerator* enumerator = (tLuaCOMEnumerator*) luaCompat_getTypedObject(L, enumerator_param); // gets the method name const char* method_name = lua_tostring(L, method_param); // call method int retval = 0; try { retval = enumerator->callCOMmethod(L, method_name, user_first_param, num_params); } catch(class tLuaCOMException& e) { luacom_error(L, e.getMessage()); return 0; } return retval; }
tLuaObject* tLuaObject::getObject(lua_State *L, int pos) { LUASTACK_SET(L); if(pos < 0) pos += lua_gettop(L) + 1; // gets lua object lua_pushstring(L, TLUAOBJECT_POINTER_FIELD); lua_rawget(L, pos); tLuaObject* lua_obj = (tLuaObject*) luaCompat_getTypedObject(L, -1); lua_pop(L, 1); LUASTACK_CLEAN(L, 0); return lua_obj; }
LuaBeans* LuaBeans::getBeans(lua_State *L, const char* module, const char* name) { LUASTACK_SET(L); luaCompat_moduleGet(L, module, "LuaBeansTable"); lua_pushstring(L, (char*)name); lua_gettable(L, -2); LuaBeans* lbeans = (LuaBeans*) luaCompat_getTypedObject(L, -1); lua_pop(L, 2); LUASTACK_CLEAN(L, 0); return lbeans; }
void* LuaBeans::from_lua(lua_State* L, int index) { LUASTACK_SET(L); void *obj = NULL; lua_pushvalue(L, index); if (lua_istable(L, -1) && luaCompat_isOfType(L, module_name, tag_name)) { lua_pushstring(L, "_USERDATA_REF_"); lua_gettable(L, index); obj = luaCompat_getTypedObject(L, -1); lua_pop(L, 1); } lua_pop(L, 1); LUASTACK_CLEAN(L, 0); return obj; }