@@ -146,7 +146,6 @@ public void generate() throws IOException
146146 out .append (sb );
147147 out .append (generateVarData (className , varData , BASE_INDENT ));
148148 out .append ("};\n " );
149- out .append (generateStaticDefinitions (className ));
150149 out .append (CppUtil .closingBraces (ir .namespaces ().length ) + "#endif\n " );
151150 }
152151 }
@@ -257,11 +256,11 @@ private static void generateGroupClassHeader(
257256 numInGroupToken .encoding ().applicableMaxValue ().longValue ()));
258257
259258 sb .append (String .format (
260- indent + " static SBE_CONST_KIND std::uint64_t sbeHeaderSize()\n " +
259+ indent + " static SBE_CONSTEXPR const std::uint64_t sbeHeaderSize()\n " +
261260 indent + " {\n " +
262261 indent + " return %1$d;\n " +
263262 indent + " }\n \n " +
264- indent + " static SBE_CONST_KIND std::uint64_t sbeBlockLength()\n " +
263+ indent + " static SBE_CONSTEXPR const std::uint64_t sbeBlockLength()\n " +
265264 indent + " {\n " +
266265 indent + " return %2$d;\n " +
267266 indent + " }\n \n " +
@@ -338,7 +337,7 @@ private static CharSequence generateGroupProperty(
338337
339338 sb .append (String .format (
340339 "\n " +
341- indent + " static SBE_CONST_KIND std::uint16_t %1$sId(void)\n " +
340+ indent + " static SBE_CONSTEXPR const std::uint16_t %1$sId(void)\n " +
342341 indent + " {\n " +
343342 indent + " return %2$d;\n " +
344343 indent + " }\n \n " ,
@@ -520,15 +519,15 @@ private void generateVarDataDescriptors(
520519 ));
521520
522521 sb .append (String .format (
523- indent + " static SBE_CONST_KIND std::uint64_t %1$sSinceVersion(void)\n " +
522+ indent + " static SBE_CONSTEXPR const std::uint64_t %1$sSinceVersion(void)\n " +
524523 indent + " {\n " +
525524 indent + " return %2$d;\n " +
526525 indent + " }\n \n " +
527526 indent + " bool %1$sInActingVersion(void)\n " +
528527 indent + " {\n " +
529528 indent + " return (m_actingVersion >= %1$sSinceVersion()) ? true : false;\n " +
530529 indent + " }\n \n " +
531- indent + " static SBE_CONST_KIND std::uint16_t %1$sId(void)\n " +
530+ indent + " static SBE_CONSTEXPR const std::uint16_t %1$sId(void)\n " +
532531 indent + " {\n " +
533532 indent + " return %3$d;\n " +
534533 indent + " }\n \n " ,
@@ -539,7 +538,7 @@ private void generateVarDataDescriptors(
539538
540539 sb .append (String .format (
541540 "\n " +
542- indent + " static SBE_CONST_KIND std::uint64_t %sHeaderLength()\n " +
541+ indent + " static SBE_CONSTEXPR const std::uint64_t %sHeaderLength()\n " +
543542 indent + " {\n " +
544543 indent + " return %d;\n " +
545544 indent + " }\n " ,
@@ -845,9 +844,9 @@ private static CharSequence generateFileHeader(
845844 "# include <cstring>\n " +
846845 "#endif\n \n " +
847846 "#if __cplusplus >= 201103L\n " +
848- "# define SBE_CONST_KIND constexpr\n " +
847+ "# define SBE_CONSTEXPR constexpr\n " +
849848 "#else\n " +
850- "# define SBE_CONST_KIND const \n " +
849+ "# define SBE_CONSTEXPR \n " +
851850 "#endif\n \n " +
852851 "#include <sbe/sbe.h>\n \n " ,
853852 String .join ("_" , namespaces ).toUpperCase (),
@@ -885,32 +884,6 @@ private static CharSequence generateClassDeclaration(final String className)
885884 );
886885 }
887886
888- private String generateStaticDefinitions (final String className )
889- {
890- return
891- generateStaticDefinition (
892- className , "SbeBlockLength" , cppTypeName (ir .headerStructure ().blockLengthType ()), false ) +
893- generateStaticDefinition (
894- className , "SbeTemplateId" , cppTypeName (ir .headerStructure ().templateIdType ()), false ) +
895- generateStaticDefinition (
896- className , "SbeSchemaId" , cppTypeName (ir .headerStructure ().schemaIdType ()), false ) +
897- generateStaticDefinition (
898- className , "SbeSchemaVersion" , cppTypeName (ir .headerStructure ().schemaVersionType ()), false ) +
899- generateStaticDefinition (className , "SbeSemanticType" , "char" , true );
900- }
901-
902- private static String generateStaticDefinition (
903- final String className , final String memberName , final String memberType , boolean isArray )
904- {
905- return String .format (
906- "SBE_CONST_KIND %3$s %1$s::%2$s%4$s;\n " ,
907- className ,
908- memberName ,
909- memberType ,
910- (isArray ? "[]" : "" )
911- );
912- }
913-
914887 private static CharSequence generateEnumDeclaration (final String name )
915888 {
916889 return "class " + name + "\n {\n public:\n \n " ;
@@ -998,7 +971,7 @@ private CharSequence generatePrimitiveFieldMetaData(final String propertyName, f
998971
999972 sb .append (String .format (
1000973 "\n " +
1001- indent + " static SBE_CONST_KIND %1$s %2$sNullValue()\n " +
974+ indent + " static SBE_CONSTEXPR const %1$s %2$sNullValue()\n " +
1002975 indent + " {\n " +
1003976 indent + " return %3$s;\n " +
1004977 indent + " }\n " ,
@@ -1009,7 +982,7 @@ private CharSequence generatePrimitiveFieldMetaData(final String propertyName, f
1009982
1010983 sb .append (String .format (
1011984 "\n " +
1012- indent + " static SBE_CONST_KIND %1$s %2$sMinValue()\n " +
985+ indent + " static SBE_CONSTEXPR const %1$s %2$sMinValue()\n " +
1013986 indent + " {\n " +
1014987 indent + " return %3$s;\n " +
1015988 indent + " }\n " ,
@@ -1020,7 +993,7 @@ private CharSequence generatePrimitiveFieldMetaData(final String propertyName, f
1020993
1021994 sb .append (String .format (
1022995 "\n " +
1023- indent + " static SBE_CONST_KIND %1$s %2$sMaxValue()\n " +
996+ indent + " static SBE_CONSTEXPR const %1$s %2$sMaxValue()\n " +
1024997 indent + " {\n " +
1025998 indent + " return %3$s;\n " +
1026999 indent + " }\n " ,
@@ -1079,7 +1052,7 @@ private CharSequence generateArrayProperty(
10791052
10801053 sb .append (String .format (
10811054 "\n " +
1082- indent + " static SBE_CONST_KIND std::uint64_t %1$sLength(void)\n " +
1055+ indent + " static SBE_CONSTEXPR const std::uint64_t %1$sLength(void)\n " +
10831056 indent + " {\n " +
10841057 indent + " return %2$d;\n " +
10851058 indent + " }\n \n " ,
@@ -1225,7 +1198,7 @@ private CharSequence generateConstPropertyMethods(final String propertyName, fin
12251198
12261199 sb .append (String .format (
12271200 "\n " +
1228- indent + " static SBE_CONST_KIND std::uint64_t %1$sLength(void)\n " +
1201+ indent + " static SBE_CONSTEXPR const std::uint64_t %1$sLength(void)\n " +
12291202 indent + " {\n " +
12301203 indent + " return %2$d;\n " +
12311204 indent + " }\n \n " ,
@@ -1324,7 +1297,7 @@ private static CharSequence generateFixedFlyweightCode(final String className, f
13241297 " reset(buffer, offset, bufferLength, actingVersion);\n " +
13251298 " return *this;\n " +
13261299 " }\n \n " +
1327- " static SBE_CONST_KIND std::uint64_t encodedLength(void)\n " +
1300+ " static SBE_CONSTEXPR const std::uint64_t encodedLength(void)\n " +
13281301 " {\n " +
13291302 " return %2$s;\n " +
13301303 " }\n \n " ,
@@ -1405,30 +1378,25 @@ private CharSequence generateMessageFlyweightCode(final String className, final
14051378 " }\n \n " +
14061379 "public:\n \n " +
14071380 "%11$s" +
1408- " static SBE_CONST_KIND %1$s SbeBlockLength{%2$s};\n " +
1409- " static const %1$s sbeBlockLength(void)\n " +
1381+ " static SBE_CONSTEXPR const %1$s sbeBlockLength(void)\n " +
14101382 " {\n " +
1411- " return SbeBlockLength ;\n " +
1383+ " return %2$s ;\n " +
14121384 " }\n \n " +
1413- " static SBE_CONST_KIND %3$s SbeTemplateId{%4$s};\n " +
1414- " static const %3$s sbeTemplateId(void)\n " +
1385+ " static SBE_CONSTEXPR const %3$s sbeTemplateId(void)\n " +
14151386 " {\n " +
1416- " return SbeTemplateId ;\n " +
1387+ " return %4$s ;\n " +
14171388 " }\n \n " +
1418- " static SBE_CONST_KIND %5$s SbeSchemaId{%6$s};\n " +
1419- " static const %5$s sbeSchemaId(void)\n " +
1389+ " static SBE_CONSTEXPR const %5$s sbeSchemaId(void)\n " +
14201390 " {\n " +
1421- " return SbeSchemaId ;\n " +
1391+ " return %6$s ;\n " +
14221392 " }\n \n " +
1423- " static SBE_CONST_KIND %7$s SbeSchemaVersion{%8$s};\n " +
1424- " static const %7$s sbeSchemaVersion(void)\n " +
1393+ " static SBE_CONSTEXPR const %7$s sbeSchemaVersion(void)\n " +
14251394 " {\n " +
1426- " return SbeSchemaVersion ;\n " +
1395+ " return %8$s ;\n " +
14271396 " }\n \n " +
1428- " static SBE_CONST_KIND char SbeSemanticType[] = \" %9$s\" ;\n " +
1429- " static const char *sbeSemanticType(void)\n " +
1397+ " static SBE_CONSTEXPR const char * sbeSemanticType(void)\n " +
14301398 " {\n " +
1431- " return SbeSemanticType ;\n " +
1399+ " return \" %9$s \" ;\n " +
14321400 " }\n \n " +
14331401 " std::uint64_t offset(void) const\n " +
14341402 " {\n " +
@@ -1498,7 +1466,7 @@ private CharSequence generateFields(final String containingClassName, final List
14981466
14991467 sb .append (String .format (
15001468 "\n " +
1501- indent + " static SBE_CONST_KIND std::uint16_t %1$sId(void)\n " +
1469+ indent + " static SBE_CONSTEXPR const std::uint16_t %1$sId(void)\n " +
15021470 indent + " {\n " +
15031471 indent + " return %2$d;\n " +
15041472 indent + " }\n \n " ,
@@ -1507,7 +1475,7 @@ private CharSequence generateFields(final String containingClassName, final List
15071475 ));
15081476
15091477 sb .append (String .format (
1510- indent + " static SBE_CONST_KIND std::uint64_t %1$sSinceVersion(void)\n " +
1478+ indent + " static SBE_CONSTEXPR const std::uint64_t %1$sSinceVersion(void)\n " +
15111479 indent + " {\n " +
15121480 indent + " return %2$d;\n " +
15131481 indent + " }\n \n " +
0 commit comments