#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
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
Unity3d 基于xlua热更新实现系列一:熟悉lua重写C# (546个子文件)
libxlua.a 2.45MB
ProjectSettings.asset 18KB
InputManager.asset 10KB
QualitySettings.asset 7KB
GraphicsSettings.asset 2KB
Physics2DSettings.asset 2KB
NavMeshAreas.asset 1KB
DynamicsManager.asset 1KB
EditorSettings.asset 1KB
PackageManagerSettings.asset 1002B
UnityConnectSettings.asset 898B
AudioManager.asset 432B
TagManager.asset 421B
VFXManager.asset 320B
EditorBuildSettings.asset 268B
TimeManager.asset 211B
VersionControlSettings.asset 188B
XRSettings.asset 167B
NetworkManager.asset 159B
PresetManager.asset 153B
ClusterInputManager.asset 120B
build.bat 900B
signatured1.lua.bytes 200B
signatured2.lua.bytes 177B
signatured3.lua.bytes 177B
xlua_webgl.cpp 1KB
HotfixFlags.cpp 959B
CodeEmit.cs 85KB
Generator.cs 79KB
Hotfix.cs 74KB
ObjectTranslator.cs 63KB
UnityEngine_ParticleSystemWrap.cs 62KB
UnityEngine_LightWrap.cs 60KB
UnityEngine_TransformWrap.cs 60KB
UnityEngine_Vector3Wrap.cs 59KB
UnityEngine_MathfWrap.cs 55KB
Utils.cs 49KB
System_Collections_Generic_List_1_System_Int32_Wrap.cs 48KB
UnityEngine_Vector2Wrap.cs 48KB
UnityEngine_RendererWrap.cs 48KB
StaticLuaCallbacks.cs 47KB
WrapPusher.cs 43KB
UnityEngine_Vector4Wrap.cs 42KB
UnityEngine_QuaternionWrap.cs 42KB
UnityEngine_GameObjectWrap.cs 40KB
UnityEngine_DebugWrap.cs 37KB
UnityEngine_ColorWrap.cs 35KB
ObjectCasters.cs 28KB
UnityEngine_BoundsWrap.cs 27KB
UnityEngine_ComponentWrap.cs 27KB
LuaDLL.cs 26KB
UnityEngine_ObjectWrap.cs 26KB
DelegatesGensBridge.cs 25KB
LuaEnv.cs 25KB
MethodWarpsCache.cs 23KB
Tutorial_DerivedClassWrap.cs 20KB
UnityEngine_AnimationCurveWrap.cs 20KB
UnityEngine_AnimationClipWrap.cs 19KB
PackUnpack.cs 19KB
UnityEngine_TimeWrap.cs 17KB
UnityEngine_SkinnedMeshRendererWrap.cs 17KB
UnityEngine_MonoBehaviourWrap.cs 15KB
ExampleConfig.cs 14KB
XLuaTest_NoGcWrap.cs 13KB
UnityEngine_KeyframeWrap.cs 13KB
UnityEngine_ResourcesWrap.cs 13KB
HotfixTest2.cs 12KB
LuaTable.cs 11KB
TemplateEngine.cs 9KB
UnityEngine_Ray2DWrap.cs 9KB
UnityEngine_RayWrap.cs 9KB
LuaCallCs.cs 8KB
GenericDelegateBridge.cs 8KB
XLuaGenAutoRegister.cs 8KB
LuaFunction.cs 8KB
DelegateBridge.cs 8KB
XLuaTest_MyStructWrap.cs 8KB
NoGc.cs 8KB
System_ObjectWrap.cs 7KB
XLuaTest_InvokeLua_ICalcBridge.cs 7KB
EnumWrap.cs 7KB
Tutorial_BaseClassWrap.cs 6KB
CopyByValue.cs 6KB
XLuaTest_Foo1ParentWrap.cs 5KB
ReImplementInLua.cs 5KB
ExampleGenConfig.cs 5KB
ObjectPool.cs 5KB
InvokeLua.cs 5KB
XLuaTest_LuaBehaviourWrap.cs 5KB
XLuaTest_BaseTestWrap.cs 4KB
GenAttributes.cs 4KB
XLuaTest_Foo1ChildWrap.cs 4KB
CSCallLua.cs 4KB
MessageBox.cs 4KB
Tutorial_CSCallLua_ItfDBridge.cs 4KB
UnityEngine_TextAssetWrap.cs 4KB
TypeExtensions.cs 4KB
XLuaTest_FooWrap.cs 4KB
LuaBase.cs 4KB
UnityEngine_BehaviourWrap.cs 4KB
共 546 条
- 1
- 2
- 3
- 4
- 5
- 6
十幺卜入
- 粉丝: 7930
- 资源: 51
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0