Skip to content

Commit

Permalink
Switched "ISubBinaryWriter" to "IBinaryWriter", for consistency with …
Browse files Browse the repository at this point in the history
…"IBinaryReader".
  • Loading branch information
MeltyPlayer committed Oct 20, 2023
1 parent 61ffa6f commit 2de82aa
Show file tree
Hide file tree
Showing 37 changed files with 98 additions and 98 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Any readonly primitives will treated as assertions, which is useful for validati

For complicated schema classes, such as ones that use decompression logic or pointers, you'll need to implement the read/write logic manually.

Specifically, you'll need to implement both a `Read(IBinaryReader br)` and `Write(ISubBinaryWriter bw)` method.
Specifically, you'll need to implement both a `Read(IBinaryReader br)` and `Write(IBinaryWriter bw)` method.
The `SchemaBinaryReader` and `SchemaBinaryWriter` classes provide many helpful methods for reading/writing a number of different primitive formats, including basic ones such as `byte`/`int`/`float`, but also more complex/unique ones such as `Half` (two-byte float) and `un16` (unsigned normalized 16-bit float).

Similar to the automatic process, you can nest schema classes and manually read/write them by calling their `Read()`/`Write()` methods.
Expand Down
2 changes: 1 addition & 1 deletion Schema Build Tests/build/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public interface IMagicSection<T> {

public class MagicSectionStub<T> : IMagicSection<T>, IBinaryConvertible {
public T Data { get; set; }
public void Write(ISubBinaryWriter ew) { }
public void Write(IBinaryWriter ew) { }
public void Read(IBinaryReader br) { }
}

Expand Down
24 changes: 12 additions & 12 deletions Schema Tests/SchemaWriterGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class ByteWrapper {
namespace foo.bar {
public partial class ByteWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteByte(this.Field);
}
}
Expand All @@ -46,7 +46,7 @@ public partial class SByteWrapper {
namespace foo.bar {
public partial class SByteWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteSByte(this.Field);
}
}
Expand All @@ -70,7 +70,7 @@ public partial class ShortWrapper {
namespace foo.bar {
public partial class ShortWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteInt16(this.Field);
}
}
Expand All @@ -94,7 +94,7 @@ public partial class ArrayWrapper {
namespace foo.bar {
public partial class ArrayWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteInt32s(this.field);
}
}
Expand All @@ -121,7 +121,7 @@ public partial class ArrayWrapper {
namespace foo.bar {
public partial class ArrayWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteInt32(this.length);
bw.WriteInt32s(this.field);
}
Expand Down Expand Up @@ -158,7 +158,7 @@ namespace foo.bar {
static internal partial class Parent {
protected partial class Middle {
private partial class Wrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteInt32(this.length);
bw.WriteInt32((int) this.value);
}
Expand All @@ -185,7 +185,7 @@ public partial class CharWrapper {
namespace foo.bar {
public partial class CharWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteChars(this.Array);
}
}
Expand All @@ -209,7 +209,7 @@ public partial class ShortWrapper {
namespace foo.bar {
public partial class ShortWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteInt16(this.Field);
}
}
Expand All @@ -233,7 +233,7 @@ public class ByteWrapper {
namespace foo.bar {
public partial class ByteWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteByte(this.field);
}
}
Expand All @@ -257,7 +257,7 @@ public class ByteWrapper {
namespace foo.bar {
public partial class ByteWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteByte(this.field);
}
}
Expand All @@ -281,7 +281,7 @@ public partial class ByteWrapper {
namespace foo.bar {
public partial class ByteWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteByte(this.Field);
}
}
Expand Down Expand Up @@ -341,7 +341,7 @@ public partial class Other : IBinaryConvertible {
namespace foo.bar {
public partial class EverythingWrapper {
public void Write(ISubBinaryWriter bw) {" +
public void Write(IBinaryWriter bw) {" +
@"
bw.WriteString(this.magicText);" +
@"
Expand Down
8 changes: 4 additions & 4 deletions Schema Tests/binary/attributes/align/AlignGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class AlignWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.Align(2);
bw.WriteByte(this.Field);
}
Expand Down Expand Up @@ -75,7 +75,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class AlignWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32(this.Value);
bw.Align(Value);
bw.WriteByte(this.Field);
Expand Down Expand Up @@ -122,7 +122,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class AlignWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
this.Wrapper.Write(bw);
bw.Align(Wrapper.Value);
bw.WriteByte(this.Field);
Expand Down Expand Up @@ -168,7 +168,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class AlignWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32((uint) this.Field.Length);
bw.Align(2);
bw.WriteInt32s(this.Field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class ChildOfWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteByte(this.Field);
}
}
Expand Down Expand Up @@ -80,7 +80,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class Parent {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
this.Child.Write(bw);
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class ChildOfWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
}
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class Parent {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32(this.Length);
foreach (var e in this.Child) {
e.Write(bw);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class EndiannessWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32(this.Field);
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class EndiannessWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32(this.Field1);
bw.PushMemberEndianness(Endianness.BigEndian);
bw.WriteUInt32(this.Field2);
Expand Down Expand Up @@ -121,7 +121,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class EndiannessWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.PushContainerEndianness(Endianness.BigEndian);
bw.WriteUInt32(this.Field1);
bw.WriteUInt32(this.Field2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class IgnoreWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class BlockWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteInt64(this.Size);
br.WriteInt64(this.Offset);
this.Pointer.Write(bw);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SizeWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32Delayed(bw.GetPointerToMemberRelativeToScope(""Foo"").ContinueWith(task => (uint) task.Result));
bw.MarkStartOfMember(""Foo"");
bw.WriteByte(this.Foo);
Expand Down Expand Up @@ -83,7 +83,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SizeWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32Delayed(bw.GetPointerToMemberRelativeToScope(""Foo.Bar"").ContinueWith(task => (uint) task.Result));
bw.MarkStartOfMember(""Foo"");
this.Foo.Write(bw);
Expand Down Expand Up @@ -133,7 +133,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SizeWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32Delayed(bw.GetPointerToMemberRelativeToScope(""Foo"").ContinueWith(task => (uint) task.Result));
}
}
Expand All @@ -158,7 +158,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class ParentImpl {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
this.Child.Write(bw);
bw.MarkStartOfMember(""Foo"");
bw.WriteByte(this.Foo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class Wrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteByte(this.Field1);
bw.WriteByte(this.Field2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class Wrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteBytes(this.Field);
}
}
Expand Down Expand Up @@ -78,7 +78,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class Wrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
for (var i = 0; i < this.Field.Count; ++i) {
bw.WriteByte(this.Field[i]);
}
Expand Down Expand Up @@ -118,7 +118,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class Wrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteInt32s(this.Field);
}
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class Wrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
for (var i = 0; i < this.Field.Count; ++i) {
bw.WriteInt32(this.Field[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class ReadonlyListClass {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32((uint) Values.Count);
for (var i = 0; i < this.Values.Count; ++i) {
bw.WriteInt32(this.Values[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SequenceWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteInt32(Sequence.Length);
bw.WriteBytes(this.Sequence);
}
Expand Down Expand Up @@ -82,7 +82,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SequenceWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt16((ushort) Sequence.Length);
bw.WriteBytes(this.Sequence);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SequenceWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
Asserts.AllEqual(Sequence1.Length, Sequence2.Count);
bw.WriteInt32(Sequence1.Length);
bw.WriteBytes(this.Sequence1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SizeWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32Delayed(bw.GetSizeOfMemberRelativeToScope(""Foo"").ContinueWith(task => (uint) task.Result));
bw.MarkStartOfMember(""Foo"");
bw.WriteByte(this.Foo);
Expand Down Expand Up @@ -83,7 +83,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SizeWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32Delayed(bw.GetSizeOfMemberRelativeToScope(""Foo.Bar"").ContinueWith(task => (uint) task.Result));
bw.MarkStartOfMember(""Foo"");
this.Foo.Write(bw);
Expand Down Expand Up @@ -133,7 +133,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class SizeWrapper {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32Delayed(bw.GetSizeOfMemberRelativeToScope(""Foo"").ContinueWith(task => (uint) task.Result));
}
}
Expand All @@ -158,7 +158,7 @@ public void Read(IBinaryReader br) {
namespace foo.bar {
public partial class ParentImpl {
public void Write(ISubBinaryWriter bw) {
public void Write(IBinaryWriter bw) {
this.Child.Write(bw);
bw.MarkStartOfMember(""Foo"");
bw.WriteByte(this.Foo);
Expand Down
Loading

0 comments on commit 2de82aa

Please sign in to comment.