Skip to content

Commit

Permalink
[Java, C#, C++] Rename flags to enable field access order checking.
Browse files Browse the repository at this point in the history
The aim of this change is to avoid naming collisions with other flags,
particularly in financial domains where "order" is used frequently.
  • Loading branch information
ZachBray committed Oct 20, 2023
1 parent dab9ae2 commit 69d13b6
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 197 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ project(':sbe-tool') {
'sbe.target.language': 'Java',
'sbe.validation.stop.on.error': 'true',
'sbe.validation.xsd': validationXsdPath,
'sbe.generate.access.order.checks': 'true')
'sbe.generate.sequencing.checks': 'true')
args = ['src/test/resources/json-printer-test-schema.xml',
'src/test/resources/composite-elements-schema.xml',
'src/test/resources/field-order-check-schema.xml']
Expand Down Expand Up @@ -544,7 +544,7 @@ project(':sbe-benchmarks') {
'sbe.validation.xsd': validationXsdPath,
'sbe.java.encoding.buffer.type': 'org.agrona.concurrent.UnsafeBuffer',
'sbe.java.decoding.buffer.type': 'org.agrona.concurrent.UnsafeBuffer',
'sbe.generate.access.order.checks': 'false')
'sbe.generate.sequencing.checks': 'false')
args = ['src/main/resources/car.xml', 'src/main/resources/fix-message-samples.xml']
}

Expand Down Expand Up @@ -734,7 +734,7 @@ tasks.register('generateCSharpCodecsTests', JavaExec) {
'sbe.target.language': 'uk.co.real_logic.sbe.generation.csharp.CSharp',
'sbe.xinclude.aware': 'true',
'sbe.validation.xsd': validationXsdPath,
'sbe.generate.access.order.checks': 'true')
'sbe.generate.sequencing.checks': 'true')
args = ['sbe-tool/src/test/resources/FixBinary.xml',
'sbe-tool/src/test/resources/issue435.xml',
'sbe-tool/src/test/resources/issue483.xml',
Expand All @@ -759,7 +759,7 @@ tasks.register('generateJavaIrCodecs', JavaExec) {
'sbe.output.dir': 'sbe-tool/src/main/java',
'sbe.target.language': 'Java',
'sbe.validation.xsd': validationXsdPath,
'sbe.generate.access.order.checks': 'true')
'sbe.generate.sequencing.checks': 'true')
args = ['sbe-tool/src/main/resources/sbe-ir.xml']
}

Expand All @@ -770,7 +770,7 @@ tasks.register('generateCppIrCodecs', JavaExec) {
'sbe.output.dir': 'sbe-tool/src/main/cpp',
'sbe.target.language': 'cpp',
'sbe.validation.xsd': validationXsdPath,
'sbe.generate.access.order.checks': 'true')
'sbe.generate.sequencing.checks': 'true')
args = ['sbe-tool/src/main/resources/sbe-ir.xml']
}

