From 2ad7c313020373e815647dde8ae83f609e029998 Mon Sep 17 00:00:00 2001 From: walon Date: Fri, 21 Oct 2022 17:42:31 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D=20ReversePInvokeWrap?= =?UTF-8?q?=20=E7=94=9F=E6=88=90=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/ABI/ParamInfo.cs | 5 +++++ Editor/ReversePInvokeWrap/Generator.cs | 6 +++--- package.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Editor/ABI/ParamInfo.cs b/Editor/ABI/ParamInfo.cs index 494b620..eded5d1 100644 --- a/Editor/ABI/ParamInfo.cs +++ b/Editor/ABI/ParamInfo.cs @@ -40,5 +40,10 @@ namespace HybridCLR.Editor.ABI { return Type.GetParamSlotNum(); } + + public override string ToString() + { + return Type.GetTypeName(); + } } } diff --git a/Editor/ReversePInvokeWrap/Generator.cs b/Editor/ReversePInvokeWrap/Generator.cs index 7491b4f..6556b66 100644 --- a/Editor/ReversePInvokeWrap/Generator.cs +++ b/Editor/ReversePInvokeWrap/Generator.cs @@ -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"); diff --git a/package.json b/package.json index 0e67720..5915c67 100644 --- a/package.json +++ b/package.json @@ -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",