Skip to content

Commit 9c8613c

Browse files
author
odeheurles
committed
[C#] Fix issue with ulong code generation (issue aeron-io#51)
1 parent d29bb53 commit 9c8613c

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed
0 Bytes
Binary file not shown.

examples/csharp/generated_stub/generated/Car.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Car
99
{
1010
public const ushort TemplateId = (ushort)1;
1111
public const byte TemplateVersion = (byte)0;
12-
public const ushort BlockLength = (ushort)41;
12+
public const ushort BlockLength = (ushort)45;
1313

1414
private readonly Car _parentMessage;
1515
private DirectBuffer _buffer;
@@ -80,21 +80,21 @@ public static string SerialNumberMetaAttribute(MetaAttribute metaAttribute)
8080
return "";
8181
}
8282

83-
public const uint SerialNumberNullVal = 4294967294U;
83+
public const ulong SerialNumberNullVal = 0x8000000000000000UL;
8484

85-
public const uint SerialNumberMinVal = 0U;
85+
public const ulong SerialNumberMinVal = 0x0UL;
8686

87-
public const uint SerialNumberMaxVal = 4294967293U;
87+
public const ulong SerialNumberMaxVal = 0x7fffffffffffffffUL;
8888

89-
public uint SerialNumber
89+
public ulong SerialNumber
9090
{
9191
get
9292
{
93-
return _buffer.Uint32GetLittleEndian(_offset + 0);
93+
return _buffer.Uint64GetLittleEndian(_offset + 0);
9494
}
9595
set
9696
{
97-
_buffer.Uint32PutLittleEndian(_offset + 0, value);
97+
_buffer.Uint64PutLittleEndian(_offset + 0, value);
9898
}
9999
}
100100

@@ -123,11 +123,11 @@ public ushort ModelYear
123123
{
124124
get
125125
{
126-
return _buffer.Uint16GetLittleEndian(_offset + 4);
126+
return _buffer.Uint16GetLittleEndian(_offset + 8);
127127
}
128128
set
129129
{
130-
_buffer.Uint16PutLittleEndian(_offset + 4, value);
130+
_buffer.Uint16PutLittleEndian(_offset + 8, value);
131131
}
132132
}
133133

@@ -150,11 +150,11 @@ public BooleanType Available
150150
{
151151
get
152152
{
153-
return (BooleanType)_buffer.Uint8Get(_offset + 6);
153+
return (BooleanType)_buffer.Uint8Get(_offset + 10);
154154
}
155155
set
156156
{
157-
_buffer.Uint8Put(_offset + 6, (byte)value);
157+
_buffer.Uint8Put(_offset + 10, (byte)value);
158158
}
159159
}
160160

@@ -177,11 +177,11 @@ public Model Code
177177
{
178178
get
179179
{
180-
return (Model)_buffer.CharGet(_offset + 7);
180+
return (Model)_buffer.CharGet(_offset + 11);
181181
}
182182
set
183183
{
184-
_buffer.CharPut(_offset + 7, (byte)value);
184+
_buffer.CharPut(_offset + 11, (byte)value);
185185
}
186186
}
187187

@@ -215,7 +215,7 @@ public int GetSomeNumbers(int index)
215215
throw new IndexOutOfRangeException("index out of range: index=" + index);
216216
}
217217

218-
return _buffer.Int32GetLittleEndian(_offset + 8 + (index * 4));
218+
return _buffer.Int32GetLittleEndian(_offset + 12 + (index * 4));
219219
}
220220

221221
public void SetSomeNumbers(int index, int value)
@@ -225,7 +225,7 @@ public void SetSomeNumbers(int index, int value)
225225
throw new IndexOutOfRangeException("index out of range: index=" + index);
226226
}
227227

228-
_buffer.Int32PutLittleEndian(_offset + 8 + (index * 4), value);
228+
_buffer.Int32PutLittleEndian(_offset + 12 + (index * 4), value);
229229
}
230230

