Skip to content

Commit

Permalink
Revert "cpp: Store compounds real bit size with its pos (#658)"
Browse files Browse the repository at this point in the history
This reverts commit 3e51e73.
  • Loading branch information
mikir committed Sep 20, 2024
1 parent c256cb6 commit adc7325
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 149 deletions.
15 changes: 0 additions & 15 deletions compiler/extensions/cpp/freemarker/Choice.cpp.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,6 @@ ${I}return {};
</#if>
}

size_t realBitSizeOf() const override
{
<#if withBitPositionCode>
return m_object.realBitSizeOf();
<#else>
throw ::zserio::CppRuntimeException("Reflectable '${name}': ") <<
"Bit position code is disabled by '-withoutBitPositionCode' zserio option!";
</#if>
}

private:
<#if isConst>const </#if>${fullName}& m_object;
};
Expand Down Expand Up @@ -601,11 +591,6 @@ size_t ${name}::bitPosition() const
{
return m_bitPosition;
}

size_t ${name}::realBitSizeOf() const
{
return m_realBitSize;
}
</#if>
<#if fieldList?has_content>

Expand Down
17 changes: 1 addition & 16 deletions compiler/extensions/cpp/freemarker/Choice.h.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -343,21 +343,6 @@ public:
*/
</#if>
size_t bitPosition() const;

<#if withCodeComments>
/**
* Get the bit size of the parsed blob after reading. This size can differ
* from the one returned by getBitSizeOf() if compression took place.
*
* This feature is experimental and can be removed without any warning!
*
* \note Note that the returned bit size is valid only directly after read! If the Zserio object
* has been changed after reading, the result is unspecified!
*
* \return Size of the object as it was stored in the blob in bits.
*/
</#if>
size_t realBitSizeOf() const;
</#if>

private:
Expand All @@ -375,7 +360,7 @@ private:
<@compound_constructor_members compoundConstructorsData/>
<#if withBitPositionCode>
<#-- Bit position must be before m_objectChoice in order to get initialized first. -->
size_t m_bitPosition, m_realBitSize;
size_t m_bitPosition;
</#if>
<#if fieldList?has_content>
${types.anyHolder.name} m_objectChoice;
Expand Down
20 changes: 0 additions & 20 deletions compiler/extensions/cpp/freemarker/CompoundConstructor.inc.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
</#if>
<#if withBitPositionCode>
m_bitPosition(0)
m_realBitSize(0)
</#if>
<#if memberInitializationMacroName != "">
<#if (numExtendedFields > 0)>
Expand Down Expand Up @@ -103,7 +102,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
</#if>
<#if withBitPositionCode>
m_bitPosition(in.getBitPosition())
m_realBitSize(0)
</#if>
<#if memberInitializationMacroName != "">
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
Expand All @@ -113,14 +111,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
</#if>
</@cpp_initializer_list>
{
<#-- Determine the real bit size after member initialization took place. -->
<#if withBitPositionCode>
<#if packed>
m_realBitSize = bitSizeOf(context, m_bitPosition);
<#else>
m_realBitSize = bitSizeOf();
</#if>
</#if>
}
</#macro>

