Beispiel #1
0
        internal static void RegObj(IntPtr l, object obj, int index, IntPtr h)
        {
            var pos = l.NormalizeIndex(index);

            if (obj != null)
            {
                LuaObjCacheSlim.Record(obj, l.topointer(pos), pos);
            }

            var cache = GetOrCreateObjCache(l);

            cache._Map[obj] = h;

            l.checkstack(5);
            PushOrCreateObjCacheReg(l); // reg
            l.pushlightuserdata(h);     // reg h
            l.pushvalue(pos);           // reg h ud
            l.settable(-3);             // reg
            l.pop(1);                   // X
        }
Beispiel #2
0
        public static object GetLuaTableObjectDirect(this IntPtr l, int index)
        {
            var    pos = l.NormalizeIndex(index);
            object rv;

            if (LuaObjCacheSlim.TryGet(l, pos, out rv))
            {
                return(rv);
            }
            l.checkstack(2);
            l.pushlightuserdata(LuaConst.LRKEY_TARGET); // #tar
            l.rawget(pos);                              // obj
            if (l.IsUserData(-1))
            {
                rv = l.GetLuaRawObject(-1);
            }
            l.pop(1);
            if (rv != null)
            {
                LuaObjCacheSlim.Record(rv, l.topointer(pos), pos);
            }
            return(rv);
        }