@@ -772,7 +772,7 @@ private CharSequence generateChoices(final String bitsetClassName, final List<To
772772 sb .append (String .format ("\n " +
773773 " static bool %1$s(const %2$s bits)\n " +
774774 " {\n " +
775- " return (bits & (static_cast<%2$s>(1) << %3$s )) != 0;\n " +
775+ " return (bits & (1u << %3$su )) != 0;\n " +
776776 " }\n " ,
777777 choiceName ,
778778 typeName ,
@@ -782,7 +782,7 @@ private CharSequence generateChoices(final String bitsetClassName, final List<To
782782 " static %2$s %1$s(const %2$s bits, const bool value)\n " +
783783 " {\n " +
784784 " return value ?" +
785- " (bits | ( static_cast<%2$s>(1) << %3$s )) : (bits & ~( static_cast<%2$s>(1) << %3$s ));\n " +
785+ " static_cast<%2$s>(bits | (1u << %3$su )) : static_cast<%2$s>(bits & ~(1u << %3$su ));\n " +
786786 " }\n " ,
787787 choiceName ,
788788 typeName ,
@@ -794,7 +794,7 @@ private CharSequence generateChoices(final String bitsetClassName, final List<To
794794 "%2$s" +
795795 " %4$s val;\n " +
796796 " std::memcpy(&val, m_buffer + m_offset, sizeof(%4$s));\n " +
797- " return (%3$s(val) & (static_cast<%4$s>(1) << %5$s )) != 0;\n " +
797+ " return (%3$s(val) & (1u << %5$su )) != 0;\n " +
798798 " }\n " ,
799799 choiceName ,
800800 generateChoiceNotPresentCondition (token .version (), BASE_INDENT ),
@@ -808,8 +808,8 @@ private CharSequence generateChoices(final String bitsetClassName, final List<To
808808 " %3$s bits;\n " +
809809 " std::memcpy(&bits, m_buffer + m_offset, sizeof(%3$s));\n " +
810810 " bits = %4$s(value ?" +
811- " (%4$s(bits) | (static_cast<%3$s>(1) << %5$s )) " +
812- ": (%4$s(bits) & ~(static_cast<%3$s>(1) << %5$s )));\n " +
811+ " static_cast<%3$s> (%4$s(bits) | (1u << %5$su )) " +
812+ ": static_cast<%3$s> (%4$s(bits) & ~(1u << %5$su )));\n " +
813813 " std::memcpy(m_buffer + m_offset, &bits, sizeof(%3$s));\n " +
814814 " return *this;\n " +
815815 " }\n " ,
@@ -1594,19 +1594,19 @@ private CharSequence generateConstPropertyMethods(
15941594 sb .append (String .format ("\n " +
15951595 indent + " SBE_NODISCARD const char *%1$s() const\n " +
15961596 indent + " {\n " +
1597- indent + " static std::uint8_t %1$sValues[] = {%2$s};\n \n " +
1597+ indent + " static const std::uint8_t %1$sValues[] = {%2$s};\n \n " +
15981598
15991599 indent + " return (const char *)%1$sValues;\n " +
16001600 indent + " }\n " ,
16011601 propertyName ,
16021602 values ));
16031603
16041604 sb .append (String .format ("\n " +
1605- indent + " %1$s %2$s(const std::uint64_t index) const\n " +
1605+ indent + " SBE_NODISCARD %1$s %2$s(const std::uint64_t index) const\n " +
16061606 indent + " {\n " +
1607- indent + " static std::uint8_t %2$sValues[] = {%3$s};\n \n " +
1607+ indent + " static const std::uint8_t %2$sValues[] = {%3$s};\n \n " +
16081608
1609- indent + " return %2$sValues[index];\n " +
1609+ indent + " return (char) %2$sValues[index];\n " +
16101610 indent + " }\n " ,
16111611 cppTypeName ,
16121612 propertyName ,
0 commit comments