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

Fixed IFormatter.Clear that JsonFormatter.Clear dose not called. #130

Merged
merged 1 commit into from
Jan 20, 2019
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
11 changes: 11 additions & 0 deletions Assets/VRM/UniJSON/Editor/Tests/Json/JsonFormatterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,16 @@ public void BooleanTest()
Assert.True(json.GetStoreBytes().ToEnumerable().SequenceEqual(bytes));
}
}

[Test]
public void ReUseFormatter()
{
IFormatter f = new JsonFormatter();
f.Value(1);

f.Clear();
// fail
f.Value(2);
}
}
}
5 changes: 0 additions & 5 deletions Assets/VRM/UniJSON/Scripts/FormatterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ namespace UniJSON
{
public static partial class FormatterExtensions
{
public static void Clear(this IFormatter f)
{
f.GetStore().Clear();
}

public static ArraySegment<Byte> GetStoreBytes(this IFormatter f)
{
return f.GetStore().Bytes;
Expand Down
1 change: 1 addition & 0 deletions Assets/VRM/UniJSON/Scripts/IFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace UniJSON
public interface IFormatter
{
IStore GetStore();
void Clear();

void BeginList(int n);
void EndList();
Expand Down
6 changes: 5 additions & 1 deletion Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Text;


namespace UniJSON
Expand All @@ -16,6 +15,11 @@ public MsgPackFormatter() : this(new BytesStore())
{
}

public void Clear()
{
m_store.Clear();
}

#if false
public bool MsgPack_Ext(IList list)
{
Expand Down