[fix] 修复 ReversePInvokeWrap 生成的bug

main
walon 2022-10-21 17:42:31 +08:00
parent 4f64ea1c6c
commit 2ad7c31302
3 changed files with 9 additions and 4 deletions

View File

@ -40,5 +40,10 @@ namespace HybridCLR.Editor.ABI
{
return Type.GetParamSlotNum();
}
public override string ToString()
{
return Type.GetTypeName();
}
}
}

View File

@ -21,17 +21,17 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
{
MethodDesc method = methodInfo.Method;
string paramDeclaringListWithoutMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}"));
string paramNameListWithoutMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"__arg{p.Index}"));
string paramNameListWithoutMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"__arg{p.Index}").Concat(new string[] { "method" }));
string paramTypeListWithMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()}").Concat(new string[] { "const MethodInfo*" }));
string methodTypeDef = $"typedef {method.ReturnInfo.Type.GetTypeName()} (*Callback)({paramTypeListWithMethodInfoStr})";
for (int i = 0; i < methodInfo.Count; i++, methodIndex++)
{
codes.Add($@"
void __ReversePInvokeMethod_{methodIndex}({paramDeclaringListWithoutMethodInfoStr})
{method.ReturnInfo.Type.GetTypeName()} __ReversePInvokeMethod_{methodIndex}({paramDeclaringListWithoutMethodInfoStr})
{{
const MethodInfo* method = MetadataModule::GetMethodInfoByReversePInvokeWrapperIndex({i});
{methodTypeDef};
((Callback)(method->methodPointerCallByInterp))({paramNameListWithoutMethodInfoStr}, method);
{(method.ReturnInfo.IsVoid ? "" : "return ")}((Callback)(method->methodPointerCallByInterp))({paramNameListWithoutMethodInfoStr});
}}
");
stubCodes.Add($"\t\t{{\"{method.Sig}\", (Il2CppMethodPointer)__ReversePInvokeMethod_{methodIndex}}},\n");

View File

@ -1,6 +1,6 @@
{
"name": "com.focus-creative-games.hybridclr_unity",
"version": "0.7.3",
"version": "0.7.4",
"displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime",