Skip to content

Commit

Permalink
Don't required a BufferedStream.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSweet committed Mar 29, 2015
1 parent 412ec15 commit 142e770
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions spine-csharp/src/SkeletonBinary.cs
Expand Up @@ -94,7 +94,7 @@ public SkeletonBinary (params Atlas[] atlasArray)
}
#endif

public SkeletonData ReadSkeletonData (BufferedStream input) {
public SkeletonData ReadSkeletonData (Stream input) {
if (input == null) throw new ArgumentNullException("input cannot be null.");
float scale = Scale;

Expand Down Expand Up @@ -194,7 +194,7 @@ public SkeletonBinary (params Atlas[] atlasArray)
}

/** @return May be null. */
private Skin ReadSkin (BufferedStream input, String skinName, bool nonessential) {
private Skin ReadSkin (Stream input, String skinName, bool nonessential) {
int slotCount = ReadInt(input, true);
if (slotCount == 0) return null;
Skin skin = new Skin(skinName);
Expand All @@ -208,7 +208,7 @@ public SkeletonBinary (params Atlas[] atlasArray)
return skin;
}

private Attachment ReadAttachment (BufferedStream input, Skin skin, String attachmentName, bool nonessential) {
private Attachment ReadAttachment (Stream input, Skin skin, String attachmentName, bool nonessential) {
float scale = Scale;

String name = ReadString(input);
Expand Down Expand Up @@ -309,7 +309,7 @@ public SkeletonBinary (params Atlas[] atlasArray)
return null;
}

private float[] ReadFloatArray (BufferedStream input, float scale) {
private float[] ReadFloatArray (Stream input, float scale) {
int n = ReadInt(input, true);
float[] array = new float[n];
if (scale == 1) {
Expand All @@ -322,23 +322,23 @@ public SkeletonBinary (params Atlas[] atlasArray)
return array;
}

private int[] ReadShortArray (BufferedStream input) {
private int[] ReadShortArray (Stream input) {
int n = ReadInt(input, true);
int[] array = new int[n];
for (int i = 0; i < n; i++)
array[i] = (input.ReadByte() << 8) + input.ReadByte();
return array;
}

private int[] ReadIntArray (BufferedStream input) {
private int[] ReadIntArray (Stream input) {
int n = ReadInt(input, true);
int[] array = new int[n];
for (int i = 0; i < n; i++)
array[i] = ReadInt(input, true);
return array;
}

private void ReadAnimation (String name, BufferedStream input, SkeletonData skeletonData) {
private void ReadAnimation (String name, Stream input, SkeletonData skeletonData) {
var timelines = new List<Timeline>();
float scale = Scale;
float duration = 0;
Expand Down Expand Up @@ -554,7 +554,7 @@ public SkeletonBinary (params Atlas[] atlasArray)
skeletonData.animations.Add(new Animation(name, timelines, duration));
}

private void ReadCurve (BufferedStream input, int frameIndex, CurveTimeline timeline) {
private void ReadCurve (Stream input, int frameIndex, CurveTimeline timeline) {
switch (input.ReadByte()) {
case CURVE_STEPPED:
timeline.SetStepped(frameIndex);
Expand All @@ -565,29 +565,29 @@ public SkeletonBinary (params Atlas[] atlasArray)
}
}

private sbyte ReadSByte (BufferedStream input) {
private sbyte ReadSByte (Stream input) {
int value = input.ReadByte();
if (value == -1) throw new EndOfStreamException();
return (sbyte)value;
}

private bool ReadBoolean (BufferedStream input) {
private bool ReadBoolean (Stream input) {
return input.ReadByte() != 0;
}

private float ReadFloat (BufferedStream input) {
private float ReadFloat (Stream input) {
buffer[3] = (byte)input.ReadByte();
buffer[2] = (byte)input.ReadByte();
buffer[1] = (byte)input.ReadByte();
buffer[0] = (byte)input.ReadByte();
return BitConverter.ToSingle(buffer, 0);
}

private int ReadInt (BufferedStream input) {
private int ReadInt (Stream input) {
return (input.ReadByte() << 24) + (input.ReadByte() << 16) + (input.ReadByte() << 8) + input.ReadByte();
}

private int ReadInt (BufferedStream input, bool optimizePositive) {
private int ReadInt (Stream input, bool optimizePositive) {
int b = input.ReadByte();
int result = b & 0x7F;
if ((b & 0x80) != 0) {
Expand All @@ -609,7 +609,7 @@ public SkeletonBinary (params Atlas[] atlasArray)
return optimizePositive ? result : ((result >> 1) ^ -(result & 1));
}

private string ReadString (BufferedStream input) {
private string ReadString (Stream input) {
int charCount = ReadInt(input, true);
switch (charCount) {
case 0:
Expand All @@ -633,7 +633,7 @@ public SkeletonBinary (params Atlas[] atlasArray)
return new String(chars, 0, charCount);
}

private void ReadUtf8_slow (BufferedStream input, int charCount, int charIndex, int b) {
private void ReadUtf8_slow (Stream input, int charCount, int charIndex, int b) {
char[] chars = this.chars;
while (true) {
switch (b >> 4) {
Expand Down

0 comments on commit 142e770

Please sign in to comment.