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); }
public static int GetEnumObject(IntPtr L, System.Enum e, out object obj) { GLuaState state = GLuaState.Get(L); obj = state.GetEnumObj(e); return(state.EnumMetatable); }
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); } }
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); }
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(); }
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)); } }
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)); } }
public static int GetMissMetaReference(IntPtr L, Type t) { GLuaState state = GLuaState.Get(L); return(state.GetMissMetaReference(t)); }
public static void GetPackTouch(IntPtr L) { GLuaState state = GLuaState.Get(L); LuaDLL.lua_getref(L, state.PackTouch); }
public static int GetArrayMetatable(IntPtr L) { GLuaState state = GLuaState.Get(L); return(state.ArrayMetatable); }
public static void GetUnpackBounds(IntPtr L) { GLuaState state = GLuaState.Get(L); LuaDLL.lua_getref(L, state.UnpackBounds); }
public static void GetPackRaycastHit(IntPtr L) { GLuaState state = GLuaState.Get(L); LuaDLL.lua_getref(L, state.PackRaycastHit); }
public static LuaThread GetLuaThread(IntPtr L, int reference) { GLuaState state = GLuaState.Get(L); return(state.GetLuaThread(reference)); }
public static void GetUnpackRayRef(IntPtr L) { GLuaState state = GLuaState.Get(L); LuaDLL.lua_getref(L, state.UnpackRay); }
public static LuaFunction GetFunction(IntPtr L, int reference) { GLuaState state = GLuaState.Get(L); return(state.GetFunction(reference)); }
public static LuaTable GetTable(IntPtr L, int reference) { GLuaState state = GLuaState.Get(L); return(state.GetTable(reference)); }
public static Type GetClassType(IntPtr L, int reference) { GLuaState state = GLuaState.Get(L); return(state.GetClassType(reference)); }
public static int GetDelegateMetatable(IntPtr L) { GLuaState state = GLuaState.Get(L); return(state.DelegateMetatable); }
public static LuaCSFunction GetPreModule(IntPtr L, Type t) { GLuaState state = GLuaState.Get(L); return(state.GetPreModule(t)); }
public static int GetEventMetatable(IntPtr L) { GLuaState state = GLuaState.Get(L); return(state.EventMetatable); }
public static int GetIterMetatable(IntPtr L) { GLuaState state = GLuaState.Get(L); return(state.IterMetatable); }