[增加] 增加2.1.16 版本
This commit is contained in:
parent
b536dd268e
commit
bd9125da14
|
@ -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日
|
||||
第一个版本
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0f2f954e4d6dd7c4ba2f284ea6a95124
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ab5420a556fefb4a803a54b6747a1ae
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9433781ad6e38724b9a26fdaac6a0b27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e866a5f1000c29940843aece98d0c706
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,47 @@
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CSObjectWrapEditor
|
||||
{
|
||||
public static class GeneratorConfig
|
||||
{
|
||||
#if XLUA_GENERAL
|
||||
public static string common_path = "./Gen/";
|
||||
#else
|
||||
public static string common_path = Application.dataPath + "/XLua/Gen/";
|
||||
#endif
|
||||
|
||||
static GeneratorConfig()
|
||||
{
|
||||
foreach(var type in (from type in XLua.Utils.GetAllTypes()
|
||||
where type.IsAbstract && type.IsSealed
|
||||
select type))
|
||||
{
|
||||
foreach (var field in type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
|
||||
{
|
||||
if (field.FieldType == typeof(string) && field.IsDefined(typeof(GenPathAttribute), false))
|
||||
{
|
||||
common_path = field.GetValue(null) as string;
|
||||
if (!common_path.EndsWith("/"))
|
||||
{
|
||||
common_path = common_path + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var prop in type.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
|
||||
{
|
||||
if (prop.PropertyType == typeof(string) && prop.IsDefined(typeof(GenPathAttribute), false))
|
||||
{
|
||||
common_path = prop.GetValue(null, null) as string;
|
||||
if (!common_path.EndsWith("/"))
|
||||
{
|
||||
common_path = common_path + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 52e8fc06193549818f5ce45980ec7fcc
|
||||
timeCreated: 1680613608
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f9f175d9e85601f4da903e391b8b7c77
|
||||
timeCreated: 1482299911
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f94464b9267f9b4cbf2f98681e22880
|
||||
folderAsset: yes
|
||||
timeCreated: 1479105499
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,34 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using XLua;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using CSObjectWrapEditor;
|
||||
|
||||
public class LinkXmlGen : ScriptableObject
|
||||
{
|
||||
public TextAsset Template;
|
||||
|
||||
public static IEnumerable<CustomGenTask> GetTasks(LuaEnv lua_env, UserConfig user_cfg)
|
||||
{
|
||||
LuaTable data = lua_env.NewTable();
|
||||
var assembly_infos = (from type in (user_cfg.ReflectionUse.Concat(user_cfg.LuaCallCSharp))
|
||||
group type by type.Assembly.GetName().Name into assembly_info
|
||||
select new { FullName = assembly_info.Key, Types = assembly_info.ToList()}).ToList();
|
||||
data.Set("assembly_infos", assembly_infos);
|
||||
|
||||
yield return new CustomGenTask
|
||||
{
|
||||
Data = data,
|
||||
Output = new StreamWriter(GeneratorConfig.common_path + "/link.xml",
|
||||
false, Encoding.UTF8)
|
||||
};
|
||||
}
|
||||
|
||||
[GenCodeMenu]//加到Generate Code菜单里头
|
||||
public static void GenLinkXml()
|
||||
{
|
||||
Generator.CustomGen(ScriptableObject.CreateInstance<LinkXmlGen>().Template.text, GetTasks);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5fa8c6bd6daed854c98654418f48a830
|
||||
timeCreated: 1482482561
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- Template: {fileID: 4900000, guid: 384feb229d259f549bbbac9e910b782b, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
<%
|
||||
require "TemplateCommon"
|
||||
%>
|
||||
|
||||
<linker>
|
||||
<%ForEachCsList(assembly_infos, function(assembly_info)%>
|
||||
<assembly fullname="<%=assembly_info.FullName%>">
|
||||
<%ForEachCsList(assembly_info.Types, function(type)
|
||||
%><type fullname="<%=type:ToString()%>" preserve="all"/>
|
||||
<%end)%>
|
||||
</assembly>
|
||||
<%end)%>
|
||||
</linker>
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 384feb229d259f549bbbac9e910b782b
|
||||
timeCreated: 1481621844
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9c7307955fb71fc4090eb2a906a78a0a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -0,0 +1,589 @@
|
|||
#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;
|
||||
<%ForEachCsList(namespaces, function(namespace)%>using <%=namespace%>;<%end)%>
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
|
||||
local OpNameMap = {
|
||||
op_Addition = "__AddMeta",
|
||||
op_Subtraction = "__SubMeta",
|
||||
op_Multiply = "__MulMeta",
|
||||
op_Division = "__DivMeta",
|
||||
op_Equality = "__EqMeta",
|
||||
op_UnaryNegation = "__UnmMeta",
|
||||
op_LessThan = "__LTMeta",
|
||||
op_LessThanOrEqual = "__LEMeta",
|
||||
op_Modulus = "__ModMeta",
|
||||
op_BitwiseAnd = "__BandMeta",
|
||||
op_BitwiseOr = "__BorMeta",
|
||||
op_ExclusiveOr = "__BxorMeta",
|
||||
op_OnesComplement = "__BnotMeta",
|
||||
op_LeftShift = "__ShlMeta",
|
||||
op_RightShift = "__ShrMeta",
|
||||
}
|
||||
|
||||
local OpCallNameMap = {
|
||||
op_Addition = "+",
|
||||
op_Subtraction = "-",
|
||||
op_Multiply = "*",
|
||||
op_Division = "/",
|
||||
op_Equality = "==",
|
||||
op_UnaryNegation = "-",
|
||||
op_LessThan = "<",
|
||||
op_LessThanOrEqual = "<=",
|
||||
op_Modulus = "%",
|
||||
op_BitwiseAnd = "&",
|
||||
op_BitwiseOr = "|",
|
||||
op_ExclusiveOr = "^",
|
||||
op_OnesComplement = "~",
|
||||
op_LeftShift = "<<",
|
||||
op_RightShift = ">>",
|
||||
}
|
||||
|
||||
local obj_method_count = 0
|
||||
local obj_getter_count = 0
|
||||
local obj_setter_count = 0
|
||||
local meta_func_count = operators.Count
|
||||
local cls_field_count = 1
|
||||
local cls_getter_count = 0
|
||||
local cls_setter_count = 0
|
||||
|
||||
ForEachCsList(methods, function(method)
|
||||
if method.IsStatic then
|
||||
cls_field_count = cls_field_count + 1
|
||||
else
|
||||
obj_method_count = obj_method_count + 1
|
||||
end
|
||||
end)
|
||||
|
||||
ForEachCsList(events, function(event)
|
||||
if event.IsStatic then
|
||||
cls_field_count = cls_field_count + 1
|
||||
else
|
||||
obj_method_count = obj_method_count + 1
|
||||
end
|
||||
end)
|
||||
|
||||
ForEachCsList(getters, function(getter)
|
||||
if getter.IsStatic then
|
||||
if getter.ReadOnly then
|
||||
cls_field_count = cls_field_count + 1
|
||||
else
|
||||
cls_getter_count = cls_getter_count + 1
|
||||
end
|
||||
else
|
||||
obj_getter_count = obj_getter_count + 1
|
||||
end
|
||||
end)
|
||||
|
||||
ForEachCsList(setters, function(setter)
|
||||
if setter.IsStatic then
|
||||
cls_setter_count = cls_setter_count + 1
|
||||
else
|
||||
obj_setter_count = obj_setter_count + 1
|
||||
end
|
||||
end)
|
||||
|
||||
ForEachCsList(lazymembers, function(lazymember)
|
||||
if lazymember.IsStatic == 'true' then
|
||||
if 'CLS_IDX' == lazymember.Index then
|
||||
cls_field_count = cls_field_count + 1
|
||||
elseif 'CLS_GETTER_IDX' == lazymember.Index then
|
||||
cls_getter_count = cls_getter_count + 1
|
||||
elseif 'CLS_SETTER_IDX' == lazymember.Index then
|
||||
cls_setter_count = cls_setter_count + 1
|
||||
end
|
||||
else
|
||||
if 'METHOD_IDX' == lazymember.Index then
|
||||
obj_method_count = obj_method_count + 1
|
||||
elseif 'GETTER_IDX' == lazymember.Index then
|
||||
obj_getter_count = obj_getter_count + 1
|
||||
elseif 'SETTER_IDX' == lazymember.Index then
|
||||
obj_setter_count = obj_setter_count + 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local generic_arg_list, type_constraints = GenericArgumentList(type)
|
||||
|
||||
%>
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
public class <%=CSVariableName(type)%>Wrap<%=generic_arg_list%> <%=type_constraints%>
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
System.Type type = typeof(<%=CsFullTypeName(type)%>);
|
||||
Utils.BeginObjectRegister(type, L, translator, <%=meta_func_count%>, <%=obj_method_count%>, <%=obj_getter_count%>, <%=obj_setter_count%>);
|
||||
<%ForEachCsList(operators, function(operator)%>Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "<%=(OpNameMap[operator.Name]):gsub('Meta', ''):lower()%>", <%=OpNameMap[operator.Name]%>);
|
||||
<%end)%>
|
||||
<%ForEachCsList(methods, function(method) if not method.IsStatic then %>Utils.RegisterFunc(L, Utils.METHOD_IDX, "<%=method.Name%>", _m_<%=method.Name%>);
|
||||
<% end end)%>
|
||||
<%ForEachCsList(events, function(event) if not event.IsStatic then %>Utils.RegisterFunc(L, Utils.METHOD_IDX, "<%=event.Name%>", _e_<%=event.Name%>);
|
||||
<% end end)%>
|
||||
<%ForEachCsList(getters, function(getter) if not getter.IsStatic then %>Utils.RegisterFunc(L, Utils.GETTER_IDX, "<%=getter.Name%>", _g_get_<%=getter.Name%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(setters, function(setter) if not setter.IsStatic then %>Utils.RegisterFunc(L, Utils.SETTER_IDX, "<%=setter.Name%>", _s_set_<%=setter.Name%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(lazymembers, function(lazymember) if lazymember.IsStatic == 'false' then %>Utils.RegisterLazyFunc(L, Utils.<%=lazymember.Index%>, "<%=lazymember.Name%>", type, <%=lazymember.MemberType%>, <%=lazymember.IsStatic%>);
|
||||
<%end end)%>
|
||||
Utils.EndObjectRegister(type, L, translator, <% if type.IsArray or ((indexers.Count or 0) > 0) then %>__CSIndexer<%else%>null<%end%>, <%if type.IsArray or ((newindexers.Count or 0) > 0) then%>__NewIndexer<%else%>null<%end%>,
|
||||
null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(type, L, __CreateInstance, <%=cls_field_count%>, <%=cls_getter_count%>, <%=cls_setter_count%>);
|
||||
<%ForEachCsList(methods, function(method) if method.IsStatic then %>Utils.RegisterFunc(L, Utils.CLS_IDX, "<%=method.Overloads[0].Name%>", _m_<%=method.Name%>);
|
||||
<% end end)%>
|
||||
<%ForEachCsList(events, function(event) if event.IsStatic then %>Utils.RegisterFunc(L, Utils.CLS_IDX, "<%=event.Name%>", _e_<%=event.Name%>);
|
||||
<% end end)%>
|
||||
<%ForEachCsList(getters, function(getter) if getter.IsStatic and getter.ReadOnly then %>Utils.RegisterObject(L, translator, Utils.CLS_IDX, "<%=getter.Name%>", <%=CsFullTypeName(type).."."..getter.Name%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(getters, function(getter) if getter.IsStatic and (not getter.ReadOnly) then %>Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "<%=getter.Name%>", _g_get_<%=getter.Name%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(setters, function(setter) if setter.IsStatic then %>Utils.RegisterFunc(L, Utils.CLS_SETTER_IDX, "<%=setter.Name%>", _s_set_<%=setter.Name%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(lazymembers, function(lazymember) if lazymember.IsStatic == 'true' then %>Utils.RegisterLazyFunc(L, Utils.<%=lazymember.Index%>, "<%=lazymember.Name%>", type, <%=lazymember.MemberType%>, <%=lazymember.IsStatic%>);
|
||||
<%end end)%>
|
||||
Utils.EndClassRegister(type, L, translator);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __CreateInstance(RealStatePtr L)
|
||||
{
|
||||
<%
|
||||
if constructors.Count == 0 and (not type.IsValueType) then
|
||||
%>return LuaAPI.luaL_error(L, "<%=CsFullTypeName(type)%> does not have a constructor!");<%
|
||||
else %>
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
<%
|
||||
local hasZeroParamsCtor = false
|
||||
ForEachCsList(constructors, function(constructor, ci)
|
||||
local parameters = constructor:GetParameters()
|
||||
if parameters.Length == 0 then
|
||||
hasZeroParamsCtor = true
|
||||
end
|
||||
local def_count = constructor_def_vals[ci]
|
||||
local param_count = parameters.Length
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local real_param_count = param_count - def_count
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
local in_pos = 0
|
||||
%>if(LuaAPI.lua_gettop(L) <%=has_v_params and ">=" or "=="%> <%=in_num + 1 - def_count - (has_v_params and 1 or 0)%><%ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
local parameterType = parameter.ParameterType
|
||||
if has_v_params and pi == param_count - 1 then parameterType = parameterType:GetElementType() end
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then in_pos = in_pos + 1
|
||||
%> && <%=GetCheckStatement(parameterType, in_pos+1, has_v_params and pi == param_count - 1)%><%
|
||||
end
|
||||
end)%>)
|
||||
{
|
||||
<%ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
%><%=GetCasterStatement(parameter.ParameterType, pi+2, LocalName(parameter.Name), true, has_v_params and pi == param_count - 1)%>;
|
||||
<%end)%>
|
||||
var gen_ret = new <%=CsFullTypeName(type)%>(<%ForEachCsList(parameters, function(parameter, pi) if pi >= real_param_count then return end; if pi ~=0 then %><%=', '%><% end ;if parameter.IsOut and parameter.ParameterType.IsByRef then %>out <% elseif parameter.ParameterType.IsByRef and not parameter.IsIn then %>ref <% end %><%=LocalName(parameter.Name)%><% end)%>);
|
||||
<%=GetPushStatement(type, "gen_ret")%>;
|
||||
<%local in_pos = 0
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
in_pos = in_pos + 1
|
||||
end
|
||||
if parameter.ParameterType.IsByRef then
|
||||
%><%=GetPushStatement(parameter.ParameterType:GetElementType(), LocalName(parameter.Name))%>;
|
||||
<%if not parameter.IsOut and parameter.ParameterType.IsByRef and NeedUpdate(parameter.ParameterType) then
|
||||
%><%=GetUpdateStatement(parameter.ParameterType:GetElementType(), in_pos+1, LocalName(parameter.Name))%>;
|
||||
<%end%>
|
||||
<%
|
||||
end
|
||||
end)
|
||||
%>
|
||||
return <%=out_num + 1%>;
|
||||
}
|
||||
<%end)
|
||||
if (not hasZeroParamsCtor) and type.IsValueType then
|
||||
%>
|
||||
if (LuaAPI.lua_gettop(L) == 1)
|
||||
{
|
||||
<%=GetPushStatement(type, "default(" .. CsFullTypeName(type).. ")")%>;
|
||||
return 1;
|
||||
}
|
||||
<%end%>
|
||||
}
|
||||
catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to <%=CsFullTypeName(type)%> constructor!");
|
||||
<% end %>
|
||||
}
|
||||
|
||||
<% if type.IsArray or ((indexers.Count or 0) > 0) then %>
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
public static int __CSIndexer(RealStatePtr L)
|
||||
{
|
||||
<%if type.IsArray then %>
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
|
||||
if (<%=GetCheckStatement(type, 1)%> && LuaAPI.lua_isnumber(L, 2))
|
||||
{
|
||||
int index = (int)LuaAPI.lua_tonumber(L, 2);
|
||||
<%=GetSelfStatement(type)%>;
|
||||
LuaAPI.lua_pushboolean(L, true);
|
||||
<%=GetPushStatement(type:GetElementType(), "gen_to_be_invoked[index]")%>;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
<%elseif indexers.Count > 0 then
|
||||
%>try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
<%
|
||||
ForEachCsList(indexers, function(indexer)
|
||||
local paramter = indexer:GetParameters()[0]
|
||||
%>
|
||||
if (<%=GetCheckStatement(type, 1)%> && <%=GetCheckStatement(paramter.ParameterType, 2)%>)
|
||||
{
|
||||
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetCasterStatement(paramter.ParameterType, 2, "index", true)%>;
|
||||
LuaAPI.lua_pushboolean(L, true);
|
||||
<%=GetPushStatement(indexer.ReturnType, "gen_to_be_invoked[index]")%>;
|
||||
return 2;
|
||||
}
|
||||
<%end)%>
|
||||
}
|
||||
catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
<%end%>
|
||||
LuaAPI.lua_pushboolean(L, false);
|
||||
return 1;
|
||||
}
|
||||
<% end %>
|
||||
|
||||
<%if type.IsArray or ((newindexers.Count or 0) > 0) then%>
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
public static int __NewIndexer(RealStatePtr L)
|
||||
{
|
||||
<%if type.IsArray or newindexers.Count > 0 then %>ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);<%end%>
|
||||
<%if type.IsArray then
|
||||
local elementType = type:GetElementType()
|
||||
%>
|
||||
try {
|
||||
if (<%=GetCheckStatement(type, 1)%> && LuaAPI.lua_isnumber(L, 2) && <%=GetCheckStatement(elementType, 3)%>)
|
||||
{
|
||||
int index = (int)LuaAPI.lua_tonumber(L, 2);
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetCasterStatement(elementType, 3, "gen_to_be_invoked[index]")%>;
|
||||
LuaAPI.lua_pushboolean(L, true);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
<%elseif newindexers.Count > 0 then%>
|
||||
try {
|
||||
<%ForEachCsList(newindexers, function(newindexer)
|
||||
local keyType = newindexer:GetParameters()[0].ParameterType
|
||||
local valueType = newindexer:GetParameters()[1].ParameterType
|
||||
%>
|
||||
if (<%=GetCheckStatement(type, 1)%> && <%=GetCheckStatement(keyType, 2)%> && <%=GetCheckStatement(valueType, 3)%>)
|
||||
{
|
||||
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetCasterStatement(keyType, 2, "key", true)%>;
|
||||
<%if IsStruct(valueType) then%><%=GetCasterStatement(valueType, 3, "gen_value", true)%>;
|
||||
gen_to_be_invoked[key] = gen_value;<%else
|
||||
%><%=GetCasterStatement(valueType, 3, "gen_to_be_invoked[key]")%>;<%end%>
|
||||
LuaAPI.lua_pushboolean(L, true);
|
||||
return 1;
|
||||
}
|
||||
<%end)%>
|
||||
}
|
||||
catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
<%end%>
|
||||
LuaAPI.lua_pushboolean(L, false);
|
||||
return 1;
|
||||
}
|
||||
<% end %>
|
||||
|
||||
<%ForEachCsList(operators, function(operator) %>
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int <%=OpNameMap[operator.Name]%>(RealStatePtr L)
|
||||
{
|
||||
<% if operator.Name ~= "op_UnaryNegation" and operator.Name ~= "op_OnesComplement" then %>
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
<%ForEachCsList(operator.Overloads, function(overload)
|
||||
local left_param = overload:GetParameters()[0]
|
||||
local right_param = overload:GetParameters()[1]
|
||||
%>
|
||||
|
||||
if (<%=GetCheckStatement(left_param.ParameterType, 1)%> && <%=GetCheckStatement(right_param.ParameterType, 2)%>)
|
||||
{
|
||||
<%=GetCasterStatement(left_param.ParameterType, 1, "leftside", true)%>;
|
||||
<%=GetCasterStatement(right_param.ParameterType, 2, "rightside", true)%>;
|
||||
|
||||
<%=GetPushStatement(overload.ReturnType, "leftside " .. OpCallNameMap[operator.Name] .. " rightside")%>;
|
||||
|
||||
return 1;
|
||||
}
|
||||
<%end)%>
|
||||
}
|
||||
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 <%=OpCallNameMap[operator.Name]%> operator, need <%=CsFullTypeName(type)%>!");
|
||||
<%else%>
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
try {
|
||||
<%=GetCasterStatement(type, 1, "rightside", true)%>;
|
||||
<%=GetPushStatement(operator.Overloads[0].ReturnType, OpCallNameMap[operator.Name] .. " rightside")%>;
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 1;
|
||||
<%end%>
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%ForEachCsList(methods, function(method)%>
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _m_<%=method.Name%>(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
<%
|
||||
local need_obj = not method.IsStatic
|
||||
if MethodCallNeedTranslator(method) then
|
||||
%>
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
<%end%>
|
||||
<%if need_obj then%>
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%end%>
|
||||
<%if method.Overloads.Count > 1 then%>
|
||||
int gen_param_count = LuaAPI.lua_gettop(L);
|
||||
<%end%>
|
||||
<%ForEachCsList(method.Overloads, function(overload, oi)
|
||||
local parameters = MethodParameters(overload)
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local param_offset = method.IsStatic and 0 or 1
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local in_pos = 0
|
||||
local has_return = (overload.ReturnType.FullName ~= "System.Void")
|
||||
local def_count = method.DefaultValues[oi]
|
||||
local param_count = parameters.Length
|
||||
local real_param_count = param_count - def_count
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
if method.Overloads.Count > 1 then
|
||||
%>if(gen_param_count <%=has_v_params and ">=" or "=="%> <%=in_num+param_offset-def_count - (has_v_params and 1 or 0)%><%
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
local parameterType = parameter.ParameterType
|
||||
if has_v_params and pi == param_count - 1 then parameterType = parameterType:GetElementType() end
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then in_pos = in_pos + 1;
|
||||
%>&& <%=GetCheckStatement(parameterType , in_pos+param_offset, has_v_params and pi == param_count - 1)%><%
|
||||
end
|
||||
end)%>) <%end%>
|
||||
{
|
||||
<%if overload.Name == "get_Item" and overload.IsSpecialName then
|
||||
local keyType = overload:GetParameters()[0].ParameterType%>
|
||||
<%=GetCasterStatement(keyType, 2, "key", true)%>;
|
||||
<%=GetPushStatement(overload.ReturnType, "gen_to_be_invoked[key]")%>;
|
||||
<%elseif overload.Name == "set_Item" and overload.IsSpecialName then
|
||||
local keyType = overload:GetParameters()[0].ParameterType
|
||||
local valueType = overload:GetParameters()[1].ParameterType%>
|
||||
<%=GetCasterStatement(keyType, 2, "key", true)%>;
|
||||
<%=GetCasterStatement(valueType, 3, "gen_value", true)%>;
|
||||
gen_to_be_invoked[key] = gen_value;
|
||||
<% else
|
||||
in_pos = 0;
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
%><%if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
in_pos = in_pos + 1
|
||||
%><%=GetCasterStatement(parameter.ParameterType, in_pos+param_offset, LocalName(parameter.Name), true, has_v_params and pi == param_count - 1)%><%
|
||||
else%><%=CsFullTypeName(parameter.ParameterType)%> <%=LocalName(parameter.Name)%><%end%>;
|
||||
<%end)%>
|
||||
<%
|
||||
if has_return then
|
||||
%> var gen_ret = <%
|
||||
end
|
||||
%><%if method.IsStatic then
|
||||
%><%=CsFullTypeName(type).."."..UnK(overload.Name)%><%
|
||||
else
|
||||
%>gen_to_be_invoked.<%=UnK(overload.Name)%><%
|
||||
end%>( <%ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
if pi ~= 0 then %>, <% end; if parameter.IsOut and parameter.ParameterType.IsByRef then %>out <% elseif parameter.ParameterType.IsByRef and not parameter.IsIn then %>ref <% end %><%=LocalName(parameter.Name)%><% end) %> );
|
||||
<%
|
||||
if has_return then
|
||||
%> <%=GetPushStatement(overload.ReturnType, "gen_ret")%>;
|
||||
<%
|
||||
end
|
||||
local in_pos = 0
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
in_pos = in_pos + 1
|
||||
end
|
||||
if parameter.ParameterType.IsByRef then
|
||||
%><%=GetPushStatement(parameter.ParameterType:GetElementType(), LocalName(parameter.Name))%>;
|
||||
<%if not parameter.IsOut and parameter.ParameterType.IsByRef and NeedUpdate(parameter.ParameterType) then
|
||||
%><%=GetUpdateStatement(parameter.ParameterType:GetElementType(), in_pos+param_offset, LocalName(parameter.Name))%>;
|
||||
<%end%>
|
||||
<%
|
||||
end
|
||||
end)
|
||||
end
|
||||
%>
|
||||
<%if NeedUpdate(type) and not method.IsStatic then%>
|
||||
<%=GetUpdateStatement(type, 1, "gen_to_be_invoked")%>;
|
||||
<%end%>
|
||||
|
||||
return <%=out_num+(has_return and 1 or 0)%>;
|
||||
}
|
||||
<% end)%>
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
<%if method.Overloads.Count > 1 then%>
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to <%=CsFullTypeName(type)%>.<%=method.Overloads[0].Name%>!");
|
||||
<%end%>
|
||||
}
|
||||
<% end)%>
|
||||
|
||||
|
||||
<%ForEachCsList(getters, function(getter)
|
||||
if getter.IsStatic and getter.ReadOnly then return end --readonly static
|
||||
%>
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _g_get_<%=getter.Name%>(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
<%if AccessorNeedTranslator(getter) then %> ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);<%end%>
|
||||
<%if not getter.IsStatic then%>
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetPushStatement(getter.Type, "gen_to_be_invoked."..UnK(getter.Name))%>;<% else %> <%=GetPushStatement(getter.Type, CsFullTypeName(type).."."..UnK(getter.Name))%>;<% end%>
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%ForEachCsList(setters, function(setter)
|
||||
local is_struct = IsStruct(setter.Type)
|
||||
%>
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _s_set_<%=setter.Name%>(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
<%if AccessorNeedTranslator(setter) then %>ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);<%end%>
|
||||
<%if not setter.IsStatic then %>
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%if is_struct then %><%=GetCasterStatement(setter.Type, 2, "gen_value", true)%>;
|
||||
gen_to_be_invoked.<%=UnK(setter.Name)%> = gen_value;<% else
|
||||
%><%=GetCasterStatement(setter.Type, 2, "gen_to_be_invoked." .. UnK(setter.Name))%>;<%end
|
||||
else
|
||||
if is_struct then %><%=GetCasterStatement(setter.Type, 1, "gen_value", true)%>;
|
||||
<%=CsFullTypeName(type)%>.<%=UnK(setter.Name)%> = gen_value;<%else
|
||||
%> <%=GetCasterStatement(setter.Type, 1, CsFullTypeName(type) .."." .. UnK(setter.Name))%>;<%end
|
||||
end%>
|
||||
<%if NeedUpdate(type) and not setter.IsStatic then%>
|
||||
<%=GetUpdateStatement(type, 1, "gen_to_be_invoked")%>;
|
||||
<%end%>
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%ForEachCsList(events, function(event) if not event.IsStatic then %>
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _e_<%=event.Name%>(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
int gen_param_count = LuaAPI.lua_gettop(L);
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetCasterStatement(event.Type, 3, "gen_delegate", true)%>;
|
||||
if (gen_delegate == null) {
|
||||
return LuaAPI.luaL_error(L, "#3 need <%=CsFullTypeName(event.Type)%>!");
|
||||
}
|
||||
|
||||
if (gen_param_count == 3)
|
||||
{
|
||||
<%if event.CanAdd then%>
|
||||
if (LuaAPI.xlua_is_eq_str(L, 2, "+")) {
|
||||
gen_to_be_invoked.<%=UnK(event.Name)%> += gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
<%end%>
|
||||
<%if event.CanRemove then%>
|
||||
if (LuaAPI.xlua_is_eq_str(L, 2, "-")) {
|
||||
gen_to_be_invoked.<%=UnK(event.Name)%> -= gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
<%end%>
|
||||
}
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
LuaAPI.luaL_error(L, "invalid arguments to <%=CsFullTypeName(type)%>.<%=event.Name%>!");
|
||||
return 0;
|
||||
}
|
||||
<%end end)%>
|
||||
|
||||
<%ForEachCsList(events, function(event) if event.IsStatic then %>
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int _e_<%=event.Name%>(RealStatePtr L)
|
||||
{
|
||||
try {
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
int gen_param_count = LuaAPI.lua_gettop(L);
|
||||
<%=GetCasterStatement(event.Type, 2, "gen_delegate", true)%>;
|
||||
if (gen_delegate == null) {
|
||||
return LuaAPI.luaL_error(L, "#2 need <%=CsFullTypeName(event.Type)%>!");
|
||||
}
|
||||
|
||||
<%if event.CanAdd then%>
|
||||
if (gen_param_count == 2 && LuaAPI.xlua_is_eq_str(L, 1, "+")) {
|
||||
<%=CsFullTypeName(type)%>.<%=UnK(event.Name)%> += gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
<%end%>
|
||||
<%if event.CanRemove then%>
|
||||
if (gen_param_count == 2 && LuaAPI.xlua_is_eq_str(L, 1, "-")) {
|
||||
<%=CsFullTypeName(type)%>.<%=UnK(event.Name)%> -= gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
<%end%>
|
||||
} catch(System.Exception gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to <%=CsFullTypeName(type)%>.<%=event.Name%>!");
|
||||
}
|
||||
<%end end)%>
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8503038eabbabe44dac0f5f749d4411a
|
||||
timeCreated: 1481620508
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,517 @@
|
|||
#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;
|
||||
<%ForEachCsList(namespaces, function(namespace)%>using <%=namespace%>;<%end)%>
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
|
||||
local OpNameMap = {
|
||||
op_Addition = "__AddMeta",
|
||||
op_Subtraction = "__SubMeta",
|
||||
op_Multiply = "__MulMeta",
|
||||
op_Division = "__DivMeta",
|
||||
op_Equality = "__EqMeta",
|
||||
op_UnaryNegation = "__UnmMeta",
|
||||
op_LessThan = "__LTMeta",
|
||||
op_LessThanOrEqual = "__LEMeta",
|
||||
op_Modulus = "__ModMeta",
|
||||
op_BitwiseAnd = "__BandMeta",
|
||||
op_BitwiseOr = "__BorMeta",
|
||||
op_ExclusiveOr = "__BxorMeta",
|
||||
op_OnesComplement = "__BnotMeta",
|
||||
op_LeftShift = "__ShlMeta",
|
||||
op_RightShift = "__ShrMeta",
|
||||
}
|
||||
|
||||
local OpCallNameMap = {
|
||||
op_Addition = "+",
|
||||
op_Subtraction = "-",
|
||||
op_Multiply = "*",
|
||||
op_Division = "/",
|
||||
op_Equality = "==",
|
||||
op_UnaryNegation = "-",
|
||||
op_LessThan = "<",
|
||||
op_LessThanOrEqual = "<=",
|
||||
op_Modulus = "%",
|
||||
op_BitwiseAnd = "&",
|
||||
op_BitwiseOr = "|",
|
||||
op_ExclusiveOr = "^",
|
||||
op_OnesComplement = "~",
|
||||
op_LeftShift = "<<",
|
||||
op_RightShift = ">>",
|
||||
}
|
||||
|
||||
local obj_method_count = 0
|
||||
local obj_getter_count = 0
|
||||
local obj_setter_count = 0
|
||||
local meta_func_count = operators.Count
|
||||
local cls_field_count = 1
|
||||
local cls_getter_count = 0
|
||||
local cls_setter_count = 0
|
||||
|
||||
ForEachCsList(methods, function(method)
|
||||
if method.IsStatic then
|
||||
cls_field_count = cls_field_count + 1
|
||||
else
|
||||
obj_method_count = obj_method_count + 1
|
||||
end
|
||||
end)
|
||||
|
||||
ForEachCsList(events, function(event)
|
||||
if event.IsStatic then
|
||||
cls_field_count = cls_field_count + 1
|
||||
else
|
||||
obj_method_count = obj_method_count + 1
|
||||
end
|
||||
end)
|
||||
|
||||
ForEachCsList(getters, function(getter)
|
||||
if getter.IsStatic then
|
||||
if getter.ReadOnly then
|
||||
cls_field_count = cls_field_count + 1
|
||||
else
|
||||
cls_getter_count = cls_getter_count + 1
|
||||
end
|
||||
else
|
||||
obj_getter_count = obj_getter_count + 1
|
||||
end
|
||||
end)
|
||||
|
||||
ForEachCsList(setters, function(setter)
|
||||
if setter.IsStatic then
|
||||
cls_setter_count = cls_setter_count + 1
|
||||
else
|
||||
obj_setter_count = obj_setter_count + 1
|
||||
end
|
||||
end)
|
||||
|
||||
ForEachCsList(lazymembers, function(lazymember)
|
||||
if lazymember.IsStatic == 'true' then
|
||||
if 'CLS_IDX' == lazymember.Index then
|
||||
cls_field_count = cls_field_count + 1
|
||||
elseif 'CLS_GETTER_IDX' == lazymember.Index then
|
||||
cls_getter_count = cls_getter_count + 1
|
||||
elseif 'CLS_SETTER_IDX' == lazymember.Index then
|
||||
cls_setter_count = cls_setter_count + 1
|
||||
end
|
||||
else
|
||||
if 'METHOD_IDX' == lazymember.Index then
|
||||
obj_method_count = obj_method_count + 1
|
||||
elseif 'GETTER_IDX' == lazymember.Index then
|
||||
obj_getter_count = obj_getter_count + 1
|
||||
elseif 'SETTER_IDX' == lazymember.Index then
|
||||
obj_setter_count = obj_setter_count + 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local v_type_name = CSVariableName(type)
|
||||
local generic_arg_list, type_constraints = GenericArgumentList(type)
|
||||
|
||||
%>
|
||||
namespace XLua
|
||||
{
|
||||
public static partial class ObjectTranslator_Gen
|
||||
{
|
||||
public static void __Register<%=v_type_name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L) <%=type_constraints%>
|
||||
{
|
||||
System.Type type = typeof(<%=CsFullTypeName(type)%>);
|
||||
Utils.BeginObjectRegister(type, L, thiz, <%=meta_func_count%>, <%=obj_method_count%>, <%=obj_getter_count%>, <%=obj_setter_count%>);
|
||||
<%ForEachCsList(operators, function(operator)%>Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "<%=(OpNameMap[operator.Name]):gsub('Meta', ''):lower()%>", thiz.<%=v_type_name%><%=OpNameMap[operator.Name]%><%=generic_arg_list%>);
|
||||
<%end)%>
|
||||
<%ForEachCsList(methods, function(method) if not method.IsStatic then %>Utils.RegisterFunc(L, Utils.METHOD_IDX, "<%=method.Name%>", thiz.<%=v_type_name%>_m_<%=method.Name%><%=generic_arg_list%>);
|
||||
<% end end)%>
|
||||
<%ForEachCsList(events, function(event) if not event.IsStatic then %>Utils.RegisterFunc(L, Utils.METHOD_IDX, "<%=event.Name%>", thiz.<%=v_type_name%>_e_<%=event.Name%><%=generic_arg_list%>);
|
||||
<% end end)%>
|
||||
<%ForEachCsList(getters, function(getter) if not getter.IsStatic then %>Utils.RegisterFunc(L, Utils.GETTER_IDX, "<%=getter.Name%>", thiz.<%=v_type_name%>_g_get_<%=getter.Name%><%=generic_arg_list%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(setters, function(setter) if not setter.IsStatic then %>Utils.RegisterFunc(L, Utils.SETTER_IDX, "<%=setter.Name%>", thiz.<%=v_type_name%>_s_set_<%=setter.Name%><%=generic_arg_list%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(lazymembers, function(lazymember) if lazymember.IsStatic == 'false' then %>Utils.RegisterLazyFunc(L, Utils.<%=lazymember.Index%>, "<%=lazymember.Name%>", type, <%=lazymember.MemberType%>, <%=lazymember.IsStatic%>);
|
||||
<%end end)%>
|
||||
Utils.EndObjectRegister(type, L, thiz, <% if type.IsArray or ((indexers.Count or 0) > 0) then %>thiz.__CSIndexer<%=v_type_name%><%=generic_arg_list%><%else%>null<%end%>, <%if type.IsArray or ((newindexers.Count or 0) > 0) then%>thiz.__NewIndexer<%=v_type_name%><%=generic_arg_list%><%else%>null<%end%>,
|
||||
null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(type, L, thiz.__CreateInstance<%=v_type_name%><%=generic_arg_list%>, <%=cls_field_count%>, <%=cls_getter_count%>, <%=cls_setter_count%>);
|
||||
<%ForEachCsList(methods, function(method) if method.IsStatic then %>Utils.RegisterFunc(L, Utils.CLS_IDX, "<%=method.Overloads[0].Name%>", thiz.<%=v_type_name%>_m_<%=method.Name%><%=generic_arg_list%>);
|
||||
<% end end)%>
|
||||
<%ForEachCsList(events, function(event) if event.IsStatic then %>Utils.RegisterFunc(L, Utils.CLS_IDX, "<%=event.Name%>", thiz.<%=v_type_name%>_e_<%=event.Name%><%=generic_arg_list%>);
|
||||
<% end end)%>
|
||||
<%ForEachCsList(getters, function(getter) if getter.IsStatic and getter.ReadOnly then %>Utils.RegisterObject(L, thiz, Utils.CLS_IDX, "<%=getter.Name%>", <%=CsFullTypeName(type).."."..getter.Name%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(getters, function(getter) if getter.IsStatic and (not getter.ReadOnly) then %>Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "<%=getter.Name%>", thiz.<%=v_type_name%>_g_get_<%=getter.Name%><%=generic_arg_list%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(setters, function(setter) if setter.IsStatic then %>Utils.RegisterFunc(L, Utils.CLS_SETTER_IDX, "<%=setter.Name%>", thiz.<%=v_type_name%>_s_set_<%=setter.Name%><%=generic_arg_list%>);
|
||||
<%end end)%>
|
||||
<%ForEachCsList(lazymembers, function(lazymember) if lazymember.IsStatic == 'true' then %>Utils.RegisterLazyFunc(L, Utils.<%=lazymember.Index%>, "<%=lazymember.Name%>", type, <%=lazymember.MemberType%>, <%=lazymember.IsStatic%>);
|
||||
<%end end)%>
|
||||
Utils.EndClassRegister(type, L, thiz);
|
||||
}
|
||||
|
||||
static int __CreateInstance<%=v_type_name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
<%
|
||||
if constructors.Count == 0 and (not type.IsValueType) then
|
||||
%>return LuaAPI.luaL_error(L, "<%=CsFullTypeName(type)%> does not have a constructor!");<%
|
||||
else %>
|
||||
ObjectTranslator translator = thiz;
|
||||
<%
|
||||
local hasZeroParamsCtor = false
|
||||
ForEachCsList(constructors, function(constructor, ci)
|
||||
local parameters = constructor:GetParameters()
|
||||
if parameters.Length == 0 then
|
||||
hasZeroParamsCtor = true
|
||||
end
|
||||
local def_count = constructor_def_vals[ci]
|
||||
local param_count = parameters.Length
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local real_param_count = param_count - def_count
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
local in_pos = 0
|
||||
%>if(gen_param_count <%=has_v_params and ">=" or "=="%> <%=in_num + 1 - def_count - (has_v_params and 1 or 0)%><%ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
local parameterType = parameter.ParameterType
|
||||
if has_v_params and pi == param_count - 1 then parameterType = parameterType:GetElementType() end
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then in_pos = in_pos + 1
|
||||
%> && <%=GetCheckStatement(parameterType, in_pos+1, has_v_params and pi == param_count - 1)%><%
|
||||
end
|
||||
end)%>)
|
||||
{
|
||||
<%ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
%><%=GetCasterStatement(parameter.ParameterType, pi+2, LocalName(parameter.Name), true, has_v_params and pi == param_count - 1)%>;
|
||||
<%end)%>
|
||||
var gen_ret = new <%=CsFullTypeName(type)%>(<%ForEachCsList(parameters, function(parameter, pi) if pi >= real_param_count then return end; if pi ~=0 then %><%=', '%><% end ;if parameter.IsOut and parameter.ParameterType.IsByRef then %>out <% elseif parameter.ParameterType.IsByRef and not parameter.IsIn then %>ref <% end %><%=LocalName(parameter.Name)%><% end)%>);
|
||||
<%=GetPushStatement(type, "gen_ret")%>;
|
||||
<%local in_pos = 0
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
in_pos = in_pos + 1
|
||||
end
|
||||
if parameter.ParameterType.IsByRef then
|
||||
%><%=GetPushStatement(parameter.ParameterType:GetElementType(), LocalName(parameter.Name))%>;
|
||||
<%if not parameter.IsOut and parameter.ParameterType.IsByRef and NeedUpdate(parameter.ParameterType) then
|
||||
%><%=GetUpdateStatement(parameter.ParameterType:GetElementType(), in_pos+1, LocalName(parameter.Name))%>;
|
||||
<%end%>
|
||||
<%
|
||||
end
|
||||
end)
|
||||
%>
|
||||
return <%=out_num + 1%>;
|
||||
}
|
||||
<%end)
|
||||
if (not hasZeroParamsCtor) and type.IsValueType then
|
||||
%>
|
||||
if (gen_param_count == 1)
|
||||
{
|
||||
<%=GetPushStatement(type, "default(" .. CsFullTypeName(type).. ")")%>;
|
||||
return 1;
|
||||
}
|
||||
<%end%>
|
||||
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to <%=CsFullTypeName(type)%> constructor!");
|
||||
<% end %>
|
||||
}
|
||||
|
||||
<% if type.IsArray or ((indexers.Count or 0) > 0) then %>
|
||||
static int __CSIndexer<%=v_type_name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
<%if type.IsArray then %>
|
||||
ObjectTranslator translator = thiz;
|
||||
if (<%=GetCheckStatement(type, 1)%> && LuaAPI.lua_isnumber(L, 2))
|
||||
{
|
||||
int index = (int)LuaAPI.lua_tonumber(L, 2);
|
||||
<%=GetSelfStatement(type)%>;
|
||||
LuaAPI.lua_pushboolean(L, true);
|
||||
<%=GetPushStatement(type:GetElementType(), "gen_to_be_invoked[index]")%>;
|
||||
return 2;
|
||||
}
|
||||
<%elseif indexers.Count > 0 then
|
||||
%>ObjectTranslator translator = thiz;
|
||||
<%
|
||||
ForEachCsList(indexers, function(indexer)
|
||||
local paramter = indexer:GetParameters()[0]
|
||||
%>
|
||||
if (<%=GetCheckStatement(type, 1)%> && <%=GetCheckStatement(paramter.ParameterType, 2)%>)
|
||||
{
|
||||
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetCasterStatement(paramter.ParameterType, 2, "index", true)%>;
|
||||
LuaAPI.lua_pushboolean(L, true);
|
||||
<%=GetPushStatement(indexer.ReturnType, "gen_to_be_invoked[index]")%>;
|
||||
return 2;
|
||||
}
|
||||
<%end)
|
||||
end%>
|
||||
LuaAPI.lua_pushboolean(L, false);
|
||||
return 1;
|
||||
}
|
||||
<% end %>
|
||||
|
||||
<%if type.IsArray or ((newindexers.Count or 0) > 0) then%>
|
||||
static int __NewIndexer<%=v_type_name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
<%if type.IsArray or newindexers.Count > 0 then %>ObjectTranslator translator = thiz;<%end%>
|
||||
<%if type.IsArray then
|
||||
local elementType = type:GetElementType()
|
||||
%>
|
||||
if (<%=GetCheckStatement(type, 1)%> && LuaAPI.lua_isnumber(L, 2) && <%=GetCheckStatement(elementType, 3)%>)
|
||||
{
|
||||
int index = (int)LuaAPI.lua_tonumber(L, 2);
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetCasterStatement(elementType, 3, "gen_to_be_invoked[index]")%>;
|
||||
LuaAPI.lua_pushboolean(L, true);
|
||||
return 1;
|
||||
}
|
||||
<%elseif newindexers.Count > 0 then%>
|
||||
<%ForEachCsList(newindexers, function(newindexer)
|
||||
local keyType = newindexer:GetParameters()[0].ParameterType
|
||||
local valueType = newindexer:GetParameters()[1].ParameterType
|
||||
%>
|
||||
if (<%=GetCheckStatement(type, 1)%> && <%=GetCheckStatement(keyType, 2)%> && <%=GetCheckStatement(valueType, 3)%>)
|
||||
{
|
||||
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetCasterStatement(keyType, 2, "key", true)%>;
|
||||
<%if IsStruct(valueType) then%><%=GetCasterStatement(valueType, 3, "gen_value", true)%>;
|
||||
gen_to_be_invoked[key] = gen_value;<%else
|
||||
%><%=GetCasterStatement(valueType, 3, "gen_to_be_invoked[key]")%>;<%end%>
|
||||
LuaAPI.lua_pushboolean(L, true);
|
||||
return 1;
|
||||
}
|
||||
<%end)
|
||||
end%>
|
||||
LuaAPI.lua_pushboolean(L, false);
|
||||
return 1;
|
||||
}
|
||||
<% end %>
|
||||
|
||||
<%ForEachCsList(operators, function(operator) %>
|
||||
static int <%=v_type_name%><%=OpNameMap[operator.Name]%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
ObjectTranslator translator = thiz;
|
||||
<% if operator.Name ~= "op_UnaryNegation" and operator.Name ~= "op_OnesComplement" then
|
||||
ForEachCsList(operator.Overloads, function(overload)
|
||||
local left_param = overload:GetParameters()[0]
|
||||
local right_param = overload:GetParameters()[1]
|
||||
%>
|
||||
if (<%=GetCheckStatement(left_param.ParameterType, 1)%> && <%=GetCheckStatement(right_param.ParameterType, 2)%>)
|
||||
{
|
||||
<%=GetCasterStatement(left_param.ParameterType, 1, "leftside", true)%>;
|
||||
<%=GetCasterStatement(right_param.ParameterType, 2, "rightside", true)%>;
|
||||
|
||||
<%=GetPushStatement(overload.ReturnType, "leftside " .. OpCallNameMap[operator.Name] .. " rightside")%>;
|
||||
|
||||
return 1;
|
||||
}
|
||||
<%end)%>
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to right hand of <%=OpCallNameMap[operator.Name]%> operator, need <%=CsFullTypeName(type)%>!");
|
||||
<%else%>
|
||||
<%=GetCasterStatement(type, 1, "rightside", true)%>;
|
||||
<%=GetPushStatement(operator.Overloads[0].ReturnType, OpCallNameMap[operator.Name] .. " rightside")%>;
|
||||
return 1;
|
||||
<%end%>
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%ForEachCsList(methods, function(method)%>
|
||||
static int <%=v_type_name%>_m_<%=method.Name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
<%
|
||||
local need_obj = not method.IsStatic
|
||||
if MethodCallNeedTranslator(method) then
|
||||
%>
|
||||
ObjectTranslator translator = thiz;
|
||||
<%end%>
|
||||
<%if need_obj then%>
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%end%>
|
||||
<%ForEachCsList(method.Overloads, function(overload, oi)
|
||||
local parameters = MethodParameters(overload)
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local param_offset = method.IsStatic and 0 or 1
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local in_pos = 0
|
||||
local has_return = (overload.ReturnType.FullName ~= "System.Void")
|
||||
local def_count = method.DefaultValues[oi]
|
||||
local param_count = parameters.Length
|
||||
local real_param_count = param_count - def_count
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
if method.Overloads.Count > 1 then
|
||||
%>if(gen_param_count <%=has_v_params and ">=" or "=="%> <%=in_num+param_offset-def_count - (has_v_params and 1 or 0)%><%
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
local parameterType = parameter.ParameterType
|
||||
if has_v_params and pi == param_count - 1 then parameterType = parameterType:GetElementType() end
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then in_pos = in_pos + 1;
|
||||
%>&& <%=GetCheckStatement(parameterType , in_pos+param_offset, has_v_params and pi == param_count - 1)%><%
|
||||
end
|
||||
end)%>) <%end%>
|
||||
{
|
||||
<%if overload.Name == "get_Item" and overload.IsSpecialName then
|
||||
local keyType = overload:GetParameters()[0].ParameterType%>
|
||||
<%=GetCasterStatement(keyType, 2, "key", true)%>;
|
||||
<%=GetPushStatement(overload.ReturnType, "gen_to_be_invoked[key]")%>;
|
||||
<%elseif overload.Name == "set_Item" and overload.IsSpecialName then
|
||||
local keyType = overload:GetParameters()[0].ParameterType
|
||||
local valueType = overload:GetParameters()[1].ParameterType%>
|
||||
<%=GetCasterStatement(keyType, 2, "key", true)%>;
|
||||
<%=GetCasterStatement(valueType, 3, "gen_to_be_invoked[key]")%>;
|
||||
<% else
|
||||
in_pos = 0;
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
%><%if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
in_pos = in_pos + 1
|
||||
%><%=GetCasterStatement(parameter.ParameterType, in_pos+param_offset, LocalName(parameter.Name), true, has_v_params and pi == param_count - 1)%><%
|
||||
else%><%=CsFullTypeName(parameter.ParameterType)%> <%=LocalName(parameter.Name)%><%end%>;
|
||||
<%end)%>
|
||||
<%
|
||||
if has_return then
|
||||
%>var gen_ret = <%
|
||||
end
|
||||
%><%if method.IsStatic then
|
||||
%><%=CsFullTypeName(type).."."..UnK(overload.Name)%><%
|
||||
else
|
||||
%>gen_to_be_invoked.<%=UnK(overload.Name)%><%
|
||||
end%>( <%ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
if pi ~= 0 then %>, <% end; if parameter.IsOut and parameter.ParameterType.IsByRef then %>out <% elseif parameter.ParameterType.IsByRef and not parameter.IsIn then %>ref <% end %><%=LocalName(parameter.Name)%><% end) %> );
|
||||
<%
|
||||
if has_return then
|
||||
%><%=GetPushStatement(overload.ReturnType, "gen_ret")%>;
|
||||
<%
|
||||
end
|
||||
local in_pos = 0
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi >= real_param_count then return end
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
in_pos = in_pos + 1
|
||||
end
|
||||
if parameter.ParameterType.IsByRef then
|
||||
%><%=GetPushStatement(parameter.ParameterType:GetElementType(), LocalName(parameter.Name))%>;
|
||||
<%if not parameter.IsOut and parameter.ParameterType.IsByRef and NeedUpdate(parameter.ParameterType) then
|
||||
%><%=GetUpdateStatement(parameter.ParameterType:GetElementType(), in_pos+param_offset, LocalName(parameter.Name))%>;
|
||||
<%end%>
|
||||
<%
|
||||
end
|
||||
end)
|
||||
end
|
||||
%>
|
||||
<%if NeedUpdate(type) and not method.IsStatic then%>
|
||||
<%=GetUpdateStatement(type, 1, "gen_to_be_invoked")%>;
|
||||
<%end%>
|
||||
|
||||
return <%=out_num+(has_return and 1 or 0)%>;
|
||||
}
|
||||
<% end)%>
|
||||
<%if method.Overloads.Count > 1 then%>
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to <%=CsFullTypeName(type)%>.<%=method.Overloads[0].Name%>!");
|
||||
<%end%>
|
||||
}
|
||||
<% end)%>
|
||||
|
||||
|
||||
<%ForEachCsList(getters, function(getter)
|
||||
if getter.IsStatic and getter.ReadOnly then return end --readonly static
|
||||
%>
|
||||
static int <%=v_type_name%>_g_get_<%=getter.Name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
<%if AccessorNeedTranslator(getter) then %>ObjectTranslator translator = thiz;<%end%>
|
||||
<%if not getter.IsStatic then%>
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetPushStatement(getter.Type, "gen_to_be_invoked."..UnK(getter.Name))%>;<% else %> <%=GetPushStatement(getter.Type, CsFullTypeName(type).."."..UnK(getter.Name))%>;<% end%>
|
||||
return 1;
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%ForEachCsList(setters, function(setter)
|
||||
local is_struct = IsStruct(setter.Type)
|
||||
%>
|
||||
static int <%=v_type_name%>_s_set_<%=setter.Name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
<%if AccessorNeedTranslator(setter) then %>ObjectTranslator translator = thiz;<%end%>
|
||||
<%if not setter.IsStatic then %>
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%if is_struct then %><%=GetCasterStatement(setter.Type, 2, "gen_value", true)%>;
|
||||
gen_to_be_invoked.<%=UnK(setter.Name)%> = gen_value;<% else
|
||||
%><%=GetCasterStatement(setter.Type, 2, "gen_to_be_invoked." .. UnK(setter.Name))%>;<%end
|
||||
else
|
||||
if is_struct then %><%=GetCasterStatement(setter.Type, 1, "gen_value", true)%>;
|
||||
<%=CsFullTypeName(type)%>.<%=UnK(setter.Name)%> = gen_value;<%else
|
||||
%><%=GetCasterStatement(setter.Type, 1, CsFullTypeName(type) .."." .. UnK(setter.Name))%>;<%end
|
||||
end%>
|
||||
<%if NeedUpdate(type) and not setter.IsStatic then%>
|
||||
<%=GetUpdateStatement(type, 1, "gen_to_be_invoked")%>;
|
||||
<%end%>
|
||||
return 0;
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%ForEachCsList(events, function(event) if not event.IsStatic then %>
|
||||
static int <%=v_type_name%>_e_<%=event.Name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
ObjectTranslator translator = thiz;
|
||||
<%=GetSelfStatement(type)%>;
|
||||
<%=GetCasterStatement(event.Type, 3, "gen_delegate", true)%>;
|
||||
if (gen_delegate == null) {
|
||||
return LuaAPI.luaL_error(L, "#3 need <%=CsFullTypeName(event.Type)%>!");
|
||||
}
|
||||
|
||||
if (gen_param_count == 3)
|
||||
{
|
||||
<%if event.CanAdd then%>
|
||||
if (LuaAPI.xlua_is_eq_str(L, 2, "+")) {
|
||||
gen_to_be_invoked.<%=UnK(event.Name)%> += gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
<%end%>
|
||||
<%if event.CanRemove then%>
|
||||
if (LuaAPI.xlua_is_eq_str(L, 2, "-")) {
|
||||
gen_to_be_invoked.<%=UnK(event.Name)%> -= gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
<%end%>
|
||||
}
|
||||
LuaAPI.luaL_error(L, "invalid arguments to <%=CsFullTypeName(type)%>.<%=event.Name%>!");
|
||||
return 0;
|
||||
}
|
||||
<%end end)%>
|
||||
|
||||
<%ForEachCsList(events, function(event) if event.IsStatic then %>
|
||||
static int <%=v_type_name%>_e_<%=event.Name%><%=generic_arg_list%>(this ObjectTranslator thiz, RealStatePtr L, int gen_param_count) <%=type_constraints%>
|
||||
{
|
||||
ObjectTranslator translator = thiz;
|
||||
<%=GetCasterStatement(event.Type, 2, "gen_delegate", true)%>;
|
||||
if (gen_delegate == null) {
|
||||
return LuaAPI.luaL_error(L, "#2 need <%=CsFullTypeName(event.Type)%>!");
|
||||
}
|
||||
|
||||
<%if event.CanAdd then%>
|
||||
if (gen_param_count == 2 && LuaAPI.xlua_is_eq_str(L, 1, "+")) {
|
||||
<%=CsFullTypeName(type)%>.<%=UnK(event.Name)%> += gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
<%end%>
|
||||
<%if event.CanRemove then%>
|
||||
if (gen_param_count == 2 && LuaAPI.xlua_is_eq_str(L, 1, "-")) {
|
||||
<%=CsFullTypeName(type)%>.<%=UnK(event.Name)%> -= gen_delegate;
|
||||
return 0;
|
||||
}
|
||||
<%end%>
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to <%=CsFullTypeName(type)%>.<%=event.Name%>!");
|
||||
}
|
||||
<%end end)%>
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2bd79d95fd859724283926ad8fa4df30
|
||||
timeCreated: 1501232428
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,100 @@
|
|||
#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 System;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
%>
|
||||
|
||||
namespace XLua
|
||||
{
|
||||
public partial class DelegateBridge_Wrap : DelegateBridge
|
||||
{
|
||||
public DelegateBridge_Wrap(int reference, LuaEnv luaenv) : base(reference, luaenv){}
|
||||
<%
|
||||
ForEachCsList(delegates_groups, function(delegates_group, group_idx)
|
||||
local delegate = delegates_group.Key
|
||||
local parameters = delegate:GetParameters()
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local in_pos = 0
|
||||
local has_return = (delegate.ReturnType.FullName ~= "System.Void")
|
||||
local return_type_name = has_return and CsFullTypeName(delegate.ReturnType) or "void"
|
||||
local out_idx = has_return and 2 or 1
|
||||
if has_return then out_num = out_num + 1 end
|
||||
%>
|
||||
public <%=return_type_name%> __Gen_Delegate_Imp<%=group_idx%>(<%ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi ~= 0 then
|
||||
%>, <%
|
||||
end
|
||||
if parameter.IsOut and parameter.ParameterType.IsByRef then
|
||||
%>out <%
|
||||
elseif parameter.ParameterType.IsByRef then
|
||||
%>ref <%
|
||||
end
|
||||
%><%=CsFullTypeName(parameter.ParameterType)%> p<%=pi%><%
|
||||
end) %>)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
|
||||
<%if CallNeedTranslator(delegate, "") then %>ObjectTranslator translator = luaEnv.translator;<%end%>
|
||||
<%
|
||||
local param_count = parameters.Length
|
||||
local has_v_params = param_count > 0 and parameters[param_count - 1].IsParamArray
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
%><%=GetPushStatement(parameter.ParameterType, 'p' .. pi, has_v_params and pi == param_count - 1)%>;
|
||||
<%
|
||||
end
|
||||
end) %>
|
||||
PCall(L, <%=has_v_params and ((in_num - 1) .. " + (p".. (param_count - 1) .. " == null ? 0 : p" .. (param_count - 1) .. ".Length)" ) or in_num%>, <%=out_num%>, errFunc);
|
||||
|
||||
<%ForEachCsList(parameters, function(parameter, pi)
|
||||
if parameter.IsOut or parameter.ParameterType.IsByRef then
|
||||
%><%=GetCasterStatement(parameter.ParameterType, "errFunc" .. (" + "..out_idx), 'p' .. pi)%>;
|
||||
<%
|
||||
out_idx = out_idx + 1
|
||||
end
|
||||
end) %>
|
||||
<%if has_return then %><%=GetCasterStatement(delegate.ReturnType, "errFunc + 1", "__gen_ret", true)%>;<% end%>
|
||||
LuaAPI.lua_settop(L, errFunc - 1);
|
||||
<%if has_return then %>return __gen_ret;<% end%>
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
public override Delegate GetDelegateByType(Type type)
|
||||
{
|
||||
<%
|
||||
ForEachCsList(delegates_groups, function(delegates_group, group_idx)
|
||||
ForEachCsList(delegates_group.Value, function(delegate)
|
||||
if delegate.DeclaringType then
|
||||
local delegate_type_name = CsFullTypeName(delegate.DeclaringType)
|
||||
%>
|
||||
if (type == typeof(<%=delegate_type_name%>))
|
||||
{
|
||||
return new <%=delegate_type_name%>(__Gen_Delegate_Imp<%=group_idx%>);
|
||||
}
|
||||
<%
|
||||
end
|
||||
end)
|
||||
end)
|
||||
%>
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3d992756e2469044484be75f78e4e556
|
||||
timeCreated: 1481620508
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,128 @@
|
|||
#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;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
|
||||
local parameters = delegate:GetParameters()
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local in_pos = 0
|
||||
local has_return = (delegate.ReturnType.Name ~= "Void")
|
||||
%>
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
public class <%=CSVariableName(type)%>Wrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
Utils.BeginObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, translator, 0, 0, 0, 0);
|
||||
Utils.EndObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, translator, null, null, null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(typeof(<%=CsFullTypeName(type)%>), L, null, 1, 0, 0);
|
||||
Utils.EndClassRegister(typeof(<%=CsFullTypeName(type)%>), L, translator);
|
||||
}
|
||||
|
||||
static Dictionary<string, LuaCSFunction> __MetaFucntions_Dic = new Dictionary<string, LuaCSFunction>(){
|
||||
{"__call", __CallMeta},
|
||||
{"__add", __AddMeta},
|
||||
{"__sub", __SubMeta},
|
||||
};
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __CallMeta(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
try {
|
||||
if(LuaAPI.lua_gettop(L) == <%=in_num+1%> && <%=GetCheckStatement(type, 1)%><%
|
||||
ForEachCsList(parameters, function(parameter)
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then in_pos = in_pos + 1;
|
||||
%>&& <%=GetCheckStatement(parameter.ParameterType, in_pos+1)%><%
|
||||
end
|
||||
end)%>)
|
||||
{
|
||||
<%
|
||||
in_pos = 0;
|
||||
ForEachCsList(parameters, function(parameter)
|
||||
%><%
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
in_pos = in_pos + 1
|
||||
%><%=GetCasterStatement(parameter.ParameterType, in_pos+1, parameter.Name, true)%><%
|
||||
else%><%=CsFullTypeName(parameter.ParameterType)%> <%=parameter.Name%><%end%>;
|
||||
<%end)%>
|
||||
<%=GetSelfStatement(type)%>;
|
||||
|
||||
<%
|
||||
if has_return then
|
||||
%> var __cl_gen_ret = <%
|
||||
end
|
||||
%> __cl_gen_to_be_invoked( <%ForEachCsList(parameters, function(parameter, pi) if pi ~= 0 then %>, <% end; if parameter.IsOut then %>out <% elseif parameter.ParameterType.IsByRef then %>ref <% end %><%=parameter.Name%><% end) %> );
|
||||
<%
|
||||
if has_return then
|
||||
%> <%=GetPushStatement(delegate.ReturnType, "__cl_gen_ret")%>;
|
||||
<%
|
||||
end
|
||||
local in_pos = 0
|
||||
ForEachCsList(parameters, function(parameter)
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
in_pos = in_pos + 1
|
||||
end
|
||||
if parameter.IsOut or parameter.ParameterType.IsByRef then
|
||||
%><%=GetPushStatement(parameter.ParameterType:GetElementType(), parameter.Name)%>;
|
||||
<%if not parameter.IsOut and parameter.ParameterType.IsByRef and NeedUpdate(parameter.ParameterType) then
|
||||
%><%=GetUpdateStatement(parameter.ParameterType:GetElementType(), in_pos+param_offset, parameter.Name)%>;
|
||||
<%end%>
|
||||
<%
|
||||
end
|
||||
end)
|
||||
%>
|
||||
|
||||
return <%=out_num+(has_return and 1 or 0)%>;
|
||||
}
|
||||
} catch(System.Exception __gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e);
|
||||
}
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to Delegate <%=CsFullTypeName(type)%>!");
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __AddMeta(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
try {
|
||||
<%=GetCasterStatement(type, 1, "leftside", true)%>;
|
||||
<%=GetCasterStatement(type, 2, "rightside", true)%>;
|
||||
<%=GetPushStatement(type, "leftside + rightside")%>;
|
||||
return 1;
|
||||
} catch(System.Exception __gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e);
|
||||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
static int __SubMeta(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
try {
|
||||
<%=GetCasterStatement(type, 1, "leftside", true)%>;
|
||||
<%=GetCasterStatement(type, 2, "rightside", true)%>;
|
||||
<%=GetPushStatement(type, "leftside - rightside")%>;
|
||||
return 1;
|
||||
} catch(System.Exception __gen_e) {
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + __gen_e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 33b33e1cd617f794b8c801a32f3b2539
|
||||
timeCreated: 1481620508
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,102 @@
|
|||
#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;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
local enum_or_op = debug.getmetatable(CS.System.Reflection.BindingFlags.Public).__bor
|
||||
%>
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
using Utils = XLua.Utils;
|
||||
<%ForEachCsList(types, function(type)
|
||||
local fields = type2fields and type2fields[type] or type:GetFields(enum_or_op(CS.System.Reflection.BindingFlags.Public, CS.System.Reflection.BindingFlags.Static))
|
||||
local fields_to_gen = {}
|
||||
ForEachCsList(fields, function(field)
|
||||
if field.Name ~= "value__" and not IsObsolute(field) then
|
||||
table.insert(fields_to_gen, field)
|
||||
end
|
||||
end)
|
||||
%>
|
||||
public class <%=CSVariableName(type)%>Wrap
|
||||
{
|
||||
public static void __Register(RealStatePtr L)
|
||||
{
|
||||
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
||||
Utils.BeginObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, translator, 0, 0, 0, 0);
|
||||
Utils.EndObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, translator, null, null, null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(typeof(<%=CsFullTypeName(type)%>), L, null, <%=fields.Length + 1%>, 0, 0);
|
||||
<%if #fields_to_gen <= 20 then%>
|
||||
<% ForEachCsList(fields, function(field)
|
||||
if field.Name == "value__" or IsObsolute(field) then return end
|
||||
%>
|
||||
Utils.RegisterObject(L, translator, Utils.CLS_IDX, "<%=field.Name%>", <%=CsFullTypeName(type)%>.<%=UnK(field.Name)%>);
|
||||
<%end)%>
|
||||
<%else%>
|
||||
Utils.RegisterEnumType(L, typeof(<%=CsFullTypeName(type)%>));
|
||||
<%end%>
|
||||
Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom);
|
||||
|
||||
Utils.EndClassRegister(typeof(<%=CsFullTypeName(type)%>), 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.Push<%=CSVariableName(type)%>(L, (<%=CsFullTypeName(type)%>)LuaAPI.xlua_tointeger(L, 1));
|
||||
}
|
||||
<%if #fields_to_gen > 0 then%>
|
||||
else if(lua_type == LuaTypes.LUA_TSTRING)
|
||||
{
|
||||
<%if #fields_to_gen <= 20 then%>
|
||||
<%
|
||||
local is_first = true
|
||||
ForEachCsList(fields, function(field, i)
|
||||
if field.Name == "value__" or IsObsolute(field) then return end
|
||||
%><%=(is_first and "" or "else ")%>if (LuaAPI.xlua_is_eq_str(L, 1, "<%=field.Name%>"))
|
||||
{
|
||||
translator.Push<%=CSVariableName(type)%>(L, <%=CsFullTypeName(type)%>.<%=UnK(field.Name)%>);
|
||||
}
|
||||
<%
|
||||
is_first = false
|
||||
end)
|
||||
%>else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid string for <%=CsFullTypeName(type)%>!");
|
||||
}
|
||||
<%else%>
|
||||
try
|
||||
{
|
||||
translator.TranslateToEnumToTop(L, typeof(<%=CsFullTypeName(type)%>), 1);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "cast to " + typeof(<%=CsFullTypeName(type)%>) + " exception:" + e);
|
||||
}
|
||||
<%end%>
|
||||
}
|
||||
<%end%>
|
||||
else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid lua type for <%=CsFullTypeName(type)%>! Expect number or string, got + " + lua_type);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
<%end)%>
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae16c73aad9a21a44aef65decb7e4928
|
||||
timeCreated: 1481620508
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,99 @@
|
|||
#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;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
local enum_or_op = debug.getmetatable(CS.System.Reflection.BindingFlags.Public).__bor
|
||||
%>
|
||||
|
||||
namespace XLua
|
||||
{
|
||||
public static partial class ObjectTranslator_Gen
|
||||
{
|
||||
<%ForEachCsList(types, function(type)
|
||||
local fields = type2fields and type2fields[type] or type:GetFields(enum_or_op(CS.System.Reflection.BindingFlags.Public, CS.System.Reflection.BindingFlags.Static))
|
||||
local fields_to_gen = {}
|
||||
ForEachCsList(fields, function(field)
|
||||
if field.Name ~= "value__" and not IsObsolute(field) then
|
||||
table.insert(fields_to_gen, field)
|
||||
end
|
||||
end)
|
||||
local v_type_name = CSVariableName(type)
|
||||
%>
|
||||
public static void __Register<%=v_type_name%>(this ObjectTranslator thiz, RealStatePtr L)
|
||||
{
|
||||
Utils.BeginObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, thiz, 0, 0, 0, 0);
|
||||
Utils.EndObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, thiz, null, null, null, null, null);
|
||||
|
||||
Utils.BeginClassRegister(typeof(<%=CsFullTypeName(type)%>), L, null, <%=fields.Length + 1%>, 0, 0);
|
||||
<%if #fields_to_gen <= 20 then%>
|
||||
<% ForEachCsList(fields, function(field)
|
||||
if field.Name == "value__" or IsObsolute(field) then return end
|
||||
%>
|
||||
Utils.RegisterObject(L, thiz, Utils.CLS_IDX, "<%=field.Name%>", <%=CsFullTypeName(type)%>.<%=UnK(field.Name)%>);
|
||||
<%end)%>
|
||||
<%else%>
|
||||
Utils.RegisterEnumType(L, typeof(<%=CsFullTypeName(type)%>));
|
||||
<%end%>
|
||||
Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", thiz.__CastFrom<%=v_type_name%>);
|
||||
|
||||
Utils.EndClassRegister(typeof(<%=CsFullTypeName(type)%>), L, thiz);
|
||||
}
|
||||
|
||||
static int __CastFrom<%=v_type_name%>(this ObjectTranslator thiz, RealStatePtr L, int __gen_top)
|
||||
{
|
||||
LuaTypes lua_type = LuaAPI.lua_type(L, 1);
|
||||
if (lua_type == LuaTypes.LUA_TNUMBER)
|
||||
{
|
||||
thiz.Push<%=v_type_name%>(L, (<%=CsFullTypeName(type)%>)LuaAPI.xlua_tointeger(L, 1));
|
||||
}
|
||||
<%if #fields_to_gen > 0 then%>
|
||||
else if(lua_type == LuaTypes.LUA_TSTRING)
|
||||
{
|
||||
<%if #fields_to_gen <= 20 then%>
|
||||
<%
|
||||
local is_first = true
|
||||
ForEachCsList(fields, function(field, i)
|
||||
if field.Name == "value__" or IsObsolute(field) then return end
|
||||
%><%=(is_first and "" or "else ")%>if (LuaAPI.xlua_is_eq_str(L, 1, "<%=field.Name%>"))
|
||||
{
|
||||
thiz.Push<%=v_type_name%>(L, <%=CsFullTypeName(type)%>.<%=UnK(field.Name)%>);
|
||||
}
|
||||
<%
|
||||
is_first = false
|
||||
end)
|
||||
%>else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid string for <%=CsFullTypeName(type)%>!");
|
||||
}
|
||||
<%else%>
|
||||
try
|
||||
{
|
||||
TranslateToEnumToTop(L, typeof(<%=CsFullTypeName(type)%>), 1);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "cast to " + typeof(<%=CsFullTypeName(type)%>) + " exception:" + e);
|
||||
}
|
||||
<%end%>
|
||||
}
|
||||
<%end%>
|
||||
else
|
||||
{
|
||||
return LuaAPI.luaL_error(L, "invalid lua type for <%=CsFullTypeName(type)%>! Expect number or string, got + " + lua_type);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
<%end)%>
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ea84a5ee7abf8e347a810eb7848add46
|
||||
timeCreated: 1501232428
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,385 @@
|
|||
#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;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
|
||||
%>
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
public class <%=CSVariableName(type)%>Bridge : LuaBase, <%=CsFullTypeName(type)%>
|
||||
{
|
||||
public static LuaBase __Create(int reference, LuaEnv luaenv)
|
||||
{
|
||||
return new <%=CSVariableName(type)%>Bridge(reference, luaenv);
|
||||
}
|
||||
|
||||
public <%=CSVariableName(type)%>Bridge(int reference, LuaEnv luaenv) : base(reference, luaenv)
|
||||
{
|
||||
}
|
||||
|
||||
<%
|
||||
ForEachCsList(methods, function(method)
|
||||
local parameters = method:GetParameters()
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local in_pos = 0
|
||||
local has_return = (method.ReturnType.FullName ~= "System.Void")
|
||||
local return_type_name = has_return and CsFullTypeName(method.ReturnType) or "void"
|
||||
local out_idx = has_return and 2 or 1
|
||||
if has_return then out_num = out_num + 1 end
|
||||
%>
|
||||
<%=return_type_name%> <%=CsFullTypeName(method.DeclaringType)%>.<%=method.Name%>(<%ForEachCsList(parameters, function(parameter, pi)
|
||||
if pi ~= 0 then
|
||||
%>, <%
|
||||
end
|
||||
if parameter.IsOut and parameter.ParameterType.IsByRef then
|
||||
%>out <%
|
||||
elseif parameter.ParameterType.IsByRef then
|
||||
%>ref <%
|
||||
end
|
||||
%><%=CsFullTypeName(parameter.ParameterType)%> <%=parameter.Name%><%
|
||||
end) %>)
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
|
||||
<%if CallNeedTranslator(method, "") then %>ObjectTranslator translator = luaEnv.translator;<%end%>
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "<%=method.Name%>");
|
||||
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 <%=method.Name%>");
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
}
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.lua_remove(L, -3);
|
||||
<%
|
||||
local param_count = parameters.Length
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
%><%=GetPushStatement(parameter.ParameterType, parameter.Name, has_v_params and pi == param_count - 1)%>;
|
||||
<%
|
||||
end
|
||||
end) %>
|
||||
int __gen_error = LuaAPI.lua_pcall(L, <%=has_v_params and ((in_num) .. " + (".. parameters[param_count - 1].Name .. " == null ? 0 : " .. parameters[param_count - 1].Name .. ".Length)" ) or (in_num + 1)%>, <%=out_num%>, err_func);
|
||||
if (__gen_error != 0)
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
|
||||
<%ForEachCsList(parameters, function(parameter)
|
||||
if parameter.IsOut or parameter.ParameterType.IsByRef then
|
||||
%><%=GetCasterStatement(parameter.ParameterType, "err_func" .. (" + "..out_idx), parameter.Name)%>;
|
||||
<%
|
||||
out_idx = out_idx + 1
|
||||
end
|
||||
end) %>
|
||||
<%if has_return then %><%=GetCasterStatement(method.ReturnType, "err_func + 1", "__gen_ret", true)%>;<% end%>
|
||||
LuaAPI.lua_settop(L, err_func - 1);
|
||||
<%if has_return then %>return __gen_ret;<% end%>
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%
|
||||
ForEachCsList(propertys, function(property)
|
||||
%>
|
||||
<%=CsFullTypeName(property.PropertyType)%> <%=CsFullTypeName(property.DeclaringType)%>.<%=property.Name%>
|
||||
{
|
||||
<%if property.CanRead then%>
|
||||
get
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int oldTop = LuaAPI.lua_gettop(L);
|
||||
<%if not JustLuaType(property.PropertyType) then %>ObjectTranslator translator = luaEnv.translator;<%end%>
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "<%=property.Name%>");
|
||||
if (0 != LuaAPI.xlua_pgettable(L, -2))
|
||||
{
|
||||
luaEnv.ThrowExceptionFromError(oldTop);
|
||||
}
|
||||
<%=GetCasterStatement(property.PropertyType, "-1", "__gen_ret", true)%>;
|
||||
LuaAPI.lua_pop(L, 2);
|
||||
return __gen_ret;
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
<%end%>
|
||||
<%if property.CanWrite then%>
|
||||
set
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int oldTop = LuaAPI.lua_gettop(L);
|
||||
<%if not JustLuaType(property.PropertyType) then %>ObjectTranslator translator = luaEnv.translator;<%end%>
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "<%=property.Name%>");
|
||||
<%=GetPushStatement(property.PropertyType, "value")%>;
|
||||
if (0 != LuaAPI.xlua_psettable(L, -3))
|
||||
{
|
||||
luaEnv.ThrowExceptionFromError(oldTop);
|
||||
}
|
||||
LuaAPI.lua_pop(L, 1);
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
<%end%>
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%ForEachCsList(events, function(event) %>
|
||||
event <%=CsFullTypeName(event.EventHandlerType)%> <%=CsFullTypeName(event.DeclaringType)%>.<%=event.Name%>
|
||||
{<%local parameters = event:GetAddMethod():GetParameters()%>
|
||||
add
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
|
||||
<%if CallNeedTranslator(event:GetAddMethod(), "") then %>ObjectTranslator translator = luaEnv.translator;<%end%>
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "add_<%=event.Name%>");
|
||||
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_<%=event.Name%>");
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
}
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.lua_remove(L, -3);
|
||||
<%
|
||||
local param_count = parameters.Length
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
%><%=GetPushStatement(parameter.ParameterType, parameter.Name, has_v_params and pi == param_count - 1)%>;
|
||||
<%
|
||||
end
|
||||
end) %>
|
||||
int __gen_error = LuaAPI.lua_pcall(L, 2, 0, err_func);
|
||||
if (__gen_error != 0)
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
|
||||
LuaAPI.lua_settop(L, err_func - 1);
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
remove
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
|
||||
<%if CallNeedTranslator(event:GetRemoveMethod(), "") then %>ObjectTranslator translator = luaEnv.translator;<%end%>
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "remove_<%=event.Name%>");
|
||||
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 remove_<%=event.Name%>");
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
}
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.lua_remove(L, -3);
|
||||
<%
|
||||
local param_count = parameters.Length
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
%><%=GetPushStatement(parameter.ParameterType, parameter.Name, has_v_params and pi == param_count - 1)%>;
|
||||
<%
|
||||
end
|
||||
end) %>
|
||||
int __gen_error = LuaAPI.lua_pcall(L, 2, 0, err_func);
|
||||
if (__gen_error != 0)
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
|
||||
LuaAPI.lua_settop(L, err_func - 1);
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
<%ForEachCsList(indexers, function(indexer)
|
||||
local ptype = (indexer:GetGetMethod() or indexer:GetSetMethod()):GetParameters()[0].ParameterType
|
||||
local pname = (indexer:GetGetMethod() or indexer:GetSetMethod()):GetParameters()[0].Name
|
||||
%>
|
||||
<%=CsFullTypeName(indexer.PropertyType)%> <%=CsFullTypeName(indexer.DeclaringType)%>.this[<%=CsFullTypeName(ptype)%> <%=pname%>]
|
||||
{<%if indexer:GetGetMethod() then
|
||||
local method = indexer:GetGetMethod()
|
||||
local parameters = method:GetParameters()
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local in_pos = 0
|
||||
local has_return = (method.ReturnType.FullName ~= "System.Void")
|
||||
local return_type_name = has_return and CsFullTypeName(method.ReturnType) or "void"
|
||||
local out_idx = has_return and 2 or 1
|
||||
if has_return then out_num = out_num + 1 end
|
||||
%>
|
||||
get
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
|
||||
<%if CallNeedTranslator(method, "") then %>ObjectTranslator translator = luaEnv.translator;<%end%>
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "<%=method.Name%>");
|
||||
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 <%=method.Name%>");
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
}
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.lua_remove(L, -3);
|
||||
<%
|
||||
local param_count = parameters.Length
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
%><%=GetPushStatement(parameter.ParameterType, parameter.Name, has_v_params and pi == param_count - 1)%>;
|
||||
<%
|
||||
end
|
||||
end) %>
|
||||
int __gen_error = LuaAPI.lua_pcall(L, <%=has_v_params and ((in_num) .. " + " .. parameters[param_count - 1].Name .. ".Length" ) or (in_num + 1)%>, <%=out_num%>, err_func);
|
||||
if (__gen_error != 0)
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
|
||||
<%ForEachCsList(parameters, function(parameter)
|
||||
if parameter.IsOut or parameter.ParameterType.IsByRef then
|
||||
%><%=GetCasterStatement(parameter.ParameterType, "err_func" .. (" + "..out_idx), parameter.Name)%>;
|
||||
<%
|
||||
out_idx = out_idx + 1
|
||||
end
|
||||
end) %>
|
||||
<%if has_return then %><%=GetCasterStatement(method.ReturnType, "err_func + 1", "__gen_ret", true)%>;<% end%>
|
||||
LuaAPI.lua_settop(L, err_func - 1);
|
||||
<%if has_return then %>return __gen_ret;<% end%>
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
<%end%>
|
||||
<%if indexer:GetSetMethod() then
|
||||
local method = indexer:GetSetMethod()
|
||||
local parameters = method:GetParameters()
|
||||
local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end)
|
||||
local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end)
|
||||
local in_pos = 0
|
||||
local has_return = (method.ReturnType.FullName ~= "System.Void")
|
||||
local return_type_name = has_return and CsFullTypeName(method.ReturnType) or "void"
|
||||
local out_idx = has_return and 2 or 1
|
||||
if has_return then out_num = out_num + 1 end
|
||||
%>
|
||||
set
|
||||
{
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
lock (luaEnv.luaEnvLock)
|
||||
{
|
||||
#endif
|
||||
RealStatePtr L = luaEnv.L;
|
||||
int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
|
||||
<%if CallNeedTranslator(method, "") then %>ObjectTranslator translator = luaEnv.translator;<%end%>
|
||||
|
||||
LuaAPI.lua_getref(L, luaReference);
|
||||
LuaAPI.xlua_pushasciistring(L, "<%=method.Name%>");
|
||||
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 <%=method.Name%>");
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
}
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.lua_remove(L, -3);
|
||||
<%
|
||||
local param_count = parameters.Length
|
||||
local has_v_params = param_count > 0 and IsParams(parameters[param_count - 1])
|
||||
|
||||
ForEachCsList(parameters, function(parameter, pi)
|
||||
if not (parameter.IsOut and parameter.ParameterType.IsByRef) then
|
||||
%><%=GetPushStatement(parameter.ParameterType, parameter.Name, has_v_params and pi == param_count - 1)%>;
|
||||
<%
|
||||
end
|
||||
end) %>
|
||||
int __gen_error = LuaAPI.lua_pcall(L, <%=has_v_params and ((in_num) .. " + " .. parameters[param_count - 1].Name .. ".Length" ) or (in_num + 1)%>, <%=out_num%>, err_func);
|
||||
if (__gen_error != 0)
|
||||
luaEnv.ThrowExceptionFromError(err_func - 1);
|
||||
|
||||
<%ForEachCsList(parameters, function(parameter)
|
||||
if parameter.IsOut or parameter.ParameterType.IsByRef then
|
||||
%><%=GetCasterStatement(parameter.ParameterType, "err_func" .. (" + "..out_idx), parameter.Name)%>;
|
||||
<%
|
||||
out_idx = out_idx + 1
|
||||
end
|
||||
end) %>
|
||||
<%if has_return then %><%=GetCasterStatement(method.ReturnType, "err_func + 1", "__gen_ret", true)%>;<% end%>
|
||||
LuaAPI.lua_settop(L, err_func - 1);
|
||||
<%if has_return then %>return __gen_ret;<% end%>
|
||||
#if THREAD_SAFE || HOTFIX_ENABLE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
<%end%>
|
||||
}
|
||||
<%end)%>
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7165d08e91378494dadeb10e5338accb
|
||||
timeCreated: 1481620508
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,134 @@
|
|||
#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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
%>
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
public class XLua_Gen_Initer_Register__
|
||||
{
|
||||
<%
|
||||
local split_method_perfix = 'wrapInit'
|
||||
local split_method_count = 0
|
||||
local wrap_in_split_method = 0
|
||||
local max_wrap_in_split_method = 50
|
||||
%>
|
||||
<%ForEachCsList(wraps, function(wrap)%>
|
||||
<%if wrap_in_split_method == 0 then%>static void <%=split_method_perfix%><%=split_method_count%>(LuaEnv luaenv, ObjectTranslator translator)
|
||||
{
|
||||
<%end%>
|
||||
translator.DelayWrapLoader(typeof(<%=CsFullTypeName(wrap)%>), <%=CSVariableName(wrap)%>Wrap.__Register);
|
||||
<%if wrap_in_split_method == max_wrap_in_split_method then
|
||||
wrap_in_split_method = 0
|
||||
split_method_count = split_method_count + 1
|
||||
%>
|
||||
}
|
||||
<%else
|
||||
wrap_in_split_method = wrap_in_split_method + 1
|
||||
end
|
||||
end)%>
|
||||
<% if generic_wraps then
|
||||
for generic_def, instances in pairs(generic_wraps) do
|
||||
for _, args in ipairs(instances) do
|
||||
local generic_arg_list = "<"
|
||||
ForEachCsList(args, function(generic_arg, gai)
|
||||
if gai ~= 0 then generic_arg_list = generic_arg_list .. ", " end
|
||||
generic_arg_list = generic_arg_list .. CsFullTypeName(generic_arg)
|
||||
end)
|
||||
generic_arg_list = generic_arg_list .. ">"
|
||||
|
||||
%>
|
||||
<%if wrap_in_split_method == 0 then%>static void <%=split_method_perfix%><%=split_method_count%>(LuaEnv luaenv, ObjectTranslator translator)
|
||||
{
|
||||
<%end%>
|
||||
translator.DelayWrapLoader(typeof(<%=generic_def.Name:gsub("`%d+", "") .. generic_arg_list%>), <%=CSVariableName(generic_def)%>Wrap<%=generic_arg_list%>.__Register);
|
||||
<%if wrap_in_split_method == max_wrap_in_split_method then
|
||||
wrap_in_split_method = 0
|
||||
split_method_count = split_method_count + 1
|
||||
%>
|
||||
}
|
||||
<%else
|
||||
wrap_in_split_method = wrap_in_split_method + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end%>
|
||||
|
||||
<%if wrap_in_split_method ~= 0 then
|
||||
split_method_count = split_method_count + 1
|
||||
%>}<%end%>
|
||||
|
||||
public static void Init(LuaEnv luaenv, ObjectTranslator translator)
|
||||
{
|
||||
<%for i = 1, split_method_count do%>
|
||||
<%=split_method_perfix%><%=(i - 1)%>(luaenv, translator);
|
||||
<%end%>
|
||||
<%ForEachCsList(itf_bridges, function(itf_bridge)%>
|
||||
translator.AddInterfaceBridgeCreator(typeof(<%=CsFullTypeName(itf_bridge)%>), <%=CSVariableName(itf_bridge)%>Bridge.__Create);
|
||||
<%end)%>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace XLua
|
||||
{
|
||||
internal partial class InternalGlobals_Gen
|
||||
{
|
||||
<%
|
||||
local type_to_methods = {}
|
||||
local seq_tbl = {}
|
||||
ForEachCsList(extension_methods, function(extension_method, idx)
|
||||
local parameters = extension_method:GetParameters()
|
||||
local type = parameters[0].ParameterType
|
||||
if not type_to_methods[type] then
|
||||
type_to_methods[type] = {type = type}
|
||||
table.insert(seq_tbl, type_to_methods[type])
|
||||
end
|
||||
table.insert(type_to_methods[type], {method = extension_method, index = idx})
|
||||
%>
|
||||
delegate <%=CsFullTypeName(extension_method.ReturnType)%> __GEN_DELEGATE<%=idx%>(<%ForEachCsList(parameters, function(parameter, pi)
|
||||
%><%if pi ~= 0 then%>, <%end%><%if parameter.IsOut then %>out <% elseif parameter.ParameterType.IsByRef then %>ref <% end %> <%=CsFullTypeName(parameter.ParameterType)%> <%=parameter.Name%><%
|
||||
end)%>);
|
||||
<%end)%>
|
||||
private delegate bool TryArrayGet(Type type, RealStatePtr L, ObjectTranslator translator, object obj, int index);
|
||||
private delegate bool TryArraySet(Type type, RealStatePtr L, ObjectTranslator translator, object obj, int array_idx, int obj_idx);
|
||||
private static void Init(
|
||||
out Dictionary<Type, IEnumerable<MethodInfo>> extensionMethodMap,
|
||||
out TryArrayGet genTryArrayGetPtr,
|
||||
out TryArraySet genTryArraySetPtr)
|
||||
{
|
||||
XLua.LuaEnv.AddIniter(XLua.CSObjectWrap.XLua_Gen_Initer_Register__.Init);
|
||||
XLua.LuaEnv.AddIniter(XLua.ObjectTranslator_Gen.Init);
|
||||
extensionMethodMap = new Dictionary<Type, IEnumerable<MethodInfo>>()
|
||||
{
|
||||
<%for _, methods_info in ipairs(seq_tbl) do%>
|
||||
{typeof(<%=CsFullTypeName(methods_info.type)%>), new List<MethodInfo>(){
|
||||
<% for _, method_info in ipairs(methods_info) do%>
|
||||
new __GEN_DELEGATE<%=method_info.index%>(<%=CsFullTypeName(method_info.method.DeclaringType)%>.<%=method_info.method.Name%>)
|
||||
#if UNITY_WSA && !UNITY_EDITOR
|
||||
.GetMethodInfo(),
|
||||
#else
|
||||
.Method,
|
||||
#endif
|
||||
<% end%>
|
||||
}},
|
||||
<%end%>
|
||||
};
|
||||
|
||||
genTryArrayGetPtr = StaticLuaCallbacks_Wrap.__tryArrayGet;
|
||||
genTryArraySetPtr = StaticLuaCallbacks_Wrap.__tryArraySet;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e416b82ec9fe340458f97cf1e3468ef7
|
||||
timeCreated: 1481620508
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,134 @@
|
|||
#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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
%>
|
||||
|
||||
namespace XLua.CSObjectWrap
|
||||
{
|
||||
public class XLua_Gen_Initer_Register__
|
||||
{
|
||||
<%
|
||||
local split_method_perfix = 'wrapInit'
|
||||
local split_method_count = 0
|
||||
local wrap_in_split_method = 0
|
||||
local max_wrap_in_split_method = 50
|
||||
%>
|
||||
<%ForEachCsList(wraps, function(wrap)%>
|
||||
<%if wrap_in_split_method == 0 then%>static void <%=split_method_perfix%><%=split_method_count%>(LuaEnv luaenv, ObjectTranslator translator)
|
||||
{
|
||||
<%end%>
|
||||
translator.DelayWrapLoader(typeof(<%=CsFullTypeName(wrap)%>), translator.__Register<%=CSVariableName(wrap)%>);
|
||||
<%if wrap_in_split_method == max_wrap_in_split_method then
|
||||
wrap_in_split_method = 0
|
||||
split_method_count = split_method_count + 1
|
||||
%>
|
||||
}
|
||||
<%else
|
||||
wrap_in_split_method = wrap_in_split_method + 1
|
||||
end
|
||||
end)%>
|
||||
<% if generic_wraps then
|
||||
for generic_def, instances in pairs(generic_wraps) do
|
||||
for _, args in ipairs(instances) do
|
||||
local generic_arg_list = "<"
|
||||
ForEachCsList(args, function(generic_arg, gai)
|
||||
if gai ~= 0 then generic_arg_list = generic_arg_list .. ", " end
|
||||
generic_arg_list = generic_arg_list .. CsFullTypeName(generic_arg)
|
||||
end)
|
||||
generic_arg_list = generic_arg_list .. ">"
|
||||
|
||||
%>
|
||||
<%if wrap_in_split_method == 0 then%>static void <%=split_method_perfix%><%=split_method_count%>(LuaEnv luaenv, ObjectTranslator translator)
|
||||
{
|
||||
<%end%>
|
||||
translator.DelayWrapLoader(typeof(<%=generic_def.Name:gsub("`%d+", "") .. generic_arg_list%>), translator.__Register<%=CSVariableName(generic_def)%><%=generic_arg_list%>);
|
||||
<%if wrap_in_split_method == max_wrap_in_split_method then
|
||||
wrap_in_split_method = 0
|
||||
split_method_count = split_method_count + 1
|
||||
%>
|
||||
}
|
||||
<%else
|
||||
wrap_in_split_method = wrap_in_split_method + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end%>
|
||||
|
||||
<%if wrap_in_split_method ~= 0 then
|
||||
split_method_count = split_method_count + 1
|
||||
%>}<%end%>
|
||||
|
||||
public static void Init(LuaEnv luaenv, ObjectTranslator translator)
|
||||
{
|
||||
<%for i = 1, split_method_count do%>
|
||||
<%=split_method_perfix%><%=(i - 1)%>(luaenv, translator);
|
||||
<%end%>
|
||||
<%ForEachCsList(itf_bridges, function(itf_bridge)%>
|
||||
translator.AddInterfaceBridgeCreator(typeof(<%=CsFullTypeName(itf_bridge)%>), <%=CSVariableName(itf_bridge)%>Bridge.__Create);
|
||||
<%end)%>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace XLua
|
||||
{
|
||||
internal partial class InternalGlobals_Gen
|
||||
{
|
||||
<%
|
||||
local type_to_methods = {}
|
||||
local seq_tbl = {}
|
||||
ForEachCsList(extension_methods, function(extension_method, idx)
|
||||
local parameters = extension_method:GetParameters()
|
||||
local type = parameters[0].ParameterType
|
||||
if not type_to_methods[type] then
|
||||
type_to_methods[type] = {type = type}
|
||||
table.insert(seq_tbl, type_to_methods[type])
|
||||
end
|
||||
table.insert(type_to_methods[type], {method = extension_method, index = idx})
|
||||
%>
|
||||
delegate <%=CsFullTypeName(extension_method.ReturnType)%> __GEN_DELEGATE<%=idx%>(<%ForEachCsList(parameters, function(parameter, pi)
|
||||
%><%if pi ~= 0 then%>, <%end%><%if parameter.IsOut then %>out <% elseif parameter.ParameterType.IsByRef then %>ref <% end %> <%=CsFullTypeName(parameter.ParameterType)%> <%=parameter.Name%><%
|
||||
end)%>);
|
||||
<%end)%>
|
||||
private delegate bool TryArrayGet(Type type, RealStatePtr L, ObjectTranslator translator, object obj, int index);
|
||||
private delegate bool TryArraySet(Type type, RealStatePtr L, ObjectTranslator translator, object obj, int array_idx, int obj_idx);
|
||||
private static void Init(
|
||||
out Dictionary<Type, IEnumerable<MethodInfo>> extensionMethodMap,
|
||||
out TryArrayGet genTryArrayGetPtr,
|
||||
out TryArraySet genTryArraySetPtr)
|
||||
{
|
||||
XLua.LuaEnv.AddIniter(XLua.CSObjectWrap.XLua_Gen_Initer_Register__.Init);
|
||||
XLua.LuaEnv.AddIniter(XLua.ObjectTranslator_Gen.Init);
|
||||
extensionMethodMap = new Dictionary<Type, IEnumerable<MethodInfo>>()
|
||||
{
|
||||
<%for _, methods_info in ipairs(seq_tbl) do%>
|
||||
{typeof(<%=CsFullTypeName(methods_info.type)%>), new List<MethodInfo>(){
|
||||
<% for _, method_info in ipairs(methods_info) do%>
|
||||
new __GEN_DELEGATE<%=method_info.index%>(<%=CsFullTypeName(method_info.method.DeclaringType)%>.<%=method_info.method.Name%>)
|
||||
#if UNITY_WSA && !UNITY_EDITOR
|
||||
.GetMethodInfo(),
|
||||
#else
|
||||
.Method,
|
||||
#endif
|
||||
<% end%>
|
||||
}},
|
||||
<%end%>
|
||||
};
|
||||
|
||||
genTryArrayGetPtr = StaticLuaCallbacks_Wrap.__tryArrayGet;
|
||||
genTryArraySetPtr = StaticLuaCallbacks_Wrap.__tryArraySet;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 46c7366d55afbf1459674448d92c44c8
|
||||
timeCreated: 1501232428
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,218 @@
|
|||
#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 System;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
%>
|
||||
|
||||
namespace XLua
|
||||
{
|
||||
public static partial class ObjectTranslator_Gen
|
||||
{
|
||||
public static void Init(LuaEnv luaenv, ObjectTranslator translator)
|
||||
{
|
||||
<%ForEachCsList(purevaluetypes, function(type_info)
|
||||
if not type_info.Type.IsValueType then return end
|
||||
local full_type_name = CsFullTypeName(type_info.Type)%>
|
||||
translator.RegisterPushAndGetAndUpdate<<%=full_type_name%>>(translator.Push<%=CSVariableName(type_info.Type)%>, translator.Get<%=CSVariableName(type_info.Type)%>, translator.Update<%=CSVariableName(type_info.Type)%>);<%
|
||||
end)%>
|
||||
<%ForEachCsList(tableoptimzetypes, function(type_info)
|
||||
local full_type_name = CsFullTypeName(type_info.Type)%>
|
||||
translator.RegisterCaster<<%=full_type_name%>>(translator.Get<%=full_type_name%>);<%
|
||||
end)%>
|
||||
}
|
||||
|
||||
<%ForEachCsList(purevaluetypes, function(type_info)
|
||||
local type_id_var_name = CSVariableName(type_info.Type) .. '_TypeID'
|
||||
local enum_ref_var_name = CSVariableName(type_info.Type)..'_EnumRef'
|
||||
local full_type_name = CsFullTypeName(type_info.Type)
|
||||
local is_enum = type_info.Type.IsEnum
|
||||
%>static int <%=type_id_var_name%> = -1;<%if is_enum then%>
|
||||
static int <%=enum_ref_var_name%> = -1;
|
||||
<%end%>
|
||||
public static void Push<%=CSVariableName(type_info.Type)%>(this ObjectTranslator thiz, RealStatePtr L, <%=full_type_name%> val)
|
||||
{
|
||||
if (<%=type_id_var_name%> == -1)
|
||||
{
|
||||
bool is_first;
|
||||
<%=type_id_var_name%> = thiz.getTypeId(L, typeof(<%=full_type_name%>), out is_first);
|
||||
<%if is_enum then%>
|
||||
if (<%=enum_ref_var_name%> == -1)
|
||||
{
|
||||
Utils.LoadCSTable(L, typeof(<%=full_type_name%>));
|
||||
<%=enum_ref_var_name%> = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
|
||||
}
|
||||
<%end%>
|
||||
}
|
||||
<%if is_enum then%>
|
||||
if (LuaAPI.xlua_tryget_cachedud(L, (int)val, <%=enum_ref_var_name%>) == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
<%
|
||||
end
|
||||
if type_info.Flag == CS.XLua.OptimizeFlag.PackAsTable then
|
||||
%>
|
||||
<%if PushObjectNeedTranslator(type_info) then %> ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);<%end%>
|
||||
LuaAPI.xlua_pushcstable(L, <%=type_info.FieldInfos.Count%>, <%=type_id_var_name%>);
|
||||
<%ForEachCsList(type_info.FieldInfos, function(fieldInfo)%>
|
||||
LuaAPI.xlua_pushasciistring(L, "<%=fieldInfo.Name%>");
|
||||
<%=GetPushStatement(fieldInfo.Type, "val."..fieldInfo.Name)%>;
|
||||
LuaAPI.lua_rawset(L, -3);
|
||||
<%end)%>
|
||||
<%else%>
|
||||
IntPtr buff = LuaAPI.xlua_pushstruct(L, <%=is_enum and 4 or type_info.Size%>, <%=type_id_var_name%>);
|
||||
if (!CopyByValue_Gen.Pack(buff, 0, <%=is_enum and "(int)" or ""%>val))
|
||||
{
|
||||
throw new Exception("pack fail fail for <%=full_type_name%> ,value="+val);
|
||||
}
|
||||
<%
|
||||
end
|
||||
if is_enum then
|
||||
%>
|
||||
LuaAPI.lua_getref(L, <%=enum_ref_var_name%>);
|
||||
LuaAPI.lua_pushvalue(L, -2);
|
||||
LuaAPI.xlua_rawseti(L, -2, (int)val);
|
||||
LuaAPI.lua_pop(L, 1);
|
||||
<%end%>
|
||||
}
|
||||
|
||||
public static void Get<%=CSVariableName(type_info.Type)%>(this ObjectTranslator thiz, RealStatePtr L, int index, out <%=full_type_name%> val)
|
||||
{
|
||||
LuaTypes type = LuaAPI.lua_type(L, index);
|
||||
if (type == LuaTypes.LUA_TUSERDATA )
|
||||
{
|
||||
if (LuaAPI.xlua_gettypeid(L, index) != <%=type_id_var_name%>)
|
||||
{
|
||||
throw new Exception("invalid userdata for <%=full_type_name%>");
|
||||
}
|
||||
|
||||
IntPtr buff = LuaAPI.lua_touserdata(L, index);<%if is_enum then%>
|
||||
int e;
|
||||
<%end%>if (!CopyByValue_Gen.UnPack(buff, 0, out <%=is_enum and "e" or "val"%>))
|
||||
{
|
||||
throw new Exception("unpack fail for <%=full_type_name%>");
|
||||
}<%if is_enum then%>
|
||||
val = (<%=full_type_name%>)e;
|
||||
<%end%>
|
||||
}<%if not is_enum then%>
|
||||
else if (type ==LuaTypes.LUA_TTABLE)
|
||||
{
|
||||
CopyByValue_Gen.UnPack(thiz, L, index, out val);
|
||||
}<%end%>
|
||||
else
|
||||
{
|
||||
val = (<%=full_type_name%>)thiz.objectCasters.GetCaster(typeof(<%=full_type_name%>))(L, index, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Update<%=CSVariableName(type_info.Type)%>(this ObjectTranslator thiz, RealStatePtr L, int index, <%=full_type_name%> val)
|
||||
{
|
||||
<%if type_info.Flag == CS.XLua.OptimizeFlag.PackAsTable then%>
|
||||
if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TTABLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
<%else%>
|
||||
if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
|
||||
{
|
||||
if (LuaAPI.xlua_gettypeid(L, index) != <%=type_id_var_name%>)
|
||||
{
|
||||
throw new Exception("invalid userdata for <%=full_type_name%>");
|
||||
}
|
||||
|
||||
IntPtr buff = LuaAPI.lua_touserdata(L, index);
|
||||
if (!CopyByValue_Gen.Pack(buff, 0, <%=is_enum and "(int)" or ""%>val))
|
||||
{
|
||||
throw new Exception("pack fail for <%=full_type_name%> ,value="+val);
|
||||
}
|
||||
}
|
||||
<%end%>
|
||||
else
|
||||
{
|
||||
throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
|
||||
}
|
||||
}
|
||||
|
||||
<%end)%>
|
||||
// table cast optimze
|
||||
<%ForEachCsList(tableoptimzetypes, function(type_info)
|
||||
local full_type_name = CsFullTypeName(type_info.Type)
|
||||
%>
|
||||
public static void Get<%=CSVariableName(type_info.Type)%>(this ObjectTranslator thiz, RealStatePtr L, int index, out <%=full_type_name%> val)
|
||||
{
|
||||
LuaTypes type = LuaAPI.lua_type(L, index);
|
||||
if (type == LuaTypes.LUA_TUSERDATA )
|
||||
{
|
||||
val = (<%=full_type_name%>)thiz.FastGetCSObj(L, index);
|
||||
}
|
||||
else if (type == LuaTypes.LUA_TTABLE)
|
||||
{
|
||||
val = new <%=full_type_name%>();
|
||||
int top = LuaAPI.lua_gettop(L);
|
||||
<%ForEachCsList(type_info.Fields, function(fieldInfo)%>
|
||||
if (Utils.LoadField(L, index, "<%=fieldInfo.Name%>"))
|
||||
{
|
||||
thiz.Get(L, top + 1, out val.<%=fieldInfo.Name%>);
|
||||
}
|
||||
LuaAPI.lua_pop(L, 1);
|
||||
<%end)%>
|
||||
}<%if not type_info.Type.IsValueType then%>
|
||||
else if (type == LuaTypes.LUA_TNIL || type == LuaTypes.LUA_TNONE)
|
||||
{
|
||||
val = null;
|
||||
}<%end%>
|
||||
else
|
||||
{
|
||||
throw new Exception("can not cast " + LuaAPI.lua_type(L, index) + " to " + typeof(<%=full_type_name%>));
|
||||
}
|
||||
}
|
||||
<%end)%>
|
||||
|
||||
}
|
||||
|
||||
public partial class StaticLuaCallbacks_Wrap
|
||||
{
|
||||
internal static bool __tryArrayGet(Type type, RealStatePtr L, ObjectTranslator translator, object obj, int index)
|
||||
{
|
||||
<%ForEachCsList(purevaluetypes, function(type_info, idx)
|
||||
if not type_info.Type.IsValueType then return end
|
||||
local full_type_name = CsFullTypeName(type_info.Type)
|
||||
%>
|
||||
<%=(idx == 0 and '' or 'else ')%>if (type == typeof(<%=full_type_name%>[]))
|
||||
{
|
||||
<%=full_type_name%>[] array = obj as <%=full_type_name%>[];
|
||||
translator.Push<%=CSVariableName(type_info.Type)%>(L, array[index]);
|
||||
return true;
|
||||
}<%
|
||||
end)%>
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool __tryArraySet(Type type, RealStatePtr L, ObjectTranslator translator, object obj, int array_idx, int obj_idx)
|
||||
{
|
||||
<%
|
||||
local is_first = true
|
||||
ForEachCsList(purevaluetypes, tableoptimzetypes, function(type_info)
|
||||
local full_type_name = CsFullTypeName(type_info.Type)
|
||||
%>
|
||||
<%=(is_first and '' or 'else ')%>if (type == typeof(<%=full_type_name%>[]))
|
||||
{
|
||||
<%=full_type_name%>[] array = obj as <%=full_type_name%>[];
|
||||
translator.Get(L, obj_idx, out array[array_idx]);
|
||||
return true;
|
||||
}<%
|
||||
is_first = false
|
||||
end)%>
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d1a916469d261d447972d287b6c5b7a0
|
||||
timeCreated: 1481620508
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,243 @@
|
|||
#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 System;
|
||||
<%
|
||||
require "TemplateCommon"
|
||||
%>
|
||||
|
||||
namespace XLua
|
||||
{
|
||||
public static partial class CopyByValue_Gen
|
||||
{
|
||||
//-------------------------- CopyByValueBase ---------------------------------//
|
||||
public static bool Pack(IntPtr buff, int offset, byte field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_int8_t(buff, offset, field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out byte field)
|
||||
{
|
||||
return LuaAPI.xlua_unpack_int8_t(buff, offset, out field);
|
||||
}
|
||||
public static bool Pack(IntPtr buff, int offset, sbyte field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_int8_t(buff, offset, (byte)field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out sbyte field)
|
||||
{
|
||||
byte tfield;
|
||||
bool ret = LuaAPI.xlua_unpack_int8_t(buff, offset, out tfield);
|
||||
field = (sbyte)tfield;
|
||||
return ret;
|
||||
}
|
||||
// for int16
|
||||
public static bool Pack(IntPtr buff, int offset, short field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_int16_t(buff, offset, field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out short field)
|
||||
{
|
||||
return LuaAPI.xlua_unpack_int16_t(buff, offset, out field);
|
||||
}
|
||||
public static bool Pack(IntPtr buff, int offset, ushort field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_int16_t(buff, offset, (short)field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out ushort field)
|
||||
{
|
||||
short tfield;
|
||||
bool ret = LuaAPI.xlua_unpack_int16_t(buff, offset, out tfield);
|
||||
field = (ushort)tfield;
|
||||
return ret;
|
||||
}
|
||||
// for int32
|
||||
public static bool Pack(IntPtr buff, int offset, int field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_int32_t(buff, offset, field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out int field)
|
||||
{
|
||||
return LuaAPI.xlua_unpack_int32_t(buff, offset, out field);
|
||||
}
|
||||
public static bool Pack(IntPtr buff, int offset, uint field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_int32_t(buff, offset, (int)field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out uint field)
|
||||
{
|
||||
int tfield;
|
||||
bool ret = LuaAPI.xlua_unpack_int32_t(buff, offset, out tfield);
|
||||
field = (uint)tfield;
|
||||
return ret;
|
||||
}
|
||||
// for int64
|
||||
public static bool Pack(IntPtr buff, int offset, long field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_int64_t(buff, offset, field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out long field)
|
||||
{
|
||||
return LuaAPI.xlua_unpack_int64_t(buff, offset, out field);
|
||||
}
|
||||
public static bool Pack(IntPtr buff, int offset, ulong field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_int64_t(buff, offset, (long)field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out ulong field)
|
||||
{
|
||||
long tfield;
|
||||
bool ret = LuaAPI.xlua_unpack_int64_t(buff, offset, out tfield);
|
||||
field = (ulong)tfield;
|
||||
return ret;
|
||||
}
|
||||
// for float
|
||||
public static bool Pack(IntPtr buff, int offset, float field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_float(buff, offset, field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out float field)
|
||||
{
|
||||
return LuaAPI.xlua_unpack_float(buff, offset, out field);
|
||||
}
|
||||
// for double
|
||||
public static bool Pack(IntPtr buff, int offset, double field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_double(buff, offset, field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out double field)
|
||||
{
|
||||
return LuaAPI.xlua_unpack_double(buff, offset, out field);
|
||||
}
|
||||
// for decimal
|
||||
public static bool Pack(IntPtr buff, int offset, decimal field)
|
||||
{
|
||||
return LuaAPI.xlua_pack_decimal(buff, offset, ref field);
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out decimal field)
|
||||
{
|
||||
byte scale;
|
||||
byte sign;
|
||||
int hi32;
|
||||
ulong lo64;
|
||||
if (!LuaAPI.xlua_unpack_decimal(buff, offset, out scale, out sign, out hi32, out lo64))
|
||||
{
|
||||
field = default(decimal);
|
||||
return false;
|
||||
}
|
||||
|
||||
field = new Decimal((int)(lo64 & 0xFFFFFFFF), (int)(lo64 >> 32), hi32, (sign & 0x80) != 0, scale);
|
||||
return true;
|
||||
}
|
||||
//-------------------------- CopyByValueBase ---------------------------------//
|
||||
|
||||
<%ForEachCsList(type_infos, function(type_info)
|
||||
local full_type_name = CsFullTypeName(type_info.Type)
|
||||
%>
|
||||
<%if type_info.IsRoot then
|
||||
ForEachCsList(type_info.FieldInfos, function(fieldInfo) fieldInfo.Name = UnK(fieldInfo.Name) end)
|
||||
%>
|
||||
public static void UnPack(ObjectTranslator translator, RealStatePtr L, int idx, out <%=full_type_name%> val)
|
||||
{
|
||||
val = new <%=full_type_name%>();
|
||||
int top = LuaAPI.lua_gettop(L);
|
||||
<%ForEachCsList(type_info.FieldInfos, function(fieldInfo)%>
|
||||
if (Utils.LoadField(L, idx, "<%=fieldInfo.Name%>"))
|
||||
{
|
||||
<%if fieldInfo.IsField then%>
|
||||
translator.Get(L, top + 1, out val.<%=fieldInfo.Name%>);
|
||||
<%else%>
|
||||
var <%=fieldInfo.Name%> = val.<%=fieldInfo.Name%>;
|
||||
translator.Get(L, top + 1, out <%=fieldInfo.Name%>);
|
||||
val.<%=fieldInfo.Name%> = <%=fieldInfo.Name%>;
|
||||
<%end%>
|
||||
}
|
||||
LuaAPI.lua_pop(L, 1);
|
||||
<%end)%>
|
||||
}
|
||||
<%end%>
|
||||
public static bool Pack(IntPtr buff, int offset, <%=full_type_name%> field)
|
||||
{
|
||||
<%
|
||||
local offset_inner = 0
|
||||
if not type_info.FieldGroup then
|
||||
ForEachCsList(type_info.FieldInfos, function(fieldInfo)
|
||||
%>
|
||||
if(!Pack(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%>, field.<%=fieldInfo.Name%>))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
<%
|
||||
offset_inner = offset_inner + fieldInfo.Size
|
||||
end)
|
||||
else
|
||||
ForEachCsList(type_info.FieldGroup, function(group)
|
||||
%>
|
||||
if(!LuaAPI.xlua_pack_float<%=(group.Count == 1 and "" or group.Count)%>(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%><%
|
||||
ForEachCsList(group, function(fieldInfo, i)
|
||||
%>, field.<%=fieldInfo.Name%><%
|
||||
end)
|
||||
%>))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
<%
|
||||
offset_inner = offset_inner + group.Count * 4
|
||||
end)
|
||||
end%>
|
||||
return true;
|
||||
}
|
||||
public static bool UnPack(IntPtr buff, int offset, out <%=full_type_name%> field)
|
||||
{
|
||||
field = default(<%=full_type_name%>);
|
||||
<%
|
||||
local offset_inner = 0
|
||||
if not type_info.FieldGroup then
|
||||
ForEachCsList(type_info.FieldInfos, function(fieldInfo)
|
||||
if fieldInfo.IsField then
|
||||
%>
|
||||
if(!UnPack(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%>, out field.<%=fieldInfo.Name%>))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
<%else%>
|
||||
var <%=fieldInfo.Name%> = field.<%=fieldInfo.Name%>;
|
||||
if(!UnPack(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%>, out <%=fieldInfo.Name%>))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
field.<%=fieldInfo.Name%> = <%=fieldInfo.Name%>;
|
||||
<%
|
||||
end
|
||||
offset_inner = offset_inner + fieldInfo.Size
|
||||
end)
|
||||
else
|
||||
ForEachCsList(type_info.FieldGroup, function(group)
|
||||
%>
|
||||
<%ForEachCsList(group, function(fieldInfo)%>float <%=fieldInfo.Name%> = default(float);
|
||||
<%end)%>
|
||||
if(!LuaAPI.xlua_unpack_float<%=(group.Count == 1 and "" or group.Count)%>(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%><%
|
||||
ForEachCsList(group, function(fieldInfo)
|
||||
%>, out <%=fieldInfo.Name%><%
|
||||
end)
|
||||
%>))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
<%ForEachCsList(group, function(fieldInfo)%>field.<%=fieldInfo.Name%> = <%=fieldInfo.Name%>;
|
||||
<%end)%>
|
||||
<%
|
||||
offset_inner = offset_inner + group.Count * 4
|
||||
end)
|
||||
end%>
|
||||
return true;
|
||||
}
|
||||
<%end)%>
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c9ef7e8f2a3b37744aad49b99370c16b
|
||||
timeCreated: 1481620508
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,471 @@
|
|||
-- 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.
|
||||
|
||||
local friendlyNameMap = {
|
||||
["System.Object"] = "object",
|
||||
["System.String"] = "string",
|
||||
["System.Boolean"] = "bool",
|
||||
["System.Byte"] = "byte",
|
||||
["System.Char"] = "char",
|
||||
["System.Decimal"] = "decimal",
|
||||
["System.Double"] = "double",
|
||||
["System.Int16"] = "short",
|
||||
["System.Int32"] = "int",
|
||||
["System.Int64"] = "long",
|
||||
["System.SByte"] = "sbyte",
|
||||
["System.Single"] = "float",
|
||||
["System.UInt16"] = "ushort",
|
||||
["System.UInt32"] = "uint",
|
||||
["System.UInt64"] = "ulong",
|
||||
["System.Void"] = "void",
|
||||
}
|
||||
|
||||
local csKeywords = {
|
||||
"abstract", "as", "base", "bool",
|
||||
"break", "byte", "case", "catch",
|
||||
"char", "checked", "class", "const",
|
||||
"continue", "decimal", "default", "delegate",
|
||||
"do", "double", "else", "enum",
|
||||
"event", "explicit", "extern", "false",
|
||||
"finally", "fixed", "float", "for",
|
||||
"foreach", "goto", "if", "implicit",
|
||||
"in", "int", "interface",
|
||||
"internal", "is", "lock", "long",
|
||||
"namespace", "new", "null", "object",
|
||||
"operator", "out", "override",
|
||||
"params", "private", "protected", "public",
|
||||
"readonly", "ref", "return", "sbyte",
|
||||
"sealed", "short", "sizeof", "stackalloc",
|
||||
"static", "string", "struct", "switch",
|
||||
"this", "throw", "true", "try",
|
||||
"typeof", "uint", "ulong", "unchecked",
|
||||
"unsafe", "ushort", "using", "virtual",
|
||||
"void", "volatile", "while"
|
||||
}
|
||||
|
||||
for _, kw in ipairs(csKeywords) do
|
||||
csKeywords[kw] = '@'..kw
|
||||
end
|
||||
for i = 1, #csKeywords do
|
||||
csKeywords[i] = nil
|
||||
end
|
||||
|
||||
function UnK(symbol)
|
||||
return csKeywords[symbol] or symbol
|
||||
end
|
||||
|
||||
local fixChecker = {
|
||||
--["System.String"] = "LuaAPI.lua_isstring",
|
||||
["System.Boolean"] = "LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type",
|
||||
["System.Byte"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.Char"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
--["System.Decimal"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.Double"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.Int16"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.Int32"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
--["System.Int64"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.SByte"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.Single"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.UInt16"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.UInt32"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
--["System.UInt64"] = "LuaTypes.LUA_TNUMBER == LuaAPI.lua_type",
|
||||
["System.IntPtr"] = "LuaTypes.LUA_TLIGHTUSERDATA == LuaAPI.lua_type",
|
||||
}
|
||||
|
||||
local typedCaster = {
|
||||
["System.Byte"] = "LuaAPI.xlua_tointeger",
|
||||
["System.Char"] = "LuaAPI.xlua_tointeger",
|
||||
["System.Int16"] = "LuaAPI.xlua_tointeger",
|
||||
["System.SByte"] = "LuaAPI.xlua_tointeger",
|
||||
["System.Single"] = "LuaAPI.lua_tonumber",
|
||||
["System.UInt16"] = "LuaAPI.xlua_tointeger",
|
||||
}
|
||||
|
||||
local fixCaster = {
|
||||
["System.Double"] = "LuaAPI.lua_tonumber",
|
||||
["System.String"] = "LuaAPI.lua_tostring",
|
||||
["System.Boolean"] = "LuaAPI.lua_toboolean",
|
||||
["System.Byte[]"] = "LuaAPI.lua_tobytes",
|
||||
["System.IntPtr"] = "LuaAPI.lua_touserdata",
|
||||
["System.UInt32"] = "LuaAPI.xlua_touint",
|
||||
["System.UInt64"] = "LuaAPI.lua_touint64",
|
||||
["System.Int32"] = "LuaAPI.xlua_tointeger",
|
||||
["System.Int64"] = "LuaAPI.lua_toint64",
|
||||
}
|
||||
|
||||
local fixPush = {
|
||||
["System.Byte"] = "LuaAPI.xlua_pushinteger",
|
||||
["System.Char"] = "LuaAPI.xlua_pushinteger",
|
||||
["System.Int16"] = "LuaAPI.xlua_pushinteger",
|
||||
["System.Int32"] = "LuaAPI.xlua_pushinteger",
|
||||
["System.Int64"] = "LuaAPI.lua_pushint64",
|
||||
["System.SByte"] = "LuaAPI.xlua_pushinteger",
|
||||
["System.Single"] = "LuaAPI.lua_pushnumber",
|
||||
["System.UInt16"] = "LuaAPI.xlua_pushinteger",
|
||||
["System.UInt32"] = "LuaAPI.xlua_pushuint",
|
||||
["System.UInt64"] = "LuaAPI.lua_pushuint64",
|
||||
["System.Double"] = "LuaAPI.lua_pushnumber",
|
||||
["System.String"] = "LuaAPI.lua_pushstring",
|
||||
["System.Byte[]"] = "LuaAPI.lua_pushstring",
|
||||
["System.Boolean"] = "LuaAPI.lua_pushboolean",
|
||||
["System.IntPtr"] = "LuaAPI.lua_pushlightuserdata",
|
||||
["System.Decimal"] = "translator.PushDecimal",
|
||||
["System.Object"] = "translator.PushAny",
|
||||
}
|
||||
|
||||
local notranslator = {
|
||||
["System.Byte"] = true,
|
||||
["System.Char"] = true,
|
||||
["System.Int16"] = true,
|
||||
["System.Int32"] = true,
|
||||
["System.Int64"] = true,
|
||||
["System.SByte"] = true,
|
||||
["System.Single"] = true,
|
||||
["System.UInt16"] = true,
|
||||
["System.UInt32"] = true,
|
||||
["System.UInt64"] = true,
|
||||
["System.Double"] = true,
|
||||
["System.String"] = true,
|
||||
["System.Boolean"] = true,
|
||||
["System.Void"] = true,
|
||||
["System.IntPtr"] = true,
|
||||
["System.Byte[]"] = true,
|
||||
}
|
||||
|
||||
function ForEachCsList(...)
|
||||
local list_count = select('#', ...) - 1
|
||||
local callback = select(list_count + 1, ...)
|
||||
for i = 1, list_count do
|
||||
local list = select(i, ...)
|
||||
for i = 0, (list.Count or list.Length) - 1 do
|
||||
callback(list[i], i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function CalcCsList(list, predicate)
|
||||
local count = 0
|
||||
for i = 0, (list.Count or list.Length) - 1 do
|
||||
if predicate(list[i], i) then count = count + 1 end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
function IfAny(list, predicate)
|
||||
for i = 0, (list.Count or list.Length) - 1 do
|
||||
if predicate(list[i], i) then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local genPushAndUpdateTypes
|
||||
|
||||
function SetGenPushAndUpdateTypes(list)
|
||||
genPushAndUpdateTypes = {}
|
||||
ForEachCsList(list, function(t)
|
||||
genPushAndUpdateTypes[t] = true
|
||||
end)
|
||||
end
|
||||
|
||||
local xLuaClasses
|
||||
function SetXLuaClasses(list)
|
||||
xLuaClasses = {}
|
||||
ForEachCsList(list, function(t)
|
||||
xLuaClasses[t.Name] = true
|
||||
end)
|
||||
end
|
||||
|
||||
local objType = typeof(CS.System.Object)
|
||||
local valueType = typeof(CS.System.ValueType)
|
||||
|
||||
local function _CsFullTypeName(t)
|
||||
if t.IsArray then
|
||||
local element_name, element_is_array = _CsFullTypeName(t:GetElementType())
|
||||
if element_is_array then
|
||||
local bracket_pos = element_name:find('%[')
|
||||
return element_name:sub(1, bracket_pos - 1) .. '[' .. string.rep(',', t:GetArrayRank() - 1) .. ']' .. element_name:sub(bracket_pos, -1), true
|
||||
else
|
||||
return element_name .. '[' .. string.rep(',', t:GetArrayRank() - 1) .. ']', true
|
||||
end
|
||||
elseif t.IsByRef then
|
||||
return _CsFullTypeName(t:GetElementType())
|
||||
elseif t.IsGenericParameter then
|
||||
return (t.BaseType == objType or t.BaseType == valueType) and t.Name or _CsFullTypeName(t.BaseType) --TODO:应该判断是否类型约束
|
||||
end
|
||||
|
||||
local name = t.FullName:gsub("&", ""):gsub("%+", ".")
|
||||
if not t.IsGenericType then
|
||||
return friendlyNameMap[name] or name
|
||||
end
|
||||
local genericParameter = ""
|
||||
ForEachCsList(t:GetGenericArguments(), function(at, ati)
|
||||
if ati ~= 0 then genericParameter = genericParameter .. ', ' end
|
||||
genericParameter = genericParameter .. _CsFullTypeName(at)
|
||||
end)
|
||||
return name:gsub("`%d+", '<' .. genericParameter .. '>'):gsub("%[[^,%]].*", ""), false
|
||||
end
|
||||
|
||||
function CsFullTypeName(t)
|
||||
if t.DeclaringType then
|
||||
local name = _CsFullTypeName(t)
|
||||
local declaringTypeName = _CsFullTypeName(t.DeclaringType);
|
||||
return xLuaClasses[declaringTypeName] and ("global::" .. name) or name
|
||||
else
|
||||
local name = _CsFullTypeName(t)
|
||||
return xLuaClasses[name] and ("global::" .. name) or name
|
||||
end
|
||||
end
|
||||
|
||||
function CSVariableName(t)
|
||||
if t.IsArray then
|
||||
return CSVariableName(t:GetElementType()) .. '_'.. t:GetArrayRank() ..'_'
|
||||
end
|
||||
return t:ToString():gsub("&", ""):gsub("%+", ""):gsub("`", "_"):gsub("%.", ""):gsub("%[", "_"):gsub("%]", "_"):gsub(",", "")
|
||||
end
|
||||
|
||||
local function getSafeFullName(t)
|
||||
if t == nil then
|
||||
return ""
|
||||
end
|
||||
|
||||
if t.IsGenericParameter then
|
||||
return t.BaseType == objType and t.Name or getSafeFullName(t.BaseType)
|
||||
end
|
||||
|
||||
if not t.FullName then return "" end
|
||||
|
||||
return t.FullName:gsub("&", "")
|
||||
end
|
||||
|
||||
function GetCheckStatement(t, idx, is_v_params)
|
||||
local cond_start = is_v_params and "(LuaTypes.LUA_TNONE == LuaAPI.lua_type(L, ".. idx ..") || " or ""
|
||||
local cond_end = is_v_params and ")" or ""
|
||||
local testname = getSafeFullName(t)
|
||||
if testname == "System.String" or testname == "System.Byte[]" then
|
||||
return cond_start .. "(LuaAPI.lua_isnil(L, " .. idx .. ") || LuaAPI.lua_type(L, ".. idx ..") == LuaTypes.LUA_TSTRING)" .. cond_end
|
||||
elseif testname == "System.Int64" then
|
||||
return cond_start .. "(LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, ".. idx ..") || LuaAPI.lua_isint64(L, ".. idx .."))" .. cond_end
|
||||
elseif testname == "System.UInt64" then
|
||||
return cond_start .. "(LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, ".. idx ..") || LuaAPI.lua_isuint64(L, ".. idx .."))" .. cond_end
|
||||
elseif testname == "System.Decimal" then
|
||||
return cond_start .. "(LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, ".. idx ..") || translator.IsDecimal(L, ".. idx .."))" .. cond_end
|
||||
elseif testname == "XLua.LuaTable" then
|
||||
return cond_start .. "(LuaAPI.lua_isnil(L, " .. idx .. ") || LuaAPI.lua_type(L, ".. idx ..") == LuaTypes.LUA_TTABLE)" .. cond_end
|
||||
elseif testname == "XLua.LuaFunction" then
|
||||
return cond_start .. "(LuaAPI.lua_isnil(L, " .. idx .. ") || LuaAPI.lua_type(L, ".. idx ..") == LuaTypes.LUA_TFUNCTION)" .. cond_end
|
||||
end
|
||||
return cond_start .. (fixChecker[testname] or ("translator.Assignable<" .. CsFullTypeName(t).. ">")) .. "(L, ".. idx ..")" .. cond_end
|
||||
end
|
||||
|
||||
local delegateType = typeof(CS.System.Delegate)
|
||||
local ExtensionAttribute = typeof(CS.System.Runtime.CompilerServices.ExtensionAttribute)
|
||||
|
||||
function IsExtensionMethod(method)
|
||||
return method:IsDefined(ExtensionAttribute, false)
|
||||
end
|
||||
|
||||
function IsDelegate(t)
|
||||
return delegateType:IsAssignableFrom(t)
|
||||
end
|
||||
|
||||
function MethodParameters(method)
|
||||
if not IsExtensionMethod(method) then
|
||||
return method:GetParameters()
|
||||
else
|
||||
local parameters = method:GetParameters()
|
||||
if parameters[0].ParameterType.IsInterface then
|
||||
return parameters
|
||||
end
|
||||
local ret = {}
|
||||
for i = 1, parameters.Length - 1 do
|
||||
ret[i - 1] = parameters[i]
|
||||
end
|
||||
ret.Length = parameters.Length - 1
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
function IsStruct(t)
|
||||
if t.IsByRef then t = t:GetElementType() end
|
||||
return t.IsValueType and not t.IsPrimitive
|
||||
end
|
||||
|
||||
function NeedUpdate(t)
|
||||
if t.IsByRef then t = t:GetElementType() end
|
||||
return t.IsValueType and not t.IsPrimitive and not t.IsEnum and t ~= typeof(CS.System.Decimal)
|
||||
end
|
||||
|
||||
function GetCasterStatement(t, idx, var_name, need_declare, is_v_params)
|
||||
local testname = getSafeFullName(t)
|
||||
local statement = ""
|
||||
local is_struct = IsStruct(t)
|
||||
|
||||
if need_declare then
|
||||
statement = CsFullTypeName(t) .. " " .. var_name
|
||||
if is_struct and not typedCaster[testname] and not fixCaster[testname] then
|
||||
statement = statement .. ";"
|
||||
else
|
||||
statement = statement .. " = "
|
||||
end
|
||||
elseif not is_struct then
|
||||
statement = var_name .. " = "
|
||||
end
|
||||
|
||||
if is_v_params then
|
||||
return statement .. "translator.GetParams<" .. CsFullTypeName(t:GetElementType()).. ">" .. "(L, ".. idx ..")"
|
||||
elseif typedCaster[testname] then
|
||||
return statement .. "(" .. CsFullTypeName(t) .. ")" ..typedCaster[testname] .. "(L, ".. idx ..")"
|
||||
elseif IsDelegate(t) then
|
||||
return statement .. "translator.GetDelegate<" .. CsFullTypeName(t).. ">" .. "(L, ".. idx ..")"
|
||||
elseif fixCaster[testname] then
|
||||
return statement .. fixCaster[testname] .. "(L, ".. idx ..")"
|
||||
elseif testname == "System.Object" then
|
||||
return statement .. "translator.GetObject(L, ".. idx ..", typeof(" .. CsFullTypeName(t) .."))"
|
||||
elseif is_struct then
|
||||
return statement .. "translator.Get(L, ".. idx ..", out " .. var_name .. ")"
|
||||
elseif t.IsGenericParameter and not t.DeclaringMethod then
|
||||
return statement .. "translator.GetByType<"..t.Name..">(L, ".. idx ..")"
|
||||
else
|
||||
return statement .. "("..CsFullTypeName(t)..")translator.GetObject(L, ".. idx ..", typeof(" .. CsFullTypeName(t) .."))"
|
||||
end
|
||||
end
|
||||
|
||||
local paramsAttriType = typeof(CS.System.ParamArrayAttribute)
|
||||
function IsParams(pi)
|
||||
if (not pi.IsDefined) then
|
||||
return pi.IsParamArray
|
||||
end
|
||||
return pi:IsDefined(paramsAttriType, false)
|
||||
end
|
||||
|
||||
local obsoluteAttriType = typeof(CS.System.ObsoleteAttribute)
|
||||
function IsObsolute(f)
|
||||
return f:IsDefined(obsoluteAttriType, false)
|
||||
end
|
||||
|
||||
local objectType = typeof(CS.System.Object)
|
||||
function GetSelfStatement(t)
|
||||
local fulltypename = CsFullTypeName(t)
|
||||
local is_struct = IsStruct(t)
|
||||
if is_struct then
|
||||
return fulltypename .. " gen_to_be_invoked;translator.Get(L, 1, out gen_to_be_invoked)"
|
||||
else
|
||||
if t == objectType then
|
||||
return "object gen_to_be_invoked = translator.FastGetCSObj(L, 1)"
|
||||
else
|
||||
return fulltypename .. " gen_to_be_invoked = (" .. fulltypename .. ")translator.FastGetCSObj(L, 1)"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local GetNullableUnderlyingType = CS.System.Nullable.GetUnderlyingType
|
||||
|
||||
function GetPushStatement(t, variable, is_v_params)
|
||||
if is_v_params then
|
||||
local item_push = GetPushStatement(t:GetElementType(), variable..'[__gen_i]')
|
||||
return 'if ('.. variable ..' != null) { for (int __gen_i = 0; __gen_i < ' .. variable .. '.Length; ++__gen_i) ' .. item_push .. '; }'
|
||||
end
|
||||
if t.IsByRef then t = t:GetElementType() end
|
||||
local testname = getSafeFullName(t)
|
||||
if fixPush[testname] then
|
||||
return fixPush[testname] .. "(L, ".. variable ..")"
|
||||
elseif genPushAndUpdateTypes[t] then
|
||||
return "translator.Push".. CSVariableName(t) .."(L, "..variable..")"
|
||||
elseif t.IsGenericParameter and not t.DeclaringMethod then
|
||||
return "translator.PushByType(L, "..variable..")"
|
||||
elseif t.IsInterface or GetNullableUnderlyingType(t) then
|
||||
return "translator.PushAny(L, "..variable..")"
|
||||
else
|
||||
return "translator.Push(L, "..variable..")"
|
||||
end
|
||||
end
|
||||
|
||||
function GetUpdateStatement(t, idx, variable)
|
||||
if t.IsByRef then t = t:GetElementType() end
|
||||
if typeof(CS.System.Decimal) == t then error('Decimal not update!') end
|
||||
if genPushAndUpdateTypes[t] then
|
||||
return "translator.Update".. CSVariableName(t) .."(L, ".. idx ..", "..variable..")"
|
||||
else
|
||||
return "translator.Update(L, ".. idx ..", "..variable..")"
|
||||
end
|
||||
end
|
||||
|
||||
function JustLuaType(t)
|
||||
return notranslator[getSafeFullName(t)]
|
||||
end
|
||||
|
||||
function CallNeedTranslator(overload, isdelegate)
|
||||
if not overload.IsStatic and not isdelegate then return true end
|
||||
local ret_type_name = getSafeFullName(overload.ReturnType)
|
||||
if not notranslator[ret_type_name] then return true end
|
||||
local parameters = overload:GetParameters()
|
||||
return IfAny(overload:GetParameters(), function(parameter)
|
||||
return IsParams(parameter) or (not notranslator[getSafeFullName(parameter.ParameterType)])
|
||||
end)
|
||||
end
|
||||
|
||||
function MethodCallNeedTranslator(method)
|
||||
return IfAny(method.Overloads, function(overload) return CallNeedTranslator(overload) end)
|
||||
end
|
||||
|
||||
function AccessorNeedTranslator(accessor)
|
||||
return not accessor.IsStatic or not JustLuaType(accessor.Type)
|
||||
end
|
||||
|
||||
function PushObjectNeedTranslator(type_info)
|
||||
return IfAny(type_info.FieldInfos, function(field_info) return not JustLuaType(field_info.Type) end)
|
||||
end
|
||||
|
||||
local GenericParameterAttributes = CS.System.Reflection.GenericParameterAttributes
|
||||
local enum_and_op = debug.getmetatable(CS.System.Reflection.BindingFlags.Public).__band
|
||||
local has_generic_flag = function(f1, f2)
|
||||
return (f1 ~= GenericParameterAttributes.None) and (enum_and_op(f1, f2) == f2)
|
||||
end
|
||||
|
||||
function GenericArgumentList(type)
|
||||
local generic_arg_list = ""
|
||||
local type_constraints = ""
|
||||
if type.IsGenericTypeDefinition then
|
||||
generic_arg_list = "<"
|
||||
|
||||
local constraints = {}
|
||||
|
||||
ForEachCsList(type:GetGenericArguments(), function(generic_arg, gai)
|
||||
local constraint = {}
|
||||
if gai ~= 0 then generic_arg_list = generic_arg_list .. ", " end
|
||||
|
||||
generic_arg_list = generic_arg_list .. generic_arg.Name
|
||||
|
||||
if has_generic_flag(generic_arg.GenericParameterAttributes, GenericParameterAttributes.ReferenceTypeConstraint) then
|
||||
table.insert(constraint, 'class')
|
||||
end
|
||||
if has_generic_flag(generic_arg.GenericParameterAttributes, GenericParameterAttributes.NotNullableValueTypeConstraint) then
|
||||
table.insert(constraint, 'struct')
|
||||
end
|
||||
ForEachCsList(generic_arg:GetGenericParameterConstraints(), function(gpc)
|
||||
if gpc ~= typeof(CS.System.ValueType) or not has_generic_flag(generic_arg.GenericParameterAttributes, GenericParameterAttributes.NotNullableValueTypeConstraint) then
|
||||
table.insert(constraint, CsFullTypeName(gpc))
|
||||
end
|
||||
end)
|
||||
if not has_generic_flag(generic_arg.GenericParameterAttributes, GenericParameterAttributes.NotNullableValueTypeConstraint) and has_generic_flag(generic_arg.GenericParameterAttributes, GenericParameterAttributes.DefaultConstructorConstraint) then
|
||||
table.insert(constraint, 'new()')
|
||||
end
|
||||
if #constraint > 0 then
|
||||
table.insert(constraints, 'where ' .. generic_arg.Name .. ' : ' .. table.concat(constraint, ','))
|
||||
end
|
||||
end)
|
||||
generic_arg_list = generic_arg_list .. ">"
|
||||
if #constraints > 0 then
|
||||
type_constraints = table.concat(constraints, ',')
|
||||
end
|
||||
end
|
||||
return generic_arg_list, type_constraints
|
||||
end
|
||||
|
||||
function LocalName(name)
|
||||
return "_" .. name
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cb41d53afe75a9443b182e284298feeb
|
||||
TextScriptImporter:
|
||||
userData:
|
|
@ -0,0 +1,20 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
namespace XLua
|
||||
{
|
||||
public class TemplateRef : ScriptableObject
|
||||
{
|
||||
public TextAsset LuaClassWrap;
|
||||
public TextAsset LuaClassWrapGCM;
|
||||
public TextAsset LuaDelegateBridge;
|
||||
public TextAsset LuaDelegateWrap;
|
||||
public TextAsset LuaEnumWrap;
|
||||
public TextAsset LuaEnumWrapGCM;
|
||||
public TextAsset LuaInterfaceBridge;
|
||||
public TextAsset LuaRegister;
|
||||
public TextAsset LuaRegisterGCM;
|
||||
public TextAsset LuaWrapPusher;
|
||||
public TextAsset PackUnpack;
|
||||
public TextAsset TemplateCommon;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4898604144dd928468ddca1af81d58ae
|
||||
timeCreated: 1501232546
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- LuaClassWrap: {fileID: 4900000, guid: 8503038eabbabe44dac0f5f749d4411a, type: 3}
|
||||
- LuaClassWrapGCM: {fileID: 4900000, guid: 2bd79d95fd859724283926ad8fa4df30, type: 3}
|
||||
- LuaDelegateBridge: {fileID: 4900000, guid: 3d992756e2469044484be75f78e4e556, type: 3}
|
||||
- LuaDelegateWrap: {fileID: 4900000, guid: 33b33e1cd617f794b8c801a32f3b2539, type: 3}
|
||||
- LuaEnumWrap: {fileID: 4900000, guid: ae16c73aad9a21a44aef65decb7e4928, type: 3}
|
||||
- LuaEnumWrapGCM: {fileID: 4900000, guid: ea84a5ee7abf8e347a810eb7848add46, type: 3}
|
||||
- LuaInterfaceBridge: {fileID: 4900000, guid: 7165d08e91378494dadeb10e5338accb,
|
||||
type: 3}
|
||||
- LuaRegister: {fileID: 4900000, guid: e416b82ec9fe340458f97cf1e3468ef7, type: 3}
|
||||
- LuaRegisterGCM: {fileID: 4900000, guid: 46c7366d55afbf1459674448d92c44c8, type: 3}
|
||||
- LuaWrapPusher: {fileID: 4900000, guid: d1a916469d261d447972d287b6c5b7a0, type: 3}
|
||||
- PackUnpack: {fileID: 4900000, guid: c9ef7e8f2a3b37744aad49b99370c16b, type: 3}
|
||||
- TemplateCommon: {fileID: 4900000, guid: cb41d53afe75a9443b182e284298feeb, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "XLua.Editor",
|
||||
"references": [
|
||||
"XLua.Runtime"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": []
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5de0c54ac5cfb9a4e85d975178cc7d93
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
LICENSE
21
LICENSE
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Blank
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 83aee958b791de247ba84ca561634b40
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0004c0a5ad641d4468ebb65779ee48b2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9cd62bafd75e7604daf2b561b80d136d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 084116138e3349d48bdf50214aebefc5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6c76d1cfa11c6b741ba30b24d36cbcf2
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM64
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b8d0cd0f5702f0144af2498bce3ee3e9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e1b2e17cce240d4c8ff5457ac996e0d
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 079ea0ed741ff194a80cce029630b5ac
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 038a89637b659e346a7a712ce0c9271b
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b8c5688e381fddc4eb22e6f96f69541c
|
||||
folderAsset: yes
|
||||
timeCreated: 1489995541
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6375603a0a1e2647b0c426b27646eb7
|
||||
folderAsset: yes
|
||||
timeCreated: 1490146877
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cb3d94d8757d66b40b20f0386b52d01d
|
||||
timeCreated: 1490146878
|
||||
licenseType: Free
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
WindowsStoreApps:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e0658821e1f1a314390dc1cb00102456
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,27 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 75c6b295657fd8f41a932708ff01a6d0
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4d5a7116d7e9a33409205303635b8635
|
||||
folderAsset: yes
|
||||
timeCreated: 1490146877
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a73864467778862409da51f9feb60004
|
||||
timeCreated: 1490146878
|
||||
licenseType: Free
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
WindowsStoreApps:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x64
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e0f35de38a8ed24fa8b20d444c9ee5e
|
||||
folderAsset: yes
|
||||
timeCreated: 1490146877
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3fd23a6414095674493657a67a8043a1
|
||||
timeCreated: 1489995544
|
||||
licenseType: Free
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
WindowsStoreApps:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e7f3a5adb034d684cb13cb257c29a1c3
|
||||
folderAsset: yes
|
||||
timeCreated: 1504062948
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,41 @@
|
|||
extern "C" {
|
||||
#include "../../../WebGLPlugins/lapi.c"
|
||||
#include "../../../WebGLPlugins/lauxlib.c"
|
||||
#include "../../../WebGLPlugins/lbaselib.c"
|
||||
#include "../../../WebGLPlugins/lbitlib.c"
|
||||
#include "../../../WebGLPlugins/lcode.c"
|
||||
#include "../../../WebGLPlugins/lcorolib.c"
|
||||
#include "../../../WebGLPlugins/lctype.c"
|
||||
#include "../../../WebGLPlugins/ldblib.c"
|
||||
#include "../../../WebGLPlugins/ldebug.c"
|
||||
#include "../../../WebGLPlugins/ldo.c"
|
||||
#include "../../../WebGLPlugins/ldump.c"
|
||||
#include "../../../WebGLPlugins/lfunc.c"
|
||||
#include "../../../WebGLPlugins/lgc.c"
|
||||
#include "../../../WebGLPlugins/linit.c"
|
||||
#include "../../../WebGLPlugins/liolib.c"
|
||||
#include "../../../WebGLPlugins/llex.c"
|
||||
#include "../../../WebGLPlugins/lmathlib.c"
|
||||
#include "../../../WebGLPlugins/lmem.c"
|
||||
#include "../../../WebGLPlugins/loadlib.c"
|
||||
#include "../../../WebGLPlugins/lobject.c"
|
||||
#include "../../../WebGLPlugins/lopcodes.c"
|
||||
#include "../../../WebGLPlugins/loslib.c"
|
||||
#include "../../../WebGLPlugins/lparser.c"
|
||||
#include "../../../WebGLPlugins/lstate.c"
|
||||
#include "../../../WebGLPlugins/lstring.c"
|
||||
#include "../../../WebGLPlugins/lstrlib.c"
|
||||
#include "../../../WebGLPlugins/ltable.c"
|
||||
#include "../../../WebGLPlugins/ltablib.c"
|
||||
#include "../../../WebGLPlugins/ltm.c"
|
||||
#include "../../../WebGLPlugins/lundump.c"
|
||||
#include "../../../WebGLPlugins/lutf8lib.c"
|
||||
#include "../../../WebGLPlugins/lvm.c"
|
||||
#include "../../../WebGLPlugins/lzio.c"
|
||||
#include "../../../WebGLPlugins/i64lib.c"
|
||||
#include "../../../WebGLPlugins/perflib.c"
|
||||
#include "../../../WebGLPlugins/xlua.c"
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 92f9773841d5ffd44b794b9b584a5c05
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Facebook: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0b517828ca6b4d943aab4f9bb8f7512d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,63 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27cd65c4cc42b42f49caa94f462466de
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM64
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM64
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5a4ab2e5e00054b03a7bf96d03e5b4e1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -0,0 +1,37 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int* xlua_hotfix_flags = NULL;
|
||||
int xlua_hotfix_flags_len = 0;
|
||||
|
||||
extern "C" {
|
||||
|
||||
int xlua_get_hotfix_flag(int idx) {
|
||||
if (idx >= xlua_hotfix_flags_len) {
|
||||
return 0;
|
||||
} else {
|
||||
return xlua_hotfix_flags[idx];
|
||||
}
|
||||
}
|
||||
|
||||
void xlua_set_hotfix_flag(int idx, int flag) {
|
||||
int i = 0;
|
||||
int* new_hotfix_flags = NULL;
|
||||
if (idx >= xlua_hotfix_flags_len) {
|
||||
if (xlua_hotfix_flags == NULL) {
|
||||
xlua_hotfix_flags = (int*)malloc((idx + 1) * sizeof(int));
|
||||
} else {
|
||||
new_hotfix_flags = (int*)realloc(xlua_hotfix_flags, (idx + 1) * sizeof(int));
|
||||
if (NULL == new_hotfix_flags) { // just skip operation
|
||||
return;
|
||||
}
|
||||
xlua_hotfix_flags = new_hotfix_flags;
|
||||
}
|
||||
for(i = xlua_hotfix_flags_len; i < (idx + 1); i++) {
|
||||
xlua_hotfix_flags[i] = 0;
|
||||
}
|
||||
xlua_hotfix_flags_len = idx + 1;
|
||||
}
|
||||
xlua_hotfix_flags[idx] = flag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ef0ed550afe43d449b58d883fad0585c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2d65468f3356ca741b3fbebea91dfb6c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8b0b0c4ffe67d2f4292c5211de91e55f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
Binary file not shown.
|
@ -0,0 +1,107 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f19d785ae44ddc478a08a87ccd9dbb2
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Linux
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
: WP8
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,107 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 79f5c811b2e4e444ab2d97cad5cfd934
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Linux
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
: OSXIntel
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
: WP8
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8dba1dfb80e5b7d40bd214fc4ed2ed6b
|
||||
folderAsset: yes
|
||||
timeCreated: 1451020766
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,107 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1055830ddb882704fa71275ed9b2a78d
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
: WP8
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,107 @@
|
|||
fileFormatVersion: 2
|
||||
guid: abe4c5ca91772ea4fae0ae15603c10e4
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
: OSXIntel64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
: WP8
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,85 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6a34038df77e48438826b6ff94aa69e
|
||||
folderAsset: yes
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
: OSXIntel
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
: OSXIntel64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: OSX
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7e4b7549f5e4a4e71806e3ec8e428b15
|
||||
folderAsset: yes
|
||||
timeCreated: 1457422691
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>15G31</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>xlua</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.xlua</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>xlua</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>7D1014</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>15E60</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.11</string>
|
||||
<key>DTXcode</key>
|
||||
<string>0731</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>7D1014</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright @2017 THL A29 Limited, a Tencent company. All rights reserved.</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ac30af4fb2add4d41a9f50fe4f8292a3
|
||||
timeCreated: 1457422749
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c9d8e68fa0fd1465294f1255f6ed8563
|
||||
folderAsset: yes
|
||||
timeCreated: 1457422691
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6f3b1cda03ac84924b1ee0595fc019f5
|
||||
timeCreated: 1457422749
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
137
README.md
137
README.md
|
@ -1,2 +1,135 @@
|
|||
# com.tencent.xlua
|
||||
从XLua二次分发而来
|
||||
# 基于`com.tencent.xlua` 的二次修改
|
||||
|
||||
该库主要服务于 `https://github.com/AlianBlank/GameFrameX` 作为子库使用。
|
||||
|
||||
|
||||
# 使用方式(三种方式)
|
||||
1. 直接在 `manifest.json` 文件中添加以下内容
|
||||
```json
|
||||
{"com.tencent.xlua": "https://github.com/AlianBlank/com.tencent.xlua.git"}
|
||||
```
|
||||
2. 在Unity 的`Packages Manager` 中使用`Git URL` 的方式添加库,地址为:https://github.com/AlianBlank/com.tencent.xlua.git
|
||||
|
||||
3. 直接下载仓库放置到Unity 项目的`Packages` 目录下。会自动加载识别
|
||||
|
||||
# 改动功能
|
||||
|
||||
1. 移除开发机器的统计代码
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
![](Assets/XLua/Doc/xLua.png)
|
||||
|
||||
[![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Tencent/xLua/blob/master/LICENSE.TXT)
|
||||
[![release](https://img.shields.io/badge/release-v2.1.15-blue.svg)](https://github.com/Tencent/xLua/releases)
|
||||
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/Tencent/xLua/pulls)
|
||||
[![Build status](https://travis-ci.org/Tencent/xLua.svg?branch=master)](https://travis-ci.org/Tencent/xLua)
|
||||
|
||||
[(English Documents Available)](README_EN.md)
|
||||
|
||||
## C#下Lua编程支持
|
||||
|
||||
xLua为Unity、 .Net、 Mono等C#环境增加Lua脚本编程的能力,借助xLua,这些Lua代码可以方便的和C#相互调用。
|
||||
|
||||
## xLua的突破
|
||||
|
||||
xLua在功能、性能、易用性都有不少突破,这几方面分别最具代表性的是:
|
||||
|
||||
* 可以运行时把C#实现(方法,操作符,属性,事件等等)替换成lua实现;
|
||||
* 出色的GC优化,自定义struct,枚举在Lua和C#间传递无C# gc alloc;
|
||||
* 编辑器下无需生成代码,开发更轻量;
|
||||
|
||||
更详细的特性、平台支持介绍请看[这里](Assets/XLua/Doc/features.md)。
|
||||
|
||||
## 安装
|
||||
|
||||
打开zip包,你会看到一个Assets目录,这目录就对应Unity工程的Assets目录,保持这目录结构放到你的Unity工程。
|
||||
|
||||
如果希望安装到其它目录,请看[FAQ](Assets/XLua/Doc/faq.md)相关介绍。
|
||||
|
||||
## 文档
|
||||
|
||||
* [常见问题解答](Assets/XLua/Doc/faq.md):常见问题都总结在这里,初使用大多数问题都可以在这里找到答案。
|
||||
* (必看)[XLua教程](Assets/XLua/Doc/XLua教程.md):教程,其配套代码[这里](Assets/XLua/Tutorial/)。
|
||||
* (必看)[XLua的配置](Assets/XLua/Doc/configure.md):介绍如何配置xLua。
|
||||
* [热补丁操作指南](Assets/XLua/Doc/hotfix.md):介绍如何使用热补丁特性。
|
||||
* [XLua增加删除第三方lua库](Assets/XLua/Doc/XLua增加删除第三方lua库.md):如何增删第三方lua扩展库。
|
||||
* [XLua API](Assets/XLua/Doc/XLua_API.md):API文档。
|
||||
* [生成引擎二次开发指南](Assets/XLua/Doc/custom_generate.md):介绍如何做生成引擎的二次开发。
|
||||
|
||||
## 快速入门
|
||||
|
||||
一个完整的例子仅需3行代码:
|
||||
|
||||
安装好xLua,建一个MonoBehaviour拖到场景,在Start加入如下代码:
|
||||
|
||||
```csharp
|
||||
XLua.LuaEnv luaenv = new XLua.LuaEnv();
|
||||
luaenv.DoString("CS.UnityEngine.Debug.Log('hello world')");
|
||||
luaenv.Dispose();
|
||||
```
|
||||
|
||||
1、DoString参数为string,可输入任意合法的Lua代码,本示例在lua里调用C#的UnityEngine.Debug.Log打印了个日志。
|
||||
|
||||
2、一个LuaEnv实例对应Lua虚拟机,出于开销的考虑,建议全局唯一。
|
||||
|
||||
C#主动调用lua也很简单,比如要调用lua的系统函数,推荐方式是:
|
||||
|
||||
* 声明
|
||||
|
||||
```csharp
|
||||
[XLua.CSharpCallLua]
|
||||
public delegate double LuaMax(double a, double b);
|
||||
```
|
||||
|
||||
* 绑定
|
||||
|
||||
```csharp
|
||||
var max = luaenv.Global.GetInPath<LuaMax>("math.max");
|
||||
```
|
||||
|
||||
* 调用
|
||||
|
||||
```csharp
|
||||
Debug.Log("max:" + max(32, 12));
|
||||
```
|
||||
|
||||
建议绑定一次,重复使用。生成了代码的话,调用max是不产生gc alloc的。
|
||||
|
||||
## 热补丁
|
||||
|
||||
* 侵入性小,老项目原有代码不做任何调整就可使用。
|
||||
* 运行时影响小,不打补丁基本和原有程序一样。
|
||||
* 出问题了可以用Lua来打补丁,这时才会走到lua代码逻辑;
|
||||
|
||||
[这里](Assets/XLua/Doc/hotfix.md)是使用指南。
|
||||
|
||||
## 更多示例
|
||||
|
||||
* [01_Helloworld](Assets/XLua/Examples/01_Helloworld/): 快速入门的例子。
|
||||
* [02_U3DScripting](Assets/XLua/Examples/02_U3DScripting/): 展示怎么用lua来写MonoBehaviour。
|
||||
* [03_UIEvent](Assets/XLua/Examples/03_UIEvent/): 展示怎么用lua来写UI逻辑。
|
||||
* [04_LuaObjectOrented](Assets/XLua/Examples/04_LuaObjectOrented/): 展示lua面向对象和C#的配合。
|
||||
* [05_NoGc](Assets/XLua/Examples/05_NoGc/): 展示怎么去避免值类型的GC。
|
||||
* [06_Coroutine](Assets/XLua/Examples/06_Coroutine/): 展示lua协程怎么和Unity协程相配合。
|
||||
* [07_AsyncTest](Assets/XLua/Examples/07_AsyncTest/): 展示怎么用lua协程来把异步逻辑同步化。
|
||||
* [08_Hotfix](Assets/XLua/Examples/08_Hotfix/): 热补丁的示例(需要开启热补丁特性,如何开启请看[指南](Assets/XLua/Doc/hotfix.md))。
|
||||
* [09_GenericMethod](Assets/XLua/Examples/09_GenericMethod/): 泛化函数支持的演示。
|
||||
* [10_SignatureLoader](Assets/XLua/Examples/10_SignatureLoader/): 展示如何读取经数字签名的lua脚本,参见[数字签名](Assets/XLua/Doc/signature.md)的文档介绍。
|
||||
* [11_RawObject](Assets/XLua/Examples/11_RawObject/): 当C#参数是object时,如何把一个lua number指定以boxing后的int传递过去。
|
||||
* [12_ReImplementInLua](Assets/XLua/Examples/12_ReImplementInLua/): 展示如何将复杂值类型改为lua实现。
|
||||
|
||||
## 技术支持
|
||||
|
||||
一群:612705778 (已满)
|
||||
|
||||
二群:703073338 (已满)
|
||||
|
||||
三群:811246782
|
||||
|
||||
入群的问题:有问题该先从哪找答案
|
||||
|
||||
回答:FAQ
|
||||
|
||||
平时也要谨记这答案,90%以上问题都可以在[FAQ](Assets/XLua/Doc/faq.md)里头找到答案。这些问题就别在群刷屏了。
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue