Skip to content

Commit 067f300

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 488273e + b8260b1 commit 067f300

File tree

7 files changed

+70
-62
lines changed

7 files changed

+70
-62
lines changed

config/checkstyle.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<property name="tabWidth" value="4"/>
2020
<property name="severity" value="error"/>
2121

22+
<module name="Indentation"/>
23+
2224
<module name="ConstantName"/>
2325

2426
<module name="FinalLocalVariable"/>

sbe-samples/src/main/cpp/OtfExample.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,17 @@ int main(int argc, char **argv)
426426
}
427427

428428
std::shared_ptr<std::vector<Token>> headerTokens = irDecoder.header();
429-
std::shared_ptr<std::vector<Token>> messageTokens = irDecoder.message(Car::sbeTemplateId(), Car::sbeSchemaVersion());
430429

431430
OtfHeaderDecoder headerDecoder(headerTokens);
432431

433432
const char *messageBuffer = buffer + headerDecoder.encodedLength();
434433
std::uint64_t length = sz - headerDecoder.encodedLength();
434+
std::uint64_t templateId = headerDecoder.getTemplateId(buffer);
435435
std::uint64_t actingVersion = headerDecoder.getSchemaVersion(buffer);
436436
std::uint64_t blockLength = headerDecoder.getBlockLength(buffer);
437437

438+
std::shared_ptr<std::vector<Token>> messageTokens = irDecoder.message(templateId, actingVersion);
439+
438440
const std::size_t result =
439441
OtfMessageDecoder::decode(messageBuffer, length, actingVersion, blockLength, messageTokens, tokenListener);
440442

sbe-samples/src/main/java/uk/co/real_logic/sbe/examples/ExampleTokenListener.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public void onEncoding(
6161

6262
printScope();
6363
out.append(fieldToken.name())
64-
.append('=')
65-
.append(value)
66-
.println();
64+
.append('=')
65+
.append(value)
66+
.println();
6767
}
6868

