Replace StructByteArrayHelpers with generated Array<byte> types

This commit is contained in:
TSR Berry 2022-12-16 15:27:17 +01:00
parent 960c426501
commit 2502a9d00f
No known key found for this signature in database
GPG key ID: 52353C0A4CCA15E2
5 changed files with 9 additions and 86 deletions

View file

@ -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 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 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 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 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 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 int Length => Size;
public ref byte this[int index] => ref AsSpan()[index];
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
}
}

View file

@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser
{
public WebExitReason ExitReason;
public uint Padding;
public ByteArray4096 LastUrl;
public Array4096<byte> LastUrl;
public ulong LastUrlSize;
}
}

View file

@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error
{
public uint ErrorNumber;
public ulong LanguageCode;
public ByteArray2048 MessageText;
public ByteArray2048 DetailsText;
public Array2048<byte> MessageText;
public Array2048<byte> DetailsText;
}
}

View file

@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
public ulong ApplicationIdMask;
public ulong ApplicationIdPattern;
private Array16<byte> _reserved;
public ByteArray256 Modulus;
public ByteArray256 Signature;
public Array256<byte> Modulus;
public Array256<byte> Signature;
}
}

View file

@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
public uint KeyGeneration; // 9.0.0+
private Array8<byte> _reserved;
public NRRCertification Certification;
public ByteArray256 Signature;
public Array256<byte> Signature;
public ulong TitleId;
public uint Size;
public byte Kind; // 7.0.0+