Example #1
0
        public static LuaState Get(IntPtr ptr)
        {
            if (ptr == oldptr)
            {
                return(oldstate);
            }

            LuaState ls;

            if (statemap.TryGetValue(ptr, out ls))
            {
                oldptr   = ptr;
                oldstate = ls;
                return(ls);
            }

            LuaNativeMethods.lua_getglobal(ptr, "__main_state");
            if (LuaNativeMethods.lua_isnil(ptr, -1))
            {
                LuaNativeMethods.lua_pop(ptr, 1);
                return(null);
            }

            IntPtr nl = LuaNativeMethods.lua_touserdata(ptr, -1);

            LuaNativeMethods.lua_pop(ptr, 1);
            if (nl != ptr)
            {
                return(Get(nl));
            }

            return(null);
        }
Example #2
0
        public static ObjectCache Get(IntPtr ptr)
        {
            if (oldPtr == ptr)
            {
                return(Oldoc);
            }

            ObjectCache oc;

            if (multiState.TryGetValue(ptr, out oc))
            {
                oldPtr = ptr;
                Oldoc  = oc;
                return(oc);
            }

            LuaNativeMethods.lua_getglobal(ptr, "__main_state");
            if (LuaNativeMethods.lua_isnil(ptr, -1))
            {
                LuaNativeMethods.lua_pop(ptr, 1);
                return(null);
            }

            IntPtr nl = LuaNativeMethods.lua_touserdata(ptr, -1);

            LuaNativeMethods.lua_pop(ptr, 1);

            if (nl != ptr)
            {
                return(Get(nl));
            }

            return(null);
        }
 public static bool CheckType(IntPtr ptr, int p, out IntPtr v)
 {
     v = LuaNativeMethods.lua_touserdata(ptr, p);
     return(true);
 }