Skip to content

Commit

Permalink
Use VYaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchLeaders committed Sep 14, 2024
1 parent 51723d0 commit 96446fe
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/BymlLibrary/Byml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using BymlLibrary.Nodes.Containers.HashMap;
using BymlLibrary.Writers;
using BymlLibrary.Yaml;
using LiteYaml.Emitter;
using Revrs;
using Revrs.Buffers;
using System.Buffers;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text;
using VYaml.Emitter;

namespace BymlLibrary;

Expand Down
2 changes: 1 addition & 1 deletion src/BymlLibrary/BymlLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="LiteYaml" Version="0.1.1" />
<PackageReference Include="Revrs" Version="1.0.6" />
<PackageReference Include="VYaml" Version="0.27.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/BymlLibrary/ImmutableByml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Text;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary;

Expand Down
8 changes: 4 additions & 4 deletions src/BymlLibrary/Nodes/Containers/BymlArray.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BymlLibrary.Extensions;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using BymlLibrary.Extensions;
using BymlLibrary.Writers;
using BymlLibrary.Yaml;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Containers;

Expand Down
10 changes: 5 additions & 5 deletions src/BymlLibrary/Nodes/Containers/BymlArrayChangelog.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BymlLibrary.Extensions;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using BymlLibrary.Extensions;
using BymlLibrary.Writers;
using BymlLibrary.Yaml;
using LiteYaml.Emitter;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Containers;

Expand All @@ -19,7 +19,7 @@ public BymlArrayChangelog(IDictionary<int, (BymlChangeType, Byml)> values) : bas

