Delete ByteArrayN and IArray

This commit is contained in:
Gabriel A 2023-11-17 20:38:30 -03:00
parent 0d8e6dd4f8
commit d89b004de8
8 changed files with 9 additions and 107 deletions

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Common.Memory
/// Represents an array of unmanaged resources.
/// </summary>
/// <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;

View file

@ -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; }
}
}

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 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);
}
}

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

@ -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<byte>)applicationErrorArg.MessageText).CopyTo(messageTextBuffer);
((Span<byte>)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());

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+