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",