Fixed issue where .ArrayPtr() would not give the pointer to the desired array, and instead returned a pointer to an array of C# objects.
This commit is contained in:
parent
2c5f35c640
commit
8a7872cf3a
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PkmnLibSharp.Utilities
|
||||
|
@ -15,11 +16,22 @@ namespace PkmnLibSharp.Utilities
|
|||
{
|
||||
return i == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(i);
|
||||
}
|
||||
|
||||
internal static IntPtr ArrayPtr(this Array a)
|
||||
|
||||
internal static IntPtr ArrayPtr(this IntPtr[] a)
|
||||
{
|
||||
return Marshal.UnsafeAddrOfPinnedArrayElement(a, 0);
|
||||
}
|
||||
internal static IntPtr ArrayPtr<T>(this T[] a) where T : struct, IConvertible
|
||||
{
|
||||
return Marshal.UnsafeAddrOfPinnedArrayElement(a, 0);
|
||||
}
|
||||
|
||||
internal static IntPtr ArrayPtr(this PointerWrapper?[] a)
|
||||
{
|
||||
return Marshal.UnsafeAddrOfPinnedArrayElement(a.Select(x => x?.Ptr ?? IntPtr.Zero).ToArray(), 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal const byte True = 1;
|
||||
internal const byte False = 0;
|
||||
|
|
Loading…
Reference in New Issue