Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add U8Span properties for all ApplicationControlProperty string fields #236

Merged
merged 1 commit into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/LibHac/Ns/ApplicationControlProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ public struct ApplicationControlProperty
public AccessibleLaunchRequiredVersionValue AccessibleLaunchRequiredVersion;
public Array3000<byte> Reserved3448;

public U8Span IsbnString => new U8Span(Isbn.ItemsRo);
public U8Span DisplayVersionString => new U8Span(DisplayVersion.ItemsRo);
public U8Span ApplicationErrorCodeCategoryString => new U8Span(ApplicationErrorCodeCategory.ItemsRo);
public U8Span BcatPassphraseString => new U8Span(BcatPassphrase.ItemsRo);
public readonly U8Span IsbnString => new U8Span(Isbn.ItemsRo);
public readonly U8Span DisplayVersionString => new U8Span(DisplayVersion.ItemsRo);
public readonly U8Span ApplicationErrorCodeCategoryString => new U8Span(ApplicationErrorCodeCategory.ItemsRo);
public readonly U8Span BcatPassphraseString => new U8Span(BcatPassphrase.ItemsRo);

public struct ApplicationTitle
{
private Array512<byte> _name;
private Array256<byte> _publisher;
public Array512<byte> Name;
public Array256<byte> Publisher;

public U8SpanMutable Name => new U8SpanMutable(_name.Items);
public U8SpanMutable Publisher => new U8SpanMutable(_publisher.Items);
public readonly U8Span NameString => new U8Span(Name.ItemsRo);
public readonly U8Span PublisherString => new U8Span(Publisher.ItemsRo);
}

public struct ApplicationNeighborDetectionClientConfiguration
Expand Down
4 changes: 2 additions & 2 deletions src/LibHac/Tools/Fs/SwitchFs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ private void ReadControls()

foreach (ref readonly ApplicationControlProperty.ApplicationTitle desc in title.Control.Value.Title.ItemsRo)
{
if (!desc.Name.IsEmpty())
if (!desc.NameString.IsEmpty())
{
title.Name = desc.Name.ToString();
title.Name = desc.NameString.ToString();
break;
}
}
Expand Down
7 changes: 5 additions & 2 deletions tests/LibHac.Tests/Ns/TypeLayoutTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ public static void ApplicationTitle_Layout()

Assert.Equal(0x300, Unsafe.SizeOf<ApplicationTitle>());

Assert.Equal(0x000, GetOffset(in s, in s.Name.Value[0]));
Assert.Equal(0x200, GetOffset(in s, in s.Publisher.Value[0]));
Assert.Equal(0x000, GetOffset(in s, in s.Name));
Assert.Equal(0x200, GetOffset(in s, in s.Publisher));

Assert.Equal(0x000, GetOffset(in s, in s.NameString.Value[0]));
Assert.Equal(0x200, GetOffset(in s, in s.PublisherString.Value[0]));
}

[Fact]
Expand Down