From dc39f581d5e18cb78332be5b8ab7daa4230c4a2d Mon Sep 17 00:00:00 2001 From: zilch Date: Thu, 22 Oct 2015 09:50:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?CodeGen=20=E8=BF=87=E6=BB=A4=E6=8E=89?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97op=5Fexplicit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Slua/Editor/LuaCodeGen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Slua/Editor/LuaCodeGen.cs b/Assets/Slua/Editor/LuaCodeGen.cs index 6810d620..6d1fd84b 100644 --- a/Assets/Slua/Editor/LuaCodeGen.cs +++ b/Assets/Slua/Editor/LuaCodeGen.cs @@ -1472,7 +1472,7 @@ bool isUsefullMethod(MethodInfo method) if (method.Name != "GetType" && method.Name != "GetHashCode" && method.Name != "Equals" && method.Name != "ToString" && method.Name != "Clone" && method.Name != "GetEnumerator" && method.Name != "CopyTo" && - method.Name != "op_Implicit" && + method.Name != "op_Implicit" && method.Name != "op_Explicit" && !method.Name.StartsWith("get_", StringComparison.Ordinal) && !method.Name.StartsWith("set_", StringComparison.Ordinal) && !method.Name.StartsWith("add_", StringComparison.Ordinal) && From 18b346fe34f4c75cff4f07b58841157b4e0db7ee Mon Sep 17 00:00:00 2001 From: zilch Date: Thu, 22 Oct 2015 10:10:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8A=A0=E5=85=A5ICustomExportPost,?= =?UTF-8?q?=E5=8F=AA=E8=A6=81=E5=AE=9E=E7=8E=B0=E6=AD=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=8D=B3=E5=8F=AF=E5=9C=A8make=20custom=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E8=87=AA=E5=8A=A8=E8=B0=83=E7=94=A8=20OnAddC?= =?UTF-8?q?ustomClass,=20=E6=97=A0=E9=9C=80=E4=BF=AE=E6=94=B9slua=E7=9A=84?= =?UTF-8?q?CustomExport.cs,=E8=BF=99=E6=A0=B7=E5=8F=AF=E4=BB=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=9B=B4=E6=96=B0=E5=BA=93=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?CustomExport.cs=E8=A2=AB=E8=A6=86=E7=9B=96=E5=8F=88=E8=A6=81?= =?UTF-8?q?=E9=87=8D=E5=86=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Slua/Editor/ICustomExportPost.cs | 8 ++++++++ Assets/Slua/Editor/ICustomExportPost.cs.meta | 12 ++++++++++++ Assets/Slua/Editor/LuaCodeGen.cs | 13 +++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 Assets/Slua/Editor/ICustomExportPost.cs create mode 100644 Assets/Slua/Editor/ICustomExportPost.cs.meta diff --git a/Assets/Slua/Editor/ICustomExportPost.cs b/Assets/Slua/Editor/ICustomExportPost.cs new file mode 100644 index 00000000..4108154f --- /dev/null +++ b/Assets/Slua/Editor/ICustomExportPost.cs @@ -0,0 +1,8 @@ +using UnityEngine; +using System.Collections; + +namespace SLua{ + public interface ICustomExportPost { + + } +} \ No newline at end of file diff --git a/Assets/Slua/Editor/ICustomExportPost.cs.meta b/Assets/Slua/Editor/ICustomExportPost.cs.meta new file mode 100644 index 00000000..618be3d3 --- /dev/null +++ b/Assets/Slua/Editor/ICustomExportPost.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0517ba8e84e8c48869fc381b0fe501a3 +timeCreated: 1445479148 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Slua/Editor/LuaCodeGen.cs b/Assets/Slua/Editor/LuaCodeGen.cs index 6d1fd84b..228c33eb 100644 --- a/Assets/Slua/Editor/LuaCodeGen.cs +++ b/Assets/Slua/Editor/LuaCodeGen.cs @@ -273,6 +273,19 @@ static public void Custom() } CustomExport.OnAddCustomClass(fun); + + //detect interface ICustomExportPost,and call OnAddCustomClass + assembly = System.Reflection.Assembly.Load("Assembly-CSharp-Editor"); + types = assembly.GetExportedTypes(); + foreach (Type t in types) + { + if(typeof(ICustomExportPost).IsAssignableFrom(t)){ + System.Reflection.MethodInfo method = t.GetMethod("OnAddCustomClass",System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); + if(method != null){ + method.Invoke(null,new object[]{fun}); + } + } + } GenerateBind(exports, "BindCustom", 3, path); if(autoRefresh) From 562597e1db98407a403a209b1f2bc957bfa10267 Mon Sep 17 00:00:00 2001 From: zilch Date: Thu, 29 Oct 2015 09:52:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?LuaCodeGen=E9=87=8C=E9=9D=A2=E5=B0=86=20fil?= =?UTF-8?q?e.WriteLine=20=E6=94=B9=E4=B8=BAfile.Write(=E2=80=9C\r\n?= =?UTF-8?q?=E2=80=9D);=20=E8=BF=99=E6=A0=B7=E5=8F=AF=E4=BB=A5=E8=AE=A9win?= =?UTF-8?q?=E8=B7=9Fmac=E4=B8=8A=E7=94=9F=E6=88=90=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=80=E8=87=B4=E3=80=82=20=E5=90=A6=E5=88=99svn=20?= =?UTF-8?q?=E5=8D=8F=E4=BD=9C=E7=9A=84=E6=97=B6=E5=80=99=E4=BC=9A=E5=86=B2?= =?UTF-8?q?=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Slua/Editor/LuaCodeGen.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Slua/Editor/LuaCodeGen.cs b/Assets/Slua/Editor/LuaCodeGen.cs index 228c33eb..26763e2a 100644 --- a/Assets/Slua/Editor/LuaCodeGen.cs +++ b/Assets/Slua/Editor/LuaCodeGen.cs @@ -1742,12 +1742,15 @@ void Write(StreamWriter file, string fmt, params object[] args) file.Write("\t"); - if (args.Length == 0) - file.WriteLine(fmt); + if (args.Length == 0){ + file.Write(fmt); + file.Write("\r\n"); //TODO add by zilch,try to make win&mac generate same files. + } else { string line = string.Format(fmt, args); - file.WriteLine(line); + file.Write(line); + file.Write("\r\n"); } if (fmt.EndsWith("{")) indent++;