Skip to content

Commit

Permalink
Add U8Span properties for all nacp string fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Thealexbarney committed Feb 21, 2022
1 parent 5f64830 commit a2c6479
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
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

0 comments on commit a2c6479

Please sign in to comment.