diff options
Diffstat (limited to 'dotnet/Qpid.Codec')
| -rw-r--r-- | dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs | 25 | ||||
| -rw-r--r-- | dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs | 10 |
2 files changed, 17 insertions, 18 deletions
diff --git a/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs b/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs index 70b4940c7b..21614cf108 100644 --- a/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs +++ b/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs @@ -28,14 +28,13 @@ namespace Qpid.Codec ByteBuffer _remaining; /// <summary> - /// Creates a new instance with the 65535 bytes initial capacity of + /// Creates a new instance with the 4096 bytes initial capacity of /// cumulative buffer. - /// Note that capacity is currently fixed as the .NET ByteBuffers does not implement auto-expansion. /// </summary> protected CumulativeProtocolDecoder() { - // Needs to be as large as the largest frame to be decoded. - _remaining = ByteBuffer.Allocate(65535); // FIXME: Probably should not be fixed. + _remaining = ByteBuffer.allocate(4096); + _remaining.setAutoExpand(true); } /// <summary> @@ -49,7 +48,7 @@ namespace Qpid.Codec /// </exception> public void Decode(ByteBuffer input, IProtocolDecoderOutput output) { - if (_remaining.Position != 0) // If there were remaining undecoded bytes + if (_remaining.position() != 0) // If there were remaining undecoded bytes { DecodeRemainingAndInput(input, output); } @@ -68,9 +67,9 @@ namespace Qpid.Codec } finally { - if (input.HasRemaining()) + if (input.hasRemaining()) { - _remaining.Put(input); + _remaining.put(input); } } } @@ -78,8 +77,8 @@ namespace Qpid.Codec private void DecodeRemainingAndInput(ByteBuffer input, IProtocolDecoderOutput output) { // Concatenate input buffer with left-over bytes. - _remaining.Put(input); - _remaining.Flip(); + _remaining.put(input); + _remaining.flip(); try { @@ -87,7 +86,7 @@ namespace Qpid.Codec } finally { - _remaining.Compact(); + _remaining.compact(); } } @@ -95,17 +94,17 @@ namespace Qpid.Codec { for (;;) { - int oldPos = buf.Position; + int oldPos = buf.position(); bool decoded = DoDecode(buf, output); if (decoded) { - if (buf.Position == oldPos) + if (buf.position() == oldPos) { throw new Exception( "doDecode() can't return true when buffer is not consumed."); } - if (!buf.HasRemaining()) + if (!buf.hasRemaining()) { break; } diff --git a/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs b/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs index 8a58eecda4..6577909cff 100644 --- a/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs +++ b/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs @@ -217,8 +217,8 @@ namespace Qpid.Codec.Demux for (int i = decoders.Length - 1; i >= 0; i --) { IMessageDecoder decoder = decoders[i]; - int limit = input.Limit; - int pos = input.Position; + int limit = input.limit(); + int pos = input.position(); try { @@ -226,8 +226,8 @@ namespace Qpid.Codec.Demux } finally { - input.Position = pos; - input.Limit = limit; + input.position(pos); + input.limit(limit); } if (result == MessageDecoderResult.OK) @@ -248,7 +248,7 @@ namespace Qpid.Codec.Demux if (undecodables == _decoders.Length) { // Throw an exception if all decoders cannot decode data. - input.Position = input.Limit; // Skip data + input.position(input.limit()); // Skip data throw new ProtocolDecoderException( "No appropriate message decoder: " + input.HexDump); } |