Expand Down Expand Up @@ -178,7 +168,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
<@cpp_initializer_list>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields(other.m_numExtendedFields)
Expand All @@ -202,7 +191,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
m_isInitialized(false)
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields(other.m_numExtendedFields)
Expand Down Expand Up @@ -249,7 +237,6 @@ ${compoundConstructorsData.compoundName}& ${compoundConstructorsData.compoundNam
{
<#if withBitPositionCode>
m_bitPosition = other.m_bitPosition;
m_realBitSize = other.m_realBitSize;
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields = other.m_numExtendedFields;
Expand All @@ -273,7 +260,6 @@ ${compoundConstructorsData.compoundName}& ${compoundConstructorsData.compoundNam
m_isInitialized = false;
<#if withBitPositionCode>
m_bitPosition = other.m_bitPosition;
m_realBitSize = other.m_realBitSize;
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields = other.m_numExtendedFields;
Expand Down Expand Up @@ -320,7 +306,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
<@cpp_initializer_list>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields(other.m_numExtendedFields)
Expand All @@ -344,7 +329,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
m_isInitialized(false)
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields(other.m_numExtendedFields)
Expand Down Expand Up @@ -392,7 +376,6 @@ ${compoundConstructorsData.compoundName}& ${compoundConstructorsData.compoundNam
{
<#if withBitPositionCode>
m_bitPosition = other.m_bitPosition;
m_realBitSize = other.m_realBitSize;
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields = other.m_numExtendedFields;
Expand All @@ -416,7 +399,6 @@ ${compoundConstructorsData.compoundName}& ${compoundConstructorsData.compoundNam
m_isInitialized = false;
<#if withBitPositionCode>
m_bitPosition = other.m_bitPosition;
m_realBitSize = other.m_realBitSize;
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields = other.m_numExtendedFields;
Expand Down Expand Up @@ -468,7 +450,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
<@cpp_initializer_list>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields(other.m_numExtendedFields)
Expand Down Expand Up @@ -497,7 +478,6 @@ ${compoundConstructorsData.compoundName}::${compoundConstructorsData.compoundNam
m_isInitialized(false)
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
<#if (num_extended_fields(compoundConstructorsData.fieldList) > 0)>
m_numExtendedFields(other.m_numExtendedFields)
Expand Down
15 changes: 0 additions & 15 deletions compiler/extensions/cpp/freemarker/Structure.cpp.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,6 @@ const ${types.typeInfo.name}& ${name}::typeInfo()
</#if>
}

size_t realBitSizeOf() const override
{
<#if withBitPositionCode>
return m_object.realBitSizeOf();
<#else>
throw ::zserio::CppRuntimeException("Reflectable '${name}': ") <<
"Bit position code is disabled by '-withoutBitPositionCode' zserio option!";
</#if>
}

private:
<#if isConst>const </#if>${fullName}& m_object;
};
Expand Down Expand Up @@ -584,11 +574,6 @@ size_t ${name}::bitPosition() const
{
return m_bitPosition;
}

size_t ${name}::realBitSizeOf() const
{
return m_realBitSize;
}
</#if>
<#if fieldList?has_content>

Expand Down
17 changes: 1 addition & 16 deletions compiler/extensions/cpp/freemarker/Structure.h.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -394,21 +394,6 @@ public:
*/
</#if>
size_t bitPosition() const;

<#if withCodeComments>
/**
* Get the bit size of the parsed blob after reading. This size can differ
* from the one returned by getBitSizeOf() if compression took place.
*
* This feature is experimental and can be removed without any warning!
*
* \note Note that the returned bit size is valid only directly after read! If the Zserio object
* has been changed after reading, the result is unspecified!
*
* \return Size of the object as it was stored in the blob in bits.
*/
</#if>
size_t realBitSizeOf() const;
</#if>

private:
Expand Down Expand Up @@ -436,7 +421,7 @@ private:
<@compound_constructor_members compoundConstructorsData/>
<#if withBitPositionCode>
<#-- Bit position must be before field members in order to get initialized first. -->
size_t m_bitPosition, m_realBitSize;
size_t m_bitPosition;
</#if>
<#if (numExtendedFields > 0)>
uint32_t m_numExtendedFields;
Expand Down
21 changes: 0 additions & 21 deletions compiler/extensions/cpp/freemarker/Union.cpp.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ ${name}::${name}(const ${name}& other)<#rt>
<@cpp_initializer_list>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
m_choiceTag(other.m_choiceTag)
<#list fieldList as field>
Expand Down Expand Up @@ -94,7 +93,6 @@ ${name}::${name}(${name}&& other)<#rt>
<@cpp_initializer_list>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
m_choiceTag(other.m_choiceTag)
<#list fieldList as field>
Expand Down Expand Up @@ -133,7 +131,6 @@ ${name}::${name}(::zserio::NoInitT, const ${name}& other)<#rt>
</#if>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
m_choiceTag(other.m_choiceTag)
<#list fieldList as field>
Expand Down Expand Up @@ -173,7 +170,6 @@ ${name}::${name}(::zserio::NoInitT, ${name}&& other)<#rt>
</#if>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
m_choiceTag(other.m_choiceTag)
<#list fieldList as field>
Expand Down Expand Up @@ -211,7 +207,6 @@ ${name}::${name}(::zserio::PropagateAllocatorT,
<@cpp_initializer_list>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
m_choiceTag(other.m_choiceTag)
<#list fieldList as field>
Expand All @@ -233,7 +228,6 @@ ${name}::${name}(::zserio::PropagateAllocatorT, ::zserio::NoInitT,
<@cpp_initializer_list>
<#if withBitPositionCode>
m_bitPosition(other.m_bitPosition)
m_realBitSize(other.m_realBitSize)
</#if>
m_choiceTag(other.m_choiceTag)
<#list fieldList as field>
Expand Down Expand Up @@ -394,16 +388,6 @@ const ${types.typeInfo.name}& ${name}::typeInfo()
</#if>
}

size_t realBitSizeOf() const override
{
<#if withBitPositionCode>
return m_object.realBitSizeOf();
<#else>
throw ::zserio::CppRuntimeException("Reflectable '${name}': ") <<
"Bit position code is disabled by '-withoutBitPositionCode' zserio option!";
</#if>
}

private:
<#if isConst>const </#if>${fullName}& m_object;
};
Expand Down Expand Up @@ -738,11 +722,6 @@ size_t ${name}::bitPosition() const
{
return m_bitPosition;
}

size_t ${name}::realBitSizeOf() const
{
return m_realBitSize;
}
</#if>
<#if fieldList?has_content>

Expand Down
17 changes: 1 addition & 16 deletions compiler/extensions/cpp/freemarker/Union.h.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,6 @@ public:
*/
</#if>
size_t bitPosition() const;

<#if withCodeComments>
/**
* Get the bit size of the parsed blob after reading. This size can differ
* from the one returned by getBitSizeOf() if compression took place.
*
* This feature is experimental and can be removed without any warning!
*
* \note Note that the returned bit size is valid only directly after read! If the Zserio object
* has been changed after reading, the result is unspecified!
*
* \return Size of the object as it was stored in the blob in bits.
*/
</#if>
size_t realBitSizeOf() const;
</#if>

private:
Expand All @@ -376,7 +361,7 @@ private:
<@compound_constructor_members compoundConstructorsData/>
<#if withBitPositionCode>
<#-- Bit position must be before m_choiceTag and m_objectChoice in order to get initialized first. -->
size_t m_bitPosition, m_realBitSize;
size_t m_bitPosition;
</#if>
ChoiceTag m_choiceTag;
<#if fieldList?has_content>
Expand Down
6 changes: 3 additions & 3 deletions compiler/extensions/cpp/runtime/ClangTidySuppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ cppcoreguidelines-pro-type-reinterpret-cast:src/zserio/ValidationSqliteUtil.h:99
cppcoreguidelines-pro-type-reinterpret-cast:src/zserio/ValidationSqliteUtil.h:100

# This multiple inheritance is intended and we think that to avoid it would mean much more obscure design.
fuchsia-multiple-inheritance:src/zserio/Reflectable.h:2026
fuchsia-multiple-inheritance:src/zserio/Reflectable.h:2025

# This is necessary for implementation of low level implementation to mimic standard C++17 abstractions.
google-explicit-constructor:src/zserio/OptionalHolder.h:232
Expand Down Expand Up @@ -123,8 +123,8 @@ misc-no-recursion:src/zserio/JsonParser.h:163
misc-no-recursion:src/zserio/ReflectableUtil.h:131
misc-no-recursion:src/zserio/ReflectableUtil.h:135
misc-no-recursion:src/zserio/ReflectableUtil.h:146
misc-no-recursion:src/zserio/Reflectable.h:1954
misc-no-recursion:src/zserio/Reflectable.h:1988
misc-no-recursion:src/zserio/Reflectable.h:1953
misc-no-recursion:src/zserio/Reflectable.h:1987
misc-no-recursion:src/zserio/Walker.h:73
misc-no-recursion:src/zserio/Walker.h:74
misc-no-recursion:src/zserio/Walker.h:75
Expand Down
14 changes: 0 additions & 14 deletions compiler/extensions/cpp/runtime/src/zserio/IReflectable.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,20 +522,6 @@ class IBasicReflectable
* \throw CppRuntimeException If the object was compiled without the bit position feature enabled.
*/
virtual size_t bitPosition() const = 0;

/**
* Returns the bit size of the parsed blob of the reflectable object.
*
* This feature is experimental and can be removed without any warning!
*
* \note Note that the returned bit size is valid only directly after read! If the Zserio object
* has been changed after reading, the result is unspecified!
* \note The bit size is only stored for code generated using `-withBitPositionCode` option.
*
* \return The blob size of the objects in bits.
* \throw CppRuntimeException If the object was compiled without the bit position feature enabled.
*/
virtual size_t realBitSizeOf() const = 0;
};

/** Typedef to reflectable smart pointer needed for convenience in generated code. */
Expand Down
Loading

0 comments on commit adc7325

Please sign in to comment.