Skip to content

Commit

Permalink
更新tolua#到1.0.7.386版
Browse files Browse the repository at this point in the history
  • Loading branch information
jarjin2000 committed Dec 19, 2017
1 parent fa4c848 commit 08dde69
Show file tree
Hide file tree
Showing 170 changed files with 3,677 additions and 21 deletions.
26 changes: 26 additions & 0 deletions Assets/LuaFramework/Editor/CustomSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using LuaInterface;
using LuaFramework;
using UnityEditor;

using BindType = ToLuaMenu.BindType;
using UnityEngine.UI;
Expand Down Expand Up @@ -149,6 +150,7 @@ public static class CustomSettings
_GT(typeof(BlendWeights)),
_GT(typeof(RenderTexture)),
_GT(typeof(Resources)),
_GT(typeof(LuaProfiler)),

//for LuaFramework
_GT(typeof(RectTransform)),
Expand Down Expand Up @@ -251,4 +253,28 @@ public static DelegateType _DT(Type t)
{
return new DelegateType(t);
}


[MenuItem("Lua/Attach Profiler", false, 151)]
static void AttachProfiler()
{
if (!Application.isPlaying)
{
EditorUtility.DisplayDialog("警告", "请在运行时执行此功能", "确定");
return;
}

LuaClient.Instance.AttachProfiler();
}

[MenuItem("Lua/Detach Profiler", false, 152)]
static void DetachProfiler()
{
if (!Application.isPlaying)
{
return;
}

LuaClient.Instance.DetachProfiler();
}
}
30 changes: 24 additions & 6 deletions Assets/LuaFramework/ToLua/Core/LuaDLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ public enum LuaThreadStatus
LUA_ERRERR = 5,
}

public enum LuaHookFlag
{
LUA_HOOKCALL = 0,
LUA_HOOKRET = 1,
LUA_HOOKLINE = 2,
LUA_HOOKCOUNT = 3,
LUA_HOOKTAILRET = 4,
}

public enum LuaMask
{
LUA_MASKCALL = 1, //1 << LUA_HOOKCALL
LUA_MASKRET = 2, //(1 << LUA_HOOKRET)
LUA_MASKLINE = 4,// (1 << LUA_HOOKLINE)
LUA_MASKCOUNT = 8, // (1 << LUA_HOOKCOUNT)
}


