From d89b004de80ce9fbe1d9ebd29cdbeaff8d34343c Mon Sep 17 00:00:00 2001 From: Gabriel A Date: Fri, 17 Nov 2023 20:38:30 -0300 Subject: [PATCH] Delete ByteArrayN and IArray --- src/Ryujinx.Common/Memory/ArrayPtr.cs | 2 +- src/Ryujinx.Common/Memory/IArray.cs | 21 ----- .../Memory/StructByteArrayHelpers.cs | 77 ------------------- .../Applets/Browser/WebCommonReturnValue.cs | 2 +- .../HOS/Applets/Error/ApplicationErrorArg.cs | 4 +- .../HOS/Applets/Error/ErrorApplet.cs | 4 +- .../HOS/Services/Ro/Types/NRRCertification.cs | 4 +- .../HOS/Services/Ro/Types/NrrHeader.cs | 2 +- 8 files changed, 9 insertions(+), 107 deletions(-) delete mode 100644 src/Ryujinx.Common/Memory/IArray.cs delete mode 100644 src/Ryujinx.Common/Memory/StructByteArrayHelpers.cs diff --git a/src/Ryujinx.Common/Memory/ArrayPtr.cs b/src/Ryujinx.Common/Memory/ArrayPtr.cs index 0365a5089..864fb61d3 100644 --- a/src/Ryujinx.Common/Memory/ArrayPtr.cs +++ b/src/Ryujinx.Common/Memory/ArrayPtr.cs @@ -9,7 +9,7 @@ namespace Ryujinx.Common.Memory /// Represents an array of unmanaged resources. /// /// Array element type - public unsafe struct ArrayPtr : IEquatable>, IArray where T : unmanaged + public unsafe struct ArrayPtr : IEquatable> where T : unmanaged { private IntPtr _ptr; diff --git a/src/Ryujinx.Common/Memory/IArray.cs b/src/Ryujinx.Common/Memory/IArray.cs deleted file mode 100644 index 8f17fade0..000000000 --- a/src/Ryujinx.Common/Memory/IArray.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Ryujinx.Common.Memory -{ - /// - /// Array interface. - /// - /// Element type - public interface IArray where T : unmanaged - { - /// - /// Used to index the array. - /// - /// Element index - /// Element at the specified index - ref T this[int index] { get; } - - /// - /// Number of elements on the array. - /// - int Length { get; } - } -} diff --git a/src/Ryujinx.Common/Memory/StructByteArrayHelpers.cs b/src/Ryujinx.Common/Memory/StructByteArrayHelpers.cs deleted file mode 100644 index f0f452730..000000000 --- a/src/Ryujinx.Common/Memory/StructByteArrayHelpers.cs +++ /dev/null @@ -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 - { - private const int Size = 128; - - byte _element; - - public readonly int Length => Size; - public ref byte this[int index] => ref AsSpan()[index]; - public Span AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size); - } - - [StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)] - public struct ByteArray256 : IArray - { - private const int Size = 256; - - byte _element; - - public readonly int Length => Size; - public ref byte this[int index] => ref AsSpan()[index]; - public Span AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size); - } - - [StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)] - public struct ByteArray512 : IArray - { - private const int Size = 512; - - byte _element; - - public readonly int Length => Size; - public ref byte this[int index] => ref AsSpan()[index]; - public Span AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size); - } - - [StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)] - public struct ByteArray1024 : IArray - { - private const int Size = 1024; - - byte _element; - - public readonly int Length => Size; - public ref byte this[int index] => ref AsSpan()[index]; - public Span AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size); - } - - [StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)] - public struct ByteArray2048 : IArray - { - private const int Size = 2048; - - byte _element; - - public readonly int Length => Size; - public ref byte this[int index] => ref AsSpan()[index]; - public Span AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size); - } - - [StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)] - public struct ByteArray4096 : IArray - { - private const int Size = 4096; - - byte _element; - - public readonly int Length => Size; - public ref byte this[int index] => ref AsSpan()[index]; - public Span AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size); - } -} diff --git a/src/Ryujinx.HLE/HOS/Applets/Browser/WebCommonReturnValue.cs b/src/Ryujinx.HLE/HOS/Applets/Browser/WebCommonReturnValue.cs index a1bdf0c76..9ea26079a 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Browser/WebCommonReturnValue.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Browser/WebCommonReturnValue.cs @@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser { public WebExitReason ExitReason; public uint Padding; - public ByteArray4096 LastUrl; + public Array4096 LastUrl; public ulong LastUrlSize; } } diff --git a/src/Ryujinx.HLE/HOS/Applets/Error/ApplicationErrorArg.cs b/src/Ryujinx.HLE/HOS/Applets/Error/ApplicationErrorArg.cs index 4263c84b8..93c2abb3d 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Error/ApplicationErrorArg.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Error/ApplicationErrorArg.cs @@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error { public uint ErrorNumber; public ulong LanguageCode; - public ByteArray2048 MessageText; - public ByteArray2048 DetailsText; + public Array2048 MessageText; + public Array2048 DetailsText; } } diff --git a/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs index fa415b396..30f3dd989 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs @@ -183,8 +183,8 @@ namespace Ryujinx.HLE.HOS.Applets.Error byte[] messageTextBuffer = new byte[0x800]; byte[] detailsTextBuffer = new byte[0x800]; - applicationErrorArg.MessageText.AsSpan().CopyTo(messageTextBuffer); - applicationErrorArg.DetailsText.AsSpan().CopyTo(detailsTextBuffer); + ((Span)applicationErrorArg.MessageText).CopyTo(messageTextBuffer); + ((Span)applicationErrorArg.DetailsText).CopyTo(detailsTextBuffer); string messageText = Encoding.ASCII.GetString(messageTextBuffer.TakeWhile(b => !b.Equals(0)).ToArray()); string detailsText = Encoding.ASCII.GetString(detailsTextBuffer.TakeWhile(b => !b.Equals(0)).ToArray()); diff --git a/src/Ryujinx.HLE/HOS/Services/Ro/Types/NRRCertification.cs b/src/Ryujinx.HLE/HOS/Services/Ro/Types/NRRCertification.cs index 8c56adb9f..d1b626913 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ro/Types/NRRCertification.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ro/Types/NRRCertification.cs @@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro public ulong ApplicationIdMask; public ulong ApplicationIdPattern; private Array16 _reserved; - public ByteArray256 Modulus; - public ByteArray256 Signature; + public Array256 Modulus; + public Array256 Signature; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Ro/Types/NrrHeader.cs b/src/Ryujinx.HLE/HOS/Services/Ro/Types/NrrHeader.cs index dbbcb1511..c6c8aaa7b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ro/Types/NrrHeader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ro/Types/NrrHeader.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro public uint KeyGeneration; // 9.0.0+ private Array8 _reserved; public NRRCertification Certification; - public ByteArray256 Signature; + public Array256 Signature; public ulong TitleId; public uint Size; public byte Kind; // 7.0.0+