Inheritance: IDisposable
Example #1
0
 // TODO 在委托调用中减掉一个LuaFunction, 此lua函数在委托中还会执行一次, 所以必须延迟删除,委托值类型表现之一
 internal void DelayDispose(LuaBaseRef br)
 {
     if (br != null)
     {
         subList.Add(br);
     }
 }
Example #2
0
        static bool Equals(LuaBaseRef a, LuaBaseRef b)
        {
            if (System.Object.ReferenceEquals(a, b))
            {
                return(true);
            }

            object l = a;
            object r = b;

            if (l == null && r != null)
            {
                return(b.luaState == null);
            }

            if (l != null && r == null)
            {
                return(a.luaState == null);
            }

            if (a.reference != b.reference || a.luaState != b.luaState)
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        static bool CompareRef(LuaBaseRef a, LuaBaseRef b)
        {
            if (System.Object.ReferenceEquals(a, b))
            {
                return(true);
            }

            object l = a;
            object r = b;

            if (l == null && r != null)
            {
                return(b.reference <= 0);
            }

            if (l != null && r == null)
            {
                return(a.reference <= 0);
            }

            if (a.reference != b.reference)
            {
                return(false);
            }

            return(a.reference > 0);
        }
Example #4
0
        public override bool Equals(object o)
        {
            if (o == null)
            {
                return(this.reference <= 0);
            }
            LuaBaseRef luaBaseRef = o as LuaBaseRef;

            return(!(luaBaseRef == null) && luaBaseRef.reference == this.reference && this.reference > 0);
        }
Example #5
0
        public override bool Equals(object o)
        {
            if (o == null)
            {
                return(false);
            }
            LuaBaseRef luaBaseRef = o as LuaBaseRef;

            return(luaBaseRef != null && luaBaseRef.reference == this.reference);
        }
Example #6
0
 public void Push(LuaBaseRef lbr)
 {
     if (lbr == null)
     {
         LuaPushNil();
     }
     else
     {
         LuaGetRef(lbr.GetReference());
     }
 }
Example #7
0
 public static void Push(IntPtr L, LuaBaseRef lbr)
 {
     if (lbr == null)
     {
         LuaDLL.lua_pushnil(L);
     }
     else
     {
         LuaDLL.lua_getref(L, lbr.GetReference());
     }
 }
Example #8
0
        public override bool Equals(object o)
        {
            if (o == null)
            {
                return(reference <= 0);
            }
            LuaBaseRef lr = o as LuaBaseRef;

            if (lr == null || lr.reference != reference)
            {
                return(false);
            }

            return(reference > 0);
        }
Example #9
0
 private static bool CompareRef(LuaBaseRef a, LuaBaseRef b)
 {
     if (object.ReferenceEquals(a, b))
     {
         return(true);
     }
     if (a == null && b != null)
     {
         return(b == null || b.reference <= 0);
     }
     if (a != null && b == null)
     {
         return(a.reference <= 0);
     }
     return(a.reference == b.reference && a.reference > 0);
 }
Example #10
0
        public override bool Equals(object o)
        {
            if (o == null)
            {
                return(luaState == null);
            }

            if (System.Object.ReferenceEquals(this, o))
            {
                return(true);
            }

            LuaBaseRef r = o as LuaBaseRef;

            if (r == null || r.reference != reference || r.luaState != luaState)
            {
                return(false);
            }

            return(true);
        }
Example #11
0
        public LuaBaseRef TryGetLuaRef(int reference)
        {
            WeakReference weak = null;

            if (funcRefMap.TryGetValue(reference, out weak))
            {
                if (weak.IsAlive)
                {
                    LuaBaseRef luaRef = (LuaBaseRef)weak.Target;

                    if (luaRef.IsAlive)
                    {
                        luaRef.AddRef();
                        return(luaRef);
                    }
                }

                funcRefMap.Remove(reference);
            }

            return(null);
        }
Example #12
0
 public void Push(LuaBaseRef lbr)
 {
     luaState.Push(lbr);
     ++argCount;
 }
Example #13
0
        static bool CompareRef(LuaBaseRef a, LuaBaseRef b)
        {
            if (System.Object.ReferenceEquals(a, b))
            {
                return true;
            }

            object l = a;
            object r = b;

            if (l == null && r != null)
            {
                return r == null || b.reference <= 0;
            }

            if (l != null && r == null)
            {
                return a.reference <= 0;
            }

            if (a.reference != b.reference)
            {
                return false;
            }

            return a.reference > 0;
        }
Example #14
0
 public void Push(LuaBaseRef lbr)
 {
     luaState.Push(lbr);
 }
Example #15
0
 public static bool operator !=(LuaBaseRef a, LuaBaseRef b)
 {
     return(!LuaBaseRef.CompareRef(a, b));
 }
Example #16
0
 public void Push(LuaBaseRef lbr)
 {
     this.luaState.Push(lbr);
     this.argCount++;
 }
Example #17
0
 public void Push(LuaBaseRef lbr)
 {
     luaState.Push(lbr);
     ++argCount;
 }