231231
public const int VehicleCodeSchemaId = 6;
@@ -257,7 +257,7 @@ public byte GetVehicleCode(int index)
257257
throw new IndexOutOfRangeException("index out of range: index=" + index);
258258
}
259259

260-
return _buffer.CharGet(_offset + 28 + (index * 1));
260+
return _buffer.CharGet(_offset + 32 + (index * 1));
261261
}
262262

263263
public void SetVehicleCode(int index, byte value)
@@ -267,7 +267,7 @@ public void SetVehicleCode(int index, byte value)
267267
throw new IndexOutOfRangeException("index out of range: index=" + index);
268268
}
269269

270-
_buffer.CharPut(_offset + 28 + (index * 1), value);
270+
_buffer.CharPut(_offset + 32 + (index * 1), value);
271271
}
272272

273273
public const string VehicleCodeCharacterEncoding = "UTF-8";
@@ -280,7 +280,7 @@ public int GetVehicleCode(byte[] dst, int dstOffset)
280280
throw new IndexOutOfRangeException("dstOffset out of range for copy: offset=" + dstOffset);
281281
}
282282

283-
_buffer.GetBytes(_offset + 28, dst, dstOffset, length);
283+
_buffer.GetBytes(_offset + 32, dst, dstOffset, length);
284284
return length;
285285
}
286286

@@ -292,7 +292,7 @@ public void SetVehicleCode(byte[] src, int srcOffset)
292292
throw new IndexOutOfRangeException("srcOffset out of range for copy: offset=" + srcOffset);
293293
}
294294

295-
_buffer.SetBytes(_offset + 28, src, srcOffset, length);
295+
_buffer.SetBytes(_offset + 32, src, srcOffset, length);
296296
}
297297

298298
public const int ExtrasSchemaId = 7;
@@ -313,11 +313,11 @@ public OptionalExtras Extras
313313
{
314314
get
315315
{
316-
return (OptionalExtras)_buffer.Uint8Get(_offset + 34);
316+
return (OptionalExtras)_buffer.Uint8Get(_offset + 38);
317317
}
318318
set
319319
{
320-
_buffer.Uint8Put(_offset + 34, (byte)value);
320+
_buffer.Uint8Put(_offset + 38, (byte)value);
321321
}
322322
}
323323

@@ -341,7 +341,7 @@ public Engine Engine
341341
{
342342
get
343343
{
344-
_engine.Wrap(_buffer, _offset + 35, _actingVersion);
344+
_engine.Wrap(_buffer, _offset + 39, _actingVersion);
345345
return _engine;
346346
}
347347
}

main/csharp/Adaptive.SimpleBinaryEncoding.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<Compile Include="ir\generated\ByteOrderCodec.cs" />
5252
<Compile Include="ir\generated\FrameCodec.cs" />
5353
<Compile Include="ir\generated\MessageHeader.cs" />
54+
<Compile Include="ir\generated\MetaAttribute.cs" />
5455
<Compile Include="ir\generated\PresenceCodec.cs" />
5556
<Compile Include="ir\generated\PrimitiveTypeCodec.cs" />
5657
<Compile Include="ir\generated\SignalCodec.cs" />
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* Generated SBE (Simple Binary Encoding) message codec */
2+
3+
using System;
4+
using Adaptive.SimpleBinaryEncoding;
5+
6+
namespace Uk.Co.Real_logic.Sbe.Ir.Generated
7+
{
8+
public enum MetaAttribute
9+
{
10+
Epoch,
11+
TimeUnit,
12+
SemanticType
13+
}
14+
}

main/java/uk/co/real_logic/sbe/generation/csharp/CSharpGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ private String generateLiteral(final PrimitiveType type, final String value)
12571257
break;
12581258

12591259
case UINT64:
1260-
literal = value + "UL";
1260+
literal = "0x" + Long.toHexString(Long.parseLong(value)) + "UL";
12611261
break;
12621262

12631263
case INT64:

0 commit comments

Comments
 (0)