[change] change type of the first argument `methodPointer` of Managed2NativeFunctionPointer from `const void*` to `Il2CppMethodPointer`
parent
361873803f
commit
585be97be9
|
|
@ -0,0 +1,9 @@
|
||||||
|
using dnlib.DotNet;
|
||||||
|
|
||||||
|
namespace HybridCLR.Editor.MethodBridge
|
||||||
|
{
|
||||||
|
public class CallNativeMethodSignatureInfo
|
||||||
|
{
|
||||||
|
public MethodSig MethodSig { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d2e4ca0a49975a84a8a72dbc70ec7795
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -10,18 +10,13 @@ using UnityEngine;
|
||||||
namespace HybridCLR.Editor.MethodBridge
|
namespace HybridCLR.Editor.MethodBridge
|
||||||
{
|
{
|
||||||
|
|
||||||
public class RawCalliMethodSignatureInfo
|
|
||||||
{
|
|
||||||
public MethodSig MethodSig { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CalliAnalyzer
|
public class CalliAnalyzer
|
||||||
{
|
{
|
||||||
private readonly List<ModuleDefMD> _rootModules = new List<ModuleDefMD>();
|
private readonly List<ModuleDefMD> _rootModules = new List<ModuleDefMD>();
|
||||||
|
|
||||||
private readonly List<RawCalliMethodSignatureInfo> _calliMethodSignatures = new List<RawCalliMethodSignatureInfo>();
|
private readonly List<CallNativeMethodSignatureInfo> _calliMethodSignatures = new List<CallNativeMethodSignatureInfo>();
|
||||||
|
|
||||||
public List<RawCalliMethodSignatureInfo> CalliMethodSignatures => _calliMethodSignatures;
|
public List<CallNativeMethodSignatureInfo> CalliMethodSignatures => _calliMethodSignatures;
|
||||||
|
|
||||||
public CalliAnalyzer(AssemblyCache cache, List<string> assemblyNames)
|
public CalliAnalyzer(AssemblyCache cache, List<string> assemblyNames)
|
||||||
{
|
{
|
||||||
|
|
@ -51,7 +46,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||||
{
|
{
|
||||||
MethodSig methodSig = (MethodSig)il.Operand;
|
MethodSig methodSig = (MethodSig)il.Operand;
|
||||||
|
|
||||||
_calliMethodSignatures.Add(new RawCalliMethodSignatureInfo()
|
_calliMethodSignatures.Add(new CallNativeMethodSignatureInfo()
|
||||||
{
|
{
|
||||||
MethodSig = methodSig,
|
MethodSig = methodSig,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||||
|
|
||||||
public List<RawReversePInvokeMethodInfo> ReversePInvokeMethods { get; set; }
|
public List<RawReversePInvokeMethodInfo> ReversePInvokeMethods { get; set; }
|
||||||
|
|
||||||
public IReadOnlyCollection<RawCalliMethodSignatureInfo> CalliMethodSignatures { get; set; }
|
public IReadOnlyCollection<CallNativeMethodSignatureInfo> CalliMethodSignatures { get; set; }
|
||||||
|
|
||||||
public bool Development { get; set; }
|
public bool Development { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +61,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||||
|
|
||||||
private readonly List<RawReversePInvokeMethodInfo> _originalReversePInvokeMethods;
|
private readonly List<RawReversePInvokeMethodInfo> _originalReversePInvokeMethods;
|
||||||
|
|
||||||
private readonly List<RawCalliMethodSignatureInfo> _originalCalliMethodSignatures;
|
private readonly List<CallNativeMethodSignatureInfo> _originalCalliMethodSignatures;
|
||||||
|
|
||||||
private readonly string _templateCode;
|
private readonly string _templateCode;
|
||||||
|
|
||||||
|
|
@ -624,7 +624,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||||
return newMethods;
|
return newMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CalliMethodInfo> BuildCalliMethods(List<RawCalliMethodSignatureInfo> rawMethods)
|
private List<CalliMethodInfo> BuildCalliMethods(List<CallNativeMethodSignatureInfo> rawMethods)
|
||||||
{
|
{
|
||||||
var methodsBySig = new Dictionary<string, CalliMethodInfo>();
|
var methodsBySig = new Dictionary<string, CalliMethodInfo>();
|
||||||
foreach (var method in rawMethods)
|
foreach (var method in rawMethods)
|
||||||
|
|
@ -1228,7 +1228,7 @@ static {method.ReturnInfo.Type.GetTypeName()} __N2M_{(adjustorThunk ? "AdjustorT
|
||||||
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => GetManaged2NativePassParam(p.Type, $"localVarBase+argVarIndexs[{p.Index}]")));
|
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => GetManaged2NativePassParam(p.Type, $"localVarBase+argVarIndexs[{p.Index}]")));
|
||||||
string il2cppCallConventionName = GetIl2cppCallConventionName(methodInfo.Callvention);
|
string il2cppCallConventionName = GetIl2cppCallConventionName(methodInfo.Callvention);
|
||||||
lines.Add($@"
|
lines.Add($@"
|
||||||
static void __M2NF_{methodInfo.Signature}(const void* methodPointer, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
|
static void __M2NF_{methodInfo.Signature}(Il2CppMethodPointer methodPointer, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
|
||||||
{{
|
{{
|
||||||
typedef {method.ReturnInfo.Type.GetTypeName()} ({il2cppCallConventionName} *NativeMethod)({paramListStr});
|
typedef {method.ReturnInfo.Type.GetTypeName()} ({il2cppCallConventionName} *NativeMethod)({paramListStr});
|
||||||
{(!method.ReturnInfo.IsVoid ? $"*({method.ReturnInfo.Type.GetTypeName()}*)ret = " : "")}((NativeMethod)(methodPointer))({paramNameListStr});
|
{(!method.ReturnInfo.IsVoid ? $"*({method.ReturnInfo.Type.GetTypeName()}*)ret = " : "")}((NativeMethod)(methodPointer))({paramNameListStr});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue