Esempio n. 1
0
        private void UF_DebugEvent()
        {
            GLuaState lua    = GLuaState.Get(System.IntPtr.Zero);
            int       oldtop = lua.LuaGetTop();

            try{
                lua.LuaGetGlobal("Lua");
                if (lua.LuaIsNil(-1) || !lua.lua_istable(-1))
                {
                    return;
                }
                lua.LuaGetField(-1, "global");
                if (lua.LuaIsNil(-1) || !lua.lua_istable(-1))
                {
                    return;
                }
                lua.LuaGetField(-1, "event");
                if (lua.LuaIsNil(-1) || !lua.lua_istable(-1))
                {
                    return;
                }
                lua.LuaGetField(-1, "debug_event");
                if (lua.LuaIsNil(-1) || !lua.lua_isfunction(-1))
                {
                    return;
                }
                lua.Push(true);
                lua.LuaCall(1, 0);
            }catch (System.Exception ex) {
                Debugger.UF_Exception(ex);
            }
            lua.LuaSetTop(oldtop);
        }
Esempio n. 2
0
        public static int GetEnumObject(IntPtr L, System.Enum e, out object obj)
        {
            GLuaState state = GLuaState.Get(L);

            obj = state.GetEnumObj(e);
            return(state.EnumMetatable);
        }
Esempio n. 3
0
 private void UF_DrawTagGC()
 {
     GUILayout.Space(4);
     if (GUILayout.Button("GC UnusedRes", GUILayout.Height(40), GUILayout.Width(120)))
     {
         Resources.UnloadUnusedAssets();
     }
     GUILayout.Space(4);
     if (GUILayout.Button("GC AssetBundle", GUILayout.Height(40), GUILayout.Width(120)))
     {
         AssetSystem.UF_GetInstance().UF_ClearAll(false);
         Resources.UnloadUnusedAssets();
     }
     GUILayout.Space(4);
     if (GUILayout.Button("GC Mono", GUILayout.Height(40), GUILayout.Width(120)))
     {
         System.GC.Collect();
     }
     GUILayout.Space(4);
     if (GUILayout.Button("GC Lua", GUILayout.Height(40), GUILayout.Width(120)))
     {
         GLuaState lua = GLuaState.Get(System.IntPtr.Zero);
         lua.LuaGC(LuaGCOptions.LUA_GCCOLLECT);
     }
 }
Esempio n. 4
0
        private string UF_GetLuaGInfo()
        {
            GLuaState lua    = GLuaState.Get(System.IntPtr.Zero);
            int       oldtop = lua.LuaGetTop();

            lua.LuaGetGlobal("TraceGlobal");
            string info = string.Empty;

            if (!lua.LuaIsNil(-1) && lua.lua_isfunction(-1))
            {
                lua.LuaCall(0, 1);
                info = lua.LuaToString(-1);
            }
            lua.LuaSetTop(oldtop);
            return(info);
        }
Esempio n. 5
0
        public static void OpenLibs(IntPtr L)
        {
            LuaDLL.lua_getglobal(L, "tolua");

            LuaDLL.lua_pushstring(L, "findtype");
            LuaDLL.lua_pushcfunction(L, FindType);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pushstring(L, "loadassembly");
            LuaDLL.tolua_pushcsfunction(L, LoadAssembly);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pushstring(L, "getmethod");
            LuaDLL.tolua_pushcsfunction(L, GetMethod);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pushstring(L, "getconstructor");
            LuaDLL.tolua_pushcsfunction(L, GetConstructor);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pushstring(L, "gettypemethod");
            LuaDLL.tolua_pushcsfunction(L, GetTypeMethod);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pushstring(L, "getfield");
            LuaDLL.tolua_pushcsfunction(L, GetField);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pushstring(L, "getproperty");
            LuaDLL.tolua_pushcsfunction(L, GetProperty);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pushstring(L, "createinstance");
            LuaDLL.tolua_pushcsfunction(L, CreateInstance);
            LuaDLL.lua_rawset(L, -3);

            LuaDLL.lua_pop(L, 1);

            GLuaState state = GLuaState.Get(L);

            state.BeginPreLoad();
            state.AddPreLoad("tolua.reflection", OpenReflectionLibs);
            state.EndPreLoad();
        }
