[refactor] 重构桥接函数签名。之前不区分 i1,u1 i2,u2之类签名,现在改为区分,因为在一些abi的编译器优化下,可能出现bug

main 0.2.0
walon 2022-09-22 16:57:01 +08:00
parent a3f0befea4
commit 7f2ee9c22b
24 changed files with 73 additions and 60 deletions

View File

@ -31,26 +31,26 @@ namespace HybridCLR.Editor
switch (typeSig.ElementType)
{
case ElementType.Void: return corTypes.Void;
case ElementType.Boolean:
case ElementType.Char:
case ElementType.I1:
case ElementType.Boolean: return corTypes.Byte;
case ElementType.Char: return corTypes.UInt16;
case ElementType.I1: return corTypes.SByte;
case ElementType.U1:return corTypes.Byte;
case ElementType.I2:
case ElementType.I2: return corTypes.Int16;
case ElementType.U2: return corTypes.UInt16;
case ElementType.I4:
case ElementType.I4: return corTypes.Int32;
case ElementType.U4: return corTypes.UInt32;
case ElementType.I8:
case ElementType.I8: return corTypes.Int64;
case ElementType.U8: return corTypes.UInt64;
case ElementType.R4: return corTypes.Single;
case ElementType.R8: return corTypes.Double;
case ElementType.String: return corTypes.Object;
case ElementType.TypedByRef: return corTypes.TypedReference;
case ElementType.I:
case ElementType.I: return corTypes.IntPtr;
case ElementType.U: return corTypes.UIntPtr;
case ElementType.Object: return corTypes.Object;
case ElementType.Sentinel: return typeSig;
case ElementType.Ptr: return corTypes.UIntPtr;
case ElementType.ByRef: return corTypes.UIntPtr;
case ElementType.Ptr: return corTypes.IntPtr;
case ElementType.ByRef: return corTypes.IntPtr;
case ElementType.SZArray: return corTypes.Object;
case ElementType.Array: return corTypes.Object;
case ElementType.ValueType: return typeSig;
@ -64,7 +64,7 @@ namespace HybridCLR.Editor
}
return new GenericInstSig(gia.GenericType, gia.GenericArguments.Select(ga => ToShareTypeSig(ga)).ToList());
}
case ElementType.FnPtr: return corTypes.UIntPtr;
case ElementType.FnPtr: return corTypes.IntPtr;
case ElementType.ValueArray: return typeSig;
case ElementType.Module: return typeSig;
default:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4aa66b41c89ed7742ad067898725f7ff
guid: 0c2444f09010bce41a52d951b7100c49
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 3171ed79d43e06c4b8c889b0a3f38969
guid: e42a0f3bcbc5ddf438a85ae16c1b3116
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: cbe63fb39b5bdcc448f3589b475fb5d8
guid: 28e06667d06f37b4990b16f54f903a35
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c04e163336b93af44b4b565d0ab195e2
guid: f97bd67938e4a9c4b9c8ddcdad621f60
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -9,13 +9,14 @@ namespace HybridCLR.Editor.MethodBridgeGenerator
public enum ParamOrReturnType
{
VOID,
I1_U1,
//U1,
I2_U2,
//U2,
I4_U4,
I8_U8,
//I_U,
I1,
U1,
I2,
U2,
I4,
U4,
I8,
U8,
R4,
R8,
ARM64_HFA_FLOAT_2,

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 7886905937fafb64999dc4e358565982
guid: 6070162cd5afff74f99af129c50fda5a
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: deee8d06a7f05bf4d9ab4b78f0a8a47c
guid: b9f06ff0612105b4ea20e0309e759e24
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -21,7 +21,7 @@ namespace HybridCLR.Editor.MethodBridgeGenerator
public virtual bool IsSupportHFA => false;
public TypeInfo GetNativeIntTypeInfo() => IsArch32 ? TypeInfo.s_i4u4 : TypeInfo.s_i8u8;
public TypeInfo GetNativeIntTypeInfo() => IsArch32 ? TypeInfo.s_i4 : TypeInfo.s_i8;
public abstract void GenerateManaged2NativeMethod(MethodBridgeSig method, List<string> lines);
@ -73,20 +73,20 @@ namespace HybridCLR.Editor.MethodBridgeGenerator
switch(type.ElementType)
{
case ElementType.Void: return TypeInfo.s_void;
case ElementType.Boolean:
case ElementType.I1:
case ElementType.U1: return TypeInfo.s_i1u1;
case ElementType.Boolean: return TypeInfo.s_u1;
case ElementType.I1: return TypeInfo.s_i1;
case ElementType.U1: return TypeInfo.s_u1;
case ElementType.I2: return TypeInfo.s_i2;
case ElementType.Char:
case ElementType.I2:
case ElementType.U2: return TypeInfo.s_i2u2;
case ElementType.I4:
case ElementType.U4: return TypeInfo.s_i4u4;
case ElementType.I8:
case ElementType.U8: return TypeInfo.s_i8u8;
case ElementType.U2: return TypeInfo.s_u2;
case ElementType.I4: return TypeInfo.s_i4;
case ElementType.U4: return TypeInfo.s_u4;
case ElementType.I8: return TypeInfo.s_i8;
case ElementType.U8: return TypeInfo.s_u8;
case ElementType.R4: return TypeInfo.s_r4;
case ElementType.R8: return TypeInfo.s_r8;
case ElementType.U: return IsArch32 ? TypeInfo.s_u4 : TypeInfo.s_u8;
case ElementType.I:
case ElementType.U:
case ElementType.String:
case ElementType.Ptr:
case ElementType.ByRef:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ebf14107fd82b364cb7d61276d444829
guid: 2d2e42e9b08396e42bbaaab79865529f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -34,7 +34,7 @@ namespace HybridCLR.Editor.MethodBridgeGenerator
int typeSize = type.Size;
if (typeSize <= 8)
{
return TypeInfo.s_i8u8;
return TypeInfo.s_i8;
}
if (typeSize <= 16)
{

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bff17a6e8ee060c4eb9ac97fcf30bf78
guid: 4bd8c3b77879ac44b8921a67b5216ca6
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: fb741900113b22443a2054ddba6b131b
guid: cee9b0142fca88747b2414ca4b3d2b7a
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 26324be9505c9f54996bcbb62ba49132
guid: 96d94c3da2c6a394590218ce38eaec72
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -10,10 +10,14 @@ namespace HybridCLR.Editor.MethodBridgeGenerator
{
public static readonly TypeInfo s_void = new TypeInfo(ParamOrReturnType.VOID);
public static readonly TypeInfo s_i1u1 = new TypeInfo(ParamOrReturnType.I1_U1);
public static readonly TypeInfo s_i2u2 = new TypeInfo(ParamOrReturnType.I2_U2);
public static readonly TypeInfo s_i4u4 = new TypeInfo(ParamOrReturnType.I4_U4);
public static readonly TypeInfo s_i8u8 = new TypeInfo(ParamOrReturnType.I8_U8);
public static readonly TypeInfo s_i1 = new TypeInfo(ParamOrReturnType.I1);
public static readonly TypeInfo s_u1 = new TypeInfo(ParamOrReturnType.U1);
public static readonly TypeInfo s_i2 = new TypeInfo(ParamOrReturnType.I2);
public static readonly TypeInfo s_u2 = new TypeInfo(ParamOrReturnType.U2);
public static readonly TypeInfo s_i4 = new TypeInfo(ParamOrReturnType.I4);
public static readonly TypeInfo s_u4 = new TypeInfo(ParamOrReturnType.U4);
public static readonly TypeInfo s_i8 = new TypeInfo(ParamOrReturnType.I8);
public static readonly TypeInfo s_u8 = new TypeInfo(ParamOrReturnType.U8);
public static readonly TypeInfo s_r4 = new TypeInfo(ParamOrReturnType.R4);
public static readonly TypeInfo s_r8 = new TypeInfo(ParamOrReturnType.R8);
public static readonly TypeInfo s_i16 = new TypeInfo(ParamOrReturnType.I16);
@ -64,10 +68,14 @@ namespace HybridCLR.Editor.MethodBridgeGenerator
switch (PorType)
{
case ParamOrReturnType.VOID: return "v";
case ParamOrReturnType.I1_U1: return "i1";
case ParamOrReturnType.I2_U2: return "i2";
case ParamOrReturnType.I4_U4: return "i4";
case ParamOrReturnType.I8_U8: return "i8";
case ParamOrReturnType.I1: return "i1";
case ParamOrReturnType.U1: return "u1";
case ParamOrReturnType.I2: return "i2";
case ParamOrReturnType.U2: return "u2";
case ParamOrReturnType.I4: return "i4";
case ParamOrReturnType.U4: return "u4";
case ParamOrReturnType.I8: return "i8";
case ParamOrReturnType.U8: return "u8";
case ParamOrReturnType.R4: return "r4";
case ParamOrReturnType.R8: return "r8";
case ParamOrReturnType.I16: return "i16";
@ -91,10 +99,14 @@ namespace HybridCLR.Editor.MethodBridgeGenerator
switch (PorType)
{
case ParamOrReturnType.VOID: return "void";
case ParamOrReturnType.I1_U1: return "int8_t";
case ParamOrReturnType.I2_U2: return "int16_t";
case ParamOrReturnType.I4_U4: return "int32_t";
case ParamOrReturnType.I8_U8: return "int64_t";
case ParamOrReturnType.I1: return "int8_t";
case ParamOrReturnType.U1: return "uint8_t";
case ParamOrReturnType.I2: return "int16_t";
case ParamOrReturnType.U2: return "uint16_t";
case ParamOrReturnType.I4: return "int32_t";
case ParamOrReturnType.U4: return "uint32_t";
case ParamOrReturnType.I8: return "int64_t";
case ParamOrReturnType.U8: return "uint64_t";
case ParamOrReturnType.R4: return "float";
case ParamOrReturnType.R8: return "double";
case ParamOrReturnType.I16: return "ValueTypeSize16";

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 5afd7344483678a4abcb56158fd1442d
guid: 804237f201e1f7a4da1729e0eb11f75f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 49b3dbcebadb1b543a42e01afec07ed1
guid: 40dd1d9a2278f7846a9baa2041f74858
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bf7714fc37515834382cd5836b503a9f
guid: 381c08faeafbc004f97504eeba87380d
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ae7ec6e3674077d46898fe821d24bf85
guid: 7f9902041e9a1ff4c9f2d65d6384530d
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 96788c7fe08d5d54d95a87cfbdcb643a
guid: 10655ce82e730324db6ae297f77df04b
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bf7c4cf970660614fb54d838ec6e7eda
guid: 12a24c30a3914be418be10cfebfa9649
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 97dc0bbfed2593247a18261f1c2fdf66
guid: b93c6604eb031674b80de14cd4458dc0
PluginImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 3c8b35876046d1747ae7d62244ec693f
guid: 0d58bdc22b6d6b54ab6791baf16a0a3d
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,6 +1,6 @@
{
"name": "com.focus-creative-games.hybridclr_unity",
"version": "0.1.0",
"version": "0.2.0",
"displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime",