MCPcopy Create free account
hub / github.com/Tencent/xLua / collectObject

Method collectObject

Assets/XLua/Src/ObjectTranslator.cs:765–792  ·  view source on GitHub ↗
(int obj_index_to_collect)

Source from the content-addressed store, hash-verified

763 }
764
765 internal void collectObject(int obj_index_to_collect)
766 {
767 object o;
768
769 if (objects.TryGetValue(obj_index_to_collect, out o))
770 {
771 objects.Remove(obj_index_to_collect);
772
773 if (o != null)
774 {
775 int obj_index;
776 //lua gc是先把weak table移除后再调用__gc,这期间同一个对象可能再次push到lua,关联到新的index
777 bool is_enum = o.GetType().IsEnum();
778 if ((is_enum ? enumMap.TryGetValue(o, out obj_index) : reverseMap.TryGetValue(o, out obj_index))
779 && obj_index == obj_index_to_collect)
780 {
781 if (is_enum)
782 {
783 enumMap.Remove(o);
784 }
785 else
786 {
787 reverseMap.Remove(o);
788 }
789 }
790 }
791 }
792 }
793
794 int addObject(object obj, bool is_valuetype, bool is_enum)
795 {

Callers 1

LuaGCFunction · 0.80

Calls 3

TryGetValueMethod · 0.80
IsEnumMethod · 0.80
RemoveMethod · 0.45

Tested by

no test coverage detected