Expand Down
4 changes: 2 additions & 2 deletions csharp/sbe-generated/sbe-generated.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>TRACE,ENABLE_ACCESS_ORDER_CHECKS</DefineConstants>
<DefineConstants>TRACE,SBE_ENABLE_SEQUENCING_CHECKS</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>TRACE,ENABLE_ACCESS_ORDER_CHECKS</DefineConstants>
<DefineConstants>TRACE,SBE_ENABLE_SEQUENCING_CHECKS</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public final class AccessOrderModel
{
private static final boolean GENERATE_ACCESS_ORDER_CHECKS = Boolean.parseBoolean(
System.getProperty("sbe.generate.access.order.checks", "false"));
System.getProperty("sbe.generate.sequencing.checks", "false"));
private final Map<Token, String> groupPathsByField = new HashMap<>();
private final Set<Token> topLevelBlockFields = new HashSet<>();
private final CodecInteraction.HashConsingFactory interactionFactory =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static CharSequence generateFullyEncodedCheck(final AccessOrderModel acc

sb.append(indent).append("void checkEncodingIsComplete()\n")
.append(indent).append("{\n")
.append("#if defined(ENABLE_ACCESS_ORDER_CHECKS)\n")
.append("#if defined(SBE_ENABLE_SEQUENCING_CHECKS)\n")
.append(indent).append(INDENT).append("switch (m_codecState)\n")
.append(indent).append(INDENT).append("{\n");

Expand Down Expand Up @@ -321,7 +321,7 @@ private static CharSequence generateAccessOrderListenerCall(
}

final StringBuilder sb = new StringBuilder();
sb.append("#if defined(ENABLE_ACCESS_ORDER_CHECKS)\n")
sb.append("#if defined(SBE_ENABLE_SEQUENCING_CHECKS)\n")
.append(indent).append(methodName).append("(");

for (int i = 0; i < arguments.length; i++)
Expand Down Expand Up @@ -3083,7 +3083,7 @@ private CharSequence generateDecoderWrapListenerCall(final AccessOrderModel acce
if (accessOrderModel.versionCount() == 1)
{
final StringBuilder sb = new StringBuilder();
sb.append("#if defined(ENABLE_ACCESS_ORDER_CHECKS)\n")
sb.append("#if defined(SBE_ENABLE_SEQUENCING_CHECKS)\n")
.append(TWO_INDENT).append("codecState(")
.append(qualifiedStateCase(accessOrderModel.latestVersionWrappedState())).append(");\n")
.append("#endif\n");
Expand All @@ -3101,7 +3101,7 @@ private CharSequence generateEncoderWrapListener(final AccessOrderModel accessOr
}

final StringBuilder sb = new StringBuilder();
sb.append("#if defined(ENABLE_ACCESS_ORDER_CHECKS)\n")
sb.append("#if defined(SBE_ENABLE_SEQUENCING_CHECKS)\n")
.append(TWO_INDENT).append("codecState(")
.append(qualifiedStateCase(accessOrderModel.latestVersionWrappedState()))
.append(");\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ private static CharSequence generateFullyEncodedCheck(

sb.append(indent).append("public void CheckEncodingIsComplete()\n")
.append(indent).append("{\n")
.append("#if ENABLE_ACCESS_ORDER_CHECKS\n")
.append("#if SBE_ENABLE_SEQUENCING_CHECKS\n")
.append(indent).append(INDENT).append("switch (_codecState)\n")
.append(indent).append(INDENT).append("{\n");

Expand Down Expand Up @@ -1670,7 +1670,7 @@ private static CharSequence generateAccessOrderListenerCall(
}

final StringBuilder sb = new StringBuilder();
sb.append("#if ENABLE_ACCESS_ORDER_CHECKS\n")
sb.append("#if SBE_ENABLE_SEQUENCING_CHECKS\n")
.append(indent).append(methodName).append("(");

for (int i = 0; i < arguments.length; i++)
Expand Down Expand Up @@ -1936,7 +1936,7 @@ private CharSequence generateEncoderWrapListener(
}

final StringBuilder sb = new StringBuilder();
sb.append("#if ENABLE_ACCESS_ORDER_CHECKS\n")
sb.append("#if SBE_ENABLE_SEQUENCING_CHECKS\n")
.append(indent).append("codecState(")
.append(qualifiedStateCase(accessOrderModel.latestVersionWrappedState()))
.append(");\n")
Expand Down Expand Up @@ -2556,7 +2556,7 @@ private CharSequence generateDisplay(
append(sb, TWO_INDENT, " int originalLimit = this.Limit;");
if (null != accessOrderModel)
{
sb.append("#if ENABLE_ACCESS_ORDER_CHECKS\n");
sb.append("#if SBE_ENABLE_SEQUENCING_CHECKS\n");
append(sb, TWO_INDENT, " CodecState originalState = _codecState;");
sb.append(THREE_INDENT).append("_codecState = ")
.append(qualifiedStateCase(accessOrderModel.notWrappedState())).append(";\n");
Expand Down Expand Up @@ -2588,7 +2588,7 @@ private CharSequence generateDisplay(
sb.append('\n');
if (null != accessOrderModel)
{
sb.append("#if ENABLE_ACCESS_ORDER_CHECKS\n");
sb.append("#if SBE_ENABLE_SEQUENCING_CHECKS\n");
append(sb, TWO_INDENT, " _codecState = originalState;");
sb.append("#endif\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ private static CharSequence generateFieldOrderStates(final AccessOrderModel acce

sb.append(" private static final boolean ENABLE_BOUNDS_CHECKS = ")
.append("!Boolean.getBoolean(\"agrona.disable.bounds.checks\");\n\n");
sb.append(" private static final boolean ENABLE_ACCESS_ORDER_CHECKS = ")
sb.append(" private static final boolean SBE_ENABLE_SEQUENCING_CHECKS = ")
.append("Boolean.parseBoolean(System.getProperty(\n")
.append(" \"sbe.enable.access.order.checks\",\n")
.append(" \"sbe.enable.sequencing.checks\",\n")
.append(" Boolean.toString(ENABLE_BOUNDS_CHECKS)));\n\n");

sb.append(" /**\n");
Expand Down Expand Up @@ -410,7 +410,7 @@ private static void generateFullyEncodedCheck(

sb.append(" public void checkEncodingIsComplete()\n")
.append(" {\n")
.append(" if (ENABLE_ACCESS_ORDER_CHECKS)\n")
.append(" if (SBE_ENABLE_SEQUENCING_CHECKS)\n")
.append(" {\n")
.append(" switch (codecState)\n")
.append(" {\n");
Expand Down Expand Up @@ -493,7 +493,7 @@ private static CharSequence generateAccessOrderListenerCall(
}

final StringBuilder sb = new StringBuilder();
sb.append(indent).append("if (ENABLE_ACCESS_ORDER_CHECKS)\n")
sb.append(indent).append("if (SBE_ENABLE_SEQUENCING_CHECKS)\n")
.append(indent).append("{\n")
.append(indent).append(" ").append(methodName).append("(");

Expand Down Expand Up @@ -755,7 +755,7 @@ private CharSequence generateEncoderWrapListener(
}

final StringBuilder sb = new StringBuilder();
sb.append(indent).append("if (ENABLE_ACCESS_ORDER_CHECKS)")
sb.append(indent).append("if (SBE_ENABLE_SEQUENCING_CHECKS)")
.append("\n").append(indent).append("{\n")
.append(indent).append(" codecState(")
.append(qualifiedStateCase(accessOrderModel.latestVersionWrappedState()))
Expand Down Expand Up @@ -3424,7 +3424,7 @@ private CharSequence generateDecoderFlyweightCode(

if (null != accessOrderModel)
{
methods.append(" if (ENABLE_ACCESS_ORDER_CHECKS)\n")
methods.append(" if (SBE_ENABLE_SEQUENCING_CHECKS)\n")
.append(" {\n")
.append(" codecState(currentCodecState);\n")
.append(" }\n\n");
Expand Down
Loading

0 comments on commit 69d13b6

Please sign in to comment.