Esempio n. 1
0
        internal void SetUDValue(object v)
        {
#if DEBUG_DUMMY_TVALUE_MODIFY
            CheckLock();
#endif
            //!ADD BY hyf042
            LuaUserDataValue ud = new LuaUserDataValue();
            ud.Value  = v;
            ud.Length = 0;

            Tt          = (int)LuaType.LUA_TUSERDATA;
            NValue      = 0.0;
            UInt64Value = 0;
            OValue      = ud;
        }
Esempio n. 2
0
        private bool V_EqualObject(ref TValue t1, ref TValue t2, bool rawEq)
        {
            Utl.Assert(t1.Tt == t2.Tt);
            StkId tm = null;

            switch (t1.Tt)
            {
            case (int)LuaType.LUA_TNIL:
                return(true);

            case (int)LuaType.LUA_TNUMBER:
                return(t1.NValue == t2.NValue);

            case (int)LuaType.LUA_TUINT64:
                return(t1.UInt64Value == t2.UInt64Value);

            case (int)LuaType.LUA_TBOOLEAN:
                return(t1.BValue() == t2.BValue());

            case (int)LuaType.LUA_TSTRING:
                return(t1.SValue() == t2.SValue());

            case (int)LuaType.LUA_TUSERDATA:
            {
                LuaUserDataValue ud1 = t1.RawUValue();
                LuaUserDataValue ud2 = t2.RawUValue();
                if (ud1.Value == ud2.Value)
                {
                    return(true);
                }
                if (rawEq)
                {
                    return(false);
                }
                tm = GetEqualTM(ud1.MetaTable, ud2.MetaTable, TMS.TM_EQ);
                break;
            }

            case (int)LuaType.LUA_TTABLE:
            {
                LuaTable tbl1 = t1.HValue();
                LuaTable tbl2 = t2.HValue();
                if (System.Object.ReferenceEquals(tbl1, tbl2))
                {
                    return(true);
                }
                if (rawEq)
                {
                    return(false);
                }
                tm = GetEqualTM(tbl1.MetaTable, tbl2.MetaTable, TMS.TM_EQ);
                break;
            }

            default:
                return(t1.OValue == t2.OValue);
            }
            if (tm == null)              // no TM?
            {
                return(false);
            }
            CallTM(ref tm.V, ref t1, ref t2, Top, true);              // call TM
            return(!IsFalse(ref Top.V));
        }