mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 15:58:56 +00:00
fixed C# bytebuffer put methods
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user