public void EmitYaml(ref Utf8YamlEmitter emitter)
{
emitter.SetTag("!array_changelog");
emitter.Tag("!array_changelog");
emitter.BeginMapping();

foreach (var (hash, (change, node)) in this) {
Expand Down
10 changes: 5 additions & 5 deletions src/BymlLibrary/Nodes/Containers/BymlMap.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using BymlLibrary.Extensions;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BymlLibrary.Extensions;
using BymlLibrary.Writers;
using BymlLibrary.Yaml;
using Revrs;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Containers;

Expand Down
10 changes: 5 additions & 5 deletions src/BymlLibrary/Nodes/Containers/HashMap/BymlHashMap32.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BymlLibrary.Extensions;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using BymlLibrary.Extensions;
using BymlLibrary.Writers;
using BymlLibrary.Yaml;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Containers.HashMap;

Expand All @@ -19,7 +19,7 @@ public BymlHashMap32(IDictionary<uint, Byml> values) : base(values)

public void EmitYaml(ref Utf8YamlEmitter emitter)
{
emitter.SetTag("!h32");
emitter.Tag("!h32");
emitter.BeginMapping((Count < Byml.YamlConfig.InlineContainerMaxCount && !HasContainerNodes()) switch {
true => MappingStyle.Flow,
false => MappingStyle.Block,
Expand Down
4 changes: 2 additions & 2 deletions src/BymlLibrary/Nodes/Containers/HashMap/BymlHashMap64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using BymlLibrary.Yaml;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Containers.HashMap;

Expand All @@ -19,7 +19,7 @@ public BymlHashMap64(IDictionary<ulong, Byml> values) : base(values)

public void EmitYaml(ref Utf8YamlEmitter emitter)
{
emitter.SetTag("!h64");
emitter.Tag("!h64");
emitter.BeginMapping((Count < Byml.YamlConfig.InlineContainerMaxCount && !HasContainerNodes()) switch {
true => MappingStyle.Flow,
false => MappingStyle.Block,
Expand Down
2 changes: 1 addition & 1 deletion src/BymlLibrary/Nodes/Containers/IBymlNode.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using BymlLibrary.Writers;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Containers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Revrs.Extensions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Immutable.Containers.HashMap;

Expand Down Expand Up @@ -102,7 +102,7 @@ public BymlHashMap32 ToMutable(in ImmutableByml root)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal unsafe void EmitYaml(ref Utf8YamlEmitter emitter, in ImmutableByml root)
{
emitter.SetTag("!h32");
emitter.Tag("!h32");
emitter.BeginMapping((Count < Byml.YamlConfig.InlineContainerMaxCount && !HasContainerNodes()) switch {
true => MappingStyle.Flow,
false => MappingStyle.Block,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Revrs.Extensions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Immutable.Containers.HashMap;

Expand Down Expand Up @@ -117,7 +117,7 @@ public static void Reverse(ref RevrsReader reader, int offset, int count, in Has
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal unsafe void EmitYaml(ref Utf8YamlEmitter emitter, in ImmutableByml root)
{
emitter.SetTag("!h64");
emitter.Tag("!h64");
emitter.BeginMapping((Count < Byml.YamlConfig.InlineContainerMaxCount && !HasContainerNodes()) switch {
true => MappingStyle.Flow,
false => MappingStyle.Block,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using BymlLibrary.Extensions;
using System.Runtime.CompilerServices;
using BymlLibrary.Extensions;
using BymlLibrary.Nodes.Containers;
using BymlLibrary.Structures;
using BymlLibrary.Yaml;
using Revrs;
using Revrs.Extensions;
using System.Runtime.CompilerServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Immutable.Containers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using BymlLibrary.Extensions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BymlLibrary.Nodes.Containers;
using BymlLibrary.Structures;
using BymlLibrary.Yaml;
using Revrs;
using Revrs.Extensions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Immutable.Containers;

Expand Down Expand Up @@ -104,7 +103,7 @@ public BymlArrayChangelog ToMutable(in ImmutableByml root)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal unsafe void EmitYaml(ref Utf8YamlEmitter emitter, in ImmutableByml root)
{
emitter.SetTag("!array-changelog");
emitter.Tag("!array-changelog");
emitter.BeginMapping();

foreach (var (index, change, node) in this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Revrs.Extensions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using LiteYaml.Emitter;
using VYaml.Emitter;

namespace BymlLibrary.Nodes.Immutable.Containers;

Expand Down
8 changes: 4 additions & 4 deletions src/BymlLibrary/Yaml/BymlYamlReader.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using BymlLibrary.Nodes.Containers;
using BymlLibrary.Nodes.Containers.HashMap;
using System.Buffers;
using System.Buffers;
using System.Runtime.CompilerServices;
using LiteYaml.Parser;
using BymlLibrary.Nodes.Containers;
using BymlLibrary.Nodes.Containers.HashMap;
using VYaml.Parser;

namespace BymlLibrary.Yaml;

Expand Down
28 changes: 14 additions & 14 deletions src/BymlLibrary/Yaml/BymlYamlWriter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BymlLibrary.Nodes.Containers;
using BymlLibrary.Nodes.Immutable.Containers;
using LiteYaml.Emitter;
using System.Buffers;
using System.Globalization;
using System.Text;
using VYaml.Emitter;

namespace BymlLibrary.Yaml;

Expand Down Expand Up @@ -56,23 +56,23 @@ public static void Write(ref Utf8YamlEmitter emitter, in ImmutableByml byml, in
WriteFloat(ref emitter, ref formattedFloatBuffer, byml.GetFloat());
break;
case BymlNodeType.UInt32:
emitter.SetTag("!u");
emitter.Tag("!u");
WriteUInt32(ref emitter, ref formattedHexBuffer, byml.GetUInt32());
break;
case BymlNodeType.Int64:
emitter.SetTag("!l");
emitter.Tag("!l");
emitter.WriteInt64(byml.GetInt64());
break;
case BymlNodeType.UInt64:
emitter.SetTag("!ul");
emitter.Tag("!ul");
WriteUInt64(ref emitter, ref formattedHexBuffer, byml.GetUInt64());
break;
case BymlNodeType.Double:
emitter.SetTag("!d");
emitter.Tag("!d");
WriteDouble(ref emitter, ref formattedFloatBuffer, byml.GetDouble());
break;
case BymlNodeType.Changelog:
emitter.SetTag("!changelog");
emitter.Tag("!changelog");
emitter.WriteString(byml.GetChangelog().ToString());
break;
case BymlNodeType.Null:
Expand Down Expand Up @@ -128,23 +128,23 @@ public static void Write(ref Utf8YamlEmitter emitter, in Byml byml)
WriteFloat(ref emitter, ref formattedFloatBuffer, byml.GetFloat());
break;
case BymlNodeType.UInt32:
emitter.SetTag("!u");
emitter.Tag("!u");
WriteUInt32(ref emitter, ref formattedHexBuffer, byml.GetUInt32());
break;
case BymlNodeType.Int64:
emitter.SetTag("!l");
emitter.Tag("!l");
emitter.WriteInt64(byml.GetInt64());
break;
case BymlNodeType.UInt64:
emitter.SetTag("!ul");
emitter.Tag("!ul");
WriteUInt64(ref emitter, ref formattedHexBuffer, byml.GetUInt64());
break;
case BymlNodeType.Double:
emitter.SetTag("!d");
emitter.Tag("!d");
WriteDouble(ref emitter, ref formattedFloatBuffer, byml.GetDouble());
break;
case BymlNodeType.Changelog:
emitter.SetTag("!changelog");
emitter.Tag("!changelog");
emitter.WriteString(byml.GetChangelog().ToString());
break;
case BymlNodeType.Null:
Expand Down Expand Up @@ -193,20 +193,20 @@ private static void WriteUInt64(ref Utf8YamlEmitter emitter, ref Span<byte> form

private static void WriteBinary(ref Utf8YamlEmitter emitter, Span<byte> data)
{
emitter.SetTag("!!binary");
emitter.Tag("!!binary");
emitter.WriteString(
Convert.ToBase64String(data)
);
}

private static void WriteBinaryAligned(ref Utf8YamlEmitter emitter, in Span<byte> data, int alignment)
{
emitter.SetTag("!!file");
emitter.Tag("!!file");
emitter.BeginMapping(MappingStyle.Flow);
emitter.WriteString("Alignment");
emitter.WriteInt32(alignment);
emitter.WriteString("Data");
emitter.SetTag("!!binary");
emitter.Tag("!!binary");
emitter.WriteString(Convert.ToBase64String(data));
emitter.EndMapping();
}
Expand Down

0 comments on commit 96446fe

Please sign in to comment.