summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMaor Itzkovitch <maor.tt@gmail.com>2015-08-07 10:51:15 +0300
committerMaor Itzkovitch <maor.tt@gmail.com>2015-08-07 10:51:15 +0300
commite4c3bf3d2cec00522fd1a8edd8704413cdc1303b (patch)
tree2e6845dab310f928af1cfbf45fc46ba55c1dc809 /net
parent7196c3684249c12571cd2e16ba8e5564c57484aa (diff)
downloadflatbuffers-e4c3bf3d2cec00522fd1a8edd8704413cdc1303b.tar.gz
flatbuffers-e4c3bf3d2cec00522fd1a8edd8704413cdc1303b.tar.bz2
flatbuffers-e4c3bf3d2cec00522fd1a8edd8704413cdc1303b.zip
fixed C# bytebuffer put methods
Diffstat (limited to 'net')
-rwxr-xr-xnet/FlatBuffers/ByteBuffer.cs14
-rw-r--r--net/FlatBuffers/FlatBufferBuilder.cs7
2 files changed, 12 insertions, 9 deletions
diff --git a/net/FlatBuffers/ByteBuffer.cs b/net/FlatBuffers/ByteBuffer.cs
index 1ea04027..fcdf8a1d 100755
--- a/net/FlatBuffers/ByteBuffer.cs
+++ b/net/FlatBuffers/ByteBuffer.cs
@@ -35,13 +35,18 @@ namespace FlatBuffers
public byte[] Data { get { return _buffer; } }
- public ByteBuffer(byte[] buffer)
+ public ByteBuffer(byte[] buffer) : this(buffer, 0) { }
+
+ public ByteBuffer(byte[] buffer, int pos)
{
_buffer = buffer;
- _pos = 0;
+ _pos = pos;
}
- public int Position { get { return _pos; } }
+ public int Position {
+ get { return _pos; }
+ set { _pos = value; }
+ }
// Pre-allocated helper arrays for convertion.
private float[] floathelper = new[] { 0.0f };
@@ -92,7 +97,6 @@ namespace FlatBuffers
_buffer[offset + count - 1 - i] = (byte)(data >> i * 8);
}
}
- _pos = offset;
}
protected ulong ReadLittleEndian(int offset, int count)
@@ -129,14 +133,12 @@ namespace FlatBuffers
{
AssertOffsetAndLength(offset, sizeof(sbyte));
_buffer[offset] = (byte)value;
- _pos = offset;
}
public void PutByte(int offset, byte value)
{
AssertOffsetAndLength(offset, sizeof(byte));
_buffer[offset] = value;
- _pos = offset;
}
// this method exists in order to conform with Java ByteBuffer standards
diff --git a/net/FlatBuffers/FlatBufferBuilder.cs b/net/FlatBuffers/FlatBufferBuilder.cs
index 453b6e5c..4d43d0dc 100644
--- a/net/FlatBuffers/FlatBufferBuilder.cs
+++ b/net/FlatBuffers/FlatBufferBuilder.cs
@@ -75,8 +75,8 @@ namespace FlatBuffers
Buffer.BlockCopy(oldBuf, 0, newBuf, newBufSize - oldBufSize,
oldBufSize);
-
- _bb = new ByteBuffer(newBuf);
+ _bb = new ByteBuffer(newBuf, newBufSize);
+ System.Diagnostics.Debug.WriteLine(_bb.Position);
}
// Prepare to write an element of `size` after `additional_bytes`
@@ -359,6 +359,7 @@ namespace FlatBuffers
{
Prep(_minAlign, sizeof(int));
AddOffset(rootTable);
+ _bb.Position = _space;
}
public ByteBuffer DataBuffer { get { return _bb; } }
@@ -387,7 +388,7 @@ namespace FlatBuffers
{
AddByte((byte)fileIdentifier[i]);
}
- AddOffset(rootTable);
+ Finish(rootTable);
}