Skip to content

Commit

Permalink
更新tolua#到1.0.7.344版
Browse files Browse the repository at this point in the history
  • Loading branch information
jarjin2000 committed Jul 20, 2017
1 parent 091d149 commit c8bfb14
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Assets/LuaFramework/ToLua/Core/LuaDLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public string short_src

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

Expand Down
3 changes: 3 additions & 0 deletions Assets/LuaFramework/ToLua/Core/LuaState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public bool LogGC
translator.LogGC = value;
}
}

public Action OnDestroy = delegate { };

Dictionary<string, WeakReference> funcMap = new Dictionary<string, WeakReference>();
Dictionary<int, WeakReference> funcRefMap = new Dictionary<int, WeakReference>();
Expand Down Expand Up @@ -1913,6 +1915,7 @@ public void Dispose()
#if MISS_WARNING
missSet.Clear();
#endif
OnDestroy();
Debugger.Log("LuaState destroy");
}

Expand Down
10 changes: 10 additions & 0 deletions Assets/LuaFramework/ToLua/Core/TypeTraits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@ static public string GetTypeName()

static public int GetLuaReference(IntPtr L)
{
#if MULTI_STATE
return LuaStatic.GetMetaReference(L, type);
#else
if (metaref > 0)
{
return metaref;
}

metaref = LuaStatic.GetMetaReference(L, type);

if (metaref > 0)
{
LuaState.Get(L).OnDestroy += () => { metaref = -1; };
}

return metaref;
#endif
}

static bool DefaultCheck(IntPtr L, int pos)
Expand Down
27 changes: 14 additions & 13 deletions Assets/LuaFramework/ToLua/Editor/ToLuaExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ public static class ToLuaExport
public static Type extendType = null;

public static HashSet<Type> eventSet = new HashSet<Type>();

public static List<Type> extendList = new List<Type>();
static List<_MethodBase> extendMethod = new List<_MethodBase>();
public static List<Type> extendList = new List<Type>();

public static List<string> memberFilter = new List<string>
{
Expand Down Expand Up @@ -199,6 +197,7 @@ public bool IsGenericMethod
return method.IsGenericMethod;
}
}


MethodBase method;
ParameterInfo[] args;
Expand Down Expand Up @@ -358,12 +357,13 @@ public Type GetReturnType()
return null;
}

public bool BeExtend = false;

public int ProcessParams(int tab, bool beConstruct, int checkTypePos)
{
ParameterInfo[] paramInfos = args;
bool beExtend = extendMethod.Contains(this);
ParameterInfo[] paramInfos = args;

if (beExtend)
if (BeExtend)
{
ParameterInfo[] pt = new ParameterInfo[paramInfos.Length - 1];
Array.Copy(paramInfos, 1, pt, 0, pt.Length);
Expand All @@ -374,7 +374,7 @@ public int ProcessParams(int tab, bool beConstruct, int checkTypePos)
string head = string.Empty;
PropertyInfo pi = null;
int methodType = GetMethodType(method, out pi);
int offset = ((method.IsStatic && !beExtend) || beConstruct) ? 1 : 2;
int offset = ((method.IsStatic && !BeExtend) || beConstruct) ? 1 : 2;

if (method.Name == "op_Equality")
{
Expand All @@ -386,7 +386,7 @@ public int ProcessParams(int tab, bool beConstruct, int checkTypePos)
head += "\t";
}

if ((!method.IsStatic && !beConstruct) || beExtend)
if ((!method.IsStatic && !beConstruct) || BeExtend)
{
if (checkTypePos > 0)
{
Expand Down Expand Up @@ -476,7 +476,7 @@ public int ProcessParams(int tab, bool beConstruct, int checkTypePos)
return refList.Count + 1;
}

string obj = (method.IsStatic && !beExtend) ? className : "obj";
string obj = (method.IsStatic && !BeExtend) ? className : "obj";
Type retType = GetReturnType();

if (retType == typeof(void))
Expand Down Expand Up @@ -643,7 +643,7 @@ public static void Clear()
nameCounter.Clear();
events = null;
getItems.Clear();
setItems.Clear();
setItems.Clear();
}

private static MetaOp GetOp(string name)
Expand Down Expand Up @@ -934,6 +934,7 @@ static void InitMethods()
for (int j = 0; j < count + 1; j++)
{
_MethodBase r = new _MethodBase(list[i].Method, length - j);
r.BeExtend = list[i].BeExtend;
methods.Add(r);
}
}
Expand Down Expand Up @@ -4123,7 +4124,7 @@ static bool IsGenericType(MethodInfo md, Type t)
return false;
}

