Use Unsafe.As casting in generated managed marshallers
This commit is contained in:
@@ -18,6 +18,8 @@ namespace FlaxEngine.Interop
|
||||
/// </summary>
|
||||
internal static class Invoker
|
||||
{
|
||||
// TODO: Use .NET8 Unsafe.BitCast<TRet, ValueType>(returnValue) for more efficient casting of value types over boxing cast
|
||||
|
||||
internal static IntPtr MarshalReturnValue<TRet>(ref TRet returnValue)
|
||||
{
|
||||
if (returnValue == null)
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace FlaxEngine.Interop
|
||||
|
||||
public static class ManagedToNative
|
||||
{
|
||||
public static IntPtr ConvertToUnmanaged(FlaxEngine.Object managed) => (object)managed != null ? ManagedHandle.ToIntPtr(managed) : IntPtr.Zero;
|
||||
public static IntPtr ConvertToUnmanaged(FlaxEngine.Object managed) => Unsafe.As<object>(managed) != null ? ManagedHandle.ToIntPtr(managed) : IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user