Skip to content

Commit 585be97

Browse files
committed
[change] change type of the first argument methodPointer of Managed2NativeFunctionPointer from const void* to Il2CppMethodPointer
1 parent 3618738 commit 585be97

4 files changed

Lines changed: 27 additions & 12 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using dnlib.DotNet;
2+
3+
namespace HybridCLR.Editor.MethodBridge
4+
{
5+
public class CallNativeMethodSignatureInfo
6+
{
7+
public MethodSig MethodSig { get; set; }
8+
}
9+
}

Editor/MethodBridge/CallNativeMethodSignatureInfo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/MethodBridge/CalliAnalyzer.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,13 @@
1010
namespace HybridCLR.Editor.MethodBridge
1111
{
1212

13-
public class RawCalliMethodSignatureInfo
14-
{
15-
public MethodSig MethodSig { get; set; }
16-
}
17-
1813
public class CalliAnalyzer
1914
{
2015
private readonly List<ModuleDefMD> _rootModules = new List<ModuleDefMD>();
2116

22-
private readonly List<RawCalliMethodSignatureInfo> _calliMethodSignatures = new List<RawCalliMethodSignatureInfo>();
17+
private readonly List<CallNativeMethodSignatureInfo> _calliMethodSignatures = new List<CallNativeMethodSignatureInfo>();
2318

24-
public List<RawCalliMethodSignatureInfo> CalliMethodSignatures => _calliMethodSignatures;
19+
public List<CallNativeMethodSignatureInfo> CalliMethodSignatures => _calliMethodSignatures;
2520

2621
public CalliAnalyzer(AssemblyCache cache, List<string> assemblyNames)
2722
{
@@ -51,7 +46,7 @@ private void CollectCalli()
5146
{
5247
MethodSig methodSig = (MethodSig)il.Operand;
5348

54-
_calliMethodSignatures.Add(new RawCalliMethodSignatureInfo()
49+
_calliMethodSignatures.Add(new CallNativeMethodSignatureInfo()
5550
{
5651
MethodSig = methodSig,
5752
});

Editor/MethodBridge/Generator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class Options
3232

3333
public List<RawReversePInvokeMethodInfo> ReversePInvokeMethods { get; set; }
3434

35-
public IReadOnlyCollection<RawCalliMethodSignatureInfo> CalliMethodSignatures { get; set; }
35+
public IReadOnlyCollection<CallNativeMethodSignatureInfo> CalliMethodSignatures { get; set; }
3636

3737
public bool Development { get; set; }
3838
}
@@ -61,7 +61,7 @@ private class CalliMethodInfo
6161

6262
private readonly List<RawReversePInvokeMethodInfo> _originalReversePInvokeMethods;
6363

64-
private readonly List<RawCalliMethodSignatureInfo> _originalCalliMethodSignatures;
64+
private readonly List<CallNativeMethodSignatureInfo> _originalCalliMethodSignatures;
6565

6666
private readonly string _templateCode;
6767

@@ -624,7 +624,7 @@ private List<ABIReversePInvokeMethodInfo> BuildABIMethods(List<RawReversePInvoke
624624
return newMethods;
625625
}
626626

627-
private List<CalliMethodInfo> BuildCalliMethods(List<RawCalliMethodSignatureInfo> rawMethods)
627+
private List<CalliMethodInfo> BuildCalliMethods(List<CallNativeMethodSignatureInfo> rawMethods)
628628
{
629629
var methodsBySig = new Dictionary<string, CalliMethodInfo>();
630630
foreach (var method in rawMethods)
@@ -1228,7 +1228,7 @@ private void GenerateManaged2NativeFunctionPointerMethod(CalliMethodInfo methodI
12281228
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => GetManaged2NativePassParam(p.Type, $"localVarBase+argVarIndexs[{p.Index}]")));
12291229
string il2cppCallConventionName = GetIl2cppCallConventionName(methodInfo.Callvention);
12301230
lines.Add($@"
1231-
static void __M2NF_{methodInfo.Signature}(const void* methodPointer, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
1231+
static void __M2NF_{methodInfo.Signature}(Il2CppMethodPointer methodPointer, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
12321232
{{
12331233
typedef {method.ReturnInfo.Type.GetTypeName()} ({il2cppCallConventionName} *NativeMethod)({paramListStr});
12341234
{(!method.ReturnInfo.IsVoid ? $"*({method.ReturnInfo.Type.GetTypeName()}*)ret = " : "")}((NativeMethod)(methodPointer))({paramNameListStr});

0 commit comments

Comments
 (0)