From 8396ba36848b6a94a73ccace665637ea6e5d1547 Mon Sep 17 00:00:00 2001 From: Yaukey Date: Wed, 22 Jul 2015 14:02:33 +0800 Subject: [PATCH 1/2] 1.Fix generate error code when exporting the generic value type, e.g. KeyValuePair, the generate code will get a wrong type name; 2.Let user change enum name when exporting to lua. --- Assets/Slua/Editor/LuaCodeGen.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Slua/Editor/LuaCodeGen.cs b/Assets/Slua/Editor/LuaCodeGen.cs index 6687ee85..cb73d100 100644 --- a/Assets/Slua/Editor/LuaCodeGen.cs +++ b/Assets/Slua/Editor/LuaCodeGen.cs @@ -723,7 +723,7 @@ void RegEnumFunction(Type t, StreamWriter file) { // Write export function Write(file, "static public void reg(IntPtr l) {"); - Write(file, "getEnumTable(l,\"{0}\");", FullName(t)); + Write(file, "getEnumTable(l,\"{0}\");", string.IsNullOrEmpty(givenNamespace) ? FullName(t) : givenNamespace); FieldInfo[] fields = t.GetFields(); foreach (FieldInfo f in fields) @@ -837,7 +837,7 @@ void RegFunction(Type t, StreamWriter file) Write(file, "LuaUnityEvent_{1}.reg(l);", FullName(t), _Name((GenericName(t.BaseType)))); } - Write(file, "getTypeTable(l,\"{0}\");", givenNamespace != null ? givenNamespace : FullName(t)); + Write(file, "getTypeTable(l,\"{0}\");", string.IsNullOrEmpty(givenNamespace) ? FullName(t) : givenNamespace); foreach (string f in funcname) { Write(file, "addMember(l,{0});", f); @@ -1488,7 +1488,7 @@ void WriteCheckSelf(StreamWriter file, Type t) { if (t.IsValueType) { - Write(file, "{0} self;", FullName(t)); + Write(file, "{0} self;", TypeDecl(t)); Write(file, "checkType(l,1,out self);"); } else From 22be22de1edc81572ced1fd8c36412dc5c180a8a Mon Sep 17 00:00:00 2001 From: Yongkang Chen Date: Mon, 27 Jul 2015 10:57:56 +0800 Subject: [PATCH 2/2] fix #57 --- Assets/Slua/Script/LuaState.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Assets/Slua/Script/LuaState.cs b/Assets/Slua/Script/LuaState.cs index f5ec3070..6f70f869 100644 --- a/Assets/Slua/Script/LuaState.cs +++ b/Assets/Slua/Script/LuaState.cs @@ -521,6 +521,14 @@ static int init(IntPtr L) if not ret[1] then UnityEngine.Debug.LogError(debug.traceback(co,ret[2])) end return unpack(ret) end + +coroutine.wrap = function(func) + local co = coroutine.create(func) + return function(...) + local ret={coroutine.resume(co,...)} + return unpack(ret, 2) + end +end "; // overload resume function for report error