misc: chore: Use explicit types in HLE project

This commit is contained in:
Evan Husted
2025-01-25 14:13:18 -06:00
parent 58c1ab7989
commit 5eba42fa06
80 changed files with 410 additions and 397 deletions

View File

@@ -76,7 +76,7 @@ namespace Ryujinx.HLE.Loaders.Executables
{
reader.GetSegmentSize(segmentType, out int uncompressedSize).ThrowIfFailure();
var span = program.AsSpan((int)offset, uncompressedSize);
Span<byte> span = program.AsSpan((int)offset, uncompressedSize);
reader.ReadSegment(segmentType, span).ThrowIfFailure();

View File

@@ -65,7 +65,7 @@ namespace Ryujinx.HLE.Loaders.Executables
{
reader.GetSegmentSize(segmentType, out uint uncompressedSize).ThrowIfFailure();
var span = Program.AsSpan((int)offset, (int)uncompressedSize);
Span<byte> span = Program.AsSpan((int)offset, (int)uncompressedSize);
reader.ReadSegment(segmentType, span).ThrowIfFailure();

View File

@@ -25,7 +25,7 @@ namespace Ryujinx.HLE.Loaders.Mods
ReadOnlySpan<byte> ips32TailMagic = "EEOF"u8;
MemPatch patches = new();
var header = reader.ReadBytes(ipsHeaderMagic.Length).AsSpan();
Span<byte> header = reader.ReadBytes(ipsHeaderMagic.Length).AsSpan();
if (header.Length != ipsHeaderMagic.Length)
{
@@ -94,7 +94,7 @@ namespace Ryujinx.HLE.Loaders.Mods
}
else // Copy mode
{
var patch = reader.ReadBytes(patchSize);
byte[] patch = reader.ReadBytes(patchSize);
if (patch.Length != patchSize)
{

View File

@@ -200,7 +200,7 @@ namespace Ryujinx.HLE.Loaders.Mods
}
else if (line.StartsWith("@flag"))
{
var tokens = line.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries);
string[] tokens = line.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length < 2)
{
@@ -234,7 +234,7 @@ namespace Ryujinx.HLE.Loaders.Mods
continue;
}
var tokens = line.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
string[] tokens = line.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length < 2)
{
@@ -259,12 +259,12 @@ namespace Ryujinx.HLE.Loaders.Mods
if (tokens[1][0] == '"')
{
var patch = Encoding.ASCII.GetBytes(tokens[1].Trim('"') + "\0");
byte[] patch = Encoding.ASCII.GetBytes(tokens[1].Trim('"') + "\0");
patches.Add((uint)offset, patch);
}
else
{
var patch = Hex2ByteArrayBE(tokens[1]);
byte[] patch = Hex2ByteArrayBE(tokens[1]);
patches.Add((uint)offset, patch);
}
}

View File

@@ -46,7 +46,7 @@ namespace Ryujinx.HLE.Loaders.Mods
return;
}
foreach (var (patchOffset, patch) in patches._patches)
foreach ((uint patchOffset, byte[] patch) in patches._patches)
{
_patches[patchOffset] = patch;
}
@@ -66,7 +66,7 @@ namespace Ryujinx.HLE.Loaders.Mods
public int Patch(Span<byte> memory, int protectedOffset = 0)
{
int count = 0;
foreach (var (offset, patch) in _patches.OrderBy(item => item.Key))
foreach ((uint offset, byte[] patch) in _patches.OrderBy(item => item.Key))
{
int patchOffset = (int)offset;
int patchSize = patch.Length;

View File

@@ -62,7 +62,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
Logger.Info?.Print(LogClass.Loader, $"Loading {name}...");
using var nsoFile = new UniqueRef<IFile>();
using UniqueRef<IFile> nsoFile = new UniqueRef<IFile>();
exeFs.OpenFile(ref nsoFile.Ref, $"/{name}".ToU8Span(), OpenMode.Read).ThrowIfFailure();

View File

@@ -12,7 +12,7 @@ namespace Ryujinx.HLE.Loaders.Processes
public static ProcessResult Load(this LocalFileSystem exeFs, Switch device, string romFsPath = "")
{
MetaLoader metaLoader = exeFs.GetNpdm();
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1);
ulong programId = metaLoader.GetProgramId();
device.Configuration.VirtualFileSystem.ModLoader.CollectMods([programId]);

View File

@@ -12,21 +12,21 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
{
public static ulong GetProgramId(this MetaLoader metaLoader)
{
metaLoader.GetNpdm(out var npdm).ThrowIfFailure();
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
return npdm.Aci.ProgramId.Value;
}
public static string GetProgramName(this MetaLoader metaLoader)
{
metaLoader.GetNpdm(out var npdm).ThrowIfFailure();
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
return StringUtils.Utf8ZToString(npdm.Meta.ProgramName);
}
public static bool IsProgram64Bit(this MetaLoader metaLoader)
{
metaLoader.GetNpdm(out var npdm).ThrowIfFailure();
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
return (npdm.Meta.Flags & 1) != 0;
}
@@ -45,7 +45,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
path = ProcessConst.MainNpdmPath;
}
using var npdmFile = new UniqueRef<IFile>();
using UniqueRef<IFile> npdmFile = new UniqueRef<IFile>();
fileSystem.OpenFile(ref npdmFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure();

View File

@@ -49,7 +49,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
ModLoader.GetSdModsBasePath());
// Load Nacp file.
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1);
if (controlNca != null)
{
@@ -214,9 +214,9 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
public static BlitStruct<ApplicationControlProperty> GetNacp(this Nca controlNca, Switch device)
{
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1);
using var controlFile = new UniqueRef<IFile>();
using UniqueRef<IFile> controlFile = new UniqueRef<IFile>();
Result result = controlNca.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel)
.OpenFile(ref controlFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read);
@@ -236,7 +236,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
public static Cnmt GetCnmt(this Nca cnmtNca, IntegrityCheckLevel checkLevel, ContentMetaType metaType)
{
string path = $"/{metaType}_{cnmtNca.Header.TitleId:x16}.cnmt";
using var cnmtFile = new UniqueRef<IFile>();
using UniqueRef<IFile> cnmtFile = new UniqueRef<IFile>();
try
{

View File

@@ -28,7 +28,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
{
fileSystem.ImportTickets(partitionFileSystem);
var programs = new Dictionary<ulong, ContentMetaData>();
Dictionary<ulong, ContentMetaData> programs = new Dictionary<ulong, ContentMetaData>();
foreach (DirectoryEntryEx fileEntry in partitionFileSystem.EnumerateEntries("/", "*.cnmt.nca"))
{
@@ -152,7 +152,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
public static Nca GetNca(this IFileSystem fileSystem, KeySet keySet, string path)
{
using var ncaFile = new UniqueRef<IFile>();
using UniqueRef<IFile> ncaFile = new UniqueRef<IFile>();
fileSystem.OpenFile(ref ncaFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure();

View File

@@ -161,7 +161,7 @@ namespace Ryujinx.HLE.Loaders.Processes
public bool LoadNxo(string path)
{
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1);
IFileSystem dummyExeFs = null;
Stream romfsStream = null;

View File

@@ -180,7 +180,7 @@ namespace Ryujinx.HLE.Loaders.Processes
KProcess process = new(context);
var processContextFactory = new ArmProcessContextFactory(
ArmProcessContextFactory processContextFactory = new ArmProcessContextFactory(
context.Device.System.TickSource,
context.Device.Gpu,
string.Empty,
@@ -235,7 +235,7 @@ namespace Ryujinx.HLE.Loaders.Processes
{
context.Device.System.ServiceTable.WaitServicesReady();
LibHac.Result resultCode = metaLoader.GetNpdm(out var npdm);
LibHac.Result resultCode = metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm);
if (resultCode.IsFailure())
{
@@ -244,14 +244,14 @@ namespace Ryujinx.HLE.Loaders.Processes
return ProcessResult.Failed;
}
ref readonly var meta = ref npdm.Meta;
ref readonly Meta meta = ref npdm.Meta;
ulong argsStart = 0;
uint argsSize = 0;
ulong codeStart = ((meta.Flags & 1) != 0 ? 0x8000000UL : 0x200000UL) + CodeStartOffset;
uint codeSize = 0;
var buildIds = new string[executables.Length];
string[] buildIds = new string[executables.Length];
for (int i = 0; i < executables.Length; i++)
{
@@ -373,7 +373,7 @@ namespace Ryujinx.HLE.Loaders.Processes
displayVersion = device.System.ContentManager.GetCurrentFirmwareVersion()?.VersionString ?? string.Empty;
}
var processContextFactory = new ArmProcessContextFactory(
ArmProcessContextFactory processContextFactory = new ArmProcessContextFactory(
context.Device.System.TickSource,
context.Device.Gpu,
$"{programId:x16}",