You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by st...@apache.org on 2006/12/12 18:36:22 UTC
svn commit: r486248 [3/3] - in /incubator/qpid/trunk/qpid/dotnet:
Qpid.Buffer/ Qpid.Client.Transport.Socket.Blocking/ Qpid.Client/Client/
Qpid.Client/Client/Message/ Qpid.Codec/ Qpid.Codec/Demux/
Qpid.Common/Framing/ Qpid.Common/stylesheets/
Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferAllocator.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferAllocator.cs?view=auto&rev=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferAllocator.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferAllocator.cs Tue Dec 12 09:36:17 2006
@@ -0,0 +1,50 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+using Qpid.Buffer;
+
+namespace Qpid.Buffer
+{
+ /**
+ * Allocates {@link ByteBuffer}s and manages them. Please implement this
+ * interface if you need more advanced memory management scheme.
+ */
+ public interface ByteBufferAllocator
+ {
+ /**
+ * Returns the buffer which is capable of the specified size.
+ *
+ * @param capacity the capacity of the buffer
+ * @param direct <tt>true</tt> to get a direct buffer,
+ * <tt>false</tt> to get a heap buffer.
+ */
+ ByteBuffer allocate(int capacity, bool direct);
+
+ /**
+ * Wraps the specified NIO {@link FixedByteBuffer} into MINA buffer.
+ */
+ ByteBuffer wrap(FixedByteBuffer nioBuffer);
+
+ /**
+ * Dispose of this allocator.
+ */
+ void dispose();
+ }
+}
\ No newline at end of file
Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferAllocator.cs
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferHexDumper.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferHexDumper.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferHexDumper.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferHexDumper.cs Tue Dec 12 09:36:17 2006
@@ -49,7 +49,7 @@
public static string GetHexDump(ByteBuffer input)
{
- int size = input.Limit - input.Position;
+ int size = input.limit() - input.position();
if (size == 0)
{
return "empty";
@@ -57,7 +57,7 @@
StringBuilder output = new StringBuilder(size * 3 - 1);
- byte[] data = input.ToByteArray();
+ byte[] data = input.array();
int byteValue = data[0] & 0xFF;
output.Append((char) highDigits[byteValue]);
output.Append((char) lowDigits[byteValue]);
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferProxy.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferProxy.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferProxy.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/ByteBufferProxy.cs Tue Dec 12 09:36:17 2006
@@ -23,7 +23,7 @@
namespace Qpid.Buffer
{
- public class ByteBufferProxy : ByteBuffer
+ public class ByteBufferProxy //: ByteBuffer
{
protected ByteBuffer _buf;
@@ -37,154 +37,154 @@
}
- public override void Acquire()
- {
- _buf.Acquire();
- }
-
- public override void Release()
- {
- _buf.Release();
- }
-
- public override int Capacity
- {
- get { return _buf.Capacity; }
- }
-
- public override bool IsAutoExpand
- {
- get { return _buf.IsAutoExpand; }
- set { _buf.IsAutoExpand = value; }
- }
-
- public override void Expand(int expectedRemaining)
- {
- _buf.Expand(expectedRemaining);
- }
-
- public override void Expand(int pos, int expectedRemaining)
- {
- _buf.Expand(pos, expectedRemaining);
- }
-
- public override bool Pooled
- {
- get { return _buf.Pooled; }
- set { _buf.Pooled = value; }
- }
-
- public override int Position
- {
- get { return _buf.Position; }
- set { _buf.Position = value; }
- }
-
- public override int Limit
- {
- get { return _buf.Limit; }
- set { _buf.Limit = value; }
- }
-
- public override void Clear()
- {
- _buf.Clear();
- }
-
- public override void Flip()
- {
- _buf.Flip();
- }
-
- public override void Rewind()
- {
- _buf.Rewind();
- }
-
- public override int Remaining
- {
- get { return _buf.Remaining; }
- }
-
- public override byte Get()
- {
- return _buf.Get();
- }
-
- public override byte Get(int index)
- {
- return _buf.Get(index);
- }
-
- public override void Get(byte[] destination)
- {
- _buf.Get(destination);
- }
-
- public override ushort GetUnsignedShort()
- {
- return _buf.GetUnsignedShort();
- }
-
- public override uint GetUnsignedInt()
- {
- return _buf.GetUnsignedInt();
- }
-
- public override ulong GetUnsignedLong()
- {
- return _buf.GetUnsignedLong();
- }
-
- public override string GetString(uint length, Encoding encoder)
- {
- return _buf.GetString(length, encoder);
- }
-
- public override void Put(byte data)
- {
- _buf.Put(data);
- }
-
- public override void Put(byte[] data, int offset, int size)
- {
- _buf.Put(data, offset, size);
- }
-
- public override void Put(byte[] data)
- {
- _buf.Put(data);
- }
-
- public override void Put(ushort data)
- {
- _buf.Put(data);
- }
-
- public override void Put(uint data)
- {
- _buf.Put(data);
- }
-
- public override void Put(ulong data)
- {
- _buf.Put(data);
- }
-
- public override void Put(ByteBuffer buf)
- {
- _buf.Put(buf);
- }
-
- public override void Compact()
- {
- _buf.Compact();
- }
-
- public override byte[] ToByteArray()
- {
- return _buf.ToByteArray();
- }
+// public /*override*/ void Acquire()
+// {
+// _buf.Acquire();
+// }
+//
+// public /*override*/ void Release()
+// {
+// _buf.Release();
+// }
+//
+// public /*override*/ int Capacity
+// {
+// get { return _buf.Capacity; }
+// }
+//
+// public /*override*/ bool IsAutoExpand
+// {
+// get { return _buf.IsAutoExpand; }
+// set { _buf.IsAutoExpand = value; }
+// }
+//
+// public /*override*/ void Expand(int expectedRemaining)
+// {
+// _buf.Expand(expectedRemaining);
+// }
+//
+// public /*override*/ void Expand(int pos, int expectedRemaining)
+// {
+// _buf.Expand(pos, expectedRemaining);
+// }
+//
+// public /*override*/ bool Pooled
+// {
+// get { return _buf.Pooled; }
+// set { _buf.Pooled = value; }
+// }
+//
+// public /*override*/ int Position
+// {
+// get { return _buf.Position; }
+// set { _buf.Position = value; }
+// }
+//
+// public /*override*/ int Limit
+// {
+// get { return _buf.Limit; }
+// set { _buf.Limit = value; }
+// }
+//
+// public /*override*/ void Clear()
+// {
+// _buf.Clear();
+// }
+//
+// public /*override*/ void Flip()
+// {
+// _buf.Flip();
+// }
+//
+// public /*override*/ void Rewind()
+// {
+// _buf.Rewind();
+// }
+//
+// public /*override*/ int Remaining
+// {
+// get { return _buf.Remaining; }
+// }
+//
+// public /*override*/ byte Get()
+// {
+// return _buf.Get();
+// }
+//
+// public /*override*/ byte Get(int index)
+// {
+// return _buf.Get(index);
+// }
+//
+// public /*override*/ void Get(byte[] destination)
+// {
+// _buf.Get(destination);
+// }
+//
+// public /*override*/ ushort GetUnsignedShort()
+// {
+// return _buf.GetUnsignedShort();
+// }
+//
+// public /*override*/ uint GetUnsignedInt()
+// {
+// return _buf.GetUnsignedInt();
+// }
+//
+// public /*override*/ ulong GetUnsignedLong()
+// {
+// return _buf.GetUnsignedLong();
+// }
+//
+// public /*override*/ string GetString(uint length, Encoding encoder)
+// {
+// return _buf.GetString(length, encoder);
+// }
+//
+// public /*override*/ void Put(byte data)
+// {
+// _buf.Put(data);
+// }
+//
+// public /*override*/ void Put(byte[] data, int offset, int size)
+// {
+// _buf.Put(data, offset, size);
+// }
+//
+// public /*override*/ void Put(byte[] data)
+// {
+// _buf.Put(data);
+// }
+//
+// public /*override*/ void Put(ushort data)
+// {
+// _buf.Put(data);
+// }
+//
+// public /*override*/ void Put(uint data)
+// {
+// _buf.Put(data);
+// }
+//
+// public /*override*/ void Put(ulong data)
+// {
+// _buf.Put(data);
+// }
+//
+// public /*override*/ void Put(ByteBuffer buf)
+// {
+// _buf.Put(buf);
+// }
+//
+// public /*override*/ void Compact()
+// {
+// _buf.Compact();
+// }
+//
+// public /*override*/ byte[] ToByteArray()
+// {
+// return _buf.ToByteArray();
+// }
}
}
Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs?view=auto&rev=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs Tue Dec 12 09:36:17 2006
@@ -0,0 +1,367 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+using System;
+
+namespace Qpid.Buffer
+{
+ public class FixedByteBuffer
+ {
+ private HeapByteBuffer _buf;
+
+ public FixedByteBuffer(int capacity)
+ {
+ _buf = new HeapByteBuffer(capacity);
+ }
+
+ public FixedByteBuffer(byte[] bytes)
+ {
+ _buf = HeapByteBuffer.wrap(bytes);
+ }
+
+ public static FixedByteBuffer wrap(byte[] array)
+ {
+ return new FixedByteBuffer(array);
+ }
+
+ public static FixedByteBuffer wrap(byte[] array, int offset, int length)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ByteOrder order()
+ {
+ return ByteOrder.LittleEndian;
+ }
+
+ public void order(ByteOrder bo)
+ {
+ // Ignore endianess.
+ }
+
+ public void compact()
+ {
+ _buf.Compact();
+ }
+
+ public char getChar()
+ {
+ throw new NotImplementedException();
+ }
+
+ public char getChar(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putChar(char value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putChar(int index, char value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool isDirect()
+ {
+ return false;
+ }
+
+ public bool isReadOnly()
+ {
+ throw new NotImplementedException();
+ }
+
+ public int capacity()
+ {
+ return _buf.Capacity;
+ }
+
+ public int limit()
+ {
+ return _buf.Limit;
+ }
+
+ public int limit(int limit)
+ {
+ int previousLimit = _buf.Limit;
+ _buf.Limit = limit;
+ return previousLimit;
+ }
+
+ public int position()
+ {
+ return _buf.Position;
+ }
+
+ public int position(int newPosition)
+ {
+ int prev = _buf.Position;
+ _buf.Position = newPosition;
+ return prev;
+ }
+
+ public void mark()
+ {
+ throw new NotImplementedException();
+ }
+
+ public static FixedByteBuffer allocateDirect(int capacity)
+ {
+ throw new NotImplementedException();
+ }
+
+ public static FixedByteBuffer allocate(int capacity)
+ {
+ return new FixedByteBuffer(capacity);
+ }
+
+ public void clear()
+ {
+ _buf.Clear();
+ }
+
+ public void put(byte b)
+ {
+ _buf.Put(b);
+ }
+
+ public void put(int index, byte b)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void put(FixedByteBuffer buf)
+ {
+ _buf.Put(buf.array(), buf.position(), buf.limit() - buf.position());
+ }
+
+ public FixedByteBuffer duplicate()
+ {
+ throw new NotImplementedException();
+ }
+
+ public FixedByteBuffer slice()
+ {
+ throw new NotImplementedException();
+ }
+
+ public FixedByteBuffer asReadOnlyBuffer()
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Returns backing array.
+ /// </summary>
+ /// <returns></returns>
+ public byte[] array()
+ {
+ return _buf.array();
+ }
+
+ public int arrayOffset()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void reset()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void flip()
+ {
+ _buf.Flip();
+ }
+
+ public void rewind()
+ {
+ _buf.Rewind();
+ }
+
+ public byte get()
+ {
+ return _buf.Get();
+ }
+
+ public byte get(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public short getShort()
+ {
+ throw new NotImplementedException();
+ }
+
+ public short getShort(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putShort(short value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putShort(int index, short value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int getInt()
+ {
+ throw new NotImplementedException();
+ }
+
+ public int getInt(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putInt(int value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putInt(int index, int value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ByteBuffer get(byte[] dst, int offset, int length)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ByteBuffer put(byte[] src, int offset, int length)
+ {
+ throw new NotImplementedException();
+ }
+
+ public long getLong()
+ {
+ throw new NotImplementedException();
+ }
+
+ public long getLong(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putLong(long value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putLong(int index, long value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int remaining()
+ {
+ return _buf.Remaining;
+ }
+
+ public float getFloat()
+ {
+ throw new NotImplementedException();
+ }
+
+ public float getFloat(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putFloat(float value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putFloat(int index, float value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public double getDouble()
+ {
+ throw new NotImplementedException();
+ }
+
+ public double getDouble(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putDouble(double value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void putDouble(int index, double value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ushort getUnsignedShort()
+ {
+ return _buf.GetUnsignedShort();
+ }
+
+ public uint getUnsignedInt()
+ {
+ return _buf.GetUnsignedInt();
+ }
+
+ public void get(byte[] dst)
+ {
+ _buf.Get(dst);
+ }
+
+ public void put(ushort value)
+ {
+ _buf.Put(value);
+ }
+
+ public void put(uint max)
+ {
+ _buf.Put(max);
+ }
+
+ public void put(ulong tag)
+ {
+ _buf.Put(tag);
+ }
+
+ public void put(byte[] src)
+ {
+ _buf.Put(src);
+ }
+
+ public ulong getUnsignedLong()
+ {
+ return _buf.GetUnsignedLong();
+ }
+ }
+}
Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs Tue Dec 12 09:36:17 2006
@@ -23,7 +23,7 @@
namespace Qpid.Buffer
{
- public class HeapByteBuffer : ByteBuffer
+ public class HeapByteBuffer //: ByteBuffer
{
private byte[] _underlyingData;
@@ -48,7 +48,7 @@
_position = length;
}
- public override int Capacity
+ public /*override*/ int Capacity
{
get
{
@@ -56,7 +56,7 @@
}
}
- public override int Position
+ public /*override*/ int Position
{
get
{
@@ -72,7 +72,7 @@
/// Sets this buffer's limit. If the position is larger than the new limit then it is set to the new limit.
/// </summary>
/// <value>The new limit value; must be non-negative and no larger than this buffer's capacity</value>
- public override int Limit
+ public /*override*/ int Limit
{
get
{
@@ -100,7 +100,7 @@
/// Returns the number of elements between the current position and the limit
/// </summary>
/// <value>The number of elements remaining in this buffer</value>
- public override int Remaining
+ public /*override*/ int Remaining
{
get
{
@@ -108,24 +108,29 @@
}
}
- public override void Clear()
+ public /*override*/ void Clear()
{
_position = 0;
_limit = Capacity;
}
- public override void Flip()
+ public /*override*/ void Flip()
{
_limit = _position;
_position = 0;
}
- public override void Rewind()
+ public /*override*/ void Rewind()
{
_position = 0;
}
- public override byte[] ToByteArray()
+ public byte[] array()
+ {
+ return _underlyingData;
+ }
+
+ public /*override*/ byte[] ToByteArray()
{
// Return copy of bytes remaining.
byte[] result = new byte[Remaining];
@@ -156,7 +161,7 @@
/// </summary>
/// <param name="data">The byte to be written</param>
/// <exception cref="BufferOverflowException">If this buffer's current position is not smaller than its limit</exception>
- public override void Put(byte data)
+ public /*override*/ void Put(byte data)
{
CheckSpace(1);
_underlyingData[_position++] = data;
@@ -168,12 +173,12 @@
/// </summary>
/// <param name="data">The data to copy.</param>
/// <exception cref="BufferOverflowException">If this buffer's current position plus the array length is not smaller than its limit</exception>
- public override void Put(byte[] data)
+ public /*override*/ void Put(byte[] data)
{
Put(data, 0, data.Length);
}
- public override void Put(byte[] data, int offset, int size)
+ public /*override*/ void Put(byte[] data, int offset, int size)
{
if (data == null)
{
@@ -188,14 +193,14 @@
/// Writes the given ushort into this buffer at the current position, and then increments the position.
/// </summary>
/// <param name="data">The ushort to be written</param>
- public override void Put(ushort data)
+ public /*override*/ void Put(ushort data)
{
CheckSpace(2);
_underlyingData[_position++] = (byte) (data >> 8);
_underlyingData[_position++] = (byte) data;
}
- public override void Put(uint data)
+ public /*override*/ void Put(uint data)
{
CheckSpace(4);
_underlyingData[_position++] = (byte) (data >> 24);
@@ -204,7 +209,7 @@
_underlyingData[_position++] = (byte) data;
}
- public override void Put(ulong data)
+ public /*override*/ void Put(ulong data)
{
CheckSpace(8);
_underlyingData[_position++] = (byte) (data >> 56);
@@ -222,7 +227,7 @@
/// </summary>
/// <returns>a byte</returns>
/// <exception cref="BufferUnderflowException">if there are no bytes left to read</exception>
- public override byte Get()
+ public /*override*/ byte Get()
{
CheckSpaceForReading(1);
return _underlyingData[_position++];
@@ -233,7 +238,7 @@
/// </summary>
/// <param name="destination">The destination array. The array must not
/// be bigger than the remaining space in the buffer, nor can it be null.</param>
- public override void Get(byte[] destination)
+ public /*override*/ void Get(byte[] destination)
{
if (destination == null)
{
@@ -250,7 +255,7 @@
/// </summary>
/// <returns>an unsigned short</returns>
/// <exception cref="BufferUnderflowException">If there are fewer than two bytes remaining in this buffer</exception>
- public override ushort GetUnsignedShort()
+ public /*override*/ ushort GetUnsignedShort()
{
CheckSpaceForReading(2);
byte upper = _underlyingData[_position++];
@@ -263,7 +268,7 @@
/// </summary>
/// <returns>an unsigned integer</returns>
/// <exception cref="BufferUnderflowException">If there are fewer than four bytes remaining in this buffer</exception>
- public override uint GetUnsignedInt()
+ public /*override*/ uint GetUnsignedInt()
{
CheckSpaceForReading(4);
byte b1 = _underlyingData[_position++];
@@ -273,7 +278,7 @@
return (uint) ((b1 << 24) + (b2 << 16) + (b3 << 8) + b4);
}
- public override ulong GetUnsignedLong()
+ public /*override*/ ulong GetUnsignedLong()
{
CheckSpaceForReading(8);
byte b1 = _underlyingData[_position++];
@@ -288,7 +293,7 @@
(b6 << 16) + (b7 << 8) + b8);
}
- public override string GetString(uint length, Encoding encoder)
+ public /*override*/ string GetString(uint length, Encoding encoder)
{
CheckSpaceForReading((int)length);
string result = encoder.GetString(_underlyingData, _position, (int)length);
@@ -296,31 +301,31 @@
return result;
}
- public override void Acquire()
+ public /*override*/ void Acquire()
{
}
- public override void Release()
+ public /*override*/ void Release()
{
}
- public override bool IsAutoExpand
+ public /*override*/ bool IsAutoExpand
{
get { return false; }
set { }
}
- public override void Expand(int expectedRemaining)
+ public /*override*/ void Expand(int expectedRemaining)
{
throw new NotImplementedException();
}
- public override void Expand(int pos, int expectedRemaining)
+ public /*override*/ void Expand(int pos, int expectedRemaining)
{
throw new NotImplementedException();
}
- public override bool Pooled
+ public /*override*/ bool Pooled
{
get { return false; }
set { }
@@ -336,38 +341,38 @@
throw new NotImplementedException();
}
- public override byte Get(int index)
+ public /*override*/ byte Get(int index)
{
throw new NotImplementedException();
}
- public override void Put(ByteBuffer src)
- {
- if (src == this)
- {
- throw new ArgumentException("Cannot copy self into self!");
- }
-
- HeapByteBuffer sb;
- if (src is HeapByteBuffer)
- {
- sb = (HeapByteBuffer) src;
- }
- else
- {
- sb = (HeapByteBuffer)((RefCountingByteBuffer) src).Buf;
- }
- int n = sb.Remaining;
- if (n > Remaining)
- {
- throw new BufferOverflowException("Not enought capacity in this buffer for " + n + " elements - only " + Remaining + " remaining");
- }
- Array.Copy(sb._underlyingData, sb._position, _underlyingData, _position, n);
- sb._position += n;
- _position += n;
- }
+// public /*override*/ void Put(ByteBuffer src)
+// {
+// if (src == this)
+// {
+// throw new ArgumentException("Cannot copy self into self!");
+// }
+//
+// HeapByteBuffer sb;
+// if (src is HeapByteBuffer)
+// {
+// sb = (HeapByteBuffer) src;
+// }
+// else
+// {
+// sb = (HeapByteBuffer)((RefCountingByteBuffer) src).Buf;
+// }
+// int n = sb.Remaining;
+// if (n > Remaining)
+// {
+// throw new BufferOverflowException("Not enought capacity in this buffer for " + n + " elements - only " + Remaining + " remaining");
+// }
+// Array.Copy(sb._underlyingData, sb._position, _underlyingData, _position, n);
+// sb._position += n;
+// _position += n;
+// }
- public override void Compact()
+ public /*override*/ void Compact()
{
if (Remaining > 0)
{
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj Tue Dec 12 09:36:17 2006
@@ -36,14 +36,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="BaseByteBuffer.cs" />
+ <Compile Include="BufferDataException.cs" />
<Compile Include="BufferOverflowException.cs" />
<Compile Include="BufferUnderflowException.cs" />
<Compile Include="ByteBuffer.cs" />
+ <Compile Include="ByteBufferAllocator.cs" />
<Compile Include="ByteBufferHexDumper.cs" />
<Compile Include="ByteBufferProxy.cs" />
+ <Compile Include="FixedByteBuffer.cs" />
<Compile Include="HeapByteBuffer.cs" />
- <Compile Include="RefCountingByteBuffer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SimpleByteBufferAllocator.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs?view=auto&rev=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs Tue Dec 12 09:36:17 2006
@@ -0,0 +1,190 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+using System;
+using System.Runtime.CompilerServices;
+
+namespace Qpid.Buffer
+{
+ /**
+ * A simplistic {@link ByteBufferAllocator} which simply allocates a new
+ * buffer every time.
+ */
+ public class SimpleByteBufferAllocator : ByteBufferAllocator
+ {
+ private const int MINIMUM_CAPACITY = 1;
+
+ public SimpleByteBufferAllocator()
+ {
+ }
+
+ public ByteBuffer allocate( int capacity, bool direct )
+ {
+ FixedByteBuffer nioBuffer;
+ if( direct )
+ {
+ nioBuffer = FixedByteBuffer.allocateDirect( capacity );
+ }
+ else
+ {
+ nioBuffer = FixedByteBuffer.allocate( capacity );
+ }
+ return new SimpleByteBuffer( nioBuffer );
+ }
+
+ public ByteBuffer wrap( FixedByteBuffer nioBuffer )
+ {
+ return new SimpleByteBuffer( nioBuffer );
+ }
+
+ public void dispose()
+ {
+ }
+
+ private class SimpleByteBuffer : BaseByteBuffer
+ {
+ private FixedByteBuffer _buf;
+ private int refCount = 1;
+
+ internal SimpleByteBuffer( FixedByteBuffer buf )
+ {
+ this._buf = buf;
+ buf.order( ByteOrder.BigEndian );
+ refCount = 1;
+ }
+
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ public override void acquire()
+ {
+ if( refCount <= 0 )
+ {
+ throw new InvalidOperationException("Already released buffer.");
+ }
+
+ refCount ++;
+ }
+
+ public override void release()
+ {
+ lock( this )
+ {
+ if( refCount <= 0 )
+ {
+ refCount = 0;
+ throw new InvalidOperationException(
+ "Already released buffer. You released the buffer too many times." );
+ }
+
+ refCount --;
+ if( refCount > 0)
+ {
+ return;
+ }
+ }
+ }
+
+ public override FixedByteBuffer buf()
+ {
+ return _buf;
+ }
+
+ public override bool isPooled()
+ {
+ return false;
+ }
+
+ public override void setPooled(bool pooled)
+ {
+ }
+
+ protected override void capacity0(int requestedCapacity)
+ {
+ Console.WriteLine("XXX capacity0 called with requestedCapacity=" + requestedCapacity); // FIXME: remove this.
+
+ int newCapacity = MINIMUM_CAPACITY;
+ while( newCapacity < requestedCapacity )
+ {
+ newCapacity <<= 1;
+ }
+
+ FixedByteBuffer oldBuf = this._buf;
+ FixedByteBuffer newBuf;
+ if( isDirect() )
+ {
+ newBuf = FixedByteBuffer.allocateDirect( newCapacity );
+ }
+ else
+ {
+ newBuf = FixedByteBuffer.allocate( newCapacity );
+ }
+
+ newBuf.clear();
+ oldBuf.clear();
+ newBuf.put( oldBuf );
+ this._buf = newBuf;
+ }
+
+ public override ByteBuffer duplicate() {
+ return new SimpleByteBuffer( this._buf.duplicate() );
+ }
+
+ public override ByteBuffer slice()
+ {
+ return new SimpleByteBuffer( this._buf.slice() );
+ }
+
+ public override ByteBuffer asReadOnlyBuffer()
+ {
+ return new SimpleByteBuffer( this._buf.asReadOnlyBuffer() );
+ }
+
+ public override byte[] array()
+ {
+ return _buf.array();
+ }
+
+ public override int arrayOffset()
+ {
+ return _buf.arrayOffset();
+ }
+
+ public override void put(ushort value)
+ {
+ _buf.put(value);
+ }
+
+ public override void put(uint max)
+ {
+ _buf.put(max);
+ }
+
+ public override void put(ulong tag)
+ {
+ _buf.put(tag);
+ }
+
+ public override ulong GetUnsignedLong()
+ {
+ return _buf.getUnsignedLong();
+ }
+
+ }
+ }
+}
Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Buffer/SimpleByteBufferAllocator.cs
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs Tue Dec 12 09:36:17 2006
@@ -71,7 +71,7 @@
{
try
{
- _networkStream.Write(byteBuffer.ToByteArray(), byteBuffer.Position, byteBuffer.Limit);
+ _networkStream.Write(byteBuffer.array(), byteBuffer.position(), byteBuffer.limit()); // FIXME
}
catch (Exception e)
{
@@ -87,9 +87,10 @@
int numOctets = _networkStream.Read(bytes, 0, bytes.Length);
- ByteBuffer byteBuffer = HeapByteBuffer.wrap(bytes, numOctets);
+ ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
+ byteBuffer.limit(numOctets);
- byteBuffer.Flip();
+ byteBuffer.flip();
return byteBuffer;
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/AmqChannel.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/AmqChannel.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/AmqChannel.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/AmqChannel.cs Tue Dec 12 09:36:17 2006
@@ -819,7 +819,8 @@
byte[] payload = null;
if (buf != null)
{
- payload = buf.ToByteArray();
+ payload = new byte[buf.remaining()];
+ buf.get(payload);
}
BasicContentHeaderProperties contentHeaderProperties = message.ContentHeaderProperties;
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/AMQMessageFactory.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/AMQMessageFactory.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/AMQMessageFactory.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/AMQMessageFactory.cs Tue Dec 12 09:36:17 2006
@@ -62,20 +62,20 @@
if (bodies != null && bodies.Count == 1)
{
_logger.Debug("Non-fragmented message body (bodySize=" + contentHeader.BodySize +")");
- data = HeapByteBuffer.wrap(((ContentBody)bodies[0]).Payload);
+ data = ByteBuffer.wrap(((ContentBody)bodies[0]).Payload);
}
else
{
_logger.Debug("Fragmented message body (" + bodies.Count + " frames, bodySize=" + contentHeader.BodySize + ")");
- data = ByteBuffer.Allocate((int)contentHeader.BodySize); // XXX: Is cast a problem?
+ data = ByteBuffer.allocate((int)contentHeader.BodySize); // XXX: Is cast a problem?
foreach (ContentBody body in bodies) {
- data.Put(body.Payload);
+ data.put(body.Payload);
//body.Payload.Release();
}
- data.Flip();
+ data.flip();
}
- _logger.Debug("Creating message from buffer with position=" + data.Position + " and remaining=" + data.Remaining);
+ _logger.Debug("Creating message from buffer with position=" + data.position() + " and remaining=" + data.remaining());
return CreateMessage(messageNbr, data, contentHeader);
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/AbstractQmsMessage.cs Tue Dec 12 09:36:17 2006
@@ -63,7 +63,7 @@
_data = data;
if (_data != null)
{
- _data.Acquire();
+ _data.acquire();
}
_readableMessage = (data != null);
}
@@ -74,7 +74,7 @@
_data = data;
if (_data != null)
{
- _data.Acquire();
+ _data.acquire();
}
_readableMessage = data != null;
}
@@ -378,7 +378,7 @@
// position beyond the start
if (_data != null)
{
- _data.Rewind();
+ _data.rewind();
}
return _data;
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/QpidBytesMessage.cs Tue Dec 12 09:36:17 2006
@@ -36,7 +36,7 @@
/// <summary>
/// The backingstore for the data
/// </summary>
- private MemoryStream _dataStream;
+ private MemoryStream _dataStream; // FIXME: Probably don't need this any more.
private int _bodyLength;
@@ -59,15 +59,17 @@
ContentHeaderProperties.ContentType = MIME_TYPE;
if (data == null)
{
- _data = ByteBuffer.Allocate(DEFAULT_BUFFER_INITIAL_SIZE);
+ _data = ByteBuffer.allocate(DEFAULT_BUFFER_INITIAL_SIZE);
//_data.AutoExpand = true;
_dataStream = new MemoryStream();
_writer = new BinaryWriter(_dataStream);
}
else
{
- _dataStream = new MemoryStream(data.ToByteArray());
- _bodyLength = data.ToByteArray().Length;
+ byte[] bytes = new byte[data.remaining()];
+ data.get(bytes);
+ _dataStream = new MemoryStream(bytes);
+ _bodyLength = bytes.Length;
_reader = new BinaryReader(_dataStream);
}
}
@@ -77,15 +79,17 @@
: base(messageNbr, (BasicContentHeaderProperties)contentHeader.Properties, data)
{
ContentHeaderProperties.ContentType = MIME_TYPE;
- _dataStream = new MemoryStream(data.ToByteArray());
- _bodyLength = data.ToByteArray().Length;
+ byte[] bytes = new byte[data.remaining()];
+ data.get(bytes);
+ _dataStream = new MemoryStream(bytes);
+ _bodyLength = bytes.Length;
_reader = new BinaryReader(_dataStream);
}
public override void ClearBodyImpl()
{
- _data.Clear();
+ _data.clear();
}
// public override void ClearBody()
@@ -165,7 +169,7 @@
get
{
CheckReadable();
- return _data.Limit; // XXX
+ return _data.limit(); // XXX
// return _bodyLength;
}
}
@@ -577,7 +581,7 @@
public void Reset()
{
base.Reset();
- _data.Flip();
+ _data.flip();
// CheckWritable();
// try
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Message/QpidTextMessage.cs Tue Dec 12 09:36:17 2006
@@ -90,7 +90,7 @@
{
if (_data != null)
{
- _data.Release();
+ _data.release();
}
_data = null;
_decodedValue = null;
@@ -122,15 +122,20 @@
return _decodedValue;
}
else
- {
+ {
+ // Read remaining bytes.
+ byte[] bytes = new byte[_data.remaining()];
+ _data.get(bytes);
+
+ // Convert to string based on encoding.
if (ContentHeaderProperties.Encoding != null)
{
// throw ArgumentException if the encoding is not supported
- _decodedValue = Encoding.GetEncoding(ContentHeaderProperties.Encoding).GetString(_data.ToByteArray());
+ _decodedValue = Encoding.GetEncoding(ContentHeaderProperties.Encoding).GetString(bytes);
}
else
{
- _decodedValue = Encoding.Default.GetString(_data.ToByteArray());
+ _decodedValue = Encoding.Default.GetString(bytes);
}
return _decodedValue;
}
@@ -148,7 +153,7 @@
// throw ArgumentException if the encoding is not supported
bytes = Encoding.GetEncoding(ContentHeaderProperties.Encoding).GetBytes(value);
}
- _data = HeapByteBuffer.wrap(bytes, bytes.Length);
+ _data = ByteBuffer.wrap(bytes);
_decodedValue = value;
}
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs Tue Dec 12 09:36:17 2006
@@ -28,14 +28,13 @@
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 @@
/// </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 @@
}
finally
{
- if (input.HasRemaining())
+ if (input.hasRemaining())
{
- _remaining.Put(input);
+ _remaining.put(input);
}
}
}
@@ -78,8 +77,8 @@
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 @@
}
finally
{
- _remaining.Compact();
+ _remaining.compact();
}
}
@@ -95,17 +94,17 @@
{
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;
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs Tue Dec 12 09:36:17 2006
@@ -217,8 +217,8 @@
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 @@
}
finally
{
- input.Position = pos;
- input.Limit = limit;
+ input.position(pos);
+ input.limit(limit);
}
if (result == MessageDecoderResult.OK)
@@ -248,7 +248,7 @@
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);
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs Tue Dec 12 09:36:17 2006
@@ -51,11 +51,11 @@
}
// final +1 represents the command end which we know we must require even
// if there is an empty body
- if (input.Remaining < 1)
+ if (input.remaining() < 1)
{
return MessageDecoderResult.NEED_DATA;
}
- byte type = input.Get();
+ byte type = input.get();
// we have to check this isn't a protocol initiation frame here - we can't tell later on and we end up
// waiting for more data. This could be improved if MINA supported some kind of state awareness when decoding
@@ -65,7 +65,7 @@
return MessageDecoderResult.NOT_OK;
}
// zero, channel, body size and end byte
- if (input.Remaining < (1 + 2 + 4 + 1))
+ if (input.remaining() < (1 + 2 + 4 + 1))
{
return MessageDecoderResult.NEED_DATA;
}
@@ -80,7 +80,7 @@
return MessageDecoderResult.NOT_OK;
}
- if (input.Remaining < (bodySize + 1))
+ if (input.remaining() < (bodySize + 1))
{
return MessageDecoderResult.NEED_DATA;
}
@@ -116,7 +116,7 @@
protected Object CreateAndPopulateFrame(ByteBuffer input)
{
- byte type = input.Get();
+ byte type = input.get();
ushort channel = input.GetUnsignedShort();
uint bodySize = input.GetUnsignedInt();
@@ -129,7 +129,7 @@
frame.PopulateFromBuffer(input, channel, bodySize, bodyFactory);
- byte marker = input.Get();
+ byte marker = input.get();
//assert marker == 0xCE;
return frame;
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs Tue Dec 12 09:36:17 2006
@@ -51,14 +51,14 @@
{
IDataBlock frame = (IDataBlock) message;
int frameSize = (int)frame.Size; // TODO: sort out signed/unsigned
- ByteBuffer buffer = ByteBuffer.Allocate(frameSize);
+ ByteBuffer buffer = ByteBuffer.allocate(frameSize);
frame.WritePayload(buffer);
if (_logger.IsDebugEnabled)
{
_logger.Debug("Encoded frame byte-buffer is '" + ByteBufferHexDumper.GetHexDump(buffer) + "'");
}
- buffer.Flip();
+ buffer.flip();
output.Write(buffer);
}
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs Tue Dec 12 09:36:17 2006
@@ -74,12 +74,12 @@
public void WritePayload(ByteBuffer buffer)
{
- buffer.Put(_bodyFrame.BodyType);
+ buffer.put(_bodyFrame.BodyType);
// TODO: how does channel get populated
- buffer.Put(_channel);
- buffer.Put(_bodyFrame.Size);
+ buffer.put(_channel);
+ buffer.put(_bodyFrame.Size);
_bodyFrame.WritePayload(buffer);
- buffer.Put((byte) 0xCE);
+ buffer.put((byte) 0xCE);
}
#endregion
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs Tue Dec 12 09:36:17 2006
@@ -62,8 +62,8 @@
public void WritePayload(ByteBuffer buffer)
{
- buffer.Put(Clazz);
- buffer.Put(Method);
+ buffer.put(Clazz);
+ buffer.put(Method);
WriteMethodPayload(buffer);
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs Tue Dec 12 09:36:17 2006
@@ -102,13 +102,13 @@
EncodingUtils.WriteShortStringBytes(buffer, ContentType);
EncodingUtils.WriteShortStringBytes(buffer, Encoding);
EncodingUtils.WriteFieldTableBytes(buffer, Headers);
- buffer.Put(DeliveryMode);
- buffer.Put(Priority);
+ buffer.put(DeliveryMode);
+ buffer.put(Priority);
EncodingUtils.WriteShortStringBytes(buffer, CorrelationId);
EncodingUtils.WriteShortStringBytes(buffer, ReplyTo);
EncodingUtils.WriteShortStringBytes(buffer, String.Format("{0:D}", Expiration));
EncodingUtils.WriteShortStringBytes(buffer, MessageId);
- buffer.Put(Timestamp);
+ buffer.put(Timestamp);
EncodingUtils.WriteShortStringBytes(buffer, Type);
EncodingUtils.WriteShortStringBytes(buffer, UserId);
EncodingUtils.WriteShortStringBytes(buffer, AppId);
@@ -125,9 +125,9 @@
if ((propertyFlags & (1 << 13)) > 0)
Headers = EncodingUtils.ReadFieldTable(buffer);
if ((propertyFlags & (1 << 12)) > 0)
- DeliveryMode = buffer.Get();
+ DeliveryMode = buffer.get();
if ((propertyFlags & (1 << 11)) > 0)
- Priority = buffer.Get();
+ Priority = buffer.get();
if ((propertyFlags & (1 << 10)) > 0)
CorrelationId = EncodingUtils.ReadShortString(buffer);
if ((propertyFlags & (1 << 9)) > 0)
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ContentBody.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ContentBody.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ContentBody.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ContentBody.cs Tue Dec 12 09:36:17 2006
@@ -54,7 +54,7 @@
{
if (Payload != null)
{
- buffer.Put(Payload);
+ buffer.put(Payload);
}
}
@@ -63,7 +63,7 @@
if (size > 0)
{
Payload = new byte[size];
- buffer.Get(Payload);
+ buffer.get(Payload);
}
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs Tue Dec 12 09:36:17 2006
@@ -73,10 +73,10 @@
public void WritePayload(ByteBuffer buffer)
{
- buffer.Put(ClassId);
- buffer.Put(Weight);
- buffer.Put(BodySize);
- buffer.Put(Properties.PropertyFlags);
+ buffer.put(ClassId);
+ buffer.put(Weight);
+ buffer.put(BodySize);
+ buffer.put(Properties.PropertyFlags);
Properties.WritePropertyListPayload(buffer);
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs Tue Dec 12 09:36:17 2006
@@ -91,14 +91,14 @@
encodedString = DEFAULT_ENCODER.GetBytes(s);
}
// TODO: check length fits in an unsigned byte
- buffer.Put((byte) encodedString.Length);
- buffer.Put(encodedString);
+ buffer.put((byte) encodedString.Length);
+ buffer.put(encodedString);
}
else
{
// really writing out unsigned byte
- buffer.Put((byte) 0);
+ buffer.put((byte) 0);
}
}
@@ -110,17 +110,17 @@
}
if (s != null)
{
- buffer.Put((uint)s.Length);
+ buffer.put((uint)s.Length);
byte[] encodedString = null;
lock (DEFAULT_ENCODER)
{
encodedString = DEFAULT_ENCODER.GetBytes(s);
}
- buffer.Put(encodedString);
+ buffer.put(encodedString);
}
else
{
- buffer.Put((uint) 0);
+ buffer.put((uint) 0);
}
}
@@ -132,7 +132,7 @@
}
else
{
- buffer.Put((uint) 0);
+ buffer.put((uint) 0);
}
}
@@ -147,25 +147,25 @@
}
}
- buffer.Put(packedValue);
+ buffer.put(packedValue);
}
public static void WriteLongstr(ByteBuffer buffer, byte[] data)
{
if (data != null)
{
- buffer.Put((uint) data.Length);
- buffer.Put(data);
+ buffer.put((uint) data.Length);
+ buffer.put(data);
}
else
{
- buffer.Put((uint) 0);
+ buffer.put((uint) 0);
}
}
public static bool[] ReadBooleans(ByteBuffer buffer)
{
- byte packedValue = buffer.Get();
+ byte packedValue = buffer.get();
bool[] result = new bool[8];
for (int i = 0; i < 8; i++)
@@ -202,39 +202,46 @@
/// <exception cref="AMQFrameDecodingException">if the buffer does not contain a decodable short string</exception>
public static string ReadShortString(ByteBuffer buffer)
{
- byte length = buffer.Get();
+ byte length = buffer.get();
if (length == 0)
{
return null;
}
else
{
+ byte[] data = new byte[length];
+ buffer.get(data);
+
lock (DEFAULT_ENCODER)
{
- return buffer.GetString(length, DEFAULT_ENCODER);
+ return DEFAULT_ENCODER.GetString(data);
+// return buffer.GetString(length, DEFAULT_ENCODER);
}
}
}
public static string ReadLongString(ByteBuffer buffer)
{
- uint length = buffer.GetUnsignedInt();
+ uint length = buffer.getUnsignedInt();
if (length == 0)
{
return null;
}
else
- {
+ {
+ byte[] data = new byte[length];
+ buffer.get(data);
lock (DEFAULT_ENCODER)
{
- return buffer.GetString(length, DEFAULT_ENCODER);
+ return DEFAULT_ENCODER.GetString(data);
+ //return buffer.GetString(length, DEFAULT_ENCODER);
}
}
}
public static byte[] ReadLongstr(ByteBuffer buffer)
{
- uint length = buffer.GetUnsignedInt();
+ uint length = buffer.getUnsignedInt();
if (length == 0)
{
return null;
@@ -242,7 +249,7 @@
else
{
byte[] result = new byte[length];
- buffer.Get(result);
+ buffer.get(result);
return result;
}
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs Tue Dec 12 09:36:17 2006
@@ -60,10 +60,10 @@
int sizeRead = 0;
while (sizeRead < _encodedSize)
{
- int sizeRemaining = buffer.Remaining;
+ int sizeRemaining = buffer.remaining();
string key = EncodingUtils.ReadShortString(buffer);
// TODO: use proper charset decoder
- char type = (char)buffer.Get();
+ char type = (char)buffer.get();
object value;
switch (type)
{
@@ -76,7 +76,7 @@
default:
throw new AMQFrameDecodingException("Unsupported field table type: '" + type + "' charcode" + (int)type);
}
- sizeRead += (sizeRemaining - buffer.Remaining);
+ sizeRead += (sizeRemaining - buffer.remaining());
_hash.Add(key, value);
}
@@ -123,7 +123,7 @@
public void WriteToBuffer(ByteBuffer buffer)
{
// Write out the total length, which we have kept up to date as data is added.
- buffer.Put(_encodedSize);
+ buffer.put(_encodedSize);
WritePayload(buffer);
}
@@ -136,20 +136,20 @@
object value = lde.Value;
if (value is byte[])
{
- buffer.Put((byte) 'S');
+ buffer.put((byte) 'S');
EncodingUtils.WriteLongstr(buffer, (byte[]) value);
}
else if (value is string)
{
// TODO: look at using proper charset encoder
- buffer.Put((byte) 'S');
+ buffer.put((byte) 'S');
EncodingUtils.WriteLongStringBytes(buffer, (string) value);
}
else if (value is uint)
{
// TODO: look at using proper charset encoder
- buffer.Put((byte) 'I');
- buffer.Put((uint) value);
+ buffer.put((byte) 'I');
+ buffer.put((uint) value);
}
else
{
@@ -161,11 +161,11 @@
public byte[] GetDataAsBytes()
{
- ByteBuffer buffer = ByteBuffer.Allocate((int)_encodedSize);
+ ByteBuffer buffer = ByteBuffer.allocate((int)_encodedSize);
WritePayload(buffer);
byte[] result = new byte[_encodedSize];
- buffer.Flip();
- buffer.Get(result);
+ buffer.flip();
+ buffer.get(result);
//buffer.Release();
return result;
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs Tue Dec 12 09:36:17 2006
@@ -52,7 +52,7 @@
if (size > 0)
{
//allow other implementations to have a payload, but ignore it:
- buffer.Skip((int) size);
+ buffer.skip((int) size);
}
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs Tue Dec 12 09:36:17 2006
@@ -72,12 +72,12 @@
{
foreach (char c in Header)
{
- buffer.Put((byte) c);
+ buffer.put((byte) c);
}
- buffer.Put(ProtocolClass);
- buffer.Put(ProtocolInstance);
- buffer.Put(ProtocolMajor);
- buffer.Put(ProtocolMinor);
+ buffer.put(ProtocolClass);
+ buffer.put(ProtocolInstance);
+ buffer.put(ProtocolMajor);
+ buffer.put(ProtocolMinor);
}
/// <summary>
@@ -99,7 +99,7 @@
{
return MessageDecoderResult.NOT_OK;
}
- if (inbuf.Remaining < 8)
+ if (inbuf.remaining() < 8)
{
return MessageDecoderResult.NEED_DATA;
}
@@ -108,7 +108,7 @@
char[] expected = new char[]{'A', 'M', 'Q', 'P'};
for (int i = 0; i < 4; i++)
{
- if (((char) inbuf.Get()) != expected[i])
+ if (((char) inbuf.get()) != expected[i])
{
return MessageDecoderResult.NOT_OK;
}
@@ -128,13 +128,13 @@
public MessageDecoderResult Decode(ByteBuffer inbuf, IProtocolDecoderOutput output)
{
byte[] header = new byte[4];
- inbuf.Get(header);
+ inbuf.get(header);
ProtocolInitiation pi = new ProtocolInitiation();
pi.Header = new char[]{'A','M','Q','P'};
- pi.ProtocolClass = inbuf.Get();
- pi.ProtocolInstance = inbuf.Get();
- pi.ProtocolMajor = inbuf.Get();
- pi.ProtocolMinor = inbuf.Get();
+ pi.ProtocolClass = inbuf.get();
+ pi.ProtocolInstance = inbuf.get();
+ pi.ProtocolMajor = inbuf.get();
+ pi.ProtocolMinor = inbuf.get();
output.Write(pi);
return MessageDecoderResult.OK;
}
Modified: incubator/qpid/trunk/qpid/dotnet/Qpid.Common/stylesheets/utils.xsl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Common/stylesheets/utils.xsl?view=diff&rev=486248&r1=486247&r2=486248
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Common/stylesheets/utils.xsl (original)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Common/stylesheets/utils.xsl Tue Dec 12 09:36:17 2006
@@ -67,19 +67,19 @@
<xsl:param name="f"/>
<xsl:choose>
<xsl:when test="$f/@type='char'">
- <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/>
+ <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/>
</xsl:when>
<xsl:when test="$f/@type='octet'">
- <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/>
+ <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/>
</xsl:when>
<xsl:when test="$f/@type='short'">
- <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/>
+ <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/>
</xsl:when>
<xsl:when test="$f/@type='long'">
- <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/>
+ <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/>
</xsl:when>
<xsl:when test="$f/@type='longlong'">
- <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/>
+ <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/>
</xsl:when>
<xsl:when test="$f/@type='shortstr'">
<xsl:value-of select="concat('EncodingUtils.WriteShortStringBytes(buffer, ', $f/@name, ')')"/>
@@ -108,7 +108,7 @@
<xsl:value-of select="concat($f/@name, ' = buffer.GetChar()')"/>
</xsl:when>
<xsl:when test="$f/@type='octet'">
- <xsl:value-of select="concat($f/@name, ' = buffer.Get()')"/>
+ <xsl:value-of select="concat($f/@name, ' = buffer.get()')"/>
</xsl:when>
<xsl:when test="$f/@type='short'">
<xsl:value-of select="concat($f/@name, ' = buffer.GetUnsignedShort()')"/>