更新Xlua 到最新版本
This commit is contained in:
Assets
Plugins
Android.metaWSA.meta
XLua.metaAndroid
libs
IOS
Script
AssetUpdate
WSA
WebGL.metaWebGL
arm64.metaarm64
x86.metaXLua
CHANGELOG.txtCHANGELOG.txt.meta
Doc
Configure_EN.mdHotfix_EN.md
Editor.metaMaterials
XLua_API.mdXLua教程.mdcompatible_bytecode.mdconfigure.mdcustom_generate.mdfaq.mdfeatures.mdhotfix.mdlogo.png.metaxLua.pngxLua.png.metaEditor
ExampleConfig.csExampleConfig.cs.metaXLuaGenConfig.csXLuaUnityDefaultConfig.csXLuaUnityDefaultConfig.cs.meta
Gen.metaGen
DelegatesGensBridge.csDelegatesGensBridge.cs.metaEnumWrap.csEnumWrap.cs.metaIMarketingActRetDelBridge.cs.metaLuaMainWrap.cs.metaLuaUIBehaviourWrap.cs.metaPackUnpack.cs.metaSdkControlWrap.csSdkControlWrap.cs.metaSystem_Collections_Generic_List_1_System_Int32_Wrap.cs.metaSystem_Collections_HashtableWrap.cs.metaSystem_Collections_IEnumerableBridge.cs.metaSystem_Collections_IEnumeratorBridge.cs.metaSystem_ObjectWrap.cs.metaTableManagerLuaWrap.cs.metaTutorial_BaseClassWrap.csTutorial_BaseClassWrap.cs.metaTutorial_CSCallLua_ItfDBridge.csTutorial_CSCallLua_ItfDBridge.cs.metaTutorial_DerivedClassExtensionsWrap.csTutorial_DerivedClassExtensionsWrap.cs.metaTutorial_DerivedClassWrap.csTutorial_DerivedClassWrap.cs.metaTutorial_ICalcWrap.csTutorial_ICalcWrap.cs.metaUnityEngine_AnimationClipWrap.cs.metaUnityEngine_AnimationCurveWrap.cs.metaUnityEngine_BehaviourWrap.cs.metaUnityEngine_BoundsWrap.cs.metaUnityEngine_ColorWrap.cs.metaUnityEngine_ComponentWrap.cs.metaUnityEngine_DebugWrap.cs.metaUnityEngine_GameObjectWrap.cs.metaUnityEngine_KeyframeWrap.cs.metaUnityEngine_LightWrap.cs.metaUnityEngine_MathfWrap.cs.metaUnityEngine_MonoBehaviourWrap.cs.metaUnityEngine_ObjectWrap.cs.metaUnityEngine_ParticleSystemWrap.cs.metaUnityEngine_QuaternionWrap.cs.metaUnityEngine_Ray2DWrap.cs.metaUnityEngine_RayWrap.cs.metaUnityEngine_RendererWrap.cs.metaUnityEngine_ResourcesWrap.cs.metaUnityEngine_SkinnedMeshRendererWrap.cs.metaUnityEngine_TextAssetWrap.cs.metaUnityEngine_TimeWrap.cs.metaUnityEngine_TransformWrap.cs.metaUnityEngine_Vector2Wrap.cs.metaUnityEngine_Vector3Wrap.cs.metaUnityEngine_Vector4Wrap.cs.metaUnityEngine_WWWWrap.cs.metaWrapPusher.csWrapPusher.cs.metaXLuaGenAutoRegister.csXLuaGenAutoRegister.cs.metalink.xmllink.xml.meta
Resources
Src.metaSrc
CodeEmit.csCodeEmit.cs.metaCopyByValue.csCopyByValue.cs.metaDelegateBridge.csDelegateBridge.cs.metaEditor.meta
Tutorial.metaEditor
Generator.csGenerator.cs.metaHotfix.csHotfix.cs.metaLinkXmlGen.meta
GenAttributes.csGenAttributes.cs.metaGenericDelegateBridge.csGenericDelegateBridge.cs.metaInternalGlobals.csInternalGlobals.cs.metaLuaBase.csLuaBase.cs.metaLuaDLL.csLuaDLL.cs.metaLuaEnv.csLuaEnv.cs.metaLuaException.csLuaException.cs.metaLuaFunction.csLuaFunction.cs.metaLuaTable.csLuaTable.cs.metaMethodWarpsCache.csMethodWarpsCache.cs.metaObjectCasters.csObjectCasters.cs.metaObjectPool.csObjectPool.cs.metaObjectTranslator.csObjectTranslator.cs.metaObjectTranslatorPool.csObjectTranslatorPool.cs.metaRawObject.csRawObject.cs.metaSignatureLoader.csSignatureLoader.cs.metaStaticLuaCallbacks.csStaticLuaCallbacks.cs.metaTemplateEngine.metaLinkXmlGen
Report.csReport.cs.metaTemplate.metaTemplate
LuaClassWrap.tpl.txtLuaClassWrap.tpl.txt.metaLuaClassWrapGCM.tpl.txtLuaClassWrapGCM.tpl.txt.metaLuaDelegateBridge.tpl.txtLuaDelegateBridge.tpl.txt.metaLuaDelegateWrap.tpl.txtLuaDelegateWrap.tpl.txt.metaLuaEnumWrap.tpl.txtLuaEnumWrap.tpl.txt.metaLuaEnumWrapGCM.tpl.txtLuaEnumWrapGCM.tpl.txt.metaLuaInterfaceBridge.tpl.txtLuaInterfaceBridge.tpl.txt.metaLuaRegister.tpl.txtLuaRegister.tpl.txt.metaLuaRegisterGCM.tpl.txtLuaRegisterGCM.tpl.txt.metaLuaWrapPusher.tpl.txtLuaWrapPusher.tpl.txt.metaPackUnpack.tpl.txtPackUnpack.tpl.txt.metaTemplateCommon.lua.txtTemplateCommon.lua.txt.meta
TemplateRef.csTemplateRef.cs.metaTemplateEngine
TypeExtensions.csTypeExtensions.cs.metaUtils.csUtils.cs.metaTutorial
CSharpCallLua.meta
CSharpCallLua
LoadLuaScript.metaLoadLuaScript
ByFile.meta
LuaCallCSharp.metaByFile
ByString.metaByString
Loader.metaLoader
LuaCallCSharp
487
Assets/XLua/CHANGELOG.txt
Normal file
487
Assets/XLua/CHANGELOG.txt
Normal file
@ -0,0 +1,487 @@
|
||||
v2.1.15 2020年6月24日
|
||||
新增特性
|
||||
1、生成代码过滤器
|
||||
2、优化反射查找delegate匹配bridge的性能
|
||||
3、unity 2019.2以上版本手机版本注入不了的问题
|
||||
|
||||
变更
|
||||
|
||||
bug修复
|
||||
1、反射查找同名delegate桥接在不生成代码的时候表现不一致
|
||||
2、嵌套struct标注为PackAsTable时生成代码报错
|
||||
3、反射wrap代码加入栈空间检查
|
||||
4、如果枚举定义了很多个值(几千个),会触发unity在android下的一个bug:函数体很大而且有很多分支,执行该函数会crash
|
||||
5、chunkname和脚本文件名不一致的问题
|
||||
6、最小生成模式枚举生成代码报错
|
||||
7、当采用反射方式注册枚举值时,如果一个枚举有多个相同的值,比如A,B都是1,那么在lua里头访问B将会为空
|
||||
8、sbyte[]在.net 4下push到lua变成字符串的问题
|
||||
9、泛型导致生成代码失败的问题
|
||||
10、非Assembly-CSharp程序集注入时,out参数处理有误
|
||||
11、内嵌类通过xlua.private_accessible设置私有访问可能失败的问题
|
||||
12、cecil插入指令后,并未自动更新offset,某种情况下会导致计算偏移量错误
|
||||
|
||||
|
||||
v2.1.14 2019年2月27日
|
||||
新增特性
|
||||
1、新增nintento switch的支持
|
||||
2、unity 2018兼容
|
||||
3、android arm64支持
|
||||
4、原生库的visual studio 2017编译支持
|
||||
5、增加“XLua/Generate Minimize Code”菜单
|
||||
6、防止有的工程有非法的dll导致生成代码中断
|
||||
7、更高效的lua_pushstring(需要通过NATIVE_LUA_PUSHSTRING开启)
|
||||
|
||||
变更
|
||||
1、window库默认编译器改为visual studio 2017
|
||||
|
||||
bug修复
|
||||
1、修正枚举类型如果只加GCOptimize不加LuaCallCSharp会crash的问题
|
||||
2、示例配置加入对Edtitor类的过滤
|
||||
3、UWP兼容修复
|
||||
4、接口继承引入的同签名方法实现
|
||||
5、未生成代码,extension方法行为不一致
|
||||
6、修复Nullable类型参数,如果最后一个参数是nil,会导致其他参数全是nil的问题
|
||||
|
||||
|
||||
v2.1.13 2018年12月5日
|
||||
新增特性
|
||||
1、新增AdaptByDelegate注入模式;
|
||||
2、新增xlua.get_generic_method,用于调用泛型函数;
|
||||
3、支持类似CS.System.Collections.Generic.List(CS.System.Int32)的泛型写法;
|
||||
4、注入新选项:忽略编译器自动生成代码,以及不生成base代理;
|
||||
5、针对lua编程以及热补丁,均添加直接可用的自动化配置样例;
|
||||
6、新增luajit的gc64支持;
|
||||
7、加入兼容字节码(一份字节码支持32位和64位系统)的支持;
|
||||
8、内置新lua内存泄漏检测工具;
|
||||
9、delegate桥接动态实例化:delegate是4个参数以内,参数均引用类型,无返回值或者返回引用类型,不用配置CSharpCallLua也能调用lua函数;
|
||||
10、提供util.print_func_ref_by_csharp函数,用于查看当前被C#引用的lua函数;
|
||||
11、支持无CS全局变量的工作方式;
|
||||
|
||||
|
||||
变更
|
||||
1、虚拟机升级:lua5.3.4 -> lua5.3.5,luajit2.1b2 -> luajit2.1b3;
|
||||
2、delegate bridge代码段占用优化;
|
||||
3、改为PostProcessBuild事件检查是否生成代码;
|
||||
4、适配xcode 10:osx平台不再支持32bit版本构建;
|
||||
5、名字空间、类名拼写错误时,对静态成员的设置会报错;
|
||||
6、防止CS全局table被删除导致xlua工作异常;
|
||||
7、Windows下构建lib,若使用vs 2015参数执行cmake失败,则继续尝试使用vs 2017;
|
||||
8、编辑器下不生成代码时,也检查Blacklist,维持和运行时一致;
|
||||
|
||||
bug修复
|
||||
1、泛型的数组生成代码报错;
|
||||
2、防止对TypeExtensions配置了LuaCallCSharp后,lua里头IsValueType之类的判断永真;
|
||||
3、生成代码过滤掉含指针的函数和字段;
|
||||
4、适应索引器属性名不是Item的情况;
|
||||
5、解决attribute初始化异常会导致生成代码,注入终止的问题;
|
||||
6、精简模式下空Enum生成代码错误;
|
||||
7、通过把初始化函数分割成小函数,规避unity在android下执行大函数crash的bug;
|
||||
8、Assignable处理obj为null情况;
|
||||
9、内嵌类不Obsolete,但外层类Obsolete的生成代码报错
|
||||
10、解决inline注入方式下,如果lua逻辑跑异常,看不到异常信息的问题;
|
||||
11、修复xlua.private_accessible访问后,同名public的方法无法访问的Bug;
|
||||
12、[Out]修饰的参数不应该生成out关键字;
|
||||
13、通过反射查找合适的适配器时,有可能访问到非适配器函数;
|
||||
14、精简模式导出代码无get_Item、set_Item;
|
||||
15、IntKey方式下不自动xlua.private_accessible的问题;
|
||||
|
||||
|
||||
v2.1.12 2018年7月9日
|
||||
新增特性
|
||||
1、Nullable的支持
|
||||
2、支持Assembly-CSharp之外的dll注入(beta)
|
||||
3、执行xlua.hotfix,会自动让该类private能访问
|
||||
4、xlua.private_accessible优化:1、会把基类的也设置能私有访问;2、延迟到第一次访问类才私有化
|
||||
5、新增xlua.util.state,可为一个c#对象新增状态
|
||||
6、this[string field]或者this[object field]操作符重载新增get_Item和set_Item调用
|
||||
7、正在编译时注入打印error信息
|
||||
8、interface配置到CSharpCallLua时的事件跟索引映射的自动实现
|
||||
9、unity5.5以上去掉WARNING: The runtime version supported by this application is unavailable打印
|
||||
|
||||
变更
|
||||
1、去除Stateful方式(因为xlua.util.state已经可以达成类似的效果)
|
||||
2、废弃掉内嵌模式模式
|
||||
|
||||
bug修复
|
||||
1、生成代码局部变量加下划线,防止符号冲突
|
||||
2、如果类没放到Hotfix列表,不生成base调用代理
|
||||
3、代码重构,可读性优化
|
||||
4、解决带params byte[]可能会导致生成代码编译错误的问题
|
||||
5、解决类含有private event的时候,无法xlua.private_accessible的问题
|
||||
6、构造函数注入,如果branch外紧跟Ret指令,注入逻辑应该在branch以及Ret之间
|
||||
7、构造函数注入,如果注入指令后导致跳转范围大于一个字节,应修改为长跳转
|
||||
8、解决一个delegate如果不是某个类的内嵌类型时,CS.namespace.classname为空的问题
|
||||
9、防止Editor下的Util类名字冲突
|
||||
10、泛型override有异常,先过滤掉
|
||||
11、解决空enum导致生成代码编译错误
|
||||
12、解决uwp平台下il2cpp方式打包无法访问任何类的问题
|
||||
13、hotfix一个私有类型的params参数的函数,导致生成代码编译错误、注入失败的问题
|
||||
14、如果两个LuaBase指向的是同一个Lua对象,GetHashCode应该返回的是同一个值
|
||||
15、[Out]标记参数生成代码编译失败
|
||||
16、交错数组+多维数组的复合,生成代码报错的问题
|
||||
|
||||
v2.1.11 2018年3月20日
|
||||
新增特性
|
||||
1、xlua.private_accessible支持私有内嵌类型
|
||||
2、添加xlua.release,用于主动解除lua对c#某对象的引用
|
||||
3、支持内嵌委托的显示构造
|
||||
4、需要传class的地方(比如xlua.private_accessible),支持传C#的Type对象
|
||||
5、支持用pairs遍历IEnumerable对象
|
||||
6、热补丁场景下,支持override函数调用被override函数(对应c# base关键字)
|
||||
|
||||
变更
|
||||
1、简化property的反射访问,简化后有更好的兼容性;
|
||||
|
||||
bug修复
|
||||
1、ios 11兼容(去除system调用)
|
||||
2、实现了interface的struct不走gc优化代码的问题
|
||||
3、emit特性的.net兼容性
|
||||
4、emit对于ulong的const值处理不当
|
||||
5、interface桥接代码,interface继承时,父interface和子interface有同名不同类型属性时的生成代码报错
|
||||
6、多虚拟机下,不断创建和销毁协程时,可能出现协程指针重复
|
||||
7、当参数为泛型类型时,如ICollectio时,不应该生成代码
|
||||
|
||||
v2.1.10 2017年9月18日
|
||||
新增特性
|
||||
1、新增DoNotGen配置,支持一个类型部分函数用反射,部分用生成;
|
||||
2、新增wrapper的emit;
|
||||
3、webgl支持;
|
||||
4、lua实现interface支持interface继承;
|
||||
5、window下支持android编译(由xdestiny110提供);
|
||||
6、打包时,如果没执行过“Generate Code”将报错;
|
||||
|
||||
变更
|
||||
1、 async_to_sync的改为resume错误时报错;
|
||||
2、il2cpp下,暂时去掉泛型的反射调用;
|
||||
3、升级到lua5.3.4并合入2017-9-1为止所有官方patch;
|
||||
|
||||
bug修复
|
||||
1、C#仅声明delegate和MulticastDelegate,通过反射创建lua function映射时crash;
|
||||
2、解决一些古老版本window(比如xp)的dll兼容问题;
|
||||
|
||||
v2.1.9 2017年8月10日
|
||||
新增特性
|
||||
1、新增最小生成模式(通过GEN_CODE_MINIMIZE切换),可以节省50%的text段空间;
|
||||
2、新增xlua.util.createdelegate,支持在lua直接用C#函数创建delegate而不需要通过lua适配;
|
||||
3、xlua.private_accessible支持public int Prop { get; private set; }
|
||||
4、新增 xlua.getmetatable、xlua.setmetatable、xlua.setclass、xlua.genaccessor,用以支持lua使用C#类型直接在lua侧完成;
|
||||
5、反射下扩展方法的支持;
|
||||
6、lua53版本支持位操作符重载:C#侧的位操作符重载对应到lua的位操作符重载;enum全部加上&和|位操作符;
|
||||
|
||||
工程优化
|
||||
1、加入travis持续集成;
|
||||
|
||||
变更
|
||||
1、LuaCallCSharp自动去除匿名类型;
|
||||
2、THREAD_SAFT改为THREAD_SAFE;
|
||||
3、GenFlag.GCOptimize标记为过时;
|
||||
4、删除过时的GenConfig配置方式;
|
||||
|
||||
bug修复
|
||||
1、window phone下一些系统api是禁用的,源码中去掉;
|
||||
2、泛型约束是struct的时候,生成代码失败;
|
||||
3、unity2017 .net 4.6,枚举生成代码报错;
|
||||
|
||||
v2.1.8 2017年6月27日
|
||||
新增特性
|
||||
1、Hotfix标签添加几个订制参数:ValueTypeBoxing、IgnoreProperty、IgnoreNotPublic、Inline、IntKey
|
||||
2、Hotfix代码注入优化,减少text段占用;
|
||||
3、Hotfix配置支持放Editor目录,可以减少text段占用;
|
||||
4、支持以指定类型传递object参数;
|
||||
5、反射调用Obsolete方法在Editor下打印warning;
|
||||
|
||||
变更
|
||||
|
||||
bug修复
|
||||
1、pinvoke独立设置的In,Out属性可能导致生成代码失败;
|
||||
2、如果业务在全局名字空间有和xLua名字空间的同名类,生成代码编译失败;
|
||||
|
||||
v2.1.7 2017年5月17日
|
||||
新增特性
|
||||
1、支持发布UWP(含HoloLens,Xbox one,Win10 Mobile、Win10 PC)应用;
|
||||
2、支持对lua源代码ras+sha1签名;
|
||||
3、如果没安装Tools提示“please install the Tools”;
|
||||
4、linxu版本的支持;
|
||||
5、支持bitcode打包;
|
||||
6、对所有struct新增无参数构造函数;
|
||||
7、delegate的参数名改为p0到pn,防止hotfix时业务代码变量和生成代码冲突;
|
||||
8、支持对成员名为C#关键字的情况;
|
||||
9、新增util.loadpackage,和require类似,通过searcher加载文件,不同的是,它不执行,而且也不会cache到package.loaded;
|
||||
10、优化模版引擎大文件的生成性能;
|
||||
11、新增不需要生成代码的注入方式;
|
||||
12、支持构造函数参数带ref和out修饰符;
|
||||
13、构造函数也支持黑名单排除;
|
||||
|
||||
变更
|
||||
1、this[object field]操作符重载;
|
||||
2、反射的数据转换规则改成和生成代码一致;
|
||||
3、忽略掉匿名类及匿名函数的注入;
|
||||
|
||||
bug修复
|
||||
1、规避Unity的bug:List<CustomType>,CustomType是当前执行程序集的类型,这在.Net是不需要指明程序集就可以通过Type.GetType得到,但Unity下不行。
|
||||
2、解决反射下,可变参数不提供时,传null的问题;
|
||||
3、继承了另外一个程序集的类型,使用了protected类型会导致注入失败;
|
||||
4、luajit去掉dlopen和dlsym的调用;
|
||||
5、解决通用版本的生成代码工具找不到模版的问题;
|
||||
6、修复通用版本反射导入泛化类型的问题;
|
||||
7、反射调用含delegate参数的的api,会因为缓存而导致调用LuaEnv.Dispose失败;
|
||||
8、兼容老版本的C编译器,声明要放开头;
|
||||
9、生成代码对hotfix的检测算法和注入工具不一致导致的注入失败;
|
||||
10、注入的nested类型是public,但其的外层类型非public,生成代码报错;
|
||||
11、析构函数只判断名字可能出现误判;
|
||||
12、构造函数是非public的,可能会导致找不到适配delegate而注入失败;
|
||||
13、修正Extension method会在所有子类都生成代码的bug(2.1.6泛化特性引入);
|
||||
14、构造函数重载,只有一个能hotfix成功;
|
||||
15、规避一个可能是il2cpp的bug(unity5.4):字符串参数默认值是"",ios下在反射的default value也是Reflection.Missing;
|
||||
16、将一个table传到List<>,取了最后一个参数,而不是那个table的长度;
|
||||
17、ldarg指令在这种场景下il2cpp转换时会出现异常:1、采用模版注入;2、从4到255间有一个输出参数;改为兼容性更好的ldarg.s;
|
||||
18、解决配置了System.Delegate到CSCallLua,执行生成代码会编辑器会crash的问题;
|
||||
19、扩展函数可能和原来的函数同名,反射实现并未考虑到这种情况;
|
||||
20、通用版本的可变参数delegate调用异常;
|
||||
21、unity4规避lua53冲突的方式改为返回null更合适,异常方式会导致IsNull无法正常工作;
|
||||
22、lua_tostring解码失败改为UTF8解码;
|
||||
|
||||
v2.1.6 2017年3月1日
|
||||
新增特性
|
||||
1、带约束的泛型支持(by forsakenyang);
|
||||
2、非Unity的.net环境支持;
|
||||
3、代码注入支持小工具方式,该方式不用拷贝cecil库,可以解决拷错cecil库版本或者和Unity,VS插件冲突的问题;
|
||||
4、Hotfix配置支持字段和属性
|
||||
5、更方便的Unity协程hotfix
|
||||
6、在hotfix触发事件;
|
||||
7、LuaTable添加ForEach方法以及Length属性;
|
||||
8、cmake生成项目优化:保留源文件目录结构;
|
||||
9、对已经Dispose的LuaEnv的访问做保护;Dispose时检查callback是否已经都释放,没释放的话报错;
|
||||
10、支持释放Hotfix回调;
|
||||
|
||||
变更
|
||||
1、构造函数改为执行原有逻辑后调用lua;
|
||||
2、this[string field]操作符重载会影响到继承调用,去掉该特性的支持;
|
||||
3、编辑器下的代码注入改为手动方式;
|
||||
|
||||
bug修复
|
||||
1、防止定义了同时定义get_xx方法以及xx属性的生成代码的重名。
|
||||
2、struct注入代码无效;
|
||||
3、Utils加名字空间,防止和业务冲突;
|
||||
4、返回定长多维数组的delegate,生成代码可能会冲突;
|
||||
5、interface,以及编辑器下不生成代码情况下,对可变参数的展开;
|
||||
6、il2cpp下,如果不生成代码,会报ManifestModule不支持;
|
||||
7、规避Unity4的bug:访问一个已经被Distroy的UnityEngine.Object,编辑器下会崩溃,这个问题在Unity5,或者luajit版本都不会出现;
|
||||
8、修改上个版本引入的问题:xlua_setglobal会漏一个值在栈上,这会导致一些32位应用不稳定;
|
||||
9、当delegate参数只有ref和out的区别的话,报重载冲突;
|
||||
|
||||
v2.1.5 2017年1月13日
|
||||
|
||||
新增特性
|
||||
1、全平台热补丁;
|
||||
2、新增线程安全模式,可通过THREAD_SAFT宏打开;
|
||||
3、新增更简便的配置方式,具体参见XLua\Doc下《XLua的配置.doc》;
|
||||
4、多虚拟机实例时的自动Dispose;
|
||||
5、内存优化:减少匿名闭包到delegate映射的内存占用;减少LuaFunction以及LuaTable内存占用;减少lua table映射C#interface的gc;
|
||||
6、生成代码速度优化;
|
||||
7、支持直接在lua侧clone C#结构体;
|
||||
8、LuaFunction新增无gc调用api;
|
||||
|
||||
变更
|
||||
1、delegate必须都加[CSharpCallLua]才支持C#到lua的回调(以前参数和返回值都相同的delegate只要其中一个加了就可以);
|
||||
2、加回string/number到枚举的自动转换;
|
||||
|
||||
bug修复
|
||||
1、枚举不生成代码时,第一次使用会产生两个不同的userdata;
|
||||
2、数组和System.Type的相互引用导致System.Type生成代码无法加载;
|
||||
3、更安全的异常处理,封装lua_setglobal,lua_getglobal的异常,C#回调保证所有C#异常都catch并转换到成lua error。
|
||||
|
||||
|
||||
v2.1.4 2016年11月29日
|
||||
新增特性
|
||||
1、加了ReflectionUse会自动生成到link.xml,可以防止il2cpp下因stripping导致的反射不可用;
|
||||
2、开放生成引擎,可二次开发自己生成插件,生成所需的代码或配置;
|
||||
3、GetInPath和SetInPath无C# gc优化;
|
||||
4、一个lua table自动转换为带GCOptimize标签的复杂类型以及该复杂类型的一维数组不使用反射,如果这复杂类型是纯值类型,无c# gc;
|
||||
|
||||
变更
|
||||
1、基于一致性以及性能的考虑,不支持数字和字符串到枚举的静默转换,须主动调用起类下的__CastFrom;
|
||||
2、名字空间从LuaInterface改为XLua;
|
||||
3、LuaTable的几个可能导致gc的api标注为Obsolete;
|
||||
4、在不指明返回类型的情况下,如果一个number是整数会优先转换成整数;
|
||||
|
||||
bug修复
|
||||
1、含能隐式转换int,long,decimal的类型传到lua变成decimal;
|
||||
2、反射的重载判断,如果可变参数的位置上是一个不匹配的参数,也会判断为匹配成功;
|
||||
3、可变参数+重载的话,可变部分不传会报无效参数;
|
||||
4、加了LuaCallCSharp的Extension method,在Editor下不生成代码不可用;
|
||||
|
||||
v2.1.3 2016年11月09日
|
||||
新增特性
|
||||
1、LuaTable新增Get<TKey, TValue>和Set<TKey, TValue>接口,table操作支持值类型无gc;
|
||||
2、支持decimal,不丢失精度而且传递到lua无gc;
|
||||
3、增加LuaEnv.LoadString<T>接口,用于指定返回的delegate类型;
|
||||
4、例子刷新:新增Helloworld,无GC调用,Lua面向对象,协程例子;
|
||||
5、enum优化:传递到lua无gc,从int或者string到枚举转换无gc;
|
||||
6、event的+/-优化:性能提升一倍,而且无gc;
|
||||
7、生成代码简化;
|
||||
|
||||
变更
|
||||
1、uint在lua53映射到lua_Integer;
|
||||
2、StreamingAssets加载改为优先级最低;
|
||||
|
||||
bug修复
|
||||
1、生成代码下,如果LuaTable或者LuaFunction参数为null会抛异常;
|
||||
2、lua5.3下,浮点到枚举的静默转换失败;
|
||||
3、反射下struct类型参数带默认值抛异常;
|
||||
4、lua53下Length返回浮点;
|
||||
|
||||
v2.1.2 2016年10月08日
|
||||
新增特性
|
||||
1、支持lua5.3,进而支持苹果bitcode,原生64位整数,位运算,utf8等特性;
|
||||
2、CMake编译,更方便加入第三方插件
|
||||
3、数组性能优化,包括访问性能以及gc
|
||||
4、C#调用lua函数减少一次lua gc;
|
||||
5、优化启动时间;
|
||||
6、减少类型加载的gc;
|
||||
7、优化ObjectPool的内存占用;
|
||||
8、优化小字符串传入lua的gc;
|
||||
9、LuaTable添加Cast接口,用于LuaTable到其它类型的转换,比如interface;
|
||||
10、LuaFunction添加Cast接口,用于LuaFunction到delegate的转换;
|
||||
|
||||
变更
|
||||
1、lua内部只有带符号的64整数类型,并增加无符号数库
|
||||
2、如果不想对Extension Method生成代码,又希望在反射下用,需要添加ReflectionUse;
|
||||
|
||||
bug修复
|
||||
1、对ObjectPool已经Destroy的UnityEngine.Object的引用自动解除功能的内存泄漏问题;
|
||||
2、规避某些版本(已知是5.3.3)的Unity的bug导致的内存泄漏问题;
|
||||
3、LuaTable或者LuaFunction做返回值的delegate生成代码可能报错;
|
||||
|
||||
v2.1.1 2016年08月29日
|
||||
新增特性
|
||||
1、支持编辑器下不用生成代码能运行;
|
||||
2、新增IntPtr的支持
|
||||
3、增加对ObjectPool已经Destroy的UnityEngine.Object的引用自动解除;
|
||||
4、在LuaEnv添加对lua_gc一些封装;
|
||||
|
||||
bug修复
|
||||
1、生成代码传送一个LuaFunction、LuaTable到lua和反射版本不一致,生成代码传送过去是一个C#对象,而反射是Lua函数、table对象,反射的处理更合适;
|
||||
2、修复同名的静态以及成员方法冲突的问题;
|
||||
3、修复对interface生成CSharpCallLua代码时,interface含indexer时的报错;
|
||||
4、修复Editor在运行后会new一个xlua实例的bug;
|
||||
5、修复通过生成代码调用同时含可变参数和默认值的函数,如果不传参数,将会出错的bug;
|
||||
6、修复调试时,找不到socket库的bug;
|
||||
|
||||
|
||||
变更
|
||||
1、反射不做重载方法顺序调整,顺序改为固定且生成代码保持一致;
|
||||
2、i64加上fade_id,参数传递时更安全;
|
||||
3、重新加入tdr的from_file的支持;
|
||||
|
||||
v2.1.0 2016年08月08日
|
||||
新增特性
|
||||
1、满足条件struct传递到lua无gc,struct需要满足什么条件才能被优化呢?
|
||||
a. struct允许嵌套其它struct,但它以及它嵌套的struct只能包含这几种基本类型:byte、sbyte、short、ushort、int、uint、long、ulong、float、double;
|
||||
b. struct本身以及使用到该struct的地方需要加LuaCallCSharp,并且加了GCOptimize设置;
|
||||
2、全新实现的反射机制,更容易和生成代码配合使用
|
||||
a. 支持extension methods,Enum.__CastFrom;
|
||||
b. ios下支持反射使用event;
|
||||
c. 对类型映射、可变参数调用调整为和生成代码一致;
|
||||
d. 性能更好,gc更少;
|
||||
3、生成代码菜单简化,并增加“Generate Minimum”选项;
|
||||
4、支持生成代码配置文件放Editor目录;
|
||||
|
||||
变更
|
||||
1、luajit统一升级成2.1.0b2;
|
||||
2、luasocket库改为按需加载;
|
||||
3、重载的string,byte[]参数检查允许为nil;
|
||||
4、子类访问不触发父类加载;
|
||||
5、struct的ref参数的修改会修改lua测该参数的值;
|
||||
6、生成代码加载改为静态(原来是反射);
|
||||
7、菜单改为更简洁;
|
||||
8、tdr改为默认不加载;
|
||||
9、StreamingAssets加载lua改为废弃特性;
|
||||
|
||||
bug修复
|
||||
1、参数或者返回值是泛型类的数组,或者是二维数组,生成代码报编译错误;
|
||||
2、抽象类生成代码报编译错误;
|
||||
3、消除Clear生成代码的warning;
|
||||
4、profiler、i64库不支持多实例;
|
||||
|
||||
v2.0.5 2016年05月18日
|
||||
新增特性
|
||||
1、util.async_to_sync,可以更好的利用lua的协程实现同步编程、异步执行;或者异步等待www等;
|
||||
2、生成代码的规范度调整,消除一些工具的告警;
|
||||
bug修复
|
||||
1、解决在lua gc移除weak table和调用__gc的时间窗内push同一对象,会生成指向同一C#对象的不同userdata的问题;
|
||||
2、上版本的的lua内存工具并未打包;
|
||||
3、修正嵌套类型不能生成代码的问题;
|
||||
|
||||
v2.0.4 2016年05月04日
|
||||
新增特性
|
||||
1、新增函数调用时长报告功能;
|
||||
2、新增lua内存泄漏定位工具;
|
||||
3、lua测加入对64位无符号数的支持;
|
||||
变更
|
||||
1、支持多种delegate绑定到一个clousre。调整之前一个clousre只能对应一种delegate;
|
||||
bug修复
|
||||
1、tdr处理长度为1的数组的错误(本来解包应该是{[1] = {a = 1}}的,却是{{a=1}});
|
||||
2、tdr数值处理错误(int的-1会解成一个很大的正数)
|
||||
|
||||
v2.0.3 2016年04月13日
|
||||
新功能
|
||||
1、添加“Advanced Gen”功能,用户可以自定义生成代码的范围;
|
||||
2、支持对库生成Static pusher;
|
||||
变更
|
||||
1、LuaTable以及InterfaceBirdage改为触发metatable;
|
||||
2、Extension Methods不自动加到被扩展类,需要加入生成列表;
|
||||
3、移除特殊ValueType优化;
|
||||
bug修复
|
||||
1、Extension Methods为私有时,生成代码语法错误;
|
||||
2、重载函数含ulong时,生成代码语法错误;
|
||||
3、反射调用时的默认值处理错误;
|
||||
4、C#向lua传中文字符的长度处理错误;
|
||||
|
||||
v2.0.2 2016年04月06日
|
||||
变更
|
||||
1、库的生成代码配置支持多份,方便项目的模块化;
|
||||
2、enum的生成代码合并到一个文件里头;
|
||||
3、优化异常处理;
|
||||
4、发布包把库和教程、例子分离,更干净;
|
||||
5、小bug修改;
|
||||
|
||||
升级指引
|
||||
由于文件有点变动,直接覆盖原有lib会报错,需要:
|
||||
1、删除原来的XLua目录;
|
||||
2、解压xlua_v2.0.2.zip到Assets下;
|
||||
3、重新执行代码生成;
|
||||
|
||||
v2.0.1 2016年03月24日
|
||||
1、支持C# 的extension methods;
|
||||
2、lua调试方面的支持;
|
||||
3、android下require一个不存在的lua文件可能成功的bug;
|
||||
4、TDR 4 Lua库的更新;
|
||||
5、多机型的兼容性测试;
|
||||
|
||||
v2.0.0 2016年03月08日
|
||||
1、性能优化,性能对比报告请看主页;
|
||||
2、加入官方lua版本的tdr;
|
||||
3、支持64位整数;
|
||||
4、修正lua中对C#异常pcall引发的不稳定;
|
||||
5、易用性的优化;
|
||||
6、其它一些bug的修改。
|
||||
|
||||
1.0.2 2015年12月09日
|
||||
1、解决新版本(已知5.2版本)下,streamAssetsPath不允许在构造函数访问导致的bug;
|
||||
2、新增windows x64版本的支持;
|
||||
3、对web版本才用到的代码加入条件编译,减少对手机版发布包的影响;
|
||||
4、生成代码文件名去掉“+”号;
|
||||
5、删除4.6的生成代码,以免在新版本报引用过时api的错;
|
||||
|
||||
v1.0.1 2015年11月30日
|
||||
1、支持pcall捕捉C#异常;
|
||||
2、新增cast方法,支持这种场景:实现类是internal声明,只提供interface;
|
||||
3、解决interface下如果有event,生成代码编译报错的bug;
|
||||
4、解决interface下有Obsolete的方法,字段,生成代码编译报错的bug;
|
||||
5、解决含private的默认geter/setter生成代码编译报错的bug;
|
||||
6、修正类在全局空间下生成代码不可用的bug;
|
||||
7、修正bridge代码返回值处理错误。
|
||||
|
||||
v1.0.0 2015年03月30日
|
||||
第一个版本
|
8
Assets/XLua/CHANGELOG.txt.meta
Normal file
8
Assets/XLua/CHANGELOG.txt.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be3fe4ee249c5274693e7b6f8053e861
|
||||
timeCreated: 1470364015
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -117,7 +117,9 @@ For example, the following adds a property of GameObject and a method of FileInf
|
||||
[BlackList]
|
||||
public static List<List<string>> BlackList = new List<List<string>>() {
|
||||
new List<string>(){"UnityEngine.GameObject", "networkView"},
|
||||
//new List<string>(){ typeof(UnityEngine.GameObject).FullName, "networkView"},
|
||||
new List<string>(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"},
|
||||
//new List<string>(){ typeof(System.IO.FileInfo).FullName, "GetAccessControl",typeof(System.Security.AccessControl.AccessControlSections).FullName },
|
||||
};
|
||||
~~~
|
||||
|
||||
|
@ -48,9 +48,7 @@ util.hotfix_ex(class, method_name, fix)
|
||||
|
||||
Like other configurations, there are two methods:
|
||||
|
||||
1. Add Hotfix flag directly in the type;
|
||||
|
||||
2. Configure a list in the static field or property of a static type. Properties can be used to implement more complex configurations, such as whitelisting based on Namespace.
|
||||
Configure a list in the static field or property of a static type. Properties can be used to implement more complex configurations, such as whitelisting based on Namespace.
|
||||
|
||||
~~~csharp
|
||||
public static class HotfixCfg
|
||||
|
@ -7,7 +7,7 @@ Material:
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: logo
|
||||
m_Shader: {fileID: 4800000, guid: 8c3ff126303ac344587210cb9f08ff6c, type: 3}
|
||||
m_Shader: {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
|
@ -1,6 +1,9 @@
|
||||
## C# API
|
||||
|
||||
### LuaEnv类
|
||||
|
||||
#### object[] DoString(string chunk, string chunkName = "chuck", LuaTable env = null)
|
||||
|
||||
描述:
|
||||
|
||||
执行一个代码块。
|
||||
@ -14,7 +17,7 @@
|
||||
|
||||
代码块里return语句的返回值;
|
||||
比如:return 1, “hello”,DoString返回将包含两个object的数组, 一个是double类型的1, 一个是string类型的“hello”
|
||||
|
||||
|
||||
例如:
|
||||
|
||||
LuaEnv luaenv = new LuaEnv();
|
||||
@ -38,7 +41,7 @@
|
||||
|
||||
代表该代码块的delegate或者LuaFunction类;
|
||||
|
||||
#### LuaTable Global;
|
||||
#### LuaTable Global
|
||||
|
||||
描述:
|
||||
|
||||
@ -64,45 +67,44 @@
|
||||
#### void Dispose()
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
Dispose该LuaEnv。
|
||||
|
||||
> LuaEnv的使用建议:全局就一个实例,并在Update中调用GC方法,完全不需要时调用Dispose
|
||||
|
||||
### LuaTable类
|
||||
|
||||
#### T Get<T>(string key)
|
||||
#### `T Get<T>(string key)`
|
||||
|
||||
描述:
|
||||
|
||||
获取在key下,类型为T的value,如果不存在或者类型不匹配,返回null;
|
||||
|
||||
|
||||
#### T GetInPath<T>(string path)
|
||||
#### `T GetInPath<T>(string path)`
|
||||
|
||||
描述:
|
||||
|
||||
和Get的区别是,这个函数会识别path里头的“.”,比如var i = tbl.GetInPath<int>(“a.b.c”)相当于在lua里头执行i = tbl.a.b.c,避免仅为了获取中间变量而多次调用Get,执行效率更高。
|
||||
|
||||
#### void SetInPath<T>(string path, T val)
|
||||
#### `void SetInPath<T>(string path, T val)`
|
||||
|
||||
描述:
|
||||
|
||||
和GetInPaht<T>对应的setter;
|
||||
|
||||
#### void Get<TKey, TValue>(TKey key, out TValue value)
|
||||
#### `void Get<TKey, TValue>(TKey key, out TValue value)`
|
||||
|
||||
描述:
|
||||
|
||||
上面的API的Key都只能是string,而这个API无此限制;
|
||||
|
||||
#### void Set<TKey, TValue>(TKey key, TValue value)
|
||||
#### `void Set<TKey, TValue>(TKey key, TValue value)`
|
||||
|
||||
描述:
|
||||
|
||||
对应Get<TKey, TValue>的setter;
|
||||
|
||||
#### T Cast<T>()
|
||||
#### `T Cast<T>()`
|
||||
|
||||
描述:
|
||||
|
||||
@ -111,12 +113,12 @@
|
||||
#### void SetMetaTable(LuaTable metaTable)
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
设置metaTable为table的metatable
|
||||
|
||||
### LuaFunction类
|
||||
### LuaFunction 类
|
||||
|
||||
> 注意:用该类访问Lua函数会有boxing,unboxing的开销,为了性能考虑,需要频繁调用的地方不要用该类。建议通过table.Get<ABCDelegate>获取一个delegate再调用(假设ABCDelegate是C#的一个delegate)。在使用使用table.Get<ABCDelegate>之前,请先把ABCDelegate加到代码生成列表。
|
||||
> 注意:用该类访问Lua函数会有boxing,unboxing的开销,为了性能考虑,需要频繁调用的地方不要用该类。建议通过 `table.Get<ABCDelegate>` 获取一个 delegate 再调用(假设 `ABCDelegate` 是 C# 的一个 delegate)。在使用使用 `table.Get<ABCDelegate>` 之前,请先把ABCDelegate加到代码生成列表。
|
||||
|
||||
#### object[] Call(params object[] args)
|
||||
|
||||
@ -155,29 +157,27 @@
|
||||
描述:
|
||||
|
||||
访问一个C#静态成员
|
||||
|
||||
|
||||
例如:
|
||||
|
||||
Print(CS.UnityEngine.Vector3.one)
|
||||
|
||||
|
||||
#### CS.namespace.enum.field
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
访问一个枚举值
|
||||
|
||||
#### typeof函数
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
类似C#里头的typeof关键字,返回一个Type对象,比如GameObject.AddComponent其中一个重载需要一个Type参数
|
||||
|
||||
例如:
|
||||
|
||||
newGameObj:AddComponent(typeof(CS.UnityEngine.ParticleSystem))
|
||||
|
||||
|
||||
#### 无符号64位支持
|
||||
|
||||
##### uint64.tostring
|
||||
@ -201,9 +201,9 @@
|
||||
##### uint64.remainder
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
无符号数取模。
|
||||
|
||||
|
||||
##### uint64.parse
|
||||
|
||||
描述:
|
||||
@ -212,24 +212,26 @@
|
||||
#### xlua.structclone
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
克隆一个c#结构体
|
||||
|
||||
#### xlua.private_accessible(class)
|
||||
|
||||
#### xlua.private_accessible(class)
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
让一个类的私有字段,属性,方法等可用
|
||||
例子:
|
||||
|
||||
xlua.private_accessible(CS.UnityEngine.GameObject)
|
||||
xlua.private_accessible(CS.UnityEngine.GameObject)
|
||||
|
||||
#### xlua.get_generic_method
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
获取一个泛型方法
|
||||
例子:
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
local foo_generic = xlua.get_generic_method(CS.GetGenericMethodTest, 'Foo')
|
||||
local bar_generic = xlua.get_generic_method(CS.GetGenericMethodTest, 'Bar')
|
||||
|
||||
@ -243,16 +245,16 @@ print(ret)
|
||||
|
||||
-- call static method
|
||||
bar(2, nil)
|
||||
~~~
|
||||
```
|
||||
|
||||
#### cast函数
|
||||
|
||||
描述:
|
||||
|
||||
|
||||
指明以特定的接口访问对象,这在实现类无法访问的时候(比如internal修饰)很有用,这时可以这么来(假设下面的calc对象实现了C#的PerformentTest.ICalc接口)
|
||||
|
||||
例子:
|
||||
|
||||
|
||||
cast(calc, typeof(CS.PerformentTest.ICalc))
|
||||
|
||||
然后就木有其它API了
|
||||
@ -272,7 +274,6 @@ bar(2, nil)
|
||||
|
||||
### 基本数据类型
|
||||
|
||||
|
||||
|C#类型|Lua类型|
|
||||
|-|-|
|
||||
|sbyte,byte,short,ushort,int,uint,double,char,float|number|
|
||||
@ -291,24 +292,24 @@ bar(2, nil)
|
||||
|class或者 struct的实例|userdata,table|
|
||||
|method,delegate|function|
|
||||
|
||||
#### LuaTable:
|
||||
#### LuaTable
|
||||
|
||||
C#侧指明从Lua侧输入(包括C#方法的输入参数或者Lua方法的返回值)LuaTable类型,则要求Lua侧为table。或者Lua侧的table,在C#侧未指明类型的情况下转换成LuaTable。
|
||||
|
||||
#### LuaFunction:
|
||||
#### LuaFunction
|
||||
|
||||
C#侧指明从Lua侧输入(包括C#方法的输入参数或者Lua方法的返回值)LuaFunction类型,则要求Lua侧为function。或者Lua侧的function,在C#侧未指明类型的情况下转换成LuaFunction。
|
||||
|
||||
#### LuaUserData:
|
||||
#### LuaUserData
|
||||
|
||||
对应非C# Managered对象的lua userdata。
|
||||
对应非 C# Managered 对象的lua userdata。
|
||||
|
||||
#### class或者 struct的实例:
|
||||
#### class 或者 struct 的实例
|
||||
|
||||
从C#传一个class或者struct的实例,将映射到Lua的userdata,并通过__index访问该userdata的成员
|
||||
C#侧指明从Lua侧输入指定类型对象,Lua侧为该类型实例的userdata可以直接使用;如果该指明类型有默认构造函数,Lua侧是table则会自动转换,转换规则是:调用构造函数构造实例,并用table对应字段转换到c#对应值后赋值各成员。
|
||||
|
||||
#### method, delegate:
|
||||
#### method, delegate
|
||||
|
||||
成员方法以及delegate都是对应lua侧的函数。
|
||||
C#侧的普通参数以及引用参数,对应lua侧函数参数;C#侧的返回值对应于Lua的第一个返回值;引用参数和out参数则按序对应于Lua的第2到第N个参数。
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
1. 获取一个全局基本数据类型
|
||||
访问LuaEnv.Global就可以了,上面有个模版Get方法,可指定返回的类型。
|
||||
|
||||
|
||||
luaenv.Global.Get<int>("a")
|
||||
luaenv.Global.Get<string>("b")
|
||||
luaenv.Global.Get<bool>("c")
|
||||
@ -66,7 +66,7 @@
|
||||
那有没有引用方式的映射呢?有,下面这个就是:
|
||||
|
||||
2. 映射到一个interface
|
||||
|
||||
|
||||
这种方式依赖于生成代码(如果没生成代码会抛InvalidCastException异常),代码生成器会生成这个interface的实例,如果get一个属性,生成代码会get对应的table字段,如果set属性也会设置对应的字段。甚至可以通过interface的方法访问lua的函数。
|
||||
|
||||
3. 更轻量级的by value方式:映射到Dictionary<>,List<>
|
||||
@ -74,7 +74,7 @@
|
||||
不想定义class或者interface的话,可以考虑用这个,前提table下key和value的类型都是一致的。
|
||||
|
||||
4. 另外一种by ref方式:映射到LuaTable类
|
||||
|
||||
|
||||
这种方式好处是不需要生成代码,但也有一些问题,比如慢,比方式2要慢一个数量级,比如没有类型检查。
|
||||
|
||||
3. 访问一个全局的function
|
||||
@ -93,7 +93,7 @@
|
||||
delegate的使用就更简单了,直接像个函数那样用就可以了。
|
||||
|
||||
2. 映射到LuaFunction
|
||||
|
||||
|
||||
这种方式的优缺点刚好和第一种相反。
|
||||
使用也简单,LuaFunction上有个变参的Call函数,可以传任意类型,任意个数的参数,返回值是object的数组,对应于lua的多返回值。
|
||||
|
||||
@ -101,9 +101,9 @@
|
||||
|
||||
1. 访问lua全局数据,特别是table以及function,代价比较大,建议尽量少做,比如在初始化时把要调用的lua function获取一次(映射到delegate)后,保存下来,后续直接调用该delegate即可。table也类似。
|
||||
|
||||
2. 如果lua测的实现的部分都以delegate和interface的方式提供,使用方可以完全和xLua解耦:由一个专门的模块负责xlua的初始化以及delegate、interface的映射,然后把这些delegate和interface设置到要用到它们的地方。
|
||||
2. 如果lua侧的实现的部分都以delegate和interface的方式提供,使用方可以完全和xLua解耦:由一个专门的模块负责xlua的初始化以及delegate、interface的映射,然后把这些delegate和interface设置到要用到它们的地方。
|
||||
|
||||
### Lua调用C#
|
||||
### Lua 调用 C#
|
||||
|
||||
> 本章节涉及到的实例均在XLua\Tutorial\LuaCallCSharp下
|
||||
|
||||
@ -167,11 +167,12 @@ xlua支持(通过派生类)访问基类的静态属性,静态方法,(
|
||||
|
||||
##### 参数的输入输出属性(out,ref)
|
||||
|
||||
Lua调用测的参数处理规则:C#的普通参数算一个输入形参,ref修饰的算一个输入形参,out不算,然后从左往右对应lua 调用测的实参列表;
|
||||
Lua调用侧的参数处理规则:C#的普通参数算一个输入形参,ref修饰的算一个输入形参,out不算,然后从左往右对应lua 调用侧的实参列表;
|
||||
|
||||
Lua调用测的返回值处理规则:C#函数的返回值(如果有的话)算一个返回值,out算一个返回值,ref算一个返回值,然后从左往右对应lua的多返回值。
|
||||
Lua调用侧的返回值处理规则:C#函数的返回值(如果有的话)算一个返回值,out算一个返回值,ref算一个返回值,然后从左往右对应lua的多返回值。
|
||||
|
||||
##### 重载方法
|
||||
|
||||
直接通过不同的参数类型进行重载函数的访问,例如:
|
||||
|
||||
testobj:TestFunc(100)
|
||||
@ -190,6 +191,7 @@ Lua调用测的返回值处理规则:C#函数的返回值(如果有的话)
|
||||
和C#调用有默认值参数的函数一样,如果所给的实参少于形参,则会用默认值补上。
|
||||
|
||||
##### 可变参数方法
|
||||
|
||||
对于C#的如下方法:
|
||||
|
||||
void VariableParamsFunc(int a, params string[] strs)
|
||||
|
@ -1,22 +1,22 @@
|
||||
# 通用字节码
|
||||
|
||||
不少项目希望把项目的lua源码通过luac编译后加载,但官方lua有个缺陷:字节码是分32位和64位版本的,换句话你32位lua环境只能跑32位luac编译出来的东西。
|
||||
不少项目希望把项目的 lua 源码通过 luac 编译后加载,但官方 lua 有个缺陷:字节码是分 32 位和 64 位版本的,换句话你 32 位 lua 环境只能跑 32 位 luac 编译出来的东西。
|
||||
|
||||
为此,xLua尝试对lua源码做了少许改造,可以编译一份字节码,跨平台使用。
|
||||
为此,xLua 尝试对 lua 源码做了少许改造,可以编译一份字节码,跨平台使用。
|
||||
|
||||
## 注意事项
|
||||
|
||||
* 1、如果你做了本文所描述的改动,你的xLua将加载不了官方luac所编译的字节码;
|
||||
* 1、如果你做了本文所描述的改动,你的 xLua 将加载不了官方 luac 所编译的字节码;
|
||||
|
||||
* 2、截至2018/9/14,已知此改法在一个上线一个多月的项目正常运行,但不代表此改法在任何情况都没问题。
|
||||
* 2、截至 2018/9/14,已知此改法在一个上线一个多月的项目正常运行,但不代表此改法在任何情况都没问题。
|
||||
|
||||
## 操作指南
|
||||
|
||||
### 1、编译xlua的Plugins
|
||||
### 1、编译 xlua 的 Plugins
|
||||
|
||||
修改各平台编译脚本,在cmake命令加上-DLUAC_COMPATIBLE_FORMAT=ON参数,以make_win64_lua53.bat为例,修改后是这样的:
|
||||
修改各平台编译脚本,在 cmake 命令加上 `-DLUAC_COMPATIBLE_FORMAT=ON` 参数,以 make_win64_lua53.bat 为例,修改后是这样的:
|
||||
|
||||
~~~bash
|
||||
```bash
|
||||
mkdir build64 & pushd build64
|
||||
cmake -DLUAC_COMPATIBLE_FORMAT=ON -G "Visual Studio 14 2015 Win64" ..
|
||||
popd
|
||||
@ -24,18 +24,18 @@ cmake --build build64 --config Release
|
||||
md plugin_lua53\Plugins\x86_64
|
||||
copy /Y build64\Release\xlua.dll plugin_lua53\Plugins\x86_64\xlua.dll
|
||||
pause
|
||||
~~~
|
||||
```
|
||||
|
||||
用修改后的编译脚本重新编译各平台的xlua库,并覆盖原Plugins目录下对应文件。
|
||||
用修改后的编译脚本重新编译各平台的 xlua 库,并覆盖原 Plugins 目录下对应文件。
|
||||
|
||||
## 2、编译能生成兼容格式的luac(后续只能用这特定的luac和步骤1的Plugins配套使用)
|
||||
|
||||
到[这里](../../../build/luac/),如果你想编译window版本的,执行make_win64.bat,如果你要编译mac或者linux的,用make_unix.sh
|
||||
到[这里](../../../build/luac/),如果你想编译 Windows 版本的,执行 make_win64.bat,如果你要编译 Mac 或者 Linux 的,用make_unix.sh
|
||||
|
||||
## 3、加载字节码
|
||||
|
||||
通过CustomLoader加载即可,CustomLoader的详细情况请看教程。这个步骤常犯的错误是用某种Encoding去加载二进制文件,这会破坏lua字节码文件格式。谨记得以二进制方式加载。
|
||||
通过 CustomLoader 加载即可,CustomLoader 的详细情况请看教程。这个步骤常犯的错误是用某种Encoding去加载二进制文件,这会破坏lua字节码文件格式。谨记得以二进制方式加载。
|
||||
|
||||
## PS: OpCode修改
|
||||
|
||||
有项目想修改为专用格式的字节码,直接在lua源码(目前是lua-5.3.5)上修改后,重新执行上述1、2操作步骤即可。
|
||||
有项目想修改为专用格式的字节码,直接在 lua 源码(目前是lua-5.3.5)上修改后,重新执行上述1、2操作步骤即可。
|
||||
|
@ -13,7 +13,7 @@ xLua所有的配置都支持三种方式:打标签;静态列表;动态列
|
||||
|
||||
xLua用白名单来指明生成哪些代码,而白名单通过attribute来配置,比如你想从lua调用c#的某个类,希望生成适配代码,你可以为这个类型打一个LuaCallCSharp标签:
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
|
||||
[LuaCallCSharp]
|
||||
publicclassA
|
||||
@ -21,7 +21,7 @@ publicclassA
|
||||
|
||||
}
|
||||
|
||||
~~~
|
||||
```
|
||||
|
||||
该方式方便,但在il2cpp下会增加不少的代码量,不建议使用。
|
||||
|
||||
@ -29,7 +29,7 @@ publicclassA
|
||||
|
||||
有时我们无法直接给一个类型打标签,比如系统api,没源码的库,或者实例化的泛化类型,这时你可以在一个静态类里声明一个静态字段,该字段的类型除BlackList和AdditionalProperties之外只要实现了IEnumerable<Type>就可以了(这两个例外后面具体会说),然后为这字段加上标签:
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
|
||||
[LuaCallCSharp]
|
||||
public static List<Type> mymodule_lua_call_cs_list = new List<Type>()
|
||||
@ -38,7 +38,7 @@ public static List<Type> mymodule_lua_call_cs_list = new List<Type>()
|
||||
typeof(Dictionary<string, int>),
|
||||
};
|
||||
|
||||
~~~
|
||||
```
|
||||
|
||||
这个字段需要放到一个 **静态类** 里头,建议放到 **Editor目录** 。
|
||||
|
||||
@ -46,7 +46,7 @@ public static List<Type> mymodule_lua_call_cs_list = new List<Type>()
|
||||
|
||||
声明一个静态属性,打上相应的标签即可。
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
|
||||
[Hotfix]
|
||||
public static List<Type> by_property
|
||||
@ -59,7 +59,7 @@ public static List<Type> by_property
|
||||
}
|
||||
}
|
||||
|
||||
~~~
|
||||
```
|
||||
|
||||
Getter是代码,你可以实现很多效果,比如按名字空间配置,按程序集配置等等。
|
||||
|
||||
@ -79,7 +79,7 @@ xLua只会生成加了该配置的类型,不会自动生成其父类的适配
|
||||
|
||||
一个C#类型类型加了这个配置,xLua会生成link.xml阻止il2cpp的代码剪裁。
|
||||
|
||||
对于扩展方法,必须加上LuaCallCSharp或者ReflectionUse才可以被访问到。
|
||||
对于扩展方法,必须加上 `LuaCallCSharp` 或者 `ReflectionUse` 才可以被访问到。
|
||||
|
||||
建议所有要在Lua访问的类型,要么加LuaCallCSharp,要么加上ReflectionUse,这才能够保证在各平台都能正常运行。
|
||||
|
||||
@ -87,7 +87,7 @@ xLua只会生成加了该配置的类型,不会自动生成其父类的适配
|
||||
|
||||
指明一个类里头的部分函数、字段、属性不生成代码,通过反射访问。
|
||||
|
||||
只能标准Dictionary<Type, List<string>>的field或者property。key指明的是生效的类,value是一个列表,配置的是不生成代码的函数、字段、属性的名字。
|
||||
只能标准 `Dictionary<Type, List<string>>` 的field或者property。key指明的是生效的类,value是一个列表,配置的是不生成代码的函数、字段、属性的名字。
|
||||
|
||||
和ReflectionUse的区别是:1、ReflectionUse指明的是整个类;2、当第一次访问一个函数(字段、属性)时,ReflectionUse会把整个类都wrap,而DoNotGen只wrap该函数(字段、属性),换句话DoNotGen更lazy一些;
|
||||
|
||||
@ -99,7 +99,7 @@ xLua只会生成加了该配置的类型,不会自动生成其父类的适配
|
||||
|
||||
### XLua.GCOptimize
|
||||
|
||||
一个C#纯值类型(注:指的是一个只包含值类型的struct,可以嵌套其它只包含值类型的struct)或者C#枚举值加上了这个配置。xLua会为该类型生成gc优化代码,效果是该值类型在lua和c#间传递不产生(C#)gc alloc,该类型的数组访问也不产生gc。各种无GC的场景,可以参考05\_NoGc例子。
|
||||
一个C#纯值类型(注:指的是一个只包含值类型的struct,可以嵌套其它只包含值类型的struct)或者C#枚举值加上了这个配置。xLua会为该类型生成gc优化代码,效果是该值类型在lua和c#间传递不产生(C#)gc alloc,该类型的数组访问也不产生gc。各种无GC的场景,可以参考 `05_Gc` 例子。
|
||||
|
||||
除枚举之外,包含无参构造函数的复杂类型,都会生成lua table到该类型,以及改类型的一维数组的转换代码,这将会优化这个转换的性能,包括更少的gc alloc。
|
||||
|
||||
@ -107,7 +107,7 @@ xLua只会生成加了该配置的类型,不会自动生成其父类的适配
|
||||
|
||||
这个是GCOptimize的扩展配置,有的时候,一些struct喜欢把field做成是私有的,通过property来访问field,这时就需要用到该配置(默认情况下GCOptimize只对public的field打解包)。
|
||||
|
||||
标签方式比较简单,配置方式复杂一点,要求是Dictionary<Type, List<string>>类型,Dictionary的Key是要生效的类型,Value是属性名列表。可以参考XLua对几个UnityEngine下值类型的配置,SysGCOptimize类。
|
||||
标签方式比较简单,配置方式复杂一点,要求是 `Dictionary<Type, List<string>>` 类型,Dictionary 的 Key 是要生效的类型,Value 是属性名列表。可以参考XLua对几个UnityEngine下值类型的配置,SysGCOptimize类。
|
||||
|
||||
### XLua.BlackList
|
||||
|
||||
@ -115,19 +115,21 @@ xLua只会生成加了该配置的类型,不会自动生成其父类的适配
|
||||
|
||||
标签方式比较简单,对应的成员上加就可以了。
|
||||
|
||||
由于考虑到有可能需要把重载函数的其中一个重载列入黑名单,配置方式比较复杂,类型是List<List<string>>,对于每个成员,在第一层List有一个条目,第二层List是个string的列表,第一个string是类型的全路径名,第二个string是成员名,如果成员是一个方法,还需要从第三个string开始,把其参数的类型全路径全列出来。
|
||||
由于考虑到有可能需要把重载函数的其中一个重载列入黑名单,配置方式比较复杂,类型是 `List<List<string>>`,对于每个成员,在第一层List有一个条目,第二层List是个string的列表,第一个string是类型的全路径名,第二个string是成员名,如果成员是一个方法,还需要从第三个string开始,把其参数的类型全路径全列出来。
|
||||
|
||||
例如下面是对GameObject的一个属性以及FileInfo的一个方法列入黑名单:
|
||||
例如下面是对 GameObject 的一个属性以及FileInfo的一个方法列入黑名单:
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
|
||||
[BlackList]
|
||||
public static List<List<string>> BlackList = new List<List<string>>() {
|
||||
new List<string>(){"UnityEngine.GameObject", "networkView"},
|
||||
//new List<string>(){ typeof(UnityEngine.GameObject).FullName, "networkView"},
|
||||
new List<string>(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"},
|
||||
//new List<string>(){ typeof(System.IO.FileInfo).FullName, "GetAccessControl",typeof(System.Security.AccessControl.AccessControlSections).FullName },
|
||||
};
|
||||
|
||||
~~~
|
||||
```
|
||||
|
||||
### 下面是生成期配置,必须放到Editor目录下
|
||||
|
||||
|
@ -16,7 +16,7 @@ xLua的生成引擎支持二次开发,你可以利用它来生成一些文本
|
||||
|
||||
示例:
|
||||
|
||||
~~~xml
|
||||
```xml
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
%>
|
||||
@ -30,47 +30,47 @@ require "TemplateCommon"
|
||||
</assembly>
|
||||
<%end)%>
|
||||
</linker>
|
||||
~~~
|
||||
```
|
||||
|
||||
TemplateCommon有一些预定义的函数可以使用,比如ForEachCsList,可以搜索下工程的TemplateCommon.lua.txt看下有那些函数可以用,就普通的lua而已,你自己写一套也可以。
|
||||
|
||||
## API
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
public static void CSObjectWrapEditor.Generator.CustomGen(string template_src, GetTasks get_tasks)
|
||||
~~~
|
||||
```
|
||||
|
||||
* template_src : 模版的源码;
|
||||
* get_tasks : 回调函数,类型是GetTasks,用来接受用户的配置,返回需要注入到模版的数据以及文件的输出流;
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
public delegate IEnumerable<CustomGenTask> GetTasks(LuaEnv lua_env, UserConfig user_cfg);
|
||||
~~~
|
||||
```
|
||||
|
||||
* lua_env : LuaEnv对象,因为返回的模版数据需要放到LuaTable,需要用到LuaEnv.NewTable;
|
||||
* user_cfg : 用户的配置;
|
||||
* return : 返回值中,CustomGenTask代表的是一个生成文件,而IEnumerable类型表示同一个模版可以生成多个文件;
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
public struct UserConfig
|
||||
{
|
||||
public IEnumerable<Type> LuaCallCSharp;
|
||||
public IEnumerable<Type> CSharpCallLua;
|
||||
public IEnumerable<Type> ReflectionUse;
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
public struct CustomGenTask
|
||||
{
|
||||
public LuaTable Data;
|
||||
public TextWriter Output;
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
示例:
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
public static IEnumerable<CustomGenTask> GetTasks(LuaEnv lua_env, UserConfig user_cfg)
|
||||
{
|
||||
LuaTable data = lua_env.NewTable();
|
||||
@ -86,7 +86,7 @@ public static IEnumerable<CustomGenTask> GetTasks(LuaEnv lua_env, UserConfig use
|
||||
false, Encoding.UTF8)
|
||||
};
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
* 这里只生成一个文件,故只返回一个CustomGenTask;
|
||||
* data就是模版要使用的数据,这里塞了一个assembly_infos字段,这个字段如何使用可以回头看看模版部分;
|
||||
@ -97,13 +97,13 @@ public static IEnumerable<CustomGenTask> GetTasks(LuaEnv lua_env, UserConfig use
|
||||
|
||||
示例:
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
[GenCodeMenu]//加到Generate Code菜单里头
|
||||
public static void GenLinkXml()
|
||||
{
|
||||
Generator.CustomGen(ScriptableObject.CreateInstance<LinkXmlGen>().Template.text, GetTasks);
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
|
||||
ps:以上所有相关代码都在XLua\Src\Editor\LinkXmlGen目录下,也正是文章开头说的link.xml的生成功能的实现。
|
||||
|
@ -68,7 +68,13 @@ ios和osx需要在mac下编译。
|
||||
|
||||
## 报类似“xlua.access, no field __Hitfix0_Update”的错误怎么解决?
|
||||
|
||||
按[Hotfix操作指南](hotfix.md)一步步操作。
|
||||
按[Hotfix操作指南](hotfix.md)一步步操作,以及注意事项。确保上述步骤完成后,可尝试使用[解决方案](https://github.com/Tencent/xLua/issues/850)。
|
||||
|
||||
出现这报错,肯定是这个导致的:最终包的这个方法(函数)没注入。
|
||||
|
||||
但造成“最终包的这个方法(函数)没注入”的原因会有很多:比如没按文档操作,注入失败,比如Hotfix列表漏了这个类,比如你的打包脚本在注入后,又触发了重新编译,覆盖了注入结果。。。
|
||||
|
||||
统一的解决方式是找出并解决导致“最终包的这个方法(函数)没注入”的具体原因。
|
||||
|
||||
## visual studio 2017下编译UWP原生库
|
||||
|
||||
@ -90,6 +96,8 @@ visual studio 2017需要安装:1、“工作负载”下的“通用Window平
|
||||
|
||||
如果编辑器下没问题,发布到手机报这错,表示你发布前没生成代码(执行“XLua/Generate Code”)。
|
||||
|
||||
如果你Unity版本大于或等于2018,看下前面兼容性的章节。
|
||||
|
||||
## unity5.5以上执行"XLua/Hotfix Inject In Editor"菜单会提示"WARNING: The runtime version supported by this application is unavailable."
|
||||
|
||||
这是因为注入工具是用.net3.5编译,而unity5.5意思MonoBleedingEdge的mono环境并没3.5支持导致的,不过一般而言都向下兼容,目前为止也没发现该warning带来什么问题。
|
||||
@ -192,6 +200,7 @@ end)
|
||||
```
|
||||
|
||||
3、如果xlua版本大于2.1.12的话,新增反射调用泛型方法的支持(有一定的限制,看后面的说明),比如对于这么个C#类型:
|
||||
|
||||
```csharp
|
||||
public class GetGenericMethodTest
|
||||
{
|
||||
@ -214,7 +223,9 @@ public class GetGenericMethodTest
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
在lua那这么调用:
|
||||
|
||||
```lua
|
||||
local foo_generic = xlua.get_generic_method(CS.GetGenericMethodTest, 'Foo')
|
||||
local bar_generic = xlua.get_generic_method(CS.GetGenericMethodTest, 'Bar')
|
||||
@ -252,12 +263,12 @@ bar(2, nil)
|
||||
|
||||
如果你的版本大于2.1.11,可以用get_Item来获取值,用set_Item来设置值。要注意只有this[string field]或者this[object field]才有这两个替代api,其它类型的key是没有的。
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
dic:set_Item('a', 1)
|
||||
dic:set_Item('b', 2)
|
||||
print(dic:get_Item('a'))
|
||||
print(dic:get_Item('b'))
|
||||
~~~
|
||||
```
|
||||
|
||||
如果你的版本小于或等于2.1.11,建议直接方法该操作符的等效方法,比如Dictionary的TryGetValue,如果该方法没有提供,可以在C#那通过Extension method封装一个使用。
|
||||
|
||||
@ -267,7 +278,7 @@ print(dic:get_Item('b'))
|
||||
|
||||
对应这种情况,可以为UnityEngine.Object写一个扩展方法:
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
[LuaCallCSharp]
|
||||
[ReflectionUse]
|
||||
public static class UnityEngineObjectExtention
|
||||
@ -277,35 +288,35 @@ public static class UnityEngineObjectExtention
|
||||
return o == null;
|
||||
}
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
然后在lua那你对所有UnityEngine.Object实例都使用IsNull判断
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
print(go:GetComponent('Animator'):IsNull())
|
||||
~~~
|
||||
```
|
||||
|
||||
## 泛型实例怎么构造
|
||||
|
||||
涉及的类型都在mscorlib,Assembly-CSharp程序集的话,泛型实例的构造和普通类型是一样的,都是CS.namespace.typename(),可能比较特殊的是typename的表达,泛型实例的typename的表达包含了标识符非法符号,最后一部分要换成["typename"],以List<string>为例
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
local lst = CS.System.Collections.Generic["List`1[System.String]"]()
|
||||
~~~
|
||||
```
|
||||
|
||||
如果某个泛型实例的typename不确定,可以在C#测打印下typeof(不确定的类型).ToString()
|
||||
|
||||
如果涉及mscorlib,Assembly-CSharp程序集之外的类型的话,可以用C#的反射来做:
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
local dic = CS.System.Activator.CreateInstance(CS.System.Type.GetType('System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UnityEngine.Vector3, UnityEngine]],mscorlib'))
|
||||
dic:Add('a', CS.UnityEngine.Vector3(1, 2, 3))
|
||||
print(dic:TryGetValue('a'))
|
||||
~~~
|
||||
```
|
||||
|
||||
如果你的xLua版本大于v2.1.12,将会有更漂亮的表达方式
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
-- local List_String = CS.System.Collections.Generic['List<>'](CS.System.String) -- another way
|
||||
local List_String = CS.System.Collections.Generic.List(CS.System.String)
|
||||
local lst = List_String()
|
||||
@ -314,7 +325,7 @@ local Dictionary_String_Vector3 = CS.System.Collections.Generic.Dictionary(CS.Sy
|
||||
local dic = Dictionary_String_Vector3()
|
||||
dic:Add('a', CS.UnityEngine.Vector3(1, 2, 3))
|
||||
print(dic:TryGetValue('a'))
|
||||
~~~
|
||||
```
|
||||
|
||||
|
||||
## 调用LuaEnv.Dispose时,报“try to dispose a LuaEnv with C# callback!”错是什么原因?
|
||||
@ -333,17 +344,17 @@ print(dic:TryGetValue('a'))
|
||||
|
||||
xlua提供了一个工具函数来帮助你找到被C#引用着的lua函数,util.print_func_ref_by_csharp,使用很简单,执行如下lua代码:
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
local util = require 'xlua.util'
|
||||
util.print_func_ref_by_csharp()
|
||||
~~~
|
||||
```
|
||||
|
||||
可以看到控制台有类似这样的输出,下面第一行表示有一个在main.lua的第2行定义的函数被C#引用着
|
||||
|
||||
~~~bash
|
||||
```bash
|
||||
LUA: main.lua:2
|
||||
LUA: main.lua:13
|
||||
~~~
|
||||
```
|
||||
|
||||
## 调用LuaEnv.Dispose崩溃
|
||||
|
||||
@ -358,14 +369,14 @@ LUA: main.lua:13
|
||||
|
||||
用util.hotfix_ex,可以调用原先的C#逻辑
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
local util = require 'xlua.util'
|
||||
util.hotfix_ex(CS.HotfixTest, 'Add', function(self, a, b)
|
||||
local org_sum = self:Add(a, b)
|
||||
print('org_sum', org_sum)
|
||||
return a + b
|
||||
end)
|
||||
~~~
|
||||
```
|
||||
|
||||
## 怎么把C#的函数赋值给一个委托字段
|
||||
|
||||
@ -375,7 +386,7 @@ end)
|
||||
|
||||
比如如下C#代码
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
public class TestClass
|
||||
{
|
||||
public void Foo(int a)
|
||||
@ -387,10 +398,10 @@ public class TestClass
|
||||
}
|
||||
}
|
||||
public delegate void TestDelegate(int a);
|
||||
~~~
|
||||
```
|
||||
|
||||
你可以指明用Foo函数创建一个TestDelegate实例
|
||||
~~~lua
|
||||
```lua
|
||||
local util = require 'xlua.util'
|
||||
|
||||
local d1 = util.createdelegate(CS.TestDelegate, obj, CS.TestClass, 'Foo', {typeof(CS.System.Int32)}) --由于Foo是实例方法,所以参数2需要传TestClass实例
|
||||
@ -398,7 +409,7 @@ local d2 = util.createdelegate(CS.TestDelegate, nil, CS.TestClass, 'SFoo', {type
|
||||
|
||||
obj_has_TestDelegate.field = d1 + d2 --到时调用field的时候将会触发Foo和SFoo,这不会经过Lua适配
|
||||
|
||||
~~~
|
||||
```
|
||||
|
||||
## 为什么有时Lua错误直接中断了而没错误信息?
|
||||
|
||||
@ -408,15 +419,15 @@ obj_has_TestDelegate.field = d1 + d2 --到时调用field的时候将会触发Foo
|
||||
|
||||
把类似下面的代码:
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
coroutine.resume(co, ...)
|
||||
~~~
|
||||
```
|
||||
|
||||
改为:
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
assert(coroutine.resume(co, ...))
|
||||
~~~
|
||||
```
|
||||
|
||||
2、上层catch后,不打印
|
||||
|
||||
@ -432,7 +443,7 @@ assert(coroutine.resume(co, ...))
|
||||
|
||||
可以通过xlua.tofunction结合反射来处理,xlua.tofunction输入一个MethodBase对象,返回一个lua函数。比如下面的C#代码:
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
class TestOverload
|
||||
{
|
||||
public int Add(int a, int b)
|
||||
@ -447,11 +458,11 @@ class TestOverload
|
||||
return (short)(a + b);
|
||||
}
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
我们可以这么调用指定重载:
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
local m1 = typeof(CS.TestOverload):GetMethod('Add', {typeof(CS.System.Int16), typeof(CS.System.Int16)})
|
||||
local m2 = typeof(CS.TestOverload):GetMethod('Add', {typeof(CS.System.Int32), typeof(CS.System.Int32)})
|
||||
local f1 = xlua.tofunction(m1) --切记对于同一个MethodBase,只tofunction一次,然后重复使用
|
||||
@ -461,7 +472,7 @@ local obj = CS.TestOverload()
|
||||
|
||||
f1(obj, 1, 2) --调用short版本,成员方法,所以要传对象,静态方法则不需要
|
||||
f2(obj, 1, 2) --调用int版本
|
||||
~~~
|
||||
```
|
||||
|
||||
注意:xlua.tofunction由于使用不太方便,以及使用了反射,所以建议做作为临时方案,尽量用封装的方法来解决。
|
||||
|
||||
@ -511,3 +522,10 @@ f2(obj, 1, 2) --调用int版本
|
||||
|
||||
常见的不明显的多线程的场景,比如c#异步socket,对象析构函数等。
|
||||
|
||||
## maOS10.15以上,启动unity的时候提示xlua.bundle损坏,移动到废纸篓
|
||||
|
||||
执行
|
||||
|
||||
```bash
|
||||
sudo xattr -r -d com.apple.quarantine xlua.bundle
|
||||
```
|
||||
|
@ -3,67 +3,67 @@
|
||||
## 总体
|
||||
|
||||
* Lua虚拟机支持
|
||||
* Lua5.3
|
||||
* Luajit2.1
|
||||
* Lua5.3
|
||||
* Luajit2.1
|
||||
* Unity3D版本支持
|
||||
* 各版本均支持
|
||||
* 各版本均支持
|
||||
* 平台支持
|
||||
* windows 64/32
|
||||
* android
|
||||
* ios 64/32/bitcode
|
||||
* osx
|
||||
* uwp
|
||||
* webgl
|
||||
* windows 64/32
|
||||
* android
|
||||
* ios 64/32/bitcode
|
||||
* osx
|
||||
* uwp
|
||||
* webgl
|
||||
* 互访技术
|
||||
* 生成适配代码
|
||||
* 反射
|
||||
* 生成适配代码
|
||||
* 反射
|
||||
* 易用性
|
||||
* 解压即可用
|
||||
* 开发期无需生成代码
|
||||
* 生成代码和反射间可无缝切换
|
||||
* 更简单的无GC api
|
||||
* 菜单简单易懂
|
||||
* 配置可以多份,按模块划分,也可以直接在目标类型上打Attribute标签
|
||||
* 自动生成link.xml防止代码剪裁
|
||||
* Plugins部分采用cmake编译,更简单
|
||||
* 核心代码不依赖生成代码,可以随时删除生成目录
|
||||
* 解压即可用
|
||||
* 开发期无需生成代码
|
||||
* 生成代码和反射间可无缝切换
|
||||
* 更简单的无GC api
|
||||
* 菜单简单易懂
|
||||
* 配置可以多份,按模块划分,也可以直接在目标类型上打Attribute标签
|
||||
* 自动生成link.xml防止代码剪裁
|
||||
* Plugins部分采用cmake编译,更简单
|
||||
* 核心代码不依赖生成代码,可以随时删除生成目录
|
||||
* 性能
|
||||
* Lazyload技术,避免用不上的类型的开销
|
||||
* lua函数映射到c# delegate,lua table映射到interface,可实现接口层面无C# gc alloc开销
|
||||
* 所有基本值类型,所有枚举,字段都是值类型的struct,在Lua和C#间传递无C# gc alloc
|
||||
* LuaTable,LuaFunction提供无gc访问接口
|
||||
* 通过代码生成期的静态分析,生成最优代码
|
||||
* 支持C#和Lua间指针传递
|
||||
* 自动解除已经Destroy的UnityEngine.Object的引用
|
||||
* Lazyload技术,避免用不上的类型的开销
|
||||
* lua函数映射到c# delegate,lua table映射到interface,可实现接口层面无C# gc alloc开销
|
||||
* 所有基本值类型,所有枚举,字段都是值类型的struct,在Lua和C#间传递无C# gc alloc
|
||||
* LuaTable,LuaFunction提供无gc访问接口
|
||||
* 通过代码生成期的静态分析,生成最优代码
|
||||
* 支持C#和Lua间指针传递
|
||||
* 自动解除已经Destroy的UnityEngine.Object的引用
|
||||
* 扩展性
|
||||
* 不用改代码就可以加入Lua第三方扩展
|
||||
* 生成引擎提供接口做二次开发
|
||||
* 不用改代码就可以加入Lua第三方扩展
|
||||
* 生成引擎提供接口做二次开发
|
||||
|
||||
## 支持为如下C#实现打补丁
|
||||
|
||||
* 构造函数
|
||||
* 析构函数
|
||||
* 成员函数
|
||||
* 静态函数
|
||||
* 泛化函数
|
||||
* 操作符重载
|
||||
* 成员属性
|
||||
* 静态属性
|
||||
* 事件
|
||||
|
||||
* 构造函数
|
||||
* 析构函数
|
||||
* 成员函数
|
||||
* 静态函数
|
||||
* 泛化函数
|
||||
* 操作符重载
|
||||
* 成员属性
|
||||
* 静态属性
|
||||
* 事件
|
||||
|
||||
## Lua代码加载
|
||||
|
||||
* 加载字符串
|
||||
* 支持加载后立即执行
|
||||
* 支持加载后返回一个delegate或者LuaFunction,调用delegate或者LuaFunction后可传脚本参数
|
||||
* 支持加载后立即执行
|
||||
* 支持加载后返回一个delegate或者LuaFunction,调用delegate或者LuaFunction后可传脚本参数
|
||||
* Resources目录的文件
|
||||
* 直接require
|
||||
* 直接require
|
||||
* 自定义loader
|
||||
* Lua里头require时触发
|
||||
* require参数透传给loader,loader读取Lua代码返回
|
||||
* Lua里头require时触发
|
||||
* require参数透传给loader,loader读取Lua代码返回
|
||||
* Lua原有的方式
|
||||
* Lua原有的方式都保留
|
||||
|
||||
* Lua原有的方式都保留
|
||||
|
||||
## Lua调用C#
|
||||
|
||||
* 创建C#对象
|
||||
@ -72,58 +72,58 @@
|
||||
* C#成员属性,字段
|
||||
* C#成员方法
|
||||
* C#继承
|
||||
* 子类对象可以直接调用父类的方法,访问父类属性
|
||||
* 子类模块可以直接调用父类的静态方法,静态属性
|
||||
* 子类对象可以直接调用父类的方法,访问父类属性
|
||||
* 子类模块可以直接调用父类的静态方法,静态属性
|
||||
* 扩展方法(Extension methods)
|
||||
* 就像普通成员方法一样使用
|
||||
* 就像普通成员方法一样使用
|
||||
* 参数的输入输出属性(out,ref)
|
||||
* out对应一个lua返回值
|
||||
* ref对应一个lua参数以及一个lua返回值
|
||||
* out对应一个lua返回值
|
||||
* ref对应一个lua参数以及一个lua返回值
|
||||
* 函数重载
|
||||
* 支持重载
|
||||
* 由于lua数据类型远比C#要少,会出现无法判断的情况,可通过扩展方法来来调用。
|
||||
* 支持重载
|
||||
* 由于lua数据类型远比C#要少,会出现无法判断的情况,可通过扩展方法来来调用。
|
||||
* 操作符重载
|
||||
* 支持的操作符:+,-,*,/,==,一元-,<,<=, %,[]
|
||||
* 其它操作符可以借助扩展方法调用
|
||||
* 支持的操作符:+,-,*,/,==,一元-,<,<=, %,[]
|
||||
* 其它操作符可以借助扩展方法调用
|
||||
* 参数默认值
|
||||
* C#参数有默认值,在lua可以不传
|
||||
* C#参数有默认值,在lua可以不传
|
||||
* 可变参数
|
||||
* 在对应可变参数部分,直接输入一个个参数即可,不需要把这些参数扩到一个数组里头
|
||||
* 在对应可变参数部分,直接输入一个个参数即可,不需要把这些参数扩到一个数组里头
|
||||
* 泛化方法调用
|
||||
* 静态方法可以自行封装使用
|
||||
* 成员函数可通过扩展方法封装使用
|
||||
* 静态方法可以自行封装使用
|
||||
* 成员函数可通过扩展方法封装使用
|
||||
* 枚举类型
|
||||
* 数字或字符串到枚举的转换
|
||||
* 数字或字符串到枚举的转换
|
||||
* delegate
|
||||
* 调用一个C# delegate
|
||||
* +操作符
|
||||
* -操作符
|
||||
* 把一个lua函数作为一个c# delegate传递给c#
|
||||
* 调用一个C# delegate
|
||||
* +操作符
|
||||
* -操作符
|
||||
* 把一个lua函数作为一个c# delegate传递给c#
|
||||
* event
|
||||
* 增加事件回调
|
||||
* 移除事件回调
|
||||
* 增加事件回调
|
||||
* 移除事件回调
|
||||
* 64位整数
|
||||
* 传递无gc而且无精度损失
|
||||
* lua53下使用原生64位支持
|
||||
* 可以和number运算
|
||||
* 以java的方式支持无符号64位整数
|
||||
* 传递无gc而且无精度损失
|
||||
* lua53下使用原生64位支持
|
||||
* 可以和number运算
|
||||
* 以java的方式支持无符号64位整数
|
||||
* table的自动转换到C#复杂类型
|
||||
* obj.complexField = {a = 1, b = {c = 1}},obj是一个C#对象,complexField是两层嵌套的struct或者class
|
||||
* obj.complexField = {a = 1, b = {c = 1}},obj是一个C#对象,complexField是两层嵌套的struct或者class
|
||||
* typeof
|
||||
* 对应C#的typeof操作符,返回Type对象
|
||||
* 对应C#的typeof操作符,返回Type对象
|
||||
* lua侧直接clone
|
||||
* decimal
|
||||
* 传递无gc而且无精度损失
|
||||
* 传递无gc而且无精度损失
|
||||
|
||||
## C#调用Lua
|
||||
|
||||
* 调用Lua函数
|
||||
* 以delegate方式调用Lua函数
|
||||
* 以LuaFunction调用lua函数
|
||||
* 以delegate方式调用Lua函数
|
||||
* 以LuaFunction调用lua函数
|
||||
* 访问Lua的table
|
||||
* LuaTable的泛化Get/Set接口,调用无gc,可指明Key,Value的类型
|
||||
* 用标注了CSharpCallLua的interface访问
|
||||
* 值拷贝到struct,class
|
||||
* LuaTable的泛化Get/Set接口,调用无gc,可指明Key,Value的类型
|
||||
* 用标注了CSharpCallLua的interface访问
|
||||
* 值拷贝到struct,class
|
||||
|
||||
## Lua虚拟机
|
||||
|
||||
@ -132,8 +132,8 @@
|
||||
## 工具链
|
||||
|
||||
* Lua Profiler
|
||||
* 可根据函数调用总时长,平均每次调用时长,调用次数排序
|
||||
* 显示lua函数名及其所在文件的名字及行号
|
||||
* 如果C#函数,会显示这个是C#函数
|
||||
* 可根据函数调用总时长,平均每次调用时长,调用次数排序
|
||||
* 显示lua函数名及其所在文件的名字及行号
|
||||
* 如果C#函数,会显示这个是C#函数
|
||||
* 支持真机调试
|
||||
|
||||
|
@ -1,32 +1,37 @@
|
||||
## 简介
|
||||
|
||||
热补丁允许你使用 xLua 的代码逻辑, 替换掉原有的 C# 程序逻辑, 以实现热补丁.
|
||||
|
||||
## 使用方式
|
||||
|
||||
1、打开该特性
|
||||
1. 打开该特性
|
||||
|
||||
添加HOTFIX_ENABLE宏,(在Unity3D的File->Build Setting->Scripting Define Symbols下添加)。编辑器、各手机平台这个宏要分别设置!如果是自动化打包,要注意在代码里头用API设置的宏是不生效的,需要在编辑器设置。
|
||||
添加 `HOTFIX_ENABLE` 宏,(在 Unity3D 的 "File->Build Setting->Scripting Define Symbols" 下添加)。编辑器、各手机平台这个宏要分别设置!如果是自动化打包,要注意在代码里头用 API 设置的宏是不生效的,需要在编辑器设置。
|
||||
|
||||
(建议平时开发业务代码不打开HOTFIX_ENABLE,只在build手机版本或者要在编译器下开发补丁时打开HOTFIX_ENABLE)
|
||||
(建议平时开发业务代码不打开 `HOTFIX_ENABLE`,只在构建手机版本或者要在编译器下开发补丁时打开 `HOTFIX_ENABLE`)
|
||||
|
||||
2、执行XLua/Generate Code菜单。
|
||||
2. 在菜单中找到 "XLua/Generate Code" 按钮并单击。
|
||||
|
||||
3、注入,构建手机包这个步骤会在构建时自动进行,编辑器下开发补丁需要手动执行"XLua/Hotfix Inject In Editor"菜单。打印“hotfix inject finish!”或者“had injected!”才算成功,否则会打印错误信息。
|
||||
3. 注入,构建手机包这个步骤会在构建时自动进行,编辑器下开发补丁需要手动执行 "XLua/Hotfix Inject In Editor" 菜单。打印 “hotfix inject finish!” 或者 “had injected!” 才算成功,否则会打印错误信息。
|
||||
|
||||
如果已经打印了“hotfix inject finish!”或者“had injected!”,执行xlua.hotfix仍然报类似“xlua.access, no field __Hitfix0_Update”的错误,要么是该类没配置到Hotfix列表,要么是注入成功后,又触发了编译,覆盖了注入结果。
|
||||
如果已经打印了 “hotfix inject finish!” 或者 “had injected!”,执行 `xlua.hotfix` 仍然报类似 “xlua.access, no field __Hitfix0_Update” 的错误,要么是该类没配置到 Hotfix 列表,要么是注入成功后,又触发了编译,覆盖了注入结果。
|
||||
|
||||
## 约束
|
||||
## 局限性
|
||||
|
||||
不支持静态构造函数。
|
||||
|
||||
目前只支持Assets下代码的热补丁,不支持引擎,c#系统库的热补丁。
|
||||
目前只支持 Assets 下代码的热补丁,不支持引擎,C# 系统库的热补丁。
|
||||
|
||||
## API
|
||||
xlua.hotfix(class, [method_name], fix)
|
||||
|
||||
`xlua.hotfix(class, [method_name], fix)`
|
||||
|
||||
* 描述 : 注入lua补丁
|
||||
* class : C#类,两种表示方法,CS.Namespace.TypeName或者字符串方式"Namespace.TypeName",字符串格式和C#的Type.GetType要求一致,如果是内嵌类型(Nested Type)是非Public类型的话,只能用字符串方式表示"Namespace.TypeName+NestedTypeName";
|
||||
* method_name : 方法名,可选;
|
||||
* fix : 如果传了method_name,fix将会是一个function,否则通过table提供一组函数。table的组织按key是method_name,value是function的方式。
|
||||
|
||||
base(csobj)
|
||||
`base(csobj)`
|
||||
|
||||
* 描述 : 子类override函数通过base调用父类实现。
|
||||
* csobj : 对象
|
||||
@ -41,7 +46,7 @@ xlua.hotfix(CS.BaseTest, 'Foo', function(self, p)
|
||||
end)
|
||||
```
|
||||
|
||||
util.hotfix_ex(class, method_name, fix)
|
||||
`util.hotfix_ex(class, method_name, fix)`
|
||||
|
||||
* 描述 : xlua.hotfix的增强版本,可以在fix函数里头执行原来的函数,缺点是fix的执行会略慢。
|
||||
* method_name : 方法名;
|
||||
@ -53,9 +58,13 @@ util.hotfix_ex(class, method_name, fix)
|
||||
|
||||
方式一:直接在类里头打Hotfix标签(不建议,示例只是为了方便演示采取这种方式);
|
||||
|
||||
方式二:在一个static类的static字段或者属性里头配置一个列表。属性可以用于实现的比较复杂的配置,比如根据Namespace做白名单。
|
||||
!!注意,方式一在高版本 Unity 不支持
|
||||
|
||||
~~~csharp
|
||||
方式二:在一个静态类的静态字段或者属性里头配置一个列表。属性可以用于实现的比较复杂的配置,比如根据命名空间做白名单。
|
||||
|
||||
!!注意,高版本 Unity 需要把配置文件放 Editor 目录下
|
||||
|
||||
```csharp
|
||||
//如果涉及到Assembly-CSharp.dll之外的其它dll,如下代码需要放到Editor目录
|
||||
public static class HotfixCfg
|
||||
{
|
||||
@ -77,7 +86,7 @@ public static class HotfixCfg
|
||||
}
|
||||
}
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
## Hotfix Flag
|
||||
|
||||
@ -85,37 +94,37 @@ Hotfix标签可以设置一些标志位对生成代码及插桩定制化
|
||||
|
||||
* Stateless、Stateful
|
||||
|
||||
遗留设置,Stateful方式在新版本已经删除,因为这种方式可以用xlua.util.state接口达到类似的效果,该接口的使用可以看下HotfixTest2.cs里的示例代码。
|
||||
遗留设置,`Stateful` 方式在新版本已经删除,因为这种方式可以用 `xlua.util.state` 接口达到类似的效果,该接口的使用可以看下`HotfixTest2.cs` 里的示例代码。
|
||||
|
||||
由于没Stateful,默认就是Stateless,所以也没必要设置该标志位。
|
||||
由于没 `Stateful`,默认就是 `Stateless`,所以也没必要设置该标志位。
|
||||
|
||||
* ValueTypeBoxing
|
||||
|
||||
值类型的适配delegate会收敛到object,好处是代码量更少,不好的是值类型会产生boxing及gc,适用于对text段敏感的业务。
|
||||
值类型的适配delegate会收敛到object,好处是代码量更少,不好的是值类型会产生boxing及gc,适用于对text段敏感的业务。
|
||||
|
||||
* IgnoreProperty
|
||||
|
||||
不对属性注入及生成适配代码,一般而言,大多数属性的实现都很简单,出错几率比较小,建议不注入。
|
||||
不对属性注入及生成适配代码,一般而言,大多数属性的实现都很简单,出错几率比较小,建议不注入。
|
||||
|
||||
* IgnoreNotPublic
|
||||
|
||||
不对非public的方法注入及生成适配代码。除了像MonoBehaviour那种会被反射调用的私有方法必须得注入,其它仅被本类调用的非public方法可以不注入,只不过修复时会工作量稍大,所有引用到这个函数的public方法都要重写。
|
||||
不对非public的方法注入及生成适配代码。除了像MonoBehaviour那种会被反射调用的私有方法必须得注入,其它仅被本类调用的非public方法可以不注入,只不过修复时会工作量稍大,所有引用到这个函数的public方法都要重写。
|
||||
|
||||
* Inline
|
||||
|
||||
不生成适配delegate,直接在函数体注入处理代码。
|
||||
不生成适配 delegate,直接在函数体注入处理代码。
|
||||
|
||||
* IntKey
|
||||
|
||||
不生成静态字段,而是把所有注入点放到一个数组集中管理。
|
||||
不生成静态字段,而是把所有注入点放到一个数组集中管理。
|
||||
|
||||
好处:对text段影响小。
|
||||
好处:对 text 段影响小。
|
||||
|
||||
坏处:使用不像默认方式那么方便,需要通过id来指明hotfix哪个函数,而这个id是代码注入工具时分配的,函数到id的映射会保存在Gen/Resources/hotfix_id_map.lua.txt,并且自动加时间戳备份到hotfix_id_map.lua.txt同级目录,发布手机版本后请妥善保存该文件。
|
||||
坏处:使用不像默认方式那么方便,需要通过id来指明hotfix哪个函数,而这个id是代码注入工具时分配的,函数到id的映射会保存在 `Gen/Resources/hotfix_id_map.lua.txt`,并且自动加时间戳备份到 `hotfix_id_map.lua.txt` 同级目录,发布手机版本后请妥善保存该文件。
|
||||
|
||||
该文件的格式大概如下(注意:该文件仅IntKey模式使用,当你没类型指定IntKey模式注入,该文件只返回个空表):
|
||||
该文件的格式大概如下(注意:该文件仅IntKey模式使用,当你没类型指定IntKey模式注入,该文件只返回个空表):
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
return {
|
||||
["HotfixTest"] = {
|
||||
[".ctor"] = {
|
||||
@ -138,19 +147,19 @@ return {
|
||||
},
|
||||
},
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
想要替换HotfixTest的Update函数,你得
|
||||
想要替换 `HotfixTest` 的 `Update` 函数,你得
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
CS.XLua.HotfixDelegateBridge.Set(7, func)
|
||||
~~~
|
||||
```
|
||||
|
||||
如果是重载函数,将会一个函数名对应多个id,比如上面的Add函数。
|
||||
如果是重载函数,将会一个函数名对应多个 id,比如上面的 `Add` 函数。
|
||||
|
||||
能不能自动化一些呢?可以,xlua.util提供了auto_id_map函数,执行一次后你就可以像以前那样直接用类,方法名去指明修补的函数。
|
||||
能不能自动化一些呢?可以,`xlua.util` 提供了 `auto_id_map` 函数,执行一次后你就可以像以前那样直接用类,方法名去指明修补的函数。
|
||||
|
||||
~~~lua
|
||||
```lua
|
||||
(require 'xlua.util').auto_id_map()
|
||||
xlua.hotfix(CS.HotfixTest, 'Update', function(self)
|
||||
self.tick = self.tick + 1
|
||||
@ -158,25 +167,24 @@ xlua.hotfix(CS.HotfixTest, 'Update', function(self)
|
||||
print('<<<<<<<<Update in lua, tick = ' .. self.tick)
|
||||
end
|
||||
end)
|
||||
~~~
|
||||
|
||||
前提是hotfix_id_map.lua.txt放到可以通过require 'hotfix_id_map'引用到的地方。
|
||||
```
|
||||
|
||||
前提是 `hotfix_id_map.lua.txt` 放到可以通过 `require 'hotfix_id_map'` 引用到的地方。
|
||||
|
||||
## 使用建议
|
||||
|
||||
* 对所有较大可能变动的类型加上Hotfix标识;
|
||||
* 建议用反射找出所有函数参数、字段、属性、事件涉及的delegate类型,标注CSharpCallLua;
|
||||
* 业务代码、引擎API、系统API,需要在Lua补丁里头高性能访问的类型,加上LuaCallCSharp;
|
||||
* 引擎API、系统API可能被代码剪裁调(C#无引用的地方都会被剪裁),如果觉得可能会新增C#代码之外的API调用,这些API所在的类型要么加LuaCallCSharp,要么加ReflectionUse;
|
||||
* 对所有较大可能变动的类型加上 `Hotfix` 标识;
|
||||
* 建议用反射找出所有函数参数、字段、属性、事件涉及的 delegate 类型,标注 `CSharpCallLua`;
|
||||
* 业务代码、引擎 API、系统 API,需要在 Lua 补丁里头高性能访问的类型,加上 `LuaCallCSharp`;
|
||||
* 引擎 API、系统 API 可能被代码剪裁调(C#无引用的地方都会被剪裁),如果觉得可能会新增 C# 代码之外的 API 调用,这些 API 所在的类型要么加 `LuaCallCSharp`,要么加 `ReflectionUse`;
|
||||
|
||||
## 打补丁
|
||||
|
||||
xlua可以用lua函数替换C#的构造函数,函数,属性,事件的替换。lua实现都是函数,比如属性对于一个getter函数和一个setter函数,事件对应一个add函数和一个remove函数。
|
||||
xlua可以用lua函数替换 C# 的构造函数,函数,属性,事件的替换。lua实现都是函数,比如属性对于一个 getter 函数和一个 setter 函数,事件对应一个 `add` 函数和一个 `remove` 函数。
|
||||
|
||||
* 函数
|
||||
|
||||
method_name传函数名,支持重载,不同重载都是转发到同一个lua函数。
|
||||
`method_name` 传函数名,支持重载,不同重载都是转发到同一个 lua 函数。
|
||||
|
||||
比如:
|
||||
|
||||
@ -207,41 +215,41 @@ end)
|
||||
|
||||
```
|
||||
|
||||
静态函数和成员函数的区别是,成员函数会加一个self参数,这个self在Stateless方式下是C#对象本身(对应C#的this)
|
||||
静态函数和成员函数的区别是,成员函数会加一个 self 参数,这个 self 在 Stateless 方式下是 C# 对象本身(对应 C# 的 this)
|
||||
|
||||
普通参数对于lua的参数,ref参数对应lua的一个参数和一个返回值,out参数对于lua的一个返回值。
|
||||
普通参数对于 lua 的参数,ref 参数对应 lua 的一个参数和一个返回值,out参数对于lua的一个返回值。
|
||||
|
||||
泛化函数的打补丁规则和普通函数一样。
|
||||
|
||||
* 构造函数
|
||||
|
||||
构造函数对应的method_name是".ctor"。
|
||||
构造函数对应的 `method_name` 是 ".ctor"。
|
||||
|
||||
和普通函数不一样的是,构造函数的热补丁并不是替换,而是执行原有逻辑后调用lua。
|
||||
|
||||
* 属性
|
||||
|
||||
对于名为“AProp”的属性,会对应一个getter,method_name等于get_AProp,setter的method_name等于set_AProp。
|
||||
对于名为 “AProp” 的属性,会对应一个 getter,`method_name` 等于 `get_AProp`,setter 的 `method_name` 等于 `set_AProp`。
|
||||
|
||||
* []操作符
|
||||
|
||||
赋值对应set_Item,取值对应get_Item。第一个参数是self,赋值后面跟key,value,取值只有key参数,返回值是取出的值。
|
||||
赋值对应 `set_Item`,取值对应 `get_Item`。第一个参数是 self,赋值后面跟 key,value,取值只有 key 参数,返回值是取出的值。
|
||||
|
||||
* 其它操作符
|
||||
|
||||
C#的操作符都有一套内部表示,比如+号的操作符函数名是op_Addition(其它操作符的内部表示可以去请参照相关资料),覆盖这函数就覆盖了C#的+号操作符。
|
||||
C#的操作符都有一套内部表示,比如 `+` 号的操作符函数名是 `op_Addition`(其它操作符的内部表示可以去请参照相关资料),覆盖这函数就覆盖了 C# 的 `+` 号操作符。
|
||||
|
||||
* 事件
|
||||
|
||||
比如对于事件“AEvent”,+=操作符是add_AEvent,-=对应的是remove_AEvent。这两个函数均是第一个参数是self,第二个参数是操作符后面跟的delegate。
|
||||
比如对于事件“AEvent”,+= 操作符是 add_AEvent,-=对应的是 remove_AEvent。这两个函数均是第一个参数是self,第二个参数是操作符后面跟的delegate。
|
||||
|
||||
通过xlua.private_accessible(版本号大于2.1.11不需要调用xlua.private_accessible)来直接访问事件对应的私有delegate的直接访问后,可以通过对象的"&事件名"字段直接触发事件,例如self\['&MyEvent'\](),其中MyEvent是事件名。
|
||||
通过 `xlua.private_accessible`(版本号大于2.1.11不需要调用 `xlua.private_accessible`)来直接访问事件对应的私有 delegate 的直接访问后,可以通过对象的"&事件名"字段直接触发事件,例如 `self['&MyEvent']()`,其中MyEvent是事件名。
|
||||
|
||||
* 析构函数
|
||||
|
||||
method_name是"Finalize",传一个self参数。
|
||||
method_name 是 "Finalize",传一个 self 参数。
|
||||
|
||||
和普通函数不一样的是,析构函数的热补丁并不是替换,而是开头调用lua函数后继续原有逻辑。
|
||||
和普通函数不一样的是,析构函数的热补丁并不是替换,而是开头调用 lua 函数后继续原有逻辑。
|
||||
|
||||
* 泛化类型
|
||||
|
||||
@ -253,10 +261,9 @@ public class GenericClass<T>
|
||||
}
|
||||
```
|
||||
|
||||
你只能对GenericClass\<double\>,GenericClass\<int\>这些类,而不是对GenericClass打补丁。
|
||||
你只能对 `GenericClass<double>`,`GenericClass<int>` 这些类,而不是对 `GenericClass` 打补丁。
|
||||
|
||||
|
||||
对GenericClass<double>打补丁的实例如下:
|
||||
对 `GenericClass<double>` 打补丁的实例如下:
|
||||
|
||||
```csharp
|
||||
luaenv.DoString(@"
|
||||
@ -277,9 +284,9 @@ luaenv.DoString(@"
|
||||
|
||||
* Unity协程
|
||||
|
||||
通过util.cs_generator可以用一个function模拟一个IEnumerator,在里头用coroutine.yield,就类似C#里头的yield return。比如下面的C#代码和对应的hotfix代码是等同效果的
|
||||
通过 `util.cs_generator` 可以用一个 function 模拟一个 `IEnumerator`,在里头用 `coroutine.yield`,就类似 C# 里头的 yield return。比如下面的 C# 代码和对应的 hotfix 代码是等同效果的
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
[XLua.Hotfix]
|
||||
public class HotFixSubClass : MonoBehaviour {
|
||||
IEnumerator Start()
|
||||
@ -291,9 +298,9 @@ public class HotFixSubClass : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
}
|
||||
~~~
|
||||
```
|
||||
|
||||
~~~csharp
|
||||
```csharp
|
||||
luaenv.DoString(@"
|
||||
local util = require 'xlua.util'
|
||||
xlua.hotfix(CS.HotFixSubClass,{
|
||||
@ -307,11 +314,11 @@ luaenv.DoString(@"
|
||||
end;
|
||||
})
|
||||
");
|
||||
~~~
|
||||
```
|
||||
|
||||
* 整个类
|
||||
|
||||
如果要替换整个类,不需要一次次的调用xlua.hotfix去替换,可以整个一次完成。只要给一个table,按method_name = function组织即可
|
||||
如果要替换整个类,不需要一次次的调用 `xlua.hotfix` 去替换,可以整个一次完成。只要给一个 table,按 `method_name = function` 组织即可
|
||||
|
||||
```lua
|
||||
|
||||
@ -365,4 +372,3 @@ xlua.hotfix(CS.StatefullTest, {
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
@ -1,85 +1,55 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b9f4e2e38c36db40bc5bdfe20038d94
|
||||
timeCreated: 1481715979
|
||||
licenseType: Pro
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapU: -1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 1
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 1
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
BIN
Assets/XLua/Doc/xLua.png
Normal file
BIN
Assets/XLua/Doc/xLua.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 28 KiB |
56
Assets/XLua/Doc/xLua.png.meta
Normal file
56
Assets/XLua/Doc/xLua.png.meta
Normal file
@ -0,0 +1,56 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2926ca0864130e40b99cbe18d0fc395
|
||||
timeCreated: 1481699971
|
||||
licenseType: Pro
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 0
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e53aa922da0a00469e5760902833e71
|
||||
guid: f890416e958ceb54694b165fb109582a
|
||||
folderAsset: yes
|
||||
timeCreated: 1534492498
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
311
Assets/XLua/Editor/ExampleConfig.cs
Normal file
311
Assets/XLua/Editor/ExampleConfig.cs
Normal file
@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making xLua available.
|
||||
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/MIT
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using XLua;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
|
||||
//配置的详细介绍请看Doc下《XLua的配置.doc》
|
||||
public static class ExampleConfig
|
||||
{
|
||||
/***************如果你全lua编程,可以参考这份自动化配置***************/
|
||||
//--------------begin 纯lua编程配置参考----------------------------
|
||||
//static List<string> exclude = new List<string> {
|
||||
// "HideInInspector", "ExecuteInEditMode",
|
||||
// "AddComponentMenu", "ContextMenu",
|
||||
// "RequireComponent", "DisallowMultipleComponent",
|
||||
// "SerializeField", "AssemblyIsEditorAssembly",
|
||||
// "Attribute", "Types",
|
||||
// "UnitySurrogateSelector", "TrackedReference",
|
||||
// "TypeInferenceRules", "FFTWindow",
|
||||
// "RPC", "Network", "MasterServer",
|
||||
// "BitStream", "HostData",
|
||||
// "ConnectionTesterStatus", "GUI", "EventType",
|
||||
// "EventModifiers", "FontStyle", "TextAlignment",
|
||||
// "TextEditor", "TextEditorDblClickSnapping",
|
||||
// "TextGenerator", "TextClipping", "Gizmos",
|
||||
// "ADBannerView", "ADInterstitialAd",
|
||||
// "Android", "Tizen", "jvalue",
|
||||
// "iPhone", "iOS", "Windows", "CalendarIdentifier",
|
||||
// "CalendarUnit", "CalendarUnit",
|
||||
// "ClusterInput", "FullScreenMovieControlMode",
|
||||
// "FullScreenMovieScalingMode", "Handheld",
|
||||
// "LocalNotification", "NotificationServices",
|
||||
// "RemoteNotificationType", "RemoteNotification",
|
||||
// "SamsungTV", "TextureCompressionQuality",
|
||||
// "TouchScreenKeyboardType", "TouchScreenKeyboard",
|
||||
// "MovieTexture", "UnityEngineInternal",
|
||||
// "Terrain", "Tree", "SplatPrototype",
|
||||
// "DetailPrototype", "DetailRenderMode",
|
||||
// "MeshSubsetCombineUtility", "AOT", "Social", "Enumerator",
|
||||
// "SendMouseEvents", "Cursor", "Flash", "ActionScript",
|
||||
// "OnRequestRebuild", "Ping",
|
||||
// "ShaderVariantCollection", "SimpleJson.Reflection",
|
||||
// "CoroutineTween", "GraphicRebuildTracker",
|
||||
// "Advertisements", "UnityEditor", "WSA",
|
||||
// "EventProvider", "Apple",
|
||||
// "ClusterInput", "Motion",
|
||||
// "UnityEngine.UI.ReflectionMethodsCache", "NativeLeakDetection",
|
||||
// "NativeLeakDetectionMode", "WWWAudioExtensions", "UnityEngine.Experimental",
|
||||
//};
|
||||
|
||||
//static bool isExcluded(Type type)
|
||||
//{
|
||||
// var fullName = type.FullName;
|
||||
// for (int i = 0; i < exclude.Count; i++)
|
||||
// {
|
||||
// if (fullName.Contains(exclude[i]))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//[LuaCallCSharp]
|
||||
//public static IEnumerable<Type> LuaCallCSharp
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// List<string> namespaces = new List<string>() // 在这里添加名字空间
|
||||
// {
|
||||
// "UnityEngine",
|
||||
// "UnityEngine.UI"
|
||||
// };
|
||||
// var unityTypes = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
|
||||
// where !(assembly.ManifestModule is System.Reflection.Emit.ModuleBuilder)
|
||||
// from type in assembly.GetExportedTypes()
|
||||
// where type.Namespace != null && namespaces.Contains(type.Namespace) && !isExcluded(type)
|
||||
// && type.BaseType != typeof(MulticastDelegate) && !type.IsInterface && !type.IsEnum
|
||||
// select type);
|
||||
|
||||
// string[] customAssemblys = new string[] {
|
||||
// "Assembly-CSharp",
|
||||
// };
|
||||
// var customTypes = (from assembly in customAssemblys.Select(s => Assembly.Load(s))
|
||||
// from type in assembly.GetExportedTypes()
|
||||
// where type.Namespace == null || !type.Namespace.StartsWith("XLua")
|
||||
// && type.BaseType != typeof(MulticastDelegate) && !type.IsInterface && !type.IsEnum
|
||||
// select type);
|
||||
// return unityTypes.Concat(customTypes);
|
||||
// }
|
||||
//}
|
||||
|
||||
////自动把LuaCallCSharp涉及到的delegate加到CSharpCallLua列表,后续可以直接用lua函数做callback
|
||||
//[CSharpCallLua]
|
||||
//public static List<Type> CSharpCallLua
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// var lua_call_csharp = LuaCallCSharp;
|
||||
// var delegate_types = new List<Type>();
|
||||
// var flag = BindingFlags.Public | BindingFlags.Instance
|
||||
// | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly;
|
||||
// foreach (var field in (from type in lua_call_csharp select type).SelectMany(type => type.GetFields(flag)))
|
||||
// {
|
||||
// if (typeof(Delegate).IsAssignableFrom(field.FieldType))
|
||||
// {
|
||||
// delegate_types.Add(field.FieldType);
|
||||
// }
|
||||
// }
|
||||
|
||||
// foreach (var method in (from type in lua_call_csharp select type).SelectMany(type => type.GetMethods(flag)))
|
||||
// {
|
||||
// if (typeof(Delegate).IsAssignableFrom(method.ReturnType))
|
||||
// {
|
||||
// delegate_types.Add(method.ReturnType);
|
||||
// }
|
||||
// foreach (var param in method.GetParameters())
|
||||
// {
|
||||
// var paramType = param.ParameterType.IsByRef ? param.ParameterType.GetElementType() : param.ParameterType;
|
||||
// if (typeof(Delegate).IsAssignableFrom(paramType))
|
||||
// {
|
||||
// delegate_types.Add(paramType);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return delegate_types.Where(t => t.BaseType == typeof(MulticastDelegate) && !hasGenericParameter(t) && !delegateHasEditorRef(t)).Distinct().ToList();
|
||||
// }
|
||||
//}
|
||||
//--------------end 纯lua编程配置参考----------------------------
|
||||
|
||||
/***************热补丁可以参考这份自动化配置***************/
|
||||
//[Hotfix]
|
||||
//static IEnumerable<Type> HotfixInject
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return (from type in Assembly.Load("Assembly-CSharp").GetTypes()
|
||||
// where type.Namespace == null || !type.Namespace.StartsWith("XLua")
|
||||
// select type);
|
||||
// }
|
||||
//}
|
||||
//--------------begin 热补丁自动化配置-------------------------
|
||||
//static bool hasGenericParameter(Type type)
|
||||
//{
|
||||
// if (type.IsGenericTypeDefinition) return true;
|
||||
// if (type.IsGenericParameter) return true;
|
||||
// if (type.IsByRef || type.IsArray)
|
||||
// {
|
||||
// return hasGenericParameter(type.GetElementType());
|
||||
// }
|
||||
// if (type.IsGenericType)
|
||||
// {
|
||||
// foreach (var typeArg in type.GetGenericArguments())
|
||||
// {
|
||||
// if (hasGenericParameter(typeArg))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//static bool typeHasEditorRef(Type type)
|
||||
//{
|
||||
// if (type.Namespace != null && (type.Namespace == "UnityEditor" || type.Namespace.StartsWith("UnityEditor.")))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// if (type.IsNested)
|
||||
// {
|
||||
// return typeHasEditorRef(type.DeclaringType);
|
||||
// }
|
||||
// if (type.IsByRef || type.IsArray)
|
||||
// {
|
||||
// return typeHasEditorRef(type.GetElementType());
|
||||
// }
|
||||
// if (type.IsGenericType)
|
||||
// {
|
||||
// foreach (var typeArg in type.GetGenericArguments())
|
||||
// {
|
||||
// if (typeArg.IsGenericParameter) {
|
||||
// //skip unsigned type parameter
|
||||
// continue;
|
||||
// }
|
||||
// if (typeHasEditorRef(typeArg))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//static bool delegateHasEditorRef(Type delegateType)
|
||||
//{
|
||||
// if (typeHasEditorRef(delegateType)) return true;
|
||||
// var method = delegateType.GetMethod("Invoke");
|
||||
// if (method == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// if (typeHasEditorRef(method.ReturnType)) return true;
|
||||
// return method.GetParameters().Any(pinfo => typeHasEditorRef(pinfo.ParameterType));
|
||||
//}
|
||||
|
||||
// 配置某Assembly下所有涉及到的delegate到CSharpCallLua下,Hotfix下拿不准那些delegate需要适配到lua function可以这么配置
|
||||
//[CSharpCallLua]
|
||||
//static IEnumerable<Type> AllDelegate
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// BindingFlags flag = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
|
||||
// List<Type> allTypes = new List<Type>();
|
||||
// var allAssemblys = new Assembly[]
|
||||
// {
|
||||
// Assembly.Load("Assembly-CSharp")
|
||||
// };
|
||||
// foreach (var t in (from assembly in allAssemblys from type in assembly.GetTypes() select type))
|
||||
// {
|
||||
// var p = t;
|
||||
// while (p != null)
|
||||
// {
|
||||
// allTypes.Add(p);
|
||||
// p = p.BaseType;
|
||||
// }
|
||||
// }
|
||||
// allTypes = allTypes.Distinct().ToList();
|
||||
// var allMethods = from type in allTypes
|
||||
// from method in type.GetMethods(flag)
|
||||
// select method;
|
||||
// var returnTypes = from method in allMethods
|
||||
// select method.ReturnType;
|
||||
// var paramTypes = allMethods.SelectMany(m => m.GetParameters()).Select(pinfo => pinfo.ParameterType.IsByRef ? pinfo.ParameterType.GetElementType() : pinfo.ParameterType);
|
||||
// var fieldTypes = from type in allTypes
|
||||
// from field in type.GetFields(flag)
|
||||
// select field.FieldType;
|
||||
// return (returnTypes.Concat(paramTypes).Concat(fieldTypes)).Where(t => t.BaseType == typeof(MulticastDelegate) && !hasGenericParameter(t) && !delegateHasEditorRef(t)).Distinct();
|
||||
// }
|
||||
//}
|
||||
//--------------end 热补丁自动化配置-------------------------
|
||||
|
||||
//黑名单
|
||||
[BlackList]
|
||||
public static List<List<string>> BlackList = new List<List<string>>() {
|
||||
new List<string>(){"System.Xml.XmlNodeList", "ItemOf"},
|
||||
new List<string>(){"UnityEngine.WWW", "movie"},
|
||||
#if UNITY_WEBGL
|
||||
new List<string>(){"UnityEngine.WWW", "threadPriority"},
|
||||
#endif
|
||||
new List<string>(){"UnityEngine.Texture2D", "alphaIsTransparency"},
|
||||
new List<string>(){"UnityEngine.Security", "GetChainOfTrustValue"},
|
||||
new List<string>(){"UnityEngine.CanvasRenderer", "onRequestRebuild"},
|
||||
new List<string>(){"UnityEngine.Light", "areaSize"},
|
||||
new List<string>(){"UnityEngine.Light", "lightmapBakeType"},
|
||||
new List<string>(){"UnityEngine.WWW", "MovieTexture"},
|
||||
new List<string>(){"UnityEngine.WWW", "GetMovieTexture"},
|
||||
new List<string>(){"UnityEngine.AnimatorOverrideController", "PerformOverrideClipListCleanup"},
|
||||
#if !UNITY_WEBPLAYER
|
||||
new List<string>(){"UnityEngine.Application", "ExternalEval"},
|
||||
#endif
|
||||
new List<string>(){"UnityEngine.GameObject", "networkView"}, //4.6.2 not support
|
||||
new List<string>(){"UnityEngine.Component", "networkView"}, //4.6.2 not support
|
||||
new List<string>(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"},
|
||||
new List<string>(){"System.IO.FileInfo", "SetAccessControl", "System.Security.AccessControl.FileSecurity"},
|
||||
new List<string>(){"System.IO.DirectoryInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"},
|
||||
new List<string>(){"System.IO.DirectoryInfo", "SetAccessControl", "System.Security.AccessControl.DirectorySecurity"},
|
||||
new List<string>(){"System.IO.DirectoryInfo", "CreateSubdirectory", "System.String", "System.Security.AccessControl.DirectorySecurity"},
|
||||
new List<string>(){"System.IO.DirectoryInfo", "Create", "System.Security.AccessControl.DirectorySecurity"},
|
||||
new List<string>(){"UnityEngine.MonoBehaviour", "runInEditMode"},
|
||||
};
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
[BlackList]
|
||||
public static Func<MemberInfo, bool> MethodFilter = (memberInfo) =>
|
||||
{
|
||||
if (memberInfo.DeclaringType.IsGenericType && memberInfo.DeclaringType.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
||||
{
|
||||
if (memberInfo.MemberType == MemberTypes.Constructor)
|
||||
{
|
||||
ConstructorInfo constructorInfo = memberInfo as ConstructorInfo;
|
||||
var parameterInfos = constructorInfo.GetParameters();
|
||||
if (parameterInfos.Length > 0)
|
||||
{
|
||||
if (typeof(System.Collections.IEnumerable).IsAssignableFrom(parameterInfos[0].ParameterType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (memberInfo.MemberType == MemberTypes.Method)
|
||||
{
|
||||
var methodInfo = memberInfo as MethodInfo;
|
||||
if (methodInfo.Name == "TryAdd" || methodInfo.Name == "Remove" && methodInfo.GetParameters().Length == 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
#endif
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 982733e7e9c70eb4ba5b8cac9812499b
|
||||
timeCreated: 1597926529
|
||||
guid: 1b852d3c62124624888d03e611f7b1fc
|
||||
timeCreated: 1534126175
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making xLua available.
|
||||
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/MIT
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using XLua;
|
||||
//using System.Reflection;
|
||||
//using System.Linq;
|
||||
|
||||
//配置的详细介绍请看Doc下《XLua的配置.doc》
|
||||
public static class XLuaGenConfig
|
||||
{
|
||||
//lua中要使用到C#库的配置,比如C#标准库,或者Unity API,第三方库等。
|
||||
[LuaCallCSharp]
|
||||
public static List<Type> LuaCallCSharp = new List<Type>() {
|
||||
typeof(System.Object),
|
||||
typeof(UnityEngine.Object),
|
||||
typeof(Vector2),
|
||||
typeof(Vector3),
|
||||
typeof(Vector4),
|
||||
typeof(Quaternion),
|
||||
typeof(Color),
|
||||
typeof(Ray),
|
||||
typeof(Bounds),
|
||||
typeof(Ray2D),
|
||||
typeof(Time),
|
||||
typeof(GameObject),
|
||||
typeof(Component),
|
||||
typeof(Behaviour),
|
||||
typeof(Transform),
|
||||
typeof(Resources),
|
||||
typeof(TextAsset),
|
||||
typeof(Keyframe),
|
||||
typeof(AnimationCurve),
|
||||
typeof(AnimationClip),
|
||||
typeof(MonoBehaviour),
|
||||
typeof(ParticleSystem),
|
||||
typeof(SkinnedMeshRenderer),
|
||||
typeof(Renderer),
|
||||
typeof(WWW),
|
||||
typeof(Light),
|
||||
typeof(Mathf),
|
||||
typeof(System.Collections.Generic.List<int>),
|
||||
typeof(Action<string>),
|
||||
typeof(UnityEngine.Debug),
|
||||
typeof(System.Collections.Hashtable)
|
||||
};
|
||||
|
||||
//C#静态调用Lua的配置(包括事件的原型),仅可以配delegate,interface
|
||||
[CSharpCallLua]
|
||||
public static List<Type> CSharpCallLua = new List<Type>() {
|
||||
typeof(Action),
|
||||
typeof(Func<double, double, double>),
|
||||
typeof(Action<string>),
|
||||
typeof(Action<double>),
|
||||
typeof(UnityEngine.Events.UnityAction),
|
||||
typeof(System.Collections.IEnumerator),
|
||||
typeof(System.Collections.IEnumerable),
|
||||
typeof(LuaUIItemBase.voidObject),
|
||||
typeof(LuaUIItemBase.voidLuaUIItemBase),
|
||||
typeof(LuaUIItemSelect.voidObject),
|
||||
typeof(LuaUIItemSelect.voidLuaUIItemSelect),
|
||||
typeof(IMarketingActRetDel),
|
||||
typeof(LuaUIManager.OnOpenUIDelegate),
|
||||
typeof(UIManager.OnOpenUIDelegate),
|
||||
};
|
||||
|
||||
//黑名单
|
||||
[BlackList]
|
||||
public static List<List<string>> BlackList = new List<List<string>>() {
|
||||
new List<string>(){"System.Xml.XmlNodeList", "ItemOf"},
|
||||
new List<string>(){"UnityEngine.WWW", "movie"},
|
||||
#if UNITY_WEBGL
|
||||
new List<string>(){"UnityEngine.WWW", "threadPriority"},
|
||||
#endif
|
||||
new List<string>(){"UnityEngine.Texture2D", "alphaIsTransparency"},
|
||||
new List<string>(){"UnityEngine.Security", "GetChainOfTrustValue"},
|
||||
new List<string>(){"UnityEngine.CanvasRenderer", "onRequestRebuild"},
|
||||
new List<string>(){"UnityEngine.Light", "areaSize"},
|
||||
new List<string>(){"UnityEngine.Light", "lightmapBakeType"},
|
||||
new List<string>(){"UnityEngine.WWW", "MovieTexture"},
|
||||
new List<string>(){"UnityEngine.WWW", "GetMovieTexture"},
|
||||
new List<string>(){"UnityEngine.AnimatorOverrideController", "PerformOverrideClipListCleanup"},
|
||||
#if !UNITY_WEBPLAYER
|
||||
new List<string>(){"UnityEngine.Application", "ExternalEval"},
|
||||
#endif
|
||||
new List<string>(){"UnityEngine.GameObject", "networkView"}, //4.6.2 not support
|
||||
new List<string>(){"UnityEngine.Component", "networkView"}, //4.6.2 not support
|
||||
new List<string>(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"},
|
||||
new List<string>(){"System.IO.FileInfo", "SetAccessControl", "System.Security.AccessControl.FileSecurity"},
|
||||
new List<string>(){"System.IO.DirectoryInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"},
|
||||
new List<string>(){"System.IO.DirectoryInfo", "SetAccessControl", "System.Security.AccessControl.DirectorySecurity"},
|
||||
new List<string>(){"System.IO.DirectoryInfo", "CreateSubdirectory", "System.String", "System.Security.AccessControl.DirectorySecurity"},
|
||||
new List<string>(){"System.IO.DirectoryInfo", "Create", "System.Security.AccessControl.DirectorySecurity"},
|
||||
new List<string>(){"UnityEngine.MonoBehaviour", "runInEditMode"},
|
||||
};
|
||||
}
|
54
Assets/XLua/Editor/XLuaUnityDefaultConfig.cs
Normal file
54
Assets/XLua/Editor/XLuaUnityDefaultConfig.cs
Normal file
@ -0,0 +1,54 @@
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using XLua;
|
||||
#endif
|
||||
/// <summary>
|
||||
/// xLua 默认配置
|
||||
/// </summary>
|
||||
static class XLuaUnityDefaultConfig
|
||||
{
|
||||
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
static bool IsSpanType(Type type)
|
||||
{
|
||||
if (!type.IsGenericType)
|
||||
return false;
|
||||
|
||||
var genericDefinition = type.GetGenericTypeDefinition();
|
||||
|
||||
return
|
||||
genericDefinition == typeof(Span<>) ||
|
||||
genericDefinition == typeof(ReadOnlySpan<>);
|
||||
}
|
||||
|
||||
static bool IsSpanMember(MemberInfo memberInfo)
|
||||
{
|
||||
switch (memberInfo)
|
||||
{
|
||||
case FieldInfo fieldInfo:
|
||||
return IsSpanType(fieldInfo.FieldType);
|
||||
|
||||
case PropertyInfo propertyInfo:
|
||||
return IsSpanType(propertyInfo.PropertyType);
|
||||
|
||||
case ConstructorInfo constructorInfo:
|
||||
return constructorInfo.GetParameters().Any(p => IsSpanType(p.ParameterType));
|
||||
|
||||
case MethodInfo methodInfo:
|
||||
return methodInfo.GetParameters().Any(p => IsSpanType(p.ParameterType)) || IsSpanType(methodInfo.ReturnType);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[BlackList]
|
||||
public static Func<MemberInfo, bool> SpanMembersFilter = IsSpanMember;
|
||||
|
||||
#endif
|
||||
}
|
11
Assets/XLua/Editor/XLuaUnityDefaultConfig.cs.meta
Normal file
11
Assets/XLua/Editor/XLuaUnityDefaultConfig.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bce017d7d868d474692a956d22e06a3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad687bd815bea714cb66d18a96951c5a
|
||||
guid: 665e21afd085cab43b8d778942bd9a2c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
@ -16,161 +16,7 @@ namespace XLua
|
||||
public partial class DelegateBridge : DelegateBridgeBase
|
||||
{
|
||||
|
||||
public void __Gen_Delegate_Imp0()
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
|
||||
|
||||
PCall(L, 0, 0, errFunc);
|
||||
|
||||
|
||||
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public double __Gen_Delegate_Imp1(double p0, double p1)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
|
||||
LuaAPI.lua_pushnumber(L, p0);
|
||||
LuaAPI.lua_pushnumber(L, p1);
|
||||
|
||||
PCall(L, 2, 1, errFunc);
|
||||
|
||||
|
||||
double __gen_ret = LuaAPI.lua_tonumber(L, errFunc + 1);
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
return __gen_ret;
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void __Gen_Delegate_Imp2(string p0)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
|
||||
LuaAPI.lua_pushstring(L, p0);
|
||||
|
||||
PCall(L, 1, 0, errFunc);
|
||||
|
||||
|
||||
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void __Gen_Delegate_Imp3(double p0)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
|
||||
LuaAPI.lua_pushnumber(L, p0);
|
||||
|
||||
PCall(L, 1, 0, errFunc);
|
||||
|
||||
|
||||
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void __Gen_Delegate_Imp4(object p0)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
ObjectTranslator translator = luaEnv.translator;
|
||||
translator.PushAny(L, p0);
|
||||
|
||||
PCall(L, 1, 0, errFunc);
|
||||
|
||||
|
||||
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void __Gen_Delegate_Imp5(LuaUIItemBase p0)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
ObjectTranslator translator = luaEnv.translator;
|
||||
translator.Push(L, p0);
|
||||
|
||||
PCall(L, 1, 0, errFunc);
|
||||
|
||||
|
||||
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void __Gen_Delegate_Imp6(LuaUIItemSelect p0)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
ObjectTranslator translator = luaEnv.translator;
|
||||
translator.Push(L, p0);
|
||||
|
||||
PCall(L, 1, 0, errFunc);
|
||||
|
||||
|
||||
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void __Gen_Delegate_Imp7(bool p0, object p1, UnityEngine.GameObject p2)
|
||||
public void __Gen_Delegate_Imp0(bool p0, object p1, UnityEngine.GameObject p2)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
@ -194,7 +40,7 @@ namespace XLua
|
||||
#endif
|
||||
}
|
||||
|
||||
public void __Gen_Delegate_Imp8(bool p0, object p1)
|
||||
public int __Gen_Delegate_Imp1(int p0, string p1, out Tutorial.CSCallLua.DClass p2)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
@ -203,15 +49,37 @@ namespace XLua
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
ObjectTranslator translator = luaEnv.translator;
|
||||
LuaAPI.lua_pushboolean(L, p0);
|
||||
translator.PushAny(L, p1);
|
||||
|
||||
PCall(L, 2, 0, errFunc);
|
||||
LuaAPI.xlua_pushinteger(L, p0);
|
||||
LuaAPI.lua_pushstring(L, p1);
|
||||
|
||||
PCall(L, 2, 2, errFunc);
|
||||
|
||||
p2 = (Tutorial.CSCallLua.DClass)translator.GetObject(L, errFunc + 2, typeof(Tutorial.CSCallLua.DClass));
|
||||
|
||||
int __gen_ret = LuaAPI.xlua_tointeger(L, errFunc + 1);
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
return __gen_ret;
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public System.Action __Gen_Delegate_Imp2()
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.rawL;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
ObjectTranslator translator = luaEnv.translator;
|
||||
|
||||
PCall(L, 0, 1, errFunc);
|
||||
|
||||
|
||||
System.Action __gen_ret = translator.GetDelegate<System.Action>(L, errFunc + 1);
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
return __gen_ret;
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
@ -226,59 +94,19 @@ namespace XLua
|
||||
public override Delegate GetDelegateByType(Type type)
|
||||
{
|
||||
|
||||
if (type == typeof(System.Action))
|
||||
{
|
||||
return new System.Action(__Gen_Delegate_Imp0);
|
||||
}
|
||||
|
||||
if (type == typeof(UnityEngine.Events.UnityAction))
|
||||
{
|
||||
return new UnityEngine.Events.UnityAction(__Gen_Delegate_Imp0);
|
||||
}
|
||||
|
||||
if (type == typeof(System.Func<double, double, double>))
|
||||
{
|
||||
return new System.Func<double, double, double>(__Gen_Delegate_Imp1);
|
||||
}
|
||||
|
||||
if (type == typeof(System.Action<string>))
|
||||
{
|
||||
return new System.Action<string>(__Gen_Delegate_Imp2);
|
||||
}
|
||||
|
||||
if (type == typeof(System.Action<double>))
|
||||
{
|
||||
return new System.Action<double>(__Gen_Delegate_Imp3);
|
||||
}
|
||||
|
||||
if (type == typeof(LuaUIItemBase.voidObject))
|
||||
{
|
||||
return new LuaUIItemBase.voidObject(__Gen_Delegate_Imp4);
|
||||
}
|
||||
|
||||
if (type == typeof(LuaUIItemSelect.voidObject))
|
||||
{
|
||||
return new LuaUIItemSelect.voidObject(__Gen_Delegate_Imp4);
|
||||
}
|
||||
|
||||
if (type == typeof(LuaUIItemBase.voidLuaUIItemBase))
|
||||
{
|
||||
return new LuaUIItemBase.voidLuaUIItemBase(__Gen_Delegate_Imp5);
|
||||
}
|
||||
|
||||
if (type == typeof(LuaUIItemSelect.voidLuaUIItemSelect))
|
||||
{
|
||||
return new LuaUIItemSelect.voidLuaUIItemSelect(__Gen_Delegate_Imp6);
|
||||
}
|
||||
|
||||
if (type == typeof(LuaUIManager.OnOpenUIDelegate))
|
||||
{
|
||||
return new LuaUIManager.OnOpenUIDelegate(__Gen_Delegate_Imp7);
|
||||
return new LuaUIManager.OnOpenUIDelegate(__Gen_Delegate_Imp0);
|
||||
}
|
||||
|
||||
if (type == typeof(UIManager.OnOpenUIDelegate))
|
||||
if (type == typeof(Tutorial.CSCallLua.FDelegate))
|
||||
{
|
||||
return new UIManager.OnOpenUIDelegate(__Gen_Delegate_Imp8);
|
||||
return new Tutorial.CSCallLua.FDelegate(__Gen_Delegate_Imp1);
|
||||
}
|
||||
|
||||
if (type == typeof(Tutorial.CSCallLua.GetE))
|
||||
{
|
||||
return new Tutorial.CSCallLua.GetE(__Gen_Delegate_Imp2);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4797b480e17a1c041baaf6c27a2faa7b
|
||||
guid: 3aa587e201b3ae240870ab706192726f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -16,4 +16,120 @@ namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
|
||||
public class TutorialTestEnumWrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
Utils.BeginObjectRegister(typeof(Tutorial.TestEnum), L, translator, 0, 0, 0, 0);
|
||||
Utils.EndObjectRegister(typeof(Tutorial.TestEnum), L, translator, null, null, null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(typeof(Tutorial.TestEnum), L, null, 3, 0, 0);
|
||||
|
||||
|
||||
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E1", Tutorial.TestEnum.E1);
|
||||
|
||||
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E2", Tutorial.TestEnum.E2);
|
||||
|
||||
|
||||
Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom);
|
||||
|
||||
Utils.EndClassRegister(typeof(Tutorial.TestEnum), L, translator);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __CastFrom(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
LuaTypes lua_type = LuaAPI.lua_type(L, 1);
|
||||
if (lua_type == LuaTypes.LUA_TNUMBER)
|
||||
{
|
||||
translator.PushTutorialTestEnum(L, (Tutorial.TestEnum)LuaAPI.xlua_tointeger(L, 1));
|
||||
}
|
||||
|
||||
else if(lua_type == LuaTypes.LUA_TSTRING)
|
||||
{
|
||||
|
||||
if (LuaAPI.xlua_is_eq_str(L, 1, "E1"))
|
||||
{
|
||||
translator.PushTutorialTestEnum(L, Tutorial.TestEnum.E1);
|
||||
}
|
||||
else if (LuaAPI.xlua_is_eq_str(L, 1, "E2"))
|
||||
{
|
||||
translator.PushTutorialTestEnum(L, Tutorial.TestEnum.E2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid string for Tutorial.TestEnum!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid lua type for Tutorial.TestEnum! Expect number or string, got + " + lua_type);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public class TutorialDerivedClassTestEnumInnerWrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
Utils.BeginObjectRegister(typeof(Tutorial.DerivedClass.TestEnumInner), L, translator, 0, 0, 0, 0);
|
||||
Utils.EndObjectRegister(typeof(Tutorial.DerivedClass.TestEnumInner), L, translator, null, null, null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(typeof(Tutorial.DerivedClass.TestEnumInner), L, null, 3, 0, 0);
|
||||
|
||||
|
||||
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E3", Tutorial.DerivedClass.TestEnumInner.E3);
|
||||
|
||||
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "E4", Tutorial.DerivedClass.TestEnumInner.E4);
|
||||
|
||||
|
||||
Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom);
|
||||
|
||||
Utils.EndClassRegister(typeof(Tutorial.DerivedClass.TestEnumInner), L, translator);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __CastFrom(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
LuaTypes lua_type = LuaAPI.lua_type(L, 1);
|
||||
if (lua_type == LuaTypes.LUA_TNUMBER)
|
||||
{
|
||||
translator.PushTutorialDerivedClassTestEnumInner(L, (Tutorial.DerivedClass.TestEnumInner)LuaAPI.xlua_tointeger(L, 1));
|
||||
}
|
||||
|
||||
else if(lua_type == LuaTypes.LUA_TSTRING)
|
||||
{
|
||||
|
||||
if (LuaAPI.xlua_is_eq_str(L, 1, "E3"))
|
||||
{
|
||||
translator.PushTutorialDerivedClassTestEnumInner(L, Tutorial.DerivedClass.TestEnumInner.E3);
|
||||
}
|
||||
else if (LuaAPI.xlua_is_eq_str(L, 1, "E4"))
|
||||
{
|
||||
translator.PushTutorialDerivedClassTestEnumInner(L, Tutorial.DerivedClass.TestEnumInner.E4);
|
||||
}
|
||||
else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid string for Tutorial.DerivedClass.TestEnumInner!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid lua type for Tutorial.DerivedClass.TestEnumInner! Expect number or string, got + " + lua_type);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8645f88f845f8e24184a8544ab074946
|
||||
guid: 95a8849a57110d147bc3c33fce585288
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f3cc4ce63cbe394490e0f157c48eed1
|
||||
guid: 317c5de54f637094085a67d30e5d255a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6964e9a023ed6d947baa485a4245d196
|
||||
guid: 39abc772b569a2c4f98802f46c7be18a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26677933e03919549bda0c1f6af15a51
|
||||
guid: ff34893e33fddfa44896f7b43352a889
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94029633e2eaf2f4588d17299699293e
|
||||
guid: 08f5d03da89f4544ebfcb3876b70d725
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -21,7 +21,7 @@ namespace XLua.CSObjectWrap
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
System.Type type = typeof(SdkControl);
|
||||
Utils.BeginObjectRegister(type, L, translator, 0, 20, 3, 0);
|
||||
Utils.BeginObjectRegister(type, L, translator, 0, 21, 3, 0);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetDefaultServer", _m_GetDefaultServer);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "IsSdkLogin", _m_IsSdkLogin);
|
||||
@ -35,6 +35,7 @@ namespace XLua.CSObjectWrap
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "LoginPhp", _m_LoginPhp);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetServerList", _m_GetServerList);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "PostServerList", _m_PostServerList);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "SubmitLoadData", _m_SubmitLoadData);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "SubmitData", _m_SubmitData);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "LoginSdk", _m_LoginSdk);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "CloseGame", _m_CloseGame);
|
||||
@ -422,6 +423,34 @@ namespace XLua.CSObjectWrap
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_SubmitLoadData(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
SdkControl gen_to_be_invoked = (SdkControl)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
LoadDataType _action;translator.Get(L, 2, out _action);
|
||||
|
||||
gen_to_be_invoked.SubmitLoadData( _action );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7ee3e045874eb44ab5a110c06c72f06
|
||||
guid: e9433347543c52242a7ebc4481f4235a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd315d4e958f61b4ead2744944d1a3f7
|
||||
guid: 95f86593f83421a4888ede838e47d922
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1ac3206a2b9a0945aec71ae5f3f9c2a
|
||||
guid: 5fe6fa7887c50fe46809f61d34f05c32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 623d5e2c7ee88fa439cdfe38062ebcb8
|
||||
guid: 329cc76ac4de33a48ae84bf6cf71f102
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89ed18de2e3af9142b89268659bc4402
|
||||
guid: a61a66046bfa4ea48ab38dabd8de7d3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e8803db0f7b3404b81116a0d6301803
|
||||
guid: c7a7f71d2ff007f4bbd96a35de063195
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f5ea83deef35174ebd17f1c98143d1c
|
||||
guid: aa9253fb586771b40ace1d97a20eba1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
223
Assets/XLua/Gen/Tutorial_BaseClassWrap.cs
Normal file
223
Assets/XLua/Gen/Tutorial_BaseClassWrap.cs
Normal file
@ -0,0 +1,223 @@
|
||||
#if USE_UNI_LUA
|
||||
using LuaAPI = UniLua.Lua;
|
||||
using RealStatePtr = UniLua.ILuaState;
|
||||
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
||||
#else
|
||||
using LuaAPI = XLua.LuaDLL.Lua;
|
||||
using RealStatePtr = System.IntPtr;
|
||||
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
||||
#endif
|
||||
|
||||
using XLua;
|
||||
using System.Collections.Generic;
|
||||
using Tutorial;
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
public class TutorialBaseClassWrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
System.Type type = typeof(Tutorial.BaseClass);
|
||||
Utils.BeginObjectRegister(type, L, translator, 0, 2, 1, 1);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "BMFunc", _m_BMFunc);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetSomeBaseData", _m_GetSomeBaseData);
|
||||
|
||||
|
||||
Utils.RegisterFunc(L, Utils.GETTER_IDX, "BMF", _g_get_BMF);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.SETTER_IDX, "BMF", _s_set_BMF);
|
||||
|
||||
|
||||
Utils.EndObjectRegister(type, L, translator, null, null,
|
||||
null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(type, L, __CreateInstance, 2, 1, 1);
|
||||
Utils.RegisterFunc(L, Utils.CLS_IDX, "BSFunc", _m_BSFunc_xlua_st_);
|
||||
|
||||
|
||||
|
||||
Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "BSF", _g_get_BSF);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.CLS_SETTER_IDX, "BSF", _s_set_BSF);
|
||||
|
||||
|
||||
Utils.EndClassRegister(type, L, translator);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __CreateInstance(RealStatePtr L)
|
||||
{
|
||||
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
if(LuaAPI.lua_gettop(L) == 1)
|
||||
{
|
||||
|
||||
var gen_ret = new Tutorial.BaseClass();
|
||||
translator.Push(L, gen_ret);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to Tutorial.BaseClass constructor!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_BSFunc_xlua_st_(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
Tutorial.BaseClass.BSFunc( );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_BMFunc(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.BaseClass gen_to_be_invoked = (Tutorial.BaseClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
gen_to_be_invoked.BMFunc( );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_GetSomeBaseData(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.BaseClass gen_to_be_invoked = (Tutorial.BaseClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
var gen_ret = gen_to_be_invoked.GetSomeBaseData( );
|
||||
LuaAPI.xlua_pushinteger(L, gen_ret);
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _g_get_BMF(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
Tutorial.BaseClass gen_to_be_invoked = (Tutorial.BaseClass)translator.FastGetCSObj(L, 1);
|
||||
LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.BMF);
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _g_get_BSF(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
LuaAPI.xlua_pushinteger(L, Tutorial.BaseClass.BSF);
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _s_set_BMF(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
Tutorial.BaseClass gen_to_be_invoked = (Tutorial.BaseClass)translator.FastGetCSObj(L, 1);
|
||||
gen_to_be_invoked.BMF = LuaAPI.xlua_tointeger(L, 2);
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _s_set_BSF(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
Tutorial.BaseClass.BSF = LuaAPI.xlua_tointeger(L, 1);
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
11
Assets/XLua/Gen/Tutorial_BaseClassWrap.cs.meta
Normal file
11
Assets/XLua/Gen/Tutorial_BaseClassWrap.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7710be590eeffd24a822a0bd92741d0d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
177
Assets/XLua/Gen/Tutorial_CSCallLua_ItfDBridge.cs
Normal file
177
Assets/XLua/Gen/Tutorial_CSCallLua_ItfDBridge.cs
Normal file
@ -0,0 +1,177 @@
|
||||
#if USE_UNI_LUA
|
||||
using LuaAPI = UniLua.Lua;
|
||||
using RealStatePtr = UniLua.ILuaState;
|
||||
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
||||
#else
|
||||
using LuaAPI = XLua.LuaDLL.Lua;
|
||||
using RealStatePtr = System.IntPtr;
|
||||
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
||||
#endif
|
||||
|
||||
using XLua;
|
||||
using System;
|
||||
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
public class TutorialCSCallLuaItfDBridge : LuaBase, Tutorial.CSCallLua.ItfD
|
||||
{
|
||||
public static LuaBase __Create(int reference, LuaEnv luaenv)
|
||||
{
|
||||
return new TutorialCSCallLuaItfDBridge(reference, luaenv);
|
||||
}
|
||||
|
||||
public TutorialCSCallLuaItfDBridge(int reference, LuaEnv luaenv) : base(reference, luaenv)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int Tutorial.CSCallLua.ItfD.add(int a, int b)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
|
||||
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "add");
|
||||
if (0 != LuaAPI.xlua_pgettable(L, -2))
|
||||
{
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
}
|
||||
if(!LuaAPI.lua_isfunction(L, -1))
|
||||
{
|
||||
LuaAPI.xlua_pushasciistring(L, "no such function add");
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
}
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.lua_remove(L, -3);
|
||||
LuaAPI.xlua_pushinteger(L, a);
|
||||
LuaAPI.xlua_pushinteger(L, b);
|
||||
|
||||
int __gen_error = LuaAPI.lua_pcall(L, 3, 1, err_func);
|
||||
if (__gen_error != 0)
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
|
||||
|
||||
int __gen_ret = LuaAPI.xlua_tointeger(L, err_func + 1);
|
||||
LuaAPI.lua_settop(L, err_func - 1);
|
||||
return __gen_ret;
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Tutorial.CSCallLua.ItfD.f1
|
||||
{
|
||||
|
||||
get
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int oldTop = LuaAPI.lua_gettop(L);
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "f1");
|
||||
if (0 != LuaAPI.xlua_pgettable(L, -2))
|
||||
{
|
||||
luaEnv.ThrowExceptionFromError(oldTop);
|
||||
}
|
||||
int __gen_ret = LuaAPI.xlua_tointeger(L, -1);
|
||||
LuaAPI.lua_pop(L, 2);
|
||||
return __gen_ret;
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
set
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int oldTop = LuaAPI.lua_gettop(L);
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "f1");
|
||||
LuaAPI.xlua_pushinteger(L, value);
|
||||
if (0 != LuaAPI.xlua_psettable(L, -3))
|
||||
{
|
||||
luaEnv.ThrowExceptionFromError(oldTop);
|
||||
}
|
||||
LuaAPI.lua_pop(L, 1);
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int Tutorial.CSCallLua.ItfD.f2
|
||||
{
|
||||
|
||||
get
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int oldTop = LuaAPI.lua_gettop(L);
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "f2");
|
||||
if (0 != LuaAPI.xlua_pgettable(L, -2))
|
||||
{
|
||||
luaEnv.ThrowExceptionFromError(oldTop);
|
||||
}
|
||||
int __gen_ret = LuaAPI.xlua_tointeger(L, -1);
|
||||
LuaAPI.lua_pop(L, 2);
|
||||
return __gen_ret;
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
set
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int oldTop = LuaAPI.lua_gettop(L);
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "f2");
|
||||
LuaAPI.xlua_pushinteger(L, value);
|
||||
if (0 != LuaAPI.xlua_psettable(L, -3))
|
||||
{
|
||||
luaEnv.ThrowExceptionFromError(oldTop);
|
||||
}
|
||||
LuaAPI.lua_pop(L, 1);
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
11
Assets/XLua/Gen/Tutorial_CSCallLua_ItfDBridge.cs.meta
Normal file
11
Assets/XLua/Gen/Tutorial_CSCallLua_ItfDBridge.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67cff5a973c7c8c4a9f12424c401a2dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
67
Assets/XLua/Gen/Tutorial_DerivedClassExtensionsWrap.cs
Normal file
67
Assets/XLua/Gen/Tutorial_DerivedClassExtensionsWrap.cs
Normal file
@ -0,0 +1,67 @@
|
||||
#if USE_UNI_LUA
|
||||
using LuaAPI = UniLua.Lua;
|
||||
using RealStatePtr = UniLua.ILuaState;
|
||||
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
||||
#else
|
||||
using LuaAPI = XLua.LuaDLL.Lua;
|
||||
using RealStatePtr = System.IntPtr;
|
||||
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
||||
#endif
|
||||
|
||||
using XLua;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
public class TutorialDerivedClassExtensionsWrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
System.Type type = typeof(Tutorial.DerivedClassExtensions);
|
||||
Utils.BeginObjectRegister(type, L, translator, 0, 0, 0, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Utils.EndObjectRegister(type, L, translator, null, null,
|
||||
null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(type, L, __CreateInstance, 1, 0, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Utils.EndClassRegister(type, L, translator);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __CreateInstance(RealStatePtr L)
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "Tutorial.DerivedClassExtensions does not have a constructor!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
11
Assets/XLua/Gen/Tutorial_DerivedClassExtensionsWrap.cs.meta
Normal file
11
Assets/XLua/Gen/Tutorial_DerivedClassExtensionsWrap.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8800a3a951483c94aaa590b9a300d21d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
588
Assets/XLua/Gen/Tutorial_DerivedClassWrap.cs
Normal file
588
Assets/XLua/Gen/Tutorial_DerivedClassWrap.cs
Normal file
@ -0,0 +1,588 @@
|
||||
#if USE_UNI_LUA
|
||||
using LuaAPI = UniLua.Lua;
|
||||
using RealStatePtr = UniLua.ILuaState;
|
||||
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
||||
#else
|
||||
using LuaAPI = XLua.LuaDLL.Lua;
|
||||
using RealStatePtr = System.IntPtr;
|
||||
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
||||
#endif
|
||||
|
||||
using XLua;
|
||||
using System.Collections.Generic;
|
||||
using Tutorial;
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
public class TutorialDerivedClassWrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
System.Type type = typeof(Tutorial.DerivedClass);
|
||||
Utils.BeginObjectRegister(type, L, translator, 1, 12, 2, 2);
|
||||
Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "__add", __AddMeta);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "DMFunc", _m_DMFunc);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "ComplexFunc", _m_ComplexFunc);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "TestFunc", _m_TestFunc);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "DefaultValueFunc", _m_DefaultValueFunc);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "VariableParamsFunc", _m_VariableParamsFunc);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "EnumTestFunc", _m_EnumTestFunc);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "CallEvent", _m_CallEvent);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "TestLong", _m_TestLong);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetCalc", _m_GetCalc);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetSomeData", _m_GetSomeData);
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "GenericMethodOfString", _m_GenericMethodOfString);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "TestEvent", _e_TestEvent);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.GETTER_IDX, "DMF", _g_get_DMF);
|
||||
Utils.RegisterFunc(L, Utils.GETTER_IDX, "TestDelegate", _g_get_TestDelegate);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.SETTER_IDX, "DMF", _s_set_DMF);
|
||||
Utils.RegisterFunc(L, Utils.SETTER_IDX, "TestDelegate", _s_set_TestDelegate);
|
||||
|
||||
|
||||
Utils.EndObjectRegister(type, L, translator, null, null,
|
||||
null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(type, L, __CreateInstance, 1, 0, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Utils.EndClassRegister(type, L, translator);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __CreateInstance(RealStatePtr L)
|
||||
{
|
||||
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
if(LuaAPI.lua_gettop(L) == 1)
|
||||
{
|
||||
|
||||
var gen_ret = new Tutorial.DerivedClass();
|
||||
translator.Push(L, gen_ret);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to Tutorial.DerivedClass constructor!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __AddMeta(RealStatePtr L)
|
||||
{
|
||||
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
if (translator.Assignable<Tutorial.DerivedClass>(L, 1) && translator.Assignable<Tutorial.DerivedClass>(L, 2))
|
||||
{
|
||||
Tutorial.DerivedClass leftside = (Tutorial.DerivedClass)translator.GetObject(L, 1, typeof(Tutorial.DerivedClass));
|
||||
Tutorial.DerivedClass rightside = (Tutorial.DerivedClass)translator.GetObject(L, 2, typeof(Tutorial.DerivedClass));
|
||||
|
||||
translator.Push(L, leftside + rightside);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to right hand of + operator, need Tutorial.DerivedClass!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_DMFunc(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
gen_to_be_invoked.DMFunc( );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_ComplexFunc(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
Tutorial.Param1 _p1;translator.Get(L, 2, out _p1);
|
||||
int _p2 = LuaAPI.xlua_tointeger(L, 3);
|
||||
string _p3;
|
||||
System.Action _luafunc = translator.GetDelegate<System.Action>(L, 4);
|
||||
System.Action _csfunc;
|
||||
|
||||
var gen_ret = gen_to_be_invoked.ComplexFunc( _p1, ref _p2, out _p3, _luafunc, out _csfunc );
|
||||
LuaAPI.lua_pushnumber(L, gen_ret);
|
||||
LuaAPI.xlua_pushinteger(L, _p2);
|
||||
|
||||
LuaAPI.lua_pushstring(L, _p3);
|
||||
|
||||
translator.Push(L, _csfunc);
|
||||
|
||||
|
||||
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_TestFunc(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
int gen_param_count = LuaAPI.lua_gettop(L);
|
||||
|
||||
if(gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
|
||||
{
|
||||
int _i = LuaAPI.xlua_tointeger(L, 2);
|
||||
|
||||
gen_to_be_invoked.TestFunc( _i );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(gen_param_count == 2&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING))
|
||||
{
|
||||
string _i = LuaAPI.lua_tostring(L, 2);
|
||||
|
||||
gen_to_be_invoked.TestFunc( _i );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to Tutorial.DerivedClass.TestFunc!");
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_DefaultValueFunc(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
int gen_param_count = LuaAPI.lua_gettop(L);
|
||||
|
||||
if(gen_param_count == 4&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING)&& (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TSTRING))
|
||||
{
|
||||
int _a = LuaAPI.xlua_tointeger(L, 2);
|
||||
string _b = LuaAPI.lua_tostring(L, 3);
|
||||
string _c = LuaAPI.lua_tostring(L, 4);
|
||||
|
||||
gen_to_be_invoked.DefaultValueFunc( _a, _b, _c );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(gen_param_count == 3&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING))
|
||||
{
|
||||
int _a = LuaAPI.xlua_tointeger(L, 2);
|
||||
string _b = LuaAPI.lua_tostring(L, 3);
|
||||
|
||||
gen_to_be_invoked.DefaultValueFunc( _a, _b );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
|
||||
{
|
||||
int _a = LuaAPI.xlua_tointeger(L, 2);
|
||||
|
||||
gen_to_be_invoked.DefaultValueFunc( _a );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(gen_param_count == 1)
|
||||
{
|
||||
|
||||
gen_to_be_invoked.DefaultValueFunc( );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to Tutorial.DerivedClass.DefaultValueFunc!");
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_VariableParamsFunc(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
int _a = LuaAPI.xlua_tointeger(L, 2);
|
||||
string[] _strs = translator.GetParams<string>(L, 3);
|
||||
|
||||
gen_to_be_invoked.VariableParamsFunc( _a, _strs );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_EnumTestFunc(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
Tutorial.TestEnum _e;translator.Get(L, 2, out _e);
|
||||
|
||||
var gen_ret = gen_to_be_invoked.EnumTestFunc( _e );
|
||||
translator.PushTutorialTestEnum(L, gen_ret);
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_CallEvent(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
gen_to_be_invoked.CallEvent( );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_TestLong(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
long _n = LuaAPI.lua_toint64(L, 2);
|
||||
|
||||
var gen_ret = gen_to_be_invoked.TestLong( _n );
|
||||
LuaAPI.lua_pushuint64(L, gen_ret);
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_GetCalc(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
var gen_ret = gen_to_be_invoked.GetCalc( );
|
||||
translator.PushAny(L, gen_ret);
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_GetSomeData(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
var gen_ret = gen_to_be_invoked.GetSomeData( );
|
||||
LuaAPI.xlua_pushinteger(L, gen_ret);
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_GenericMethodOfString(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
gen_to_be_invoked.GenericMethodOfString( );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _g_get_DMF(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.DMF);
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _g_get_TestDelegate(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
translator.Push(L, gen_to_be_invoked.TestDelegate);
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _s_set_DMF(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
gen_to_be_invoked.DMF = LuaAPI.xlua_tointeger(L, 2);
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _s_set_TestDelegate(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
gen_to_be_invoked.TestDelegate = translator.GetDelegate<System.Action<string>>(L, 2);
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _e_TestEvent(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
int gen_param_count = LuaAPI.lua_gettop(L);
|
||||
Tutorial.DerivedClass gen_to_be_invoked = (Tutorial.DerivedClass)translator.FastGetCSObj(L, 1);
|
||||
System.Action gen_delegate = translator.GetDelegate<System.Action>(L, 3);
|
||||
if (gen_delegate == null) {
|
||||
return LuaAPI.luaL_error(L, "#3 need System.Action!");
|
||||
}
|
||||
|
||||
if (gen_param_count == 3)
|
||||
{
|
||||
|
||||
if (LuaAPI.xlua_is_eq_str(L, 2, "+")) {
|
||||
gen_to_be_invoked.TestEvent += gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (LuaAPI.xlua_is_eq_str(L, 2, "-")) {
|
||||
gen_to_be_invoked.TestEvent -= gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
LuaAPI.luaL_error(L, "invalid arguments to Tutorial.DerivedClass.TestEvent!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
11
Assets/XLua/Gen/Tutorial_DerivedClassWrap.cs.meta
Normal file
11
Assets/XLua/Gen/Tutorial_DerivedClassWrap.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ba1758fa203c5641ba023884fb9e400
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
98
Assets/XLua/Gen/Tutorial_ICalcWrap.cs
Normal file
98
Assets/XLua/Gen/Tutorial_ICalcWrap.cs
Normal file
@ -0,0 +1,98 @@
|
||||
#if USE_UNI_LUA
|
||||
using LuaAPI = UniLua.Lua;
|
||||
using RealStatePtr = UniLua.ILuaState;
|
||||
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
||||
#else
|
||||
using LuaAPI = XLua.LuaDLL.Lua;
|
||||
using RealStatePtr = System.IntPtr;
|
||||
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
||||
#endif
|
||||
|
||||
using XLua;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
public class TutorialICalcWrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
System.Type type = typeof(Tutorial.ICalc);
|
||||
Utils.BeginObjectRegister(type, L, translator, 0, 1, 0, 0);
|
||||
|
||||
Utils.RegisterFunc(L, Utils.METHOD_IDX, "add", _m_add);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Utils.EndObjectRegister(type, L, translator, null, null,
|
||||
null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(type, L, __CreateInstance, 1, 0, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Utils.EndClassRegister(type, L, translator);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __CreateInstance(RealStatePtr L)
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "Tutorial.ICalc does not have a constructor!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_add(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
|
||||
Tutorial.ICalc gen_to_be_invoked = (Tutorial.ICalc)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
{
|
||||
int _a = LuaAPI.xlua_tointeger(L, 2);
|
||||
int _b = LuaAPI.xlua_tointeger(L, 3);
|
||||
|
||||
var gen_ret = gen_to_be_invoked.add( _a, _b );
|
||||
LuaAPI.xlua_pushinteger(L, gen_ret);
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
11
Assets/XLua/Gen/Tutorial_ICalcWrap.cs.meta
Normal file
11
Assets/XLua/Gen/Tutorial_ICalcWrap.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25cdb7840aba565438e7895290647faa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bb5f9a2ae7c8054a9f25a8a57750957
|
||||
guid: 68371e894dc4e3443b4160a233a99b8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b333347953071d54d860eef6a0ca1c7a
|
||||
guid: 40a9eaa3e666427409aad39c7a3ed8ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0232246804b21246a6b608f205af252
|
||||
guid: c8a19cb8fceaf1c469bd36870db507bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: adb503b772bc60d46ab1453dbf036115
|
||||
guid: 11920ececb4991941a4e0153b482c573
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 160a1c6cfaf54c44d8254eb460a4f04b
|
||||
guid: 6599f08f0db163b4d8a61f17c391e3d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11d60c01a727eb847aa8c21168c786a3
|
||||
guid: 1afb1439e494d2c49abee537d7227e36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1dfde75c1191db0468fd9c26cac56a84
|
||||
guid: 611b5394c8538724b9dd3160b01e1664
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1661c1df9dbadb44b90a8fb5430736d
|
||||
guid: 900d37d56e40dec4a81e1665a027a0f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 824677f4375417546b2de0acd0a730a2
|
||||
guid: bf7550cfc6233ef4f931d018ca5e1e01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39980aca30048db4a914d54871813977
|
||||
guid: 919b0f7c797c14c40aa60fd799d0adf9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f63bf30521e432c44a6bad89540c6f4e
|
||||
guid: d7a53b2353f2e6e4e9b3cddf79be7784
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9edcfeb80fe1044a981fe1ed0e5e4a3
|
||||
guid: 530bdfed8c846a24ba2cdde2a2e75b74
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04013f6f4fb24014d94fec367bb1e03f
|
||||
guid: fcb00702fc6f6754ca9a894e18ef2223
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bd44fdc562bac44db31e3e05fea9053
|
||||
guid: bdabe9321097c424cac47612f60e5f20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd301e47f80fa534c9678690b6cd0845
|
||||
guid: e58f2c232ba578549bc41c923a1a5dca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 636b040c3a8558340bff8acdd677e548
|
||||
guid: fe1afab448b11b346abcd544102edc50
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07b293b2159210f4ba36c280e4df1cfc
|
||||
guid: 6c4214c0cd38bd441a35a5754ba5f8a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11f99f92166187048890ab063af826cc
|
||||
guid: b9674ab747d3bd049b2d0c479a4627b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4aefb997e09adb4db3214ec2038c0f7
|
||||
guid: b4d8e31a911ab23408352eec7437d425
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42db8ea32f53e704ab17813c2b434aa6
|
||||
guid: c6cccc12700efe84b92ed42500ba5522
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcaa7c6d3a38b8448bfa0b52259b4b05
|
||||
guid: fde8bce6c5d195740b3592ff3a41678e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 254b27362b3a00142bbb4b7f9ee34608
|
||||
guid: 3aa631cce4a7e04419886cdb6d29bcf0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73a939ac4eb7a204eafddf57040c28c7
|
||||
guid: 9c4085e16499eaa41b51d2a408df3d05
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9299a50afeb87b4584bc2e01577cd29
|
||||
guid: b90762747f37a21408ca6c3b35d84bb4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f831fc4cf8ac714ea63d2a93c7a78de
|
||||
guid: 8ff91b362932b9a49a4c15a36933d9b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8948a122de911749922d3a9c1fd4093
|
||||
guid: ba06410f2c4cfe34ab1a7af423180de1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97f1ef9d5f5182b4ea1368f3cc7f0c0e
|
||||
guid: 89173378345d35f468b6a3866a64ffce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -34,6 +34,8 @@ namespace XLua
|
||||
translator.RegisterPushAndGetAndUpdate<UnityEngine.Ray>(translator.PushUnityEngineRay, translator.Get, translator.UpdateUnityEngineRay);
|
||||
translator.RegisterPushAndGetAndUpdate<UnityEngine.Bounds>(translator.PushUnityEngineBounds, translator.Get, translator.UpdateUnityEngineBounds);
|
||||
translator.RegisterPushAndGetAndUpdate<UnityEngine.Ray2D>(translator.PushUnityEngineRay2D, translator.Get, translator.UpdateUnityEngineRay2D);
|
||||
translator.RegisterPushAndGetAndUpdate<Tutorial.TestEnum>(translator.PushTutorialTestEnum, translator.Get, translator.UpdateTutorialTestEnum);
|
||||
translator.RegisterPushAndGetAndUpdate<Tutorial.DerivedClass.TestEnumInner>(translator.PushTutorialDerivedClassTestEnumInner, translator.Get, translator.UpdateTutorialDerivedClassTestEnumInner);
|
||||
|
||||
}
|
||||
}
|
||||
@ -570,6 +572,174 @@ namespace XLua
|
||||
}
|
||||
}
|
||||
|
||||
int TutorialTestEnum_TypeID = -1;
|
||||
int TutorialTestEnum_EnumRef = -1;
|
||||
|
||||
public void PushTutorialTestEnum(RealStatePtr L, Tutorial.TestEnum val)
|
||||
{
|
||||
if (TutorialTestEnum_TypeID == -1)
|
||||
{
|
||||
bool is_first;
|
||||
TutorialTestEnum_TypeID = getTypeId(L, typeof(Tutorial.TestEnum), out is_first);
|
||||
|
||||
if (TutorialTestEnum_EnumRef == -1)
|
||||
{
|
||||
Utils.LoadCSTable(L, typeof(Tutorial.TestEnum));
|
||||
TutorialTestEnum_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (LuaAPI.xlua_tryget_cachedud(L, (int)val, TutorialTestEnum_EnumRef) == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, TutorialTestEnum_TypeID);
|
||||
if (!CopyByValue.Pack(buff, 0, (int)val))
|
||||
{
|
||||
throw new Exception("pack fail fail for Tutorial.TestEnum ,value="+val);
|
||||
}
|
||||
|
||||
LuaAPI.lua_getref(L, TutorialTestEnum_EnumRef);
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.xlua_rawseti(L, -2, (int)val);
|
||||
LuaAPI.lua_pop(L, 1);
|
||||
|
||||
}
|
||||
|
||||
public void Get(RealStatePtr L, int index, out Tutorial.TestEnum val)
|
||||
{
|
||||
LuaTypes type = LuaAPI.lua_type(L, index);
|
||||
if (type == LuaTypes.LUA_TUSERDATA )
|
||||
{
|
||||
if (LuaAPI.xlua_gettypeid(L, index) != TutorialTestEnum_TypeID)
|
||||
{
|
||||
throw new Exception("invalid userdata for Tutorial.TestEnum");
|
||||
}
|
||||
|
||||
IntPtr buff = LuaAPI.lua_touserdata(L, index);
|
||||
int e;
|
||||
if (!CopyByValue.UnPack(buff, 0, out e))
|
||||
{
|
||||
throw new Exception("unpack fail for Tutorial.TestEnum");
|
||||
}
|
||||
val = (Tutorial.TestEnum)e;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
val = (Tutorial.TestEnum)objectCasters.GetCaster(typeof(Tutorial.TestEnum))(L, index, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateTutorialTestEnum(RealStatePtr L, int index, Tutorial.TestEnum val)
|
||||
{
|
||||
|
||||
if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
|
||||
{
|
||||
if (LuaAPI.xlua_gettypeid(L, index) != TutorialTestEnum_TypeID)
|
||||
{
|
||||
throw new Exception("invalid userdata for Tutorial.TestEnum");
|
||||
}
|
||||
|
||||
IntPtr buff = LuaAPI.lua_touserdata(L, index);
|
||||
if (!CopyByValue.Pack(buff, 0, (int)val))
|
||||
{
|
||||
throw new Exception("pack fail for Tutorial.TestEnum ,value="+val);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
|
||||
}
|
||||
}
|
||||
|
||||
int TutorialDerivedClassTestEnumInner_TypeID = -1;
|
||||
int TutorialDerivedClassTestEnumInner_EnumRef = -1;
|
||||
|
||||
public void PushTutorialDerivedClassTestEnumInner(RealStatePtr L, Tutorial.DerivedClass.TestEnumInner val)
|
||||
{
|
||||
if (TutorialDerivedClassTestEnumInner_TypeID == -1)
|
||||
{
|
||||
bool is_first;
|
||||
TutorialDerivedClassTestEnumInner_TypeID = getTypeId(L, typeof(Tutorial.DerivedClass.TestEnumInner), out is_first);
|
||||
|
||||
if (TutorialDerivedClassTestEnumInner_EnumRef == -1)
|
||||
{
|
||||
Utils.LoadCSTable(L, typeof(Tutorial.DerivedClass.TestEnumInner));
|
||||
TutorialDerivedClassTestEnumInner_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (LuaAPI.xlua_tryget_cachedud(L, (int)val, TutorialDerivedClassTestEnumInner_EnumRef) == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, TutorialDerivedClassTestEnumInner_TypeID);
|
||||
if (!CopyByValue.Pack(buff, 0, (int)val))
|
||||
{
|
||||
throw new Exception("pack fail fail for Tutorial.DerivedClass.TestEnumInner ,value="+val);
|
||||
}
|
||||
|
||||
LuaAPI.lua_getref(L, TutorialDerivedClassTestEnumInner_EnumRef);
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.xlua_rawseti(L, -2, (int)val);
|
||||
LuaAPI.lua_pop(L, 1);
|
||||
|
||||
}
|
||||
|
||||
public void Get(RealStatePtr L, int index, out Tutorial.DerivedClass.TestEnumInner val)
|
||||
{
|
||||
LuaTypes type = LuaAPI.lua_type(L, index);
|
||||
if (type == LuaTypes.LUA_TUSERDATA )
|
||||
{
|
||||
if (LuaAPI.xlua_gettypeid(L, index) != TutorialDerivedClassTestEnumInner_TypeID)
|
||||
{
|
||||
throw new Exception("invalid userdata for Tutorial.DerivedClass.TestEnumInner");
|
||||
}
|
||||
|
||||
IntPtr buff = LuaAPI.lua_touserdata(L, index);
|
||||
int e;
|
||||
if (!CopyByValue.UnPack(buff, 0, out e))
|
||||
{
|
||||
throw new Exception("unpack fail for Tutorial.DerivedClass.TestEnumInner");
|
||||
}
|
||||
val = (Tutorial.DerivedClass.TestEnumInner)e;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
val = (Tutorial.DerivedClass.TestEnumInner)objectCasters.GetCaster(typeof(Tutorial.DerivedClass.TestEnumInner))(L, index, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateTutorialDerivedClassTestEnumInner(RealStatePtr L, int index, Tutorial.DerivedClass.TestEnumInner val)
|
||||
{
|
||||
|
||||
if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
|
||||
{
|
||||
if (LuaAPI.xlua_gettypeid(L, index) != TutorialDerivedClassTestEnumInner_TypeID)
|
||||
{
|
||||
throw new Exception("invalid userdata for Tutorial.DerivedClass.TestEnumInner");
|
||||
}
|
||||
|
||||
IntPtr buff = LuaAPI.lua_touserdata(L, index);
|
||||
if (!CopyByValue.Pack(buff, 0, (int)val))
|
||||
{
|
||||
throw new Exception("pack fail for Tutorial.DerivedClass.TestEnumInner ,value="+val);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// table cast optimze
|
||||
|
||||
@ -629,6 +799,18 @@ namespace XLua
|
||||
translator.PushUnityEngineRay2D(L, array[index]);
|
||||
return true;
|
||||
}
|
||||
else if (type == typeof(Tutorial.TestEnum[]))
|
||||
{
|
||||
Tutorial.TestEnum[] array = obj as Tutorial.TestEnum[];
|
||||
translator.PushTutorialTestEnum(L, array[index]);
|
||||
return true;
|
||||
}
|
||||
else if (type == typeof(Tutorial.DerivedClass.TestEnumInner[]))
|
||||
{
|
||||
Tutorial.DerivedClass.TestEnumInner[] array = obj as Tutorial.DerivedClass.TestEnumInner[];
|
||||
translator.PushTutorialDerivedClassTestEnumInner(L, array[index]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -683,6 +865,18 @@ namespace XLua
|
||||
translator.Get(L, obj_idx, out array[array_idx]);
|
||||
return true;
|
||||
}
|
||||
else if (type == typeof(Tutorial.TestEnum[]))
|
||||
{
|
||||
Tutorial.TestEnum[] array = obj as Tutorial.TestEnum[];
|
||||
translator.Get(L, obj_idx, out array[array_idx]);
|
||||
return true;
|
||||
}
|
||||
else if (type == typeof(Tutorial.DerivedClass.TestEnumInner[]))
|
||||
{
|
||||
Tutorial.DerivedClass.TestEnumInner[] array = obj as Tutorial.DerivedClass.TestEnumInner[];
|
||||
translator.Get(L, obj_idx, out array[array_idx]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4077cbfd734acfc489abfa6835fbbb6f
|
||||
guid: 739f3c1f53f9dcf4fa3e067c6f025b74
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -22,96 +22,6 @@ namespace XLua.CSObjectWrap
|
||||
static void wrapInit0(LuaEnv luaenv, ObjectTranslator translator)
|
||||
{
|
||||
|
||||
translator.DelayWrapLoader(typeof(object), SystemObjectWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Object), UnityEngineObjectWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Vector2), UnityEngineVector2Wrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Vector3), UnityEngineVector3Wrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Vector4), UnityEngineVector4Wrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Quaternion), UnityEngineQuaternionWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Color), UnityEngineColorWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Ray), UnityEngineRayWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Bounds), UnityEngineBoundsWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Ray2D), UnityEngineRay2DWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Time), UnityEngineTimeWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.GameObject), UnityEngineGameObjectWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Component), UnityEngineComponentWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Behaviour), UnityEngineBehaviourWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Transform), UnityEngineTransformWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Resources), UnityEngineResourcesWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.TextAsset), UnityEngineTextAssetWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Keyframe), UnityEngineKeyframeWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.AnimationCurve), UnityEngineAnimationCurveWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.AnimationClip), UnityEngineAnimationClipWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.MonoBehaviour), UnityEngineMonoBehaviourWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.ParticleSystem), UnityEngineParticleSystemWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.SkinnedMeshRenderer), UnityEngineSkinnedMeshRendererWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Renderer), UnityEngineRendererWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.WWW), UnityEngineWWWWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Light), UnityEngineLightWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Mathf), UnityEngineMathfWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(System.Collections.Generic.List<int>), SystemCollectionsGenericList_1_SystemInt32_Wrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(UnityEngine.Debug), UnityEngineDebugWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(System.Collections.Hashtable), SystemCollectionsHashtableWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(TableManagerLua), TableManagerLuaWrap.__Register);
|
||||
|
||||
|
||||
@ -124,6 +34,24 @@ namespace XLua.CSObjectWrap
|
||||
translator.DelayWrapLoader(typeof(SdkControl), SdkControlWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(Tutorial.BaseClass), TutorialBaseClassWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(Tutorial.TestEnum), TutorialTestEnumWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(Tutorial.DerivedClass), TutorialDerivedClassWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(Tutorial.DerivedClass.TestEnumInner), TutorialDerivedClassTestEnumInnerWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(Tutorial.ICalc), TutorialICalcWrap.__Register);
|
||||
|
||||
|
||||
translator.DelayWrapLoader(typeof(Tutorial.DerivedClassExtensions), TutorialDerivedClassExtensionsWrap.__Register);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -133,11 +61,7 @@ namespace XLua.CSObjectWrap
|
||||
wrapInit0(luaenv, translator);
|
||||
|
||||
|
||||
translator.AddInterfaceBridgeCreator(typeof(System.Collections.IEnumerator), SystemCollectionsIEnumeratorBridge.__Create);
|
||||
|
||||
translator.AddInterfaceBridgeCreator(typeof(System.Collections.IEnumerable), SystemCollectionsIEnumerableBridge.__Create);
|
||||
|
||||
translator.AddInterfaceBridgeCreator(typeof(IMarketingActRetDel), IMarketingActRetDelBridge.__Create);
|
||||
translator.AddInterfaceBridgeCreator(typeof(Tutorial.CSCallLua.ItfD), TutorialCSCallLuaItfDBridge.__Create);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e17ab85f51fc5ab4890d510baad5f2b5
|
||||
guid: d83e0e59732bbdb4db1b9db468746d60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
@ -2,61 +2,17 @@
|
||||
|
||||
<linker>
|
||||
|
||||
<assembly fullname="mscorlib">
|
||||
<type fullname="System.Object" preserve="all"/>
|
||||
<type fullname="System.Collections.Generic.List`1[System.Int32]" preserve="all"/>
|
||||
<type fullname="System.Collections.Hashtable" preserve="all"/>
|
||||
|
||||
</assembly>
|
||||
|
||||
<assembly fullname="UnityEngine.CoreModule">
|
||||
<type fullname="UnityEngine.Object" preserve="all"/>
|
||||
<type fullname="UnityEngine.Vector2" preserve="all"/>
|
||||
<type fullname="UnityEngine.Vector3" preserve="all"/>
|
||||
<type fullname="UnityEngine.Vector4" preserve="all"/>
|
||||
<type fullname="UnityEngine.Quaternion" preserve="all"/>
|
||||
<type fullname="UnityEngine.Color" preserve="all"/>
|
||||
<type fullname="UnityEngine.Ray" preserve="all"/>
|
||||
<type fullname="UnityEngine.Bounds" preserve="all"/>
|
||||
<type fullname="UnityEngine.Ray2D" preserve="all"/>
|
||||
<type fullname="UnityEngine.Time" preserve="all"/>
|
||||
<type fullname="UnityEngine.GameObject" preserve="all"/>
|
||||
<type fullname="UnityEngine.Component" preserve="all"/>
|
||||
<type fullname="UnityEngine.Behaviour" preserve="all"/>
|
||||
<type fullname="UnityEngine.Transform" preserve="all"/>
|
||||
<type fullname="UnityEngine.Resources" preserve="all"/>
|
||||
<type fullname="UnityEngine.TextAsset" preserve="all"/>
|
||||
<type fullname="UnityEngine.Keyframe" preserve="all"/>
|
||||
<type fullname="UnityEngine.AnimationCurve" preserve="all"/>
|
||||
<type fullname="UnityEngine.MonoBehaviour" preserve="all"/>
|
||||
<type fullname="UnityEngine.SkinnedMeshRenderer" preserve="all"/>
|
||||
<type fullname="UnityEngine.Renderer" preserve="all"/>
|
||||
<type fullname="UnityEngine.Light" preserve="all"/>
|
||||
<type fullname="UnityEngine.Mathf" preserve="all"/>
|
||||
<type fullname="UnityEngine.Debug" preserve="all"/>
|
||||
|
||||
</assembly>
|
||||
|
||||
<assembly fullname="UnityEngine.AnimationModule">
|
||||
<type fullname="UnityEngine.AnimationClip" preserve="all"/>
|
||||
|
||||
</assembly>
|
||||
|
||||
<assembly fullname="UnityEngine.ParticleSystemModule">
|
||||
<type fullname="UnityEngine.ParticleSystem" preserve="all"/>
|
||||
|
||||
</assembly>
|
||||
|
||||
<assembly fullname="UnityEngine.UnityWebRequestWWWModule">
|
||||
<type fullname="UnityEngine.WWW" preserve="all"/>
|
||||
|
||||
</assembly>
|
||||
|
||||
<assembly fullname="Assembly-CSharp">
|
||||
<type fullname="TableManagerLua" preserve="all"/>
|
||||
<type fullname="LuaMain" preserve="all"/>
|
||||
<type fullname="LuaUIBehaviour" preserve="all"/>
|
||||
<type fullname="SdkControl" preserve="all"/>
|
||||
<type fullname="Tutorial.BaseClass" preserve="all"/>
|
||||
<type fullname="Tutorial.TestEnum" preserve="all"/>
|
||||
<type fullname="Tutorial.DerivedClass" preserve="all"/>
|
||||
<type fullname="Tutorial.DerivedClass+TestEnumInner" preserve="all"/>
|
||||
<type fullname="Tutorial.ICalc" preserve="all"/>
|
||||
<type fullname="Tutorial.DerivedClassExtensions" preserve="all"/>
|
||||
|
||||
</assembly>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cd9392ac962103468a773fed4e9c5b8
|
||||
guid: 51f4ec9961d636c419a9b02559e1037b
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8393443682ec1647b5d91ed8f30e391
|
||||
timeCreated: 1463477791
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
5
Assets/XLua/Src.meta
Normal file
5
Assets/XLua/Src.meta
Normal file
@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac2f50d02ed9ec24b8fcc1921bfb244c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
@ -207,7 +207,11 @@ namespace XLua
|
||||
{
|
||||
var assemblyName = new AssemblyName();
|
||||
assemblyName.Name = "XLuaCodeEmit";
|
||||
#if NET5_0_OR_GREATER
|
||||
codeEmitModule = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run)
|
||||
#else
|
||||
codeEmitModule = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run)
|
||||
#endif
|
||||
.DefineDynamicModule("XLuaCodeEmit");
|
||||
}
|
||||
return codeEmitModule;
|
5
Assets/XLua/Src/Editor.meta
Normal file
5
Assets/XLua/Src/Editor.meta
Normal file
@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e53aa922da0a00469e5760902833e71
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
@ -940,6 +940,8 @@ namespace CSObjectWrapEditor
|
||||
.Where(method => !ignoreCompilerGenerated || !isDefined(method, typeof(CompilerGeneratedAttribute)))
|
||||
.Where(method => !ignoreNotPublic || method.IsPublic)
|
||||
.Where(method => !ignoreProperty || !method.IsSpecialName || (!method.Name.StartsWith("get_") && !method.Name.StartsWith("set_")))
|
||||
.Where(method => !method.GetParameters().Any(pInfo => pInfo.ParameterType.IsPointer))
|
||||
.Where(method => !method.ReturnType.IsPointer)
|
||||
.Cast<MethodBase>()
|
||||
.Concat(kv.Key.GetConstructors(bindingAttrOfConstructor).Cast<MethodBase>())
|
||||
.Where(method => !injectByGeneric(method, kv.Value))
|
||||
@ -1816,7 +1818,7 @@ namespace CSObjectWrapEditor
|
||||
}
|
||||
#if !XLUA_GENERAL
|
||||
[UnityEditor.Callbacks.PostProcessBuild(1)]
|
||||
public static void CheckGenrate(BuildTarget target, string pathToBuiltProject)
|
||||
public static void CheckGenerate(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (EditorApplication.isCompiling || Application.isPlaying)
|
||||
{
|
||||
@ -1824,7 +1826,7 @@ namespace CSObjectWrapEditor
|
||||
}
|
||||
if (!DelegateBridge.Gen_Flag)
|
||||
{
|
||||
throw new InvalidOperationException("Code has not been genrated, may be not work in phone!");
|
||||
throw new InvalidOperationException("Code has not been generated, may be not work in phone!");
|
||||
}
|
||||
}
|
||||
#endif
|
@ -24,7 +24,7 @@ using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using System.Diagnostics;
|
||||
#if UNITY_2019
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
#endif
|
||||
@ -591,10 +591,16 @@ namespace XLua
|
||||
|
||||
static bool hasGenericParameter(MethodDefinition method)
|
||||
{
|
||||
if (method.HasGenericParameters) return true;
|
||||
if (!method.IsStatic && hasGenericParameter(method.DeclaringType)) return true;
|
||||
return hasGenericParameterSkipDelaringType(method);
|
||||
}
|
||||
|
||||
static bool hasGenericParameterSkipDelaringType(MethodDefinition method)
|
||||
{
|
||||
if (method.HasGenericParameters) return true;
|
||||
//if (!method.IsStatic && hasGenericParameter(method.DeclaringType)) return true;
|
||||
if (hasGenericParameter(method.ReturnType)) return true;
|
||||
foreach(var paramInfo in method.Parameters)
|
||||
foreach (var paramInfo in method.Parameters)
|
||||
{
|
||||
if (hasGenericParameter(paramInfo.ParameterType)) return true;
|
||||
}
|
||||
@ -737,6 +743,10 @@ namespace XLua
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (method.Parameters.Any(pd => pd.ParameterType.IsPointer) || method.ReturnType.IsPointer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (method.Name != ".cctor" && !method.IsAbstract && !method.IsPInvokeImpl && method.Body != null && !method.Name.Contains("<"))
|
||||
{
|
||||
//Debug.Log(method);
|
||||
@ -766,6 +776,10 @@ namespace XLua
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (method.Parameters.Any(pd => pd.ParameterType.IsPointer) || method.ReturnType.IsPointer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (method.Name != ".cctor" && !method.IsAbstract && !method.IsPInvokeImpl && method.Body != null && !method.Name.Contains("<"))
|
||||
{
|
||||
var proxyMethod = tryAddBaseProxy(type, method);
|
||||
@ -1068,7 +1082,7 @@ namespace XLua
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return _findBase(td.BaseType, method);
|
||||
return _findBase(getBaseType(type), method);
|
||||
}
|
||||
|
||||
static MethodReference findBase(TypeDefinition type, MethodDefinition method)
|
||||
@ -1081,7 +1095,7 @@ namespace XLua
|
||||
var b = _findBase(type.BaseType, method);
|
||||
try
|
||||
{
|
||||
if (hasGenericParameter(b.Resolve())) return null;
|
||||
if (hasGenericParameterSkipDelaringType(b.Resolve())) return null;
|
||||
}catch { }
|
||||
return b;
|
||||
}
|
||||
@ -1090,6 +1104,24 @@ namespace XLua
|
||||
return null;
|
||||
}
|
||||
|
||||
static TypeReference getBaseType(TypeReference typeReference)
|
||||
{
|
||||
var typeDefinition = typeReference.Resolve();
|
||||
var baseType = typeDefinition.BaseType;
|
||||
if (typeReference.IsGenericInstance && baseType.IsGenericInstance)
|
||||
{
|
||||
var genericType = typeReference as GenericInstanceType;
|
||||
var baseGenericType = baseType as GenericInstanceType;
|
||||
var genericInstanceType = new GenericInstanceType(tryImport(typeReference, baseGenericType.ElementType));
|
||||
foreach (var genericArgument in genericType.GenericArguments)
|
||||
{
|
||||
genericInstanceType.GenericArguments.Add(genericArgument);
|
||||
}
|
||||
baseType = genericInstanceType;
|
||||
}
|
||||
return baseType;
|
||||
}
|
||||
|
||||
const string BASE_RPOXY_PERFIX = "<>xLuaBaseProxy_";
|
||||
|
||||
static TypeReference tryImport(TypeReference type, TypeReference toImport)
|
||||
@ -1589,7 +1621,7 @@ namespace XLua
|
||||
|
||||
namespace XLua
|
||||
{
|
||||
#if UNITY_2019
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
class MyCustomBuildProcessor : IPostBuildPlayerScriptDLLs
|
||||
{
|
||||
public int callbackOrder { get { return 0; } }
|
||||
@ -1615,7 +1647,7 @@ namespace XLua
|
||||
return false;
|
||||
}
|
||||
|
||||
#if !UNITY_2019
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
[PostProcessScene]
|
||||
#endif
|
||||
[MenuItem("XLua/Hotfix Inject In Editor", false, 3)]
|
||||
@ -1683,7 +1715,11 @@ namespace XLua
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
List<string> args = new List<string>() { assembly_csharp_path, assembly_csharp_path, id_map_file_path, hotfix_cfg_in_editor };
|
||||
#else
|
||||
List<string> args = new List<string>() { assembly_csharp_path, typeof(LuaEnv).Module.FullyQualifiedName, id_map_file_path, hotfix_cfg_in_editor };
|
||||
#endif
|
||||
|
||||
foreach (var path in
|
||||
(from asm in AppDomain.CurrentDomain.GetAssemblies() select asm.ManifestModule.FullyQualifiedName)
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user