Skip to content

Commit c37ca97

Browse files
author
Olivier Deheurles
committed
Port for dbd304c ([Java]: Reworked messageHeader in all schemas to reflect Issue aeron-io#94)
1 parent f0d6016 commit c37ca97

File tree

14 files changed

+54
-84
lines changed

14 files changed

+54
-84
lines changed
-42 Bytes
Binary file not shown.

examples/csharp/generated_stub/ExampleUsingGeneratedStub.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static void Main()
6363
// In a real app you would use that to lookup the applicable flyweight to decode this type of message based on templateId and version.
6464
int actingBlockLength = MessageHeader.BlockLength;
6565
int schemaId = MessageHeader.SchemaId;
66-
short actingVersion = MessageHeader.Version;
66+
int actingVersion = MessageHeader.Version;
6767

6868
bufferOffset += MessageHeader.Size;
6969
// now we decode the message
@@ -162,7 +162,7 @@ public static void Decode(Car car,
162162

163163
// decode the car properties on by one, directly from the buffer
164164
sb.Append("\ncar.templateId=").Append(Car.TemplateId);
165-
sb.Append("\ncar.schemaId=").Append(Car.SchemaId);
165+
sb.Append("\ncar.schemaId=").Append(schemaId);
166166
sb.Append("\ncar.schemaVersion=").Append(Car.Schema_Version);
167167
sb.Append("\ncar.serialNumber=").Append(car.SerialNumber);
168168
sb.Append("\ncar.modelYear=").Append(car.ModelYear);

examples/csharp/generated_stub/generated/Car.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class Car
1010
{
1111
public const ushort BlockLength = (ushort)45;
1212
public const ushort TemplateId = (ushort)1;
13-
public const byte SchemaId = (byte)1;
14-
public const byte Schema_Version = (byte)0;
13+
public const ushort SchemaId = (ushort)1;
14+
public const ushort Schema_Version = (ushort)0;
1515
public const string SematicType = "";
1616

1717
private readonly Car _parentMessage;

examples/csharp/generated_stub/generated/MessageHeader.cs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,21 @@ public ushort SchemaId
7878
}
7979

8080

81-
public const byte VersionNullValue = (byte)255;
81+
public const ushort VersionNullValue = (ushort)65535;
8282

83-
public const byte VersionMinValue = (byte)0;
83+
public const ushort VersionMinValue = (ushort)0;
8484

85-
public const byte VersionMaxValue = (byte)254;
85+
public const ushort VersionMaxValue = (ushort)65534;
8686

87-
public byte Version
87+
public ushort Version
8888
{
8989
get
9090
{
91-
return _buffer.Uint8Get(_offset + 6);
91+
return _buffer.Uint16GetLittleEndian(_offset + 6);
9292
}
9393
set
9494
{
95-
_buffer.Uint8Put(_offset + 6, value);
96-
}
97-
}
98-
99-
100-
public const byte ReservedNullValue = (byte)255;
101-
102-
public const byte ReservedMinValue = (byte)0;
103-
104-
public const byte ReservedMaxValue = (byte)254;
105-
106-
public byte Reserved
107-
{
108-
get
109-
{
110-
return _buffer.Uint8Get(_offset + 7);
111-
}
112-
set
113-
{
114-
_buffer.Uint8Put(_offset + 7, value);
95+
_buffer.Uint16PutLittleEndian(_offset + 6, value);
11596
}
11697
}
11798

main/csharp/ir/generated/FrameCodec.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ namespace Adaptive.SimpleBinaryEncoding.Ir.Generated
88
{
99
public class FrameCodec
1010
{
11-
public const ushort TemplateId = (ushort)1;
12-
public const ushort TemplateVersion = (ushort)0;
1311
public const ushort BlockLength = (ushort)12;
12+
public const ushort TemplateId = (ushort)1;
13+
public const ushort SchemaId = (ushort)0;
14+
public const ushort Schema_Version = (ushort)0;
1415
public const string SematicType = "";
1516

1617
private readonly FrameCodec _parentMessage;
@@ -32,7 +33,7 @@ public void WrapForEncode(DirectBuffer buffer, int offset)
3233
_buffer = buffer;
3334
_offset = offset;
3435
_actingBlockLength = BlockLength;
35-
_actingVersion = TemplateVersion;
36+
_actingVersion = Schema_Version;
3637
Limit = offset + _actingBlockLength;
3738
}
3839

@@ -183,7 +184,7 @@ public static string PackageNameMetaAttribute(MetaAttribute metaAttribute)
183184
return "";
184185
}
185186

186-
public const int PackageNameHeaderSize = 1
187+
public const int PackageNameHeaderSize = 1;
187188

188189
public int GetPackageName(byte[] dst, int dstOffset, int length)
189190
{
@@ -226,7 +227,7 @@ public static string NamespaceNameMetaAttribute(MetaAttribute metaAttribute)
226227
return "";
227228
}
228229

229-
public const int NamespaceNameHeaderSize = 1
230+
public const int NamespaceNameHeaderSize = 1;
230231

231232
public int GetNamespaceName(byte[] dst, int dstOffset, int length)
232233
{
@@ -269,7 +270,7 @@ public static string SemanticVersionMetaAttribute(MetaAttribute metaAttribute)
269270
return "";
270271
}
271272

272-
public const int SemanticVersionHeaderSize = 1
273+
public const int SemanticVersionHeaderSize = 1;
273274

274275
public int GetSemanticVersion(byte[] dst, int dstOffset, int length)
275276
{

main/csharp/ir/generated/TokenCodec.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ namespace Adaptive.SimpleBinaryEncoding.Ir.Generated
88
{
99
public class TokenCodec
1010
{
11-
public const ushort TemplateId = (ushort)2;
12-
public const ushort TemplateVersion = (ushort)0;
1311
public const ushort BlockLength = (ushort)20;
12+
public const ushort TemplateId = (ushort)2;
13+
public const ushort SchemaId = (ushort)0;
14+
public const ushort Schema_Version = (ushort)0;
1415
public const string SematicType = "";
1516

1617
private readonly TokenCodec _parentMessage;
@@ -32,7 +33,7 @@ public void WrapForEncode(DirectBuffer buffer, int offset)
3233
_buffer = buffer;
3334
_offset = offset;
3435
_actingBlockLength = BlockLength;
35-
_actingVersion = TemplateVersion;
36+
_actingVersion = Schema_Version;
3637
Limit = offset + _actingBlockLength;
3738
}
3839

@@ -324,7 +325,7 @@ public static string NameMetaAttribute(MetaAttribute metaAttribute)
324325
return "";
325326
}
326327

327-
public const int NameHeaderSize = 1
328+
public const int NameHeaderSize = 1;
328329

329330
public int GetName(byte[] dst, int dstOffset, int length)
330331
{
@@ -367,7 +368,7 @@ public static string ConstValueMetaAttribute(MetaAttribute metaAttribute)
367368
return "";
368369
}
369370

370-
public const int ConstValueHeaderSize = 1
371+
public const int ConstValueHeaderSize = 1;
371372

372373
public int GetConstValue(byte[] dst, int dstOffset, int length)
373374
{
@@ -410,7 +411,7 @@ public static string MinValueMetaAttribute(MetaAttribute metaAttribute)
410411
return "";
411412
}
412413

413-
public const int MinValueHeaderSize = 1
414+
public const int MinValueHeaderSize = 1;
414415

415416
public int GetMinValue(byte[] dst, int dstOffset, int length)
416417
{
@@ -453,7 +454,7 @@ public static string MaxValueMetaAttribute(MetaAttribute metaAttribute)
453454
return "";
454455
}
455456

456-
public const int MaxValueHeaderSize = 1
457+
public const int MaxValueHeaderSize = 1;
457458

458459
public int GetMaxValue(byte[] dst, int dstOffset, int length)
459460
{
@@ -496,7 +497,7 @@ public static string NullValueMetaAttribute(MetaAttribute metaAttribute)
496497
return "";
497498
}
498499

499-
public const int NullValueHeaderSize = 1
500+
public const int NullValueHeaderSize = 1;
500501

501502
public int GetNullValue(byte[] dst, int dstOffset, int length)
502503
{
@@ -539,7 +540,7 @@ public static string CharacterEncodingMetaAttribute(MetaAttribute metaAttribute)
539540
return "";
540541
}
541542

542-
public const int CharacterEncodingHeaderSize = 1
543+
public const int CharacterEncodingHeaderSize = 1;
543544

544545
public int GetCharacterEncoding(byte[] dst, int dstOffset, int length)
545546
{
@@ -582,7 +583,7 @@ public static string EpochMetaAttribute(MetaAttribute metaAttribute)
582583
return "";
583584
}
584585

585-
public const int EpochHeaderSize = 1
586+
public const int EpochHeaderSize = 1;
586587

587588
public int GetEpoch(byte[] dst, int dstOffset, int length)
588589
{
@@ -625,7 +626,7 @@ public static string TimeUnitMetaAttribute(MetaAttribute metaAttribute)
625626
return "";
626627
}
627628

628-
public const int TimeUnitHeaderSize = 1
629+
public const int TimeUnitHeaderSize = 1;
629630

630631
public int GetTimeUnit(byte[] dst, int dstOffset, int length)
631632
{
@@ -668,7 +669,7 @@ public static string SemanticTypeMetaAttribute(MetaAttribute metaAttribute)
668669
return "";
669670
}
670671

671-
public const int SemanticTypeHeaderSize = 1
672+
public const int SemanticTypeHeaderSize = 1;
672673

673674
public int GetSemanticType(byte[] dst, int dstOffset, int length)
674675
{

perf/csharp/Adaptive.SimpleBinaryEncoding.PerfTests/Bench/SBE/FIX/MarketDataIncrementalRefresh.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class MarketDataIncrementalRefresh
1010
{
1111
public const ushort BlockLength = (ushort)2;
1212
public const ushort TemplateId = (ushort)88;
13-
public const byte SchemaId = (byte)2;
14-
public const byte Schema_Version = (byte)0;
13+
public const ushort SchemaId = (ushort)2;
14+
public const ushort Schema_Version = (ushort)0;
1515
public const string SematicType = "X";
1616

1717
private readonly MarketDataIncrementalRefresh _parentMessage;

perf/csharp/Adaptive.SimpleBinaryEncoding.PerfTests/Bench/SBE/FIX/MarketDataIncrementalRefreshTrades.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class MarketDataIncrementalRefreshTrades
1010
{
1111
public const ushort BlockLength = (ushort)11;
1212
public const ushort TemplateId = (ushort)2;
13-
public const byte SchemaId = (byte)2;
14-
public const byte Schema_Version = (byte)0;
13+
public const ushort SchemaId = (ushort)2;
14+
public const ushort Schema_Version = (ushort)0;
1515
public const string SematicType = "X";
1616

1717
private readonly MarketDataIncrementalRefreshTrades _parentMessage;

perf/csharp/Adaptive.SimpleBinaryEncoding.PerfTests/Bench/SBE/FIX/MassQuote.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class MassQuote
1010
{
1111
public const ushort BlockLength = (ushort)62;
1212
public const ushort TemplateId = (ushort)105;
13-
public const byte SchemaId = (byte)2;
14-
public const byte Schema_Version = (byte)0;
13+
public const ushort SchemaId = (ushort)2;
14+
public const ushort Schema_Version = (ushort)0;
1515
public const string SematicType = "i";
1616

1717
private readonly MassQuote _parentMessage;

perf/csharp/Adaptive.SimpleBinaryEncoding.PerfTests/Bench/SBE/FIX/MessageHeader.cs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,21 @@ public ushort SchemaId
7878
}
7979

8080

81-
public const byte VersionNullValue = (byte)255;
81+
public const ushort VersionNullValue = (ushort)65535;
8282

83-
public const byte VersionMinValue = (byte)0;
83+
public const ushort VersionMinValue = (ushort)0;
8484

85-
public const byte VersionMaxValue = (byte)254;
85+
public const ushort VersionMaxValue = (ushort)65534;
8686

87-
public byte Version
87+
public ushort Version
8888
{
8989
get
9090
{
91-
return _buffer.Uint8Get(_offset + 6);
91+
return _buffer.Uint16GetLittleEndian(_offset + 6);
9292
}
9393
set
9494
{
95-
_buffer.Uint8Put(_offset + 6, value);
96-
}
97-
}
98-
99-
100-
public const byte ReservedNullValue = (byte)255;
101-
102-
public const byte ReservedMinValue = (byte)0;
103-
104-
public const byte ReservedMaxValue = (byte)254;
105-
106-
public byte Reserved
107-
{
108-
get
109-
{
110-
return _buffer.Uint8Get(_offset + 7);
111-
}
112-
set
113-
{
114-
_buffer.Uint8Put(_offset + 7, value);
95+
_buffer.Uint16PutLittleEndian(_offset + 6, value);
11596
}
11697
}
11798

0 commit comments

Comments
 (0)