Skip to content

Commit

Permalink
Merge pull request #74 from cjsworld/cjs
Browse files Browse the repository at this point in the history
1、有人通过namespace白名单来注入,结果lambda对应的匿名类也注入了,它的函数参数名可能为空。
2、白名单注入,有些情况下method.Body为空,但不是抽象方法和pinvoke方法;
3、有的同学有定义了名字为Item的property,这和this[]重载的名字是一样的,需要区分。
  • Loading branch information
chexiongsheng authored Jan 13, 2017
2 parents 527f1e4 + 0f0afff commit 6e4bda4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Assets/XLua/Src/Editor/Hotfix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static bool injectType(AssemblyDefinition assembly, TypeReference hotfixAttribut
}
foreach (var method in type.Methods)
{
if (method.Name != ".cctor" && !method.IsAbstract && !method.IsPInvokeImpl)
if (method.Name != ".cctor" && !method.IsAbstract && !method.IsPInvokeImpl && method.Body != null)
{
if ((method.HasGenericParameters || genericInOut(assembly, method)) ? !injectGenericMethod(assembly, method, hotfixType, stateTable) :
!injectMethod(assembly, method, hotfixType, stateTable))
Expand Down
8 changes: 6 additions & 2 deletions Assets/XLua/Src/Editor/Template/LuaDelegateBridge.tpl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace XLua
if has_return then out_num = out_num + 1 end
%>
public <%=return_type_name%> <%=CSVariableName(delegate.ReturnType)%>(<%ForEachCsList(parameters, function(parameter, pi)
local pname = parameter.Name
if pname == '' or pname == 'object' then pname = 'p' .. tostring(pi) end
if pi ~= 0 then
%>, <%
end
Expand All @@ -37,7 +39,7 @@ namespace XLua
elseif parameter.ParameterType.IsByRef then
%>ref <%
end
%><%=CsFullTypeName(parameter.ParameterType)%> <%=parameter.Name%><%
%><%=CsFullTypeName(parameter.ParameterType)%> <%=pname%><%
end) %>)
{
#if THREAD_SAFT || HOTFIX_ENABLE
Expand All @@ -54,8 +56,10 @@ namespace XLua
local param_count = parameters.Length
local has_v_params = param_count > 0 and parameters[param_count - 1].IsParamArray
ForEachCsList(parameters, function(parameter, pi)
local pname = parameter.Name
if pname == '' or pname == 'object' then pname = 'p' .. tostring(pi) end
if parameter.IsIn or not parameter.IsOut then
%><%=GetPushStatement(parameter.ParameterType, parameter.Name, has_v_params and pi == param_count - 1)%>;
%><%=GetPushStatement(parameter.ParameterType, pname, has_v_params and pi == param_count - 1)%>;
<%
end
end) %>
Expand Down
2 changes: 1 addition & 1 deletion Assets/XLua/Src/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ static void makeReflectionWrap(RealStatePtr L, Type type, int cls_field, int cls
for (int i = 0; i < props.Length; ++i)
{
PropertyInfo prop = props[i];
if (prop.Name == "Item")
if (prop.Name == "Item" && prop.GetIndexParameters().Length > 0)
{
items.Add(prop);
}
Expand Down

0 comments on commit 6e4bda4

Please sign in to comment.