Fix array return type marshalling
This commit is contained in:
@@ -2045,8 +2045,10 @@ namespace FlaxEngine
|
||||
return (bool)returnObject ? boolTruePtr : boolFalsePtr;
|
||||
else if (methodHolder.method.ReturnType == typeof(Type))
|
||||
return GCHandle.ToIntPtr(GetTypeGCHandle(Unsafe.As<Type>(returnObject)));
|
||||
else if (methodHolder.method.ReturnType == typeof(object[]))
|
||||
return GCHandle.ToIntPtr(GCHandle.Alloc(ManagedArray.WrapNewArray(ManagedArrayToGCHandleArray(Unsafe.As<object[]>(returnObject))), GCHandleType.Weak));
|
||||
else if (methodHolder.method.ReturnType.IsArray && ArrayFactory.GetMarshalledType(methodHolder.method.ReturnType.GetElementType()) == methodHolder.method.ReturnType.GetElementType())
|
||||
return GCHandle.ToIntPtr(GCHandle.Alloc(ManagedArray.WrapNewArray(Unsafe.As<Array>(returnObject)), GCHandleType.Weak));
|
||||
else if (methodHolder.method.ReturnType.IsArray)
|
||||
return GCHandle.ToIntPtr(GCHandle.Alloc(ManagedArray.WrapNewArray(ManagedArrayToGCHandleArray(Unsafe.As<Array>(returnObject))), GCHandleType.Weak));
|
||||
else
|
||||
return GCHandle.ToIntPtr(GCHandle.Alloc(returnObject, GCHandleType.Weak));
|
||||
}
|
||||
|
||||
@@ -59,8 +59,10 @@ namespace FlaxEngine
|
||||
return (bool)(object)returnValue ? boolTruePtr : boolFalsePtr;
|
||||
else if (typeof(TRet) == typeof(Type))
|
||||
return returnValue != null ? GCHandle.ToIntPtr(GetTypeGCHandle(Unsafe.As<Type>(returnValue))) : IntPtr.Zero;
|
||||
else if (typeof(TRet) == typeof(object[]))
|
||||
return returnValue != null ? GCHandle.ToIntPtr(GCHandle.Alloc(ManagedArray.WrapNewArray(ManagedArrayToGCHandleArray(Unsafe.As<object[]>(returnValue))), GCHandleType.Weak)) : IntPtr.Zero;
|
||||
else if (typeof(TRet).IsArray && ArrayFactory.GetMarshalledType(typeof(TRet).GetElementType()) == typeof(TRet).GetElementType())
|
||||
return returnValue != null ? GCHandle.ToIntPtr(GCHandle.Alloc(ManagedArray.WrapNewArray(Unsafe.As<Array>(returnValue)), GCHandleType.Weak)) : IntPtr.Zero;
|
||||
else if (typeof(TRet).IsArray)
|
||||
return returnValue != null ? GCHandle.ToIntPtr(GCHandle.Alloc(ManagedArray.WrapNewArray(ManagedArrayToGCHandleArray(Unsafe.As<Array>(returnValue))), GCHandleType.Weak)) : IntPtr.Zero;
|
||||
else
|
||||
return returnValue != null ? GCHandle.ToIntPtr(GCHandle.Alloc(returnValue, GCHandleType.Weak)) : IntPtr.Zero;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user