diff options
author | Jon Skeet <skeet@pobox.com> | 2009-09-09 13:22:36 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2009-09-09 13:22:36 +0100 |
commit | 3c80886fa9043cba3b0ecc0362935b014066b89f (patch) | |
tree | 45bb5b6ae25875edf877bc59d3e071f3596d252a /src/ProtocolBuffers/CodedOutputStream.cs | |
parent | 79a8c010332d3255bc20ad2b8da463c6179bb422 (diff) | |
download | protobuf-3c80886fa9043cba3b0ecc0362935b014066b89f.tar.gz protobuf-3c80886fa9043cba3b0ecc0362935b014066b89f.tar.bz2 protobuf-3c80886fa9043cba3b0ecc0362935b014066b89f.zip |
Silverlight compatibility other than SortedList
Diffstat (limited to 'src/ProtocolBuffers/CodedOutputStream.cs')
-rw-r--r-- | src/ProtocolBuffers/CodedOutputStream.cs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ProtocolBuffers/CodedOutputStream.cs b/src/ProtocolBuffers/CodedOutputStream.cs index e5f890f9..241c4acb 100644 --- a/src/ProtocolBuffers/CodedOutputStream.cs +++ b/src/ProtocolBuffers/CodedOutputStream.cs @@ -114,9 +114,8 @@ namespace Google.ProtocolBuffers { /// Writes a double field value, including tag, to the stream. /// </summary> public void WriteDouble(int fieldNumber, double value) { - // TODO(jonskeet): Test this on different endiannesses WriteTag(fieldNumber, WireFormat.WireType.Fixed64); - WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value)); + WriteDoubleNoTag(value); } /// <summary> @@ -124,10 +123,7 @@ namespace Google.ProtocolBuffers { /// </summary> public void WriteFloat(int fieldNumber, float value) { WriteTag(fieldNumber, WireFormat.WireType.Fixed32); - // TODO(jonskeet): Test this on different endiannesses - byte[] rawBytes = BitConverter.GetBytes(value); - uint asInteger = BitConverter.ToUInt32(rawBytes, 0); - WriteRawLittleEndian32(asInteger); + WriteFloatNoTag(value); } /// <summary> @@ -332,7 +328,13 @@ namespace Google.ProtocolBuffers { /// Writes a double field value, including tag, to the stream. /// </summary> public void WriteDoubleNoTag(double value) { + // TODO(jonskeet): Test this on different endiannesses +#if SILVERLIGHT2 + byte[] bytes = BitConverter.GetBytes(value); + WriteRawBytes(bytes, 0, 8); +#else WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value)); +#endif } /// <summary> |