public class LuaIndexes
{
public static int LUA_REGISTRYINDEX = -10000;
Expand Down Expand Up @@ -179,15 +197,15 @@ public string short_src
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int LuaCSFunction(IntPtr luaState);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void LuaHook(IntPtr L, ref Lua_Debug ar);
public delegate void LuaHookFunc(IntPtr L, ref Lua_Debug ar);
#else
public delegate int LuaCSFunction(IntPtr luaState);
public delegate void LuaHook(IntPtr L, ref Lua_Debug ar);
public delegate void LuaHookFunc(IntPtr L, ref Lua_Debug ar);
#endif

public class LuaDLL
{
public static string version = "1.0.7.377";
public static string version = "1.0.7.386";
public static int LUA_MULTRET = -1;
public static string[] LuaTypeName = { "none", "nil", "boolean", "lightuserdata", "number", "string", "table", "function", "userdata", "thread" };

Expand Down Expand Up @@ -624,9 +642,9 @@ public static int lua_getgccount(IntPtr L)
public static extern string lua_setupvalue(IntPtr L, int funcindex, int n);

[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int lua_sethook(IntPtr L, LuaHook func, int mask, int count);
public static extern int lua_sethook(IntPtr L, LuaHookFunc func, int mask, int count);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern LuaHook lua_gethook(IntPtr L);
public static extern LuaHookFunc lua_gethook(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int lua_gethookmask(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
Expand Down Expand Up @@ -779,7 +797,7 @@ public static void luaL_checkstack(IntPtr L, int space, string mes)
{
if (lua_checkstack(L, space) == 0)
{
throw new LuaException(string.Format("stack overflow (%s)", mes));
throw new LuaException(string.Format("stack overflow {0}", mes));
}
}

Expand Down
6 changes: 5 additions & 1 deletion Assets/LuaFramework/ToLua/Core/LuaMisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,29 @@ public GCRef(int reference, string name)
public struct LuaByteBuffer
{
public LuaByteBuffer(IntPtr source, int len)
: this()
{
buffer = new byte[len];
Length = len;
Marshal.Copy(source, buffer, 0, len);
}

public LuaByteBuffer(byte[] buf)
: this()
{
buffer = buf;
Length = buf.Length;
}

public LuaByteBuffer(byte[] buf, int len)
: this()
{
buffer = buf;
Length = len;
}

public LuaByteBuffer(System.IO.MemoryStream stream)
public LuaByteBuffer(System.IO.MemoryStream stream)
: this()
{
buffer = stream.GetBuffer();
Length = (int)stream.Length;
Expand Down
54 changes: 52 additions & 2 deletions Assets/LuaFramework/ToLua/Core/LuaStatePtr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ public int LuaStatus()
return LuaDLL.lua_status(L);
}

public void LuaGC(LuaGCOptions what, int data = 0)
public int LuaGC(LuaGCOptions what, int data = 0)
{
LuaDLL.lua_gc(L, what, data);
return LuaDLL.lua_gc(L, what, data);
}

public bool LuaNext(int index)
Expand Down Expand Up @@ -636,5 +636,55 @@ public void ToLuaUnRef(int reference)
{
LuaDLL.toluaL_unref(L, reference);
}

public int LuaGetStack(int level, ref Lua_Debug ar)
{
return LuaDLL.lua_getstack(L, level, ref ar);
}

public int LuaGetInfo(string what, ref Lua_Debug ar)
{
return LuaDLL.lua_getinfo(L, what, ref ar);
}

public string LuaGetLocal(ref Lua_Debug ar, int n)
{
return LuaDLL.lua_getlocal(L, ref ar, n);
}

public string LuaSetLocal(ref Lua_Debug ar, int n)
{
return LuaDLL.lua_setlocal(L, ref ar, n);
}

public string LuaGetUpvalue(int funcindex, int n)
{
return LuaDLL.lua_getupvalue(L, funcindex, n);
}

public string LuaSetUpvalue(int funcindex, int n)
{
return LuaDLL.lua_setupvalue(L, funcindex, n);
}

public int LuaSetHook(LuaHookFunc func, int mask, int count)
{
return LuaDLL.lua_sethook(L, func, mask, count);
}

public LuaHookFunc LuaGetHook()
{
return LuaDLL.lua_gethook(L);
}

public int LuaGetHookMask()
{
return LuaDLL.lua_gethookmask(L);
}

public int LuaGetHookCount()
{
return LuaDLL.lua_gethookcount(L);
}
}
}
1 change: 1 addition & 0 deletions Assets/LuaFramework/ToLua/Core/LuaTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ public void Dispose()
public struct LuaDictEntry<K, V>
{
public LuaDictEntry(K key, V value)
: this()
{
Key = key;
Value = value;
Expand Down
11 changes: 2 additions & 9 deletions Assets/LuaFramework/ToLua/Examples/17_Inherit/TestInherit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,8 @@ void Start ()
}

time = Time.realtimeSinceStartup - time;
Debugger.Log("c# Transform get set cost time: " + time);

LuaFunction func = lua.GetFunction("Test");
func.BeginPCall();
func.Push(transform);
func.PCall();
func.EndPCall();

lua.CheckTop();
Debugger.Log("c# Transform get set cost time: " + time);
lua.Call("Test", transform, true);
lua.Dispose();
lua = null;
}
Expand Down
6 changes: 6 additions & 0 deletions Assets/LuaFramework/ToLua/Examples/18_Bundle/TestABLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ void Awake()
#endif
LuaFileUtils file = new LuaFileUtils();
file.beZip = true;
#if UNITY_ANDROID && UNITY_EDITOR
if (IntPtr.Size == 8)
{
throw new Exception("can't run this in unity5.x process for 64 bits, switch to pc platform, or run it in android mobile");
}
#endif
StartCoroutine(LoadBundles());
}

Expand Down
12 changes: 12 additions & 0 deletions Assets/LuaFramework/ToLua/Lua/System/Timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function Timer:Stop()
end

function Timer:Update()
if not self.running then
return
end

local delta = self.scale and Time.deltaTime or Time.unscaledDeltaTime
self.time = self.time - delta

Expand Down Expand Up @@ -103,6 +107,10 @@ function FrameTimer:Stop()
end

function FrameTimer:Update()
if not self.running then
return
end

if Time.frameCount >= self.count then
self.func()

Expand Down Expand Up @@ -153,6 +161,10 @@ function CoTimer:Stop()
end

function CoTimer:Update()
if not self.running then
return
end

if self.time <= 0 then
self.func()

Expand Down
Loading

0 comments on commit 08dde69

Please sign in to comment.