diff --git a/Editor/MethodBridge/CallNativeMethodSignatureInfo.cs b/Editor/MethodBridge/CallNativeMethodSignatureInfo.cs new file mode 100644 index 0000000..3459e15 --- /dev/null +++ b/Editor/MethodBridge/CallNativeMethodSignatureInfo.cs @@ -0,0 +1,9 @@ +using dnlib.DotNet; + +namespace HybridCLR.Editor.MethodBridge +{ + public class CallNativeMethodSignatureInfo + { + public MethodSig MethodSig { get; set; } + } +} diff --git a/Editor/MethodBridge/CallNativeMethodSignatureInfo.cs.meta b/Editor/MethodBridge/CallNativeMethodSignatureInfo.cs.meta new file mode 100644 index 0000000..026237d --- /dev/null +++ b/Editor/MethodBridge/CallNativeMethodSignatureInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d2e4ca0a49975a84a8a72dbc70ec7795 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/MethodBridge/CalliAnalyzer.cs b/Editor/MethodBridge/CalliAnalyzer.cs index 2027135..14611ac 100644 --- a/Editor/MethodBridge/CalliAnalyzer.cs +++ b/Editor/MethodBridge/CalliAnalyzer.cs @@ -10,18 +10,13 @@ using UnityEngine; namespace HybridCLR.Editor.MethodBridge { - public class RawCalliMethodSignatureInfo - { - public MethodSig MethodSig { get; set; } - } - public class CalliAnalyzer { private readonly List _rootModules = new List(); - private readonly List _calliMethodSignatures = new List(); + private readonly List _calliMethodSignatures = new List(); - public List CalliMethodSignatures => _calliMethodSignatures; + public List CalliMethodSignatures => _calliMethodSignatures; public CalliAnalyzer(AssemblyCache cache, List assemblyNames) { @@ -51,7 +46,7 @@ namespace HybridCLR.Editor.MethodBridge { MethodSig methodSig = (MethodSig)il.Operand; - _calliMethodSignatures.Add(new RawCalliMethodSignatureInfo() + _calliMethodSignatures.Add(new CallNativeMethodSignatureInfo() { MethodSig = methodSig, }); diff --git a/Editor/MethodBridge/Generator.cs b/Editor/MethodBridge/Generator.cs index 73a29e1..ecd3485 100644 --- a/Editor/MethodBridge/Generator.cs +++ b/Editor/MethodBridge/Generator.cs @@ -32,7 +32,7 @@ namespace HybridCLR.Editor.MethodBridge public List ReversePInvokeMethods { get; set; } - public IReadOnlyCollection CalliMethodSignatures { get; set; } + public IReadOnlyCollection CalliMethodSignatures { get; set; } public bool Development { get; set; } } @@ -61,7 +61,7 @@ namespace HybridCLR.Editor.MethodBridge private readonly List _originalReversePInvokeMethods; - private readonly List _originalCalliMethodSignatures; + private readonly List _originalCalliMethodSignatures; private readonly string _templateCode; @@ -624,7 +624,7 @@ namespace HybridCLR.Editor.MethodBridge return newMethods; } - private List BuildCalliMethods(List rawMethods) + private List BuildCalliMethods(List rawMethods) { var methodsBySig = new Dictionary(); 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 il2cppCallConventionName = GetIl2cppCallConventionName(methodInfo.Callvention); 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}); {(!method.ReturnInfo.IsVoid ? $"*({method.ReturnInfo.Type.GetTypeName()}*)ret = " : "")}((NativeMethod)(methodPointer))({paramNameListStr});