mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-12 21:59:12 +00:00
Delete ByteArrayN and IArray
This commit is contained in:
parent
0d8e6dd4f8
commit
d89b004de8
8 changed files with 9 additions and 107 deletions
|
@ -9,7 +9,7 @@ namespace Ryujinx.Common.Memory
|
||||||
/// Represents an array of unmanaged resources.
|
/// Represents an array of unmanaged resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">Array element type</typeparam>
|
/// <typeparam name="T">Array element type</typeparam>
|
||||||
public unsafe struct ArrayPtr<T> : IEquatable<ArrayPtr<T>>, IArray<T> where T : unmanaged
|
public unsafe struct ArrayPtr<T> : IEquatable<ArrayPtr<T>> where T : unmanaged
|
||||||
{
|
{
|
||||||
private IntPtr _ptr;
|
private IntPtr _ptr;
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
namespace Ryujinx.Common.Memory
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Array interface.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Element type</typeparam>
|
|
||||||
public interface IArray<T> where T : unmanaged
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Used to index the array.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="index">Element index</param>
|
|
||||||
/// <returns>Element at the specified index</returns>
|
|
||||||
ref T this[int index] { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of elements on the array.
|
|
||||||
/// </summary>
|
|
||||||
int Length { get; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Ryujinx.Common.Memory
|
|
||||||
{
|
|
||||||
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)]
|
|
||||||
public struct ByteArray128 : IArray<byte>
|
|
||||||
{
|
|
||||||
private const int Size = 128;
|
|
||||||
|
|
||||||
byte _element;
|
|
||||||
|
|
||||||
public readonly int Length => Size;
|
|
||||||
public ref byte this[int index] => ref AsSpan()[index];
|
|
||||||
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)]
|
|
||||||
public struct ByteArray256 : IArray<byte>
|
|
||||||
{
|
|
||||||
private const int Size = 256;
|
|
||||||
|
|
||||||
byte _element;
|
|
||||||
|
|
||||||
public readonly int Length => Size;
|
|
||||||
public ref byte this[int index] => ref AsSpan()[index];
|
|
||||||
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)]
|
|
||||||
public struct ByteArray512 : IArray<byte>
|
|
||||||
{
|
|
||||||
private const int Size = 512;
|
|
||||||
|
|
||||||
byte _element;
|
|
||||||
|
|
||||||
public readonly int Length => Size;
|
|
||||||
public ref byte this[int index] => ref AsSpan()[index];
|
|
||||||
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)]
|
|
||||||
public struct ByteArray1024 : IArray<byte>
|
|
||||||
{
|
|
||||||
private const int Size = 1024;
|
|
||||||
|
|
||||||
byte _element;
|
|
||||||
|
|
||||||
public readonly int Length => Size;
|
|
||||||
public ref byte this[int index] => ref AsSpan()[index];
|
|
||||||
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)]
|
|
||||||
public struct ByteArray2048 : IArray<byte>
|
|
||||||
{
|
|
||||||
private const int Size = 2048;
|
|
||||||
|
|
||||||
byte _element;
|
|
||||||
|
|
||||||
public readonly int Length => Size;
|
|
||||||
public ref byte this[int index] => ref AsSpan()[index];
|
|
||||||
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)]
|
|
||||||
public struct ByteArray4096 : IArray<byte>
|
|
||||||
{
|
|
||||||
private const int Size = 4096;
|
|
||||||
|
|
||||||
byte _element;
|
|
||||||
|
|
||||||
public readonly int Length => Size;
|
|
||||||
public ref byte this[int index] => ref AsSpan()[index];
|
|
||||||
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser
|
||||||
{
|
{
|
||||||
public WebExitReason ExitReason;
|
public WebExitReason ExitReason;
|
||||||
public uint Padding;
|
public uint Padding;
|
||||||
public ByteArray4096 LastUrl;
|
public Array4096<byte> LastUrl;
|
||||||
public ulong LastUrlSize;
|
public ulong LastUrlSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error
|
||||||
{
|
{
|
||||||
public uint ErrorNumber;
|
public uint ErrorNumber;
|
||||||
public ulong LanguageCode;
|
public ulong LanguageCode;
|
||||||
public ByteArray2048 MessageText;
|
public Array2048<byte> MessageText;
|
||||||
public ByteArray2048 DetailsText;
|
public Array2048<byte> DetailsText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,8 +183,8 @@ namespace Ryujinx.HLE.HOS.Applets.Error
|
||||||
byte[] messageTextBuffer = new byte[0x800];
|
byte[] messageTextBuffer = new byte[0x800];
|
||||||
byte[] detailsTextBuffer = new byte[0x800];
|
byte[] detailsTextBuffer = new byte[0x800];
|
||||||
|
|
||||||
applicationErrorArg.MessageText.AsSpan().CopyTo(messageTextBuffer);
|
((Span<byte>)applicationErrorArg.MessageText).CopyTo(messageTextBuffer);
|
||||||
applicationErrorArg.DetailsText.AsSpan().CopyTo(detailsTextBuffer);
|
((Span<byte>)applicationErrorArg.DetailsText).CopyTo(detailsTextBuffer);
|
||||||
|
|
||||||
string messageText = Encoding.ASCII.GetString(messageTextBuffer.TakeWhile(b => !b.Equals(0)).ToArray());
|
string messageText = Encoding.ASCII.GetString(messageTextBuffer.TakeWhile(b => !b.Equals(0)).ToArray());
|
||||||
string detailsText = Encoding.ASCII.GetString(detailsTextBuffer.TakeWhile(b => !b.Equals(0)).ToArray());
|
string detailsText = Encoding.ASCII.GetString(detailsTextBuffer.TakeWhile(b => !b.Equals(0)).ToArray());
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
||||||
public ulong ApplicationIdMask;
|
public ulong ApplicationIdMask;
|
||||||
public ulong ApplicationIdPattern;
|
public ulong ApplicationIdPattern;
|
||||||
private Array16<byte> _reserved;
|
private Array16<byte> _reserved;
|
||||||
public ByteArray256 Modulus;
|
public Array256<byte> Modulus;
|
||||||
public ByteArray256 Signature;
|
public Array256<byte> Signature;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
||||||
public uint KeyGeneration; // 9.0.0+
|
public uint KeyGeneration; // 9.0.0+
|
||||||
private Array8<byte> _reserved;
|
private Array8<byte> _reserved;
|
||||||
public NRRCertification Certification;
|
public NRRCertification Certification;
|
||||||
public ByteArray256 Signature;
|
public Array256<byte> Signature;
|
||||||
public ulong TitleId;
|
public ulong TitleId;
|
||||||
public uint Size;
|
public uint Size;
|
||||||
public byte Kind; // 7.0.0+
|
public byte Kind; // 7.0.0+
|
||||||
|
|
Loading…
Reference in a new issue