示例#1
0
        internal void collectObject(int obj_index_to_collect)
        {
            object o;

            if (objects.TryGetValue(obj_index_to_collect, out o))
            {
                objects.Remove(obj_index_to_collect);

                if (o != null)
                {
                    int obj_index;
                    //lua gc是先把weak table移除后再调用__gc,这期间同一个对象可能再次push到lua,关联到新的index
                    bool is_enum = o.GetType().IsEnum;
                    if ((is_enum ? enumMap.TryGetValue(o, out obj_index) : reverseMap.TryGetValue(o, out obj_index)) &&
                        obj_index == obj_index_to_collect)
                    {
                        if (is_enum)
                        {
                            enumMap.Remove(o);
                        }
                        else
                        {
                            reverseMap.Remove(o);
                        }
                    }
                }
            }
        }
示例#2
0
        static int _m_Remove(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                XLua.ObjectPool gen_to_be_invoked = (XLua.ObjectPool)translator.FastGetCSObj(L, 1);



                {
                    int _index = LuaAPI.xlua_tointeger(L, 2);

                    object gen_ret = gen_to_be_invoked.Remove(_index);
                    translator.PushAny(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }