From 303c6c7b356f0b36333f8eef1be730e2c84890c2 Mon Sep 17 00:00:00 2001 From: walon Date: Mon, 10 Jun 2024 13:18:46 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D=E8=AE=A1=E7=AE=97Nat?= =?UTF-8?q?ive2Manager=E6=A1=A5=E6=8E=A5=E5=87=BD=E6=95=B0=E6=9C=AA?= =?UTF-8?q?=E8=80=83=E8=99=91=E5=88=B0MonoPInvokeCallback=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=AF=BC=E8=87=B4=E4=BB=8Elua=E6=88=96?= =?UTF-8?q?=E8=80=85=E5=85=B6=E4=BB=96=E8=AF=AD=E8=A8=80=E8=B0=83=E7=94=A8?= =?UTF-8?q?c#=E7=83=AD=E6=9B=B4=E6=96=B0=E5=87=BD=E6=95=B0=E6=9C=89?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=BC=9A=E5=87=BA=E7=8E=B0UnsupportedNative2?= =?UTF-8?q?ManagedMethod=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/MethodBridge/Generator.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Editor/MethodBridge/Generator.cs b/Editor/MethodBridge/Generator.cs index 930bf2c..cd1b9a0 100644 --- a/Editor/MethodBridge/Generator.cs +++ b/Editor/MethodBridge/Generator.cs @@ -15,6 +15,7 @@ using UnityEditor; using UnityEngine; using TypeInfo = HybridCLR.Editor.ABI.TypeInfo; using CallingConvention = System.Runtime.InteropServices.CallingConvention; +using System.Security.Cryptography; namespace HybridCLR.Editor.MethodBridge { @@ -181,12 +182,23 @@ namespace HybridCLR.Editor.MethodBridge } } - private void PrepareGenericMethods() + private void PrepareMethodBridges() { - foreach(var method in _genericMethods) + foreach (var method in _genericMethods) { ProcessMethod(method.Method, method.KlassInst, method.MethodInst); } + foreach (var reversePInvokeMethod in _originalReversePInvokeMethods) + { + MethodDef method = reversePInvokeMethod.Method; + ICorLibTypes corLibTypes = method.Module.CorLibTypes; + + var returnType = MetaUtil.ToShareTypeSig(corLibTypes, method.ReturnType); + var parameters = method.Parameters.Select(p => MetaUtil.ToShareTypeSig(corLibTypes, p.Type)).ToList(); + var sharedMethod = CreateMethodDesc(method, true, returnType, parameters); + sharedMethod.Init(); + AddNative2ManagedMethod(sharedMethod); + } } static void CheckUnique(IEnumerable names) @@ -595,7 +607,7 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu public void Generate() { - PrepareGenericMethods(); + PrepareMethodBridges(); CollectTypesAndMethods(); OptimizationTypesAndMethods(); GenerateCode();