Esempio n. 6
0
    static int op_Subtraction(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 2);
            Delegate arg0 = (Delegate)ToLua.CheckObject(L, 1, typeof(Delegate));
            LuaTypes type = LuaDLL.lua_type(L, 2);

            if (type == LuaTypes.LUA_TFUNCTION)
            {
                GLuaState   state = GLuaState.Get(L);
                LuaFunction func  = ToLua.ToLuaFunction(L, 2);
                Delegate[]  ds    = arg0.GetInvocationList();

                for (int i = 0; i < ds.Length; i++)
                {
                    LuaDelegate ld = ds[i].Target as LuaDelegate;

                    if (ld != null && ld.func == func && ld.self == null)
                    {
                        arg0 = Delegate.Remove(arg0, ds[i]);
                        state.DelayDispose(ld.func);
                        break;
                    }
                }

                func.Dispose();
                ToLua.Push(L, arg0);
                return(1);
            }
            else
            {
                Delegate arg1 = (Delegate)ToLua.CheckObject(L, 2, typeof(Delegate));
                arg0 = DelegateFactory.RemoveDelegate(arg0, arg1);
                ToLua.Push(L, arg0);
                return(1);
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Esempio n. 7
0
 static int OpenReflectionLibs(IntPtr L)
 {
     try
     {
         GLuaState state = GLuaState.Get(L);
         state.BeginModule(null);
         state.BeginModule("LuaInterface");
         LuaInterface_LuaMethodWrap.Register(state);
         LuaInterface_LuaPropertyWrap.Register(state);
         LuaInterface_LuaFieldWrap.Register(state);
         LuaInterface_LuaConstructorWrap.Register(state);
         state.EndModule();
         state.EndModule();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 8
0
        public static int GetMissMetaReference(IntPtr L, Type t)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.GetMissMetaReference(t));
        }
Esempio n. 9
0
        public static void GetPackTouch(IntPtr L)
        {
            GLuaState state = GLuaState.Get(L);

            LuaDLL.lua_getref(L, state.PackTouch);
        }
Esempio n. 10
0
        public static int GetArrayMetatable(IntPtr L)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.ArrayMetatable);
        }
Esempio n. 11
0
        public static void GetUnpackBounds(IntPtr L)
        {
            GLuaState state = GLuaState.Get(L);

            LuaDLL.lua_getref(L, state.UnpackBounds);
        }
Esempio n. 12
0
        public static void GetPackRaycastHit(IntPtr L)
        {
            GLuaState state = GLuaState.Get(L);

            LuaDLL.lua_getref(L, state.PackRaycastHit);
        }
Esempio n. 13
0
        public static LuaThread GetLuaThread(IntPtr L, int reference)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.GetLuaThread(reference));
        }
Esempio n. 14
0
        public static void GetUnpackRayRef(IntPtr L)
        {
            GLuaState state = GLuaState.Get(L);

            LuaDLL.lua_getref(L, state.UnpackRay);
        }
Esempio n. 15
0
        public static LuaFunction GetFunction(IntPtr L, int reference)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.GetFunction(reference));
        }
Esempio n. 16
0
        public static LuaTable GetTable(IntPtr L, int reference)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.GetTable(reference));
        }
Esempio n. 17
0
        public static Type GetClassType(IntPtr L, int reference)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.GetClassType(reference));
        }
Esempio n. 18
0
        public static int GetDelegateMetatable(IntPtr L)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.DelegateMetatable);
        }
Esempio n. 19
0
        public static LuaCSFunction GetPreModule(IntPtr L, Type t)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.GetPreModule(t));
        }
Esempio n. 20
0
        public static int GetEventMetatable(IntPtr L)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.EventMetatable);
        }
Esempio n. 21
0
        public static int GetIterMetatable(IntPtr L)
        {
            GLuaState state = GLuaState.Get(L);

            return(state.IterMetatable);
        }