static void ProcessExtendType(Type extendType, List<_MethodBase> list, List<_MethodBase> extendList)
static void ProcessExtendType(Type extendType, List<_MethodBase> list)
{
HashSet<string> removeSet = new HashSet<string>();

Expand Down Expand Up @@ -4157,7 +4158,7 @@ static void ProcessExtendType(Type extendType, List<_MethodBase> list, List<_Met
if (!IsObsolete(list2[i]))
{
_MethodBase mb = new _MethodBase(md);
extendList.Add(mb);
mb.BeExtend = true;
list.Add(mb);
}
}
Expand All @@ -4174,7 +4175,7 @@ static void ProcessExtends(List<_MethodBase> list)

for (int i = 0; i < extendList.Count; i++)
{
ProcessExtendType(extendList[i], list, extendMethod);
ProcessExtendType(extendList[i], list);
string nameSpace = GetNameSpace(extendList[i], out temp);

if (!string.IsNullOrEmpty(nameSpace))
Expand Down
15 changes: 9 additions & 6 deletions Assets/LuaFramework/ToLua/Editor/ToLuaMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public static class ToLuaMenu
#if !UNITY_5 && !UNITY_2017
typeof(Motion), //很多平台只是空类
#endif
//typeof(UnityEngine.CustomYieldInstruction),

#if UNITY_5_3_OR_NEWER
typeof(UnityEngine.CustomYieldInstruction),
#endif
typeof(UnityEngine.YieldInstruction), //无需导出的类
typeof(UnityEngine.WaitForEndOfFrame), //内部支持
typeof(UnityEngine.WaitForFixedUpdate),
Expand Down Expand Up @@ -795,7 +798,7 @@ static void BuildLuaBundle(string subDir, string sourceDir)
string bundleName = subDir == null ? "lua.unity3d" : "lua" + subDir.Replace('/', '_') + ".unity3d";
bundleName = bundleName.ToLower();

#if UNITY_5 || UNITY_2017
#if UNITY_5 || UNITY_2017
for (int i = 0; i < files.Length; i++)
{
AssetImporter importer = AssetImporter.GetAtPath(files[i]);
Expand All @@ -806,7 +809,7 @@ static void BuildLuaBundle(string subDir, string sourceDir)
importer.assetBundleVariant = null;
}
}
#else
#else
List<Object> list = new List<Object>();

for (int i = 0; i < files.Length; i++)
Expand All @@ -823,7 +826,7 @@ static void BuildLuaBundle(string subDir, string sourceDir)
File.Delete(output);
BuildPipeline.BuildAssetBundle(null, list.ToArray(), output, options, EditorUserBuildSettings.activeBuildTarget);
}
#endif
#endif
}

static void ClearAllLuaFiles()
Expand Down Expand Up @@ -1126,7 +1129,7 @@ public static void BuildNotJitBundles()
List<string> dirs = new List<string>();
GetAllDirs(tempDir, dirs);

#if UNITY_5 || UNITY_2017
#if UNITY_5 || UNITY_2017
for (int i = 0; i < dirs.Count; i++)
{
string str = dirs[i].Remove(0, tempDir.Length);
Expand All @@ -1149,7 +1152,7 @@ public static void BuildNotJitBundles()

BuildLuaBundle(null, "Assets/StreamingAssets/Lua");
Directory.Delete(Application.streamingAssetsPath + "/Lua/", true);
#endif
#endif
AssetDatabase.Refresh();
}

Expand Down
Loading

0 comments on commit c8bfb14

Please sign in to comment.