summaryrefslogtreecommitdiff
path: root/qpid/dotnet/Qpid.Buffer
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-02-13 16:56:03 +0000
committerRobert Greig <rgreig@apache.org>2007-02-13 16:56:03 +0000
commit3c02c7504d1bd1e155288a4b98d8e412f7f87f0d (patch)
tree58b64c2ac727adc2cda41a72f50222083202efb4 /qpid/dotnet/Qpid.Buffer
parent75604802beb83083aa66f2400fbcb7df2e681f1f (diff)
downloadqpid-python-3c02c7504d1bd1e155288a4b98d8e412f7f87f0d.tar.gz
(Path submitted by Tomas Restrepo) Qpid-336 Field table updated to match Java client.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@507096 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/dotnet/Qpid.Buffer')
-rw-r--r--qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs22
-rw-r--r--qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs75
-rw-r--r--qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj2
-rw-r--r--qpid/dotnet/Qpid.Buffer/Qpid.Buffer.mdp6
4 files changed, 89 insertions, 16 deletions
diff --git a/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs b/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs
index 39a17a6fa7..d2f3ca8a3c 100644
--- a/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs
+++ b/qpid/dotnet/Qpid.Buffer/FixedByteBuffer.cs
@@ -211,7 +211,7 @@ namespace Qpid.Buffer
public short getShort()
{
- throw new NotImplementedException();
+ return _buf.GetShort();
}
public short getShort(int index)
@@ -221,7 +221,7 @@ namespace Qpid.Buffer
public void putShort(short value)
{
- throw new NotImplementedException();
+ _buf.Put(value);
}
public void putShort(int index, short value)
@@ -231,7 +231,7 @@ namespace Qpid.Buffer
public int getInt()
{
- throw new NotImplementedException();
+ return _buf.GetInt();
}
public int getInt(int index)
@@ -241,7 +241,7 @@ namespace Qpid.Buffer
public void putInt(int value)
{
- throw new NotImplementedException();
+ _buf.Put(value);
}
public void putInt(int index, int value)
@@ -261,7 +261,7 @@ namespace Qpid.Buffer
public long getLong()
{
- throw new NotImplementedException();
+ return _buf.GetLong();
}
public long getLong(int index)
@@ -271,7 +271,7 @@ namespace Qpid.Buffer
public void putLong(long value)
{
- throw new NotImplementedException();
+ _buf.Put(value);
}
public void putLong(int index, long value)
@@ -286,17 +286,17 @@ namespace Qpid.Buffer
public float getFloat()
{
- throw new NotImplementedException();
+ return _buf.GetFloat();
}
public float getFloat(int index)
{
- throw new NotImplementedException();
+ throw new NotImplementedException();
}
public void putFloat(float value)
{
- throw new NotImplementedException();
+ _buf.Put(value);
}
public void putFloat(int index, float value)
@@ -306,7 +306,7 @@ namespace Qpid.Buffer
public double getDouble()
{
- throw new NotImplementedException();
+ return _buf.GetDouble();
}
public double getDouble(int index)
@@ -316,7 +316,7 @@ namespace Qpid.Buffer
public void putDouble(double value)
{
- throw new NotImplementedException();
+ _buf.Put(value);
}
public void putDouble(int index, double value)
diff --git a/qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs b/qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs
index 3ac99021d7..f95fe1c241 100644
--- a/qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs
+++ b/qpid/dotnet/Qpid.Buffer/HeapByteBuffer.cs
@@ -221,6 +221,40 @@ namespace Qpid.Buffer
_underlyingData[_position++] = (byte) (data >> 8);
_underlyingData[_position++] = (byte) data;
}
+
+ public void Put(short data)
+ {
+ Put((ushort)data);
+ }
+
+ public void Put(int data)
+ {
+ Put((uint)data);
+ }
+
+ public void Put(long data)
+ {
+ Put((ulong)data);
+ }
+
+ public void Put(float data)
+ {
+ unsafe
+ {
+ uint val = *((uint*)&data);
+ Put(val);
+ }
+ }
+
+ public void Put(double data)
+ {
+ unsafe
+ {
+ ulong val = *((ulong*)&data);
+ Put(val);
+ }
+ }
+
/// <summary>
/// Read the byte at the current position and increment the position
@@ -289,8 +323,44 @@ namespace Qpid.Buffer
byte b6 = _underlyingData[_position++];
byte b7 = _underlyingData[_position++];
byte b8 = _underlyingData[_position++];
- return (ulong)((b1 << 56) + (b2 << 48) + (b3 << 40) + (b4 << 32) + (b5 << 24) +
- (b6 << 16) + (b7 << 8) + b8);
+ // all the casts necessary because otherwise each subexpression
+ // only gets promoted to uint and cause incorrect results
+ return (((ulong)b1 << 56) + ((ulong)b2 << 48) + ((ulong)b3 << 40) +
+ ((ulong)b4 << 32) + ((ulong)b5 << 24) +
+ ((ulong)b6 << 16) + ((ulong)b7 << 8) + b8);
+ }
+
+ public short GetShort()
+ {
+ return (short) GetUnsignedShort();
+ }
+
+ public int GetInt()
+ {
+ return (int) GetUnsignedInt();
+ }
+
+ public long GetLong()
+ {
+ return (long) GetUnsignedLong();
+ }
+
+ public float GetFloat()
+ {
+ unsafe
+ {
+ uint val = GetUnsignedInt();
+ return *((float*)&val);
+ }
+ }
+
+ public double GetDouble()
+ {
+ unsafe
+ {
+ ulong val = GetUnsignedLong();
+ return *((double*)&val);
+ }
}
public /*override*/ string GetString(uint length, Encoding encoder)
@@ -401,3 +471,4 @@ namespace Qpid.Buffer
}
}
+
diff --git a/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj b/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj
index 3e4b302a3a..e6bade037b 100644
--- a/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj
+++ b/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.csproj
@@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -29,6 +30,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
diff --git a/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.mdp b/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.mdp
index 1e2a655357..8f2497e8b9 100644
--- a/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.mdp
+++ b/qpid/dotnet/Qpid.Buffer/Qpid.Buffer.mdp
@@ -4,13 +4,13 @@
<Output directory="./bin/Debug" assembly="Qpid.Buffer" />
<Build debugmode="True" target="Library" />
<Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" />
- <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+ <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="True" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
<Configuration name="Release" ctype="DotNetProjectConfiguration">
<Output directory="./bin/Release" assembly="Qpid.Buffer" />
<Build debugmode="False" target="Library" />
<Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_1_1" />
- <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+ <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="True" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
</Configurations>
<DeployTargets />
@@ -32,4 +32,4 @@
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</References>
-</Project> \ No newline at end of file
+</Project>