【m】hybrid更新为8.11.0
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 3s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 5s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 10s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 8s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 34s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 2s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 17s
Plugin Library CI / publish (07.RKTools) (push) Successful in 4s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 17s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 4s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 3s
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 3s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 5s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 10s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 8s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 34s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 2s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 17s
Plugin Library CI / publish (07.RKTools) (push) Successful in 4s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 17s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 4s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 3s
This commit is contained in:
@@ -5,5 +5,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
public class CallNativeMethodSignatureInfo
|
||||
{
|
||||
public MethodSig MethodSig { get; set; }
|
||||
|
||||
public CallingConvention? Callvention { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,6 +287,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
CollectStructDefs(_managed2NativeMethodList0, structTypeSet);
|
||||
CollectStructDefs(_native2ManagedMethodList0, structTypeSet);
|
||||
CollectStructDefs(_adjustThunkMethodList0, structTypeSet);
|
||||
CollectStructDefs(_originalCalliMethodSignatures.Select(m => m.MethodSig).ToList(), structTypeSet);
|
||||
_structTypes0 = structTypeSet.ToList();
|
||||
_structTypes0.Sort((a, b) => a.TypeId - b.TypeId);
|
||||
|
||||
@@ -558,6 +559,11 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
return CallingConvention.Winapi;
|
||||
}
|
||||
if (monoPInvokeCallbackAttr.ConstructorArguments.Count == 0)
|
||||
{
|
||||
Debug.LogError($"MonoPInvokeCallbackAttribute on method {method.FullName} has no constructor arguments. Using CallingConvention.Winapi as default.");
|
||||
return CallingConvention.Winapi;
|
||||
}
|
||||
object delegateTypeSig = monoPInvokeCallbackAttr.ConstructorArguments[0].Value;
|
||||
|
||||
TypeDef delegateTypeDef;
|
||||
@@ -579,7 +585,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
throw new NotSupportedException($"Unsupported delegate type: {delegateTypeSig}");
|
||||
}
|
||||
var attr = delegateTypeDef.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute");
|
||||
if (attr == null)
|
||||
if (attr == null || attr.ConstructorArguments.Count == 0)
|
||||
{
|
||||
return CallingConvention.Winapi;
|
||||
}
|
||||
@@ -637,7 +643,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
sharedMethod.Init();
|
||||
sharedMethod = ToIsomorphicMethod(sharedMethod);
|
||||
|
||||
CallingConvention callingConv = (CallingConvention)((int)(method.MethodSig.CallingConvention & dnlib.DotNet.CallingConvention.Mask) + 1);
|
||||
CallingConvention callingConv = (CallingConvention)((int)((method.Callvention ?? method.MethodSig.CallingConvention) & dnlib.DotNet.CallingConvention.Mask) + 1);
|
||||
string signature = MakeCalliSignature(sharedMethod, callingConv);
|
||||
|
||||
if (!methodsBySig.TryGetValue(signature, out var arm))
|
||||
@@ -829,6 +835,38 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu
|
||||
|
||||
}
|
||||
|
||||
private void CollectStructDefs(List<MethodSig> methods, HashSet<TypeInfo> structTypes)
|
||||
{
|
||||
ICorLibTypes corLibTypes = _genericMethods[0].Method.Module.CorLibTypes;
|
||||
|
||||
foreach (var method in methods)
|
||||
{
|
||||
foreach (var paramInfo in method.Params)
|
||||
{
|
||||
var paramType = GetSharedTypeInfo(MetaUtil.ToShareTypeSig(corLibTypes, paramInfo));
|
||||
if (paramType.IsStruct)
|
||||
{
|
||||
structTypes.Add(paramType);
|
||||
if (paramType.Klass.ContainsGenericParameter)
|
||||
{
|
||||
throw new Exception($"[CollectStructDefs] method:{method} type:{paramType.Klass} contains generic parameter");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
var returnType = GetSharedTypeInfo(MetaUtil.ToShareTypeSig(corLibTypes, method.RetType));
|
||||
if (returnType.IsStruct)
|
||||
{
|
||||
structTypes.Add(returnType);
|
||||
if (returnType.Klass.ContainsGenericParameter)
|
||||
{
|
||||
throw new Exception($"[CollectStructDefs] method:{method} type:{returnType.Klass} contains generic parameter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FieldInfo
|
||||
{
|
||||
public FieldDef field;
|
||||
|
||||
@@ -3,6 +3,7 @@ using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
@@ -26,6 +27,19 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
}
|
||||
}
|
||||
|
||||
private CallingConvention GetCallingConvention(MethodDef method)
|
||||
{
|
||||
switch (method.ImplMap.CallConv)
|
||||
{
|
||||
case PInvokeAttributes.CallConvWinapi: return CallingConvention.Default;
|
||||
case PInvokeAttributes.CallConvCdecl: return CallingConvention.C;
|
||||
case PInvokeAttributes.CallConvStdCall: return CallingConvention.StdCall;
|
||||
case PInvokeAttributes.CallConvThiscall: return CallingConvention.ThisCall;
|
||||
case PInvokeAttributes.CallConvFastcall: return CallingConvention.FastCall;
|
||||
default: return CallingConvention.Default;
|
||||
}
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
foreach (var mod in _rootModules)
|
||||
@@ -40,7 +54,11 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
Debug.LogError($"PInvoke method {method.FullName} has unsupported parameter or return type. Please check the method signature.");
|
||||
}
|
||||
_pinvokeMethodSignatures.Add(new CallNativeMethodSignatureInfo { MethodSig = method.MethodSig });
|
||||
_pinvokeMethodSignatures.Add(new CallNativeMethodSignatureInfo
|
||||
{
|
||||
MethodSig = method.MethodSig,
|
||||
Callvention = method.HasImplMap? GetCallingConvention(method) : (CallingConvention?)null,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user