6969
public void onEnum(
@@ -90,9 +90,9 @@ public void onEnum(
9090

9191
printScope();
9292
out.append(fieldToken.name())
93-
.append('=')
94-
.append(value)
95-
.println();
93+
.append('=')
94+
.append(value)
95+
.println();
9696
}
9797

9898
public void onBitSet(
@@ -137,9 +137,9 @@ public void onGroupHeader(final Token token, final int numInGroup)
137137
{
138138
printScope();
139139
out.append(token.name())
140-
.append(" Group Header : numInGroup=")
141-
.append(Integer.toString(numInGroup))
142-
.println();
140+
.append(" Group Header : numInGroup=")
141+
.append(Integer.toString(numInGroup))
142+
.println();
143143
}
144144

145145
public void onBeginGroup(final Token token, final int groupIndex, final int numInGroup)
@@ -169,9 +169,9 @@ public void onVarData(
169169

170170
printScope();
171171
out.append(fieldToken.name())
172-
.append('=')
173-
.append(value)
174-
.println();
172+
.append('=')
173+
.append(value)
174+
.println();
175175
}
176176

177177
private static CharSequence readEncodingAsString(

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@
3131
public enum TargetCodeGenerator
3232
{
3333
JAVA()
34+
{
35+
public CodeGenerator newInstance(final Ir ir, final String outputDir) throws IOException
3436
{
35-
public CodeGenerator newInstance(final Ir ir, final String outputDir) throws IOException
36-
{
37-
return new JavaGenerator(
38-
ir,
39-
System.getProperty(JAVA_ENCODING_BUFFER_TYPE, JAVA_DEFAULT_ENCODING_BUFFER_TYPE),
40-
System.getProperty(JAVA_DECODING_BUFFER_TYPE, JAVA_DEFAULT_DECODING_BUFFER_TYPE),
41-
Boolean.getBoolean(JAVA_GROUP_ORDER_ANNOTATION),
42-
new PackageOutputManager(outputDir, ir.applicableNamespace()));
43-
}
44-
},
37+
return new JavaGenerator(
38+
ir,
39+
System.getProperty(JAVA_ENCODING_BUFFER_TYPE, JAVA_DEFAULT_ENCODING_BUFFER_TYPE),
40+
System.getProperty(JAVA_DECODING_BUFFER_TYPE, JAVA_DEFAULT_DECODING_BUFFER_TYPE),
41+
Boolean.getBoolean(JAVA_GROUP_ORDER_ANNOTATION),
42+
new PackageOutputManager(outputDir, ir.applicableNamespace()));
43+
}
44+
},
4545

4646
CPP()
47+
{
48+
public CodeGenerator newInstance(final Ir ir, final String outputDir) throws IOException
4749
{
48-
public CodeGenerator newInstance(final Ir ir, final String outputDir) throws IOException
49-
{
50-
return new CppGenerator(ir, new NamespaceOutputManager(outputDir, ir.applicableNamespace()));
51-
}
52-
};
50+
return new CppGenerator(ir, new NamespaceOutputManager(outputDir, ir.applicableNamespace()));
51+
}
52+
};
5353

5454

5555
/**

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private void generateGroupClassHeader(
218218

219219
sb.append(String.format(
220220
indent + " inline void wrapForDecode(char *buffer, std::uint64_t *pos, const std::uint64_t actingVersion," +
221-
" const std::uint64_t bufferLength)\n" +
221+
" const std::uint64_t bufferLength)\n" +
222222
indent + " {\n" +
223223
indent + " m_buffer = buffer;\n" +
224224
indent + " m_bufferLength = bufferLength;\n" +
@@ -235,7 +235,7 @@ private void generateGroupClassHeader(
235235

236236
sb.append(String.format(
237237
indent + " inline void wrapForEncode(char *buffer, const %3$s count," +
238-
" std::uint64_t *pos, const std::uint64_t actingVersion, const std::uint64_t bufferLength)\n" +
238+
" std::uint64_t *pos, const std::uint64_t actingVersion, const std::uint64_t bufferLength)\n" +
239239
indent + " {\n" +
240240
indent + " m_buffer = buffer;\n" +
241241
indent + " m_bufferLength = bufferLength;\n" +
@@ -396,7 +396,7 @@ private CharSequence generateVarData(final String className, final List<Token> t
396396
sb.append(String.format(
397397
indent + " const char *%1$s(void)\n" +
398398
indent + " {\n" +
399-
"%2$s" +
399+
"%2$s" +
400400
indent + " const char *fieldPtr = (m_buffer + position() + %3$d);\n" +
401401
indent + " position(position() + %3$d + *((%4$s *)(m_buffer + position())));\n" +
402402
indent + " return fieldPtr;\n" +
@@ -410,7 +410,7 @@ private CharSequence generateVarData(final String className, final List<Token> t
410410
sb.append(String.format(
411411
indent + " std::uint64_t get%1$s(char *dst, const std::uint64_t length)\n" +
412412
indent + " {\n" +
413-
"%2$s" +
413+
"%2$s" +
414414
indent + " std::uint64_t lengthOfLengthField = %3$d;\n" +
415415
indent + " std::uint64_t lengthPosition = position();\n" +
416416
indent + " position(lengthPosition + lengthOfLengthField);\n" +
@@ -449,7 +449,7 @@ private CharSequence generateVarData(final String className, final List<Token> t
449449
sb.append(String.format(
450450
indent + " const std::string get%1$sAsString()\n" +
451451
indent + " {\n" +
452-
"%2$s" +
452+
"%2$s" +
453453
indent + " std::uint64_t lengthOfLengthField = %3$d;\n" +
454454
indent + " std::uint64_t lengthPosition = position();\n" +
455455
indent + " position(lengthPosition + lengthOfLengthField);\n" +
@@ -638,7 +638,8 @@ private CharSequence generateChoices(final String bitsetClassName, final List<To
638638
tokens
639639
.stream()
640640
.filter((token) -> token.signal() == Signal.CHOICE)
641-
.forEach((token) ->
641+
.forEach(
642+
(token) ->
642643
{
643644
final String choiceName = formatPropertyName(token.name());
644645
final String typeName = cppTypeName(token.encoding().primitiveType());
@@ -712,12 +713,12 @@ private CharSequence generateEnumLookupMethod(final List<Token> tokens, final To
712713
final StringBuilder sb = new StringBuilder();
713714

714715
sb.append(String.format(
715-
" static %1$s::Value get(const %2$s value)\n" +
716-
" {\n" +
717-
" switch (value)\n" +
718-
" {\n",
719-
enumName,
720-
cppTypeName(tokens.get(0).encoding().primitiveType())
716+
" static %1$s::Value get(const %2$s value)\n" +
717+
" {\n" +
718+
" switch (value)\n" +
719+
" {\n",
720+
enumName,
721+
cppTypeName(tokens.get(0).encoding().primitiveType())
721722
));
722723

723724
for (final Token token : tokens)
@@ -904,7 +905,7 @@ private CharSequence generateCompositePropertyElements(
904905
i += tokens.get(i).componentTokenCount();
905906
}
906907

907-
return sb;
908+
return sb;
908909
}
909910

910911
private CharSequence generatePrimitiveProperty(
@@ -999,7 +1000,7 @@ private CharSequence generateSingleValueProperty(
9991000
"\n" +
10001001
indent + " %1$s %2$s(void) const\n" +
10011002
indent + " {\n" +
1002-
"%3$s" +
1003+
"%3$s" +
10031004
indent + " return %4$s(*((%1$s *)(m_buffer + m_offset + %5$d)));\n" +
10041005
indent + " }\n\n",
10051006
cppTypeName,
@@ -1061,7 +1062,7 @@ private CharSequence generateArrayProperty(
10611062
indent + " {\n" +
10621063
indent + " throw std::runtime_error(\"index out of range for %2$s [E104]\");\n" +
10631064
indent + " }\n\n" +
1064-
"%4$s" +
1065+
"%4$s" +
10651066
indent + " return %5$s(*((%1$s *)(m_buffer + m_offset + %6$d + (index * %7$d))));\n" +
10661067
indent + " }\n\n",
10671068
cppTypeName,
@@ -1097,7 +1098,7 @@ private CharSequence generateArrayProperty(
10971098
indent + " {\n" +
10981099
indent + " throw std::runtime_error(\"length too large for get%1$s [E106]\");\n" +
10991100
indent + " }\n\n" +
1100-
"%3$s" +
1101+
"%3$s" +
11011102
indent + " std::memcpy(dst, m_buffer + m_offset + %4$d, length);\n" +
11021103
indent + " return length;\n" +
11031104
indent + " }\n\n",

sbe-tool/src/main/java/uk/co/real_logic/sbe/util/ValidationUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ private static boolean isSbeCppIdentifierPart(final char c)
3434
return Character.isLetterOrDigit(c) || c == '_';
3535
}
3636

37-
private static final Set<String> CPP_KEYWORDS = new HashSet<>(Arrays.asList(new String[]
37+
private static final Set<String> CPP_KEYWORDS = new HashSet<>(
38+
Arrays.asList(new String[]
3839
{
3940
"alignas", "and", "and_eq", "asm", "auto",
4041
"bitand", "bitor", "bool", "break", "case",
@@ -107,7 +108,8 @@ private static boolean possibleCppKeyword(final String stringVal)
107108
return true;
108109
}
109110

110-
private static final Set<String> JAVA_KEYWORDS = new HashSet<>(Arrays.asList(new String[]
111+
private static final Set<String> JAVA_KEYWORDS = new HashSet<>(
112+
Arrays.asList(new String[]
111113
{
112114
"abstract", "assert", "boolean", "break", "byte",
113115
"case", "catch", "char", "class", "const",

sbe-tool/src/test/java/uk/co/real_logic/sbe/xml/SetTypeTest.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ else if (choice.name().equals("Bit3"))
102102
{
103103
foundBit3++;
104104
}
105+
105106
count++;
106107
}
107108

@@ -172,31 +173,31 @@ public void shouldThrowExceptionWhenValueOutOfBoundsSpecified()
172173
parseTestXmlWithMap("/types/set", testXmlString);
173174
}
174175

175-
@Test
176-
public void shouldHandleEncodingTypesWithNamedTypes()
177-
throws Exception
178-
{
179-
final MessageSchema schema = parse(TestUtil.getLocalResource("encoding-types-schema.xml"), ParserOptions.DEFAULT);
180-
final List<Field> fields = schema.getMessage(1).fields();
176+
@Test
177+
public void shouldHandleEncodingTypesWithNamedTypes()
178+
throws Exception
179+
{
180+
final MessageSchema schema = parse(TestUtil.getLocalResource("encoding-types-schema.xml"), ParserOptions.DEFAULT);
181+
final List<Field> fields = schema.getMessage(1).fields();
181182

182-
assertNotNull(fields);
183+
assertNotNull(fields);
183184

184-
SetType type = (SetType)fields.get(3).type();
185+
SetType type = (SetType)fields.get(3).type();
185186

186-
assertThat(type.encodingType(), is(PrimitiveType.UINT8));
187+
assertThat(type.encodingType(), is(PrimitiveType.UINT8));
187188

188-
type = (SetType)fields.get(4).type();
189+
type = (SetType)fields.get(4).type();
189190

190-
assertThat(type.encodingType(), is(PrimitiveType.UINT16));
191+
assertThat(type.encodingType(), is(PrimitiveType.UINT16));
191192

192-
type = (SetType)fields.get(5).type();
193+
type = (SetType)fields.get(5).type();
193194

194-
assertThat(type.encodingType(), is(PrimitiveType.UINT32));
195+
assertThat(type.encodingType(), is(PrimitiveType.UINT32));
195196

196-
type = (SetType)fields.get(6).type();
197+
type = (SetType)fields.get(6).type();
197198

198-
assertThat(type.encodingType(), is(PrimitiveType.UINT64));
199-
}
199+
assertThat(type.encodingType(), is(PrimitiveType.UINT64));
200+
}
200201

201202
private static Map<String, Type> parseTestXmlWithMap(final String xPathExpr, final String xml)
202203
throws ParserConfigurationException, XPathExpressionException, IOException, SAXException

0 commit comments

Comments
 (0)