Skip to content

Commit e8bd9de

Browse files
committed
[Java] Allow uint32 for blockLength with warning. Issue #609.
1 parent 4f91847 commit e8bd9de

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ private void generateGroupDecoderClassHeader(
354354
indent + " this.parentMessage = parentMessage;\n" +
355355
indent + " this.buffer = buffer;\n" +
356356
indent + " dimensions.wrap(buffer, parentMessage.limit());\n" +
357-
indent + " blockLength = dimensions.blockLength();\n" +
357+
indent + " blockLength = (int)dimensions.blockLength();\n" +
358358
indent + " count = (int)dimensions.numInGroup();\n" +
359359
indent + " index = -1;\n" +
360360
indent + " parentMessage.limit(parentMessage.limit() + HEADER_SIZE);\n" +

sbe-tool/src/main/java/uk/co/real_logic/sbe/xml/CompositeType.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ else if (!isUnsigned(blockLengthType.primitiveType()))
167167
{
168168
XmlSchemaParser.handleError(node, "\"blockLength\" must be unsigned type");
169169
}
170+
else
171+
{
172+
if (blockLengthType.primitiveType() != UINT8 && blockLengthType.primitiveType() != UINT16)
173+
{
174+
XmlSchemaParser.handleWarning(node, "\"blockLength\" should be UINT8 or UINT16");
175+
}
176+
177+
final PrimitiveValue blockLengthTypeMaxValue = blockLengthType.maxValue();
178+
validateMaxValue(node, blockLengthType.primitiveType(), blockLengthTypeMaxValue);
179+
}
170180

171181
if (numInGroupType == null)
172182
{
@@ -176,25 +186,26 @@ else if (!isUnsigned(numInGroupType.primitiveType()))
176186
{
177187
XmlSchemaParser.handleError(node, "\"numInGroup\" must be unsigned type");
178188
}
179-
else if (numInGroupType.primitiveType() != UINT8 && numInGroupType.primitiveType() != UINT16)
180-
{
181-
XmlSchemaParser.handleWarning(node, "\"numInGroup\" should be UINT8 or UINT16");
182-
}
183189
else
184190
{
185-
final PrimitiveValue maxValue = numInGroupType.maxValue();
186-
validateMaxValue(node, numInGroupType.primitiveType(), maxValue);
191+
if (numInGroupType.primitiveType() != UINT8 && numInGroupType.primitiveType() != UINT16)
192+
{
193+
XmlSchemaParser.handleWarning(node, "\"numInGroup\" should be UINT8 or UINT16");
194+
}
195+
196+
final PrimitiveValue numInGroupMaxValue = numInGroupType.maxValue();
197+
validateMaxValue(node, numInGroupType.primitiveType(), numInGroupMaxValue);
187198

188-
final PrimitiveValue minValue = numInGroupType.minValue();
189-
if (null != minValue)
199+
final PrimitiveValue numInGroupMinValue = numInGroupType.minValue();
200+
if (null != numInGroupMinValue)
190201
{
191-
final long max = maxValue != null ?
192-
maxValue.longValue() : numInGroupType.primitiveType().maxValue().longValue();
202+
final long max = numInGroupMaxValue != null ?
203+
numInGroupMaxValue.longValue() : numInGroupType.primitiveType().maxValue().longValue();
193204

194-
if (minValue.longValue() > max)
205+
if (numInGroupMinValue.longValue() > max)
195206
{
196207
XmlSchemaParser.handleError(node, String.format(
197-
"\"numInGroup\" minValue=%s greater than maxValue=%d", minValue, max));
208+
"\"numInGroup\" minValue=%s greater than maxValue=%d", numInGroupMinValue, max));
198209
}
199210
}
200211
}

0 commit comments

Comments
 (0)