Hello,
please include the attached patch to fix the ABI nightmare that r1810
creates. Mixing C++ standard versions is still very popular, especially
since the GCC versions in LTS Linux distributions default to C++03
still. The patch avoids the difference by making it explicit in the one
place where the size matters and hiding it as implementation detail.
Joerg
PS:
<rant> While I love PoDoFo, it certainly needs a lot of love when it
comes to API and ABI stability. Having to debug crashes after every
update due to unnecessarily careless changes is not nice. Case point:
adding another parameter to the Load() functions which used to have a
default argument already. Please add a second function for those cases
instead of breaking existing code silently. </rant>
--- src/base/PdfCompilerCompat.h.orig 2017-01-11 20:32:50.000000000 +0000
+++ src/base/PdfCompilerCompat.h
@@ -198,16 +201,6 @@ namespace PoDoFo {
#endif // defined(_WIN32)
-// Visual C++ 2015 (_MSC_VER 1900) still uses __cplusplus = 199711 so, we need
both tests
-// this shrinks enum types from sizeof(int) to sizeof(char) which creates
significant
-// space savings on PdfObject / PdfVariant
-#if (defined(_MSC_VER) && _MSC_VER < 1900) || (!defined(_MSC_VER) &&
__cplusplus < 201103)
-#define PODOFO_ENUM_UINT8
-#else
-#define PODOFO_ENUM_UINT8 : uint8_t
-#endif
-
-
/**
* \page PoDoFo PdfCompilerCompat Header
*
--- src/base/PdfDefines.h.orig 2017-07-20 09:37:05.760146737 +0000
+++ src/base/PdfDefines.h
@@ -194,7 +194,7 @@ const EPdfWriteMode ePdfWriteMode_Defaul
*
* Remember to update PdfVariant::GetDataTypeString() when adding members here.
*/
-enum EPdfDataType PODOFO_ENUM_UINT8 {
+enum EPdfDataType {
ePdfDataType_Bool, /**< Boolean datatype: Accepts the
values "true" and "false" */
ePdfDataType_Number, /**< Number datatype for integer
values */
ePdfDataType_Real, /**< Real datatype for floating point
numbers */
--- src/base/PdfVariant.cpp.orig 2017-07-20 10:08:13.104201531 +0000
+++ src/base/PdfVariant.cpp
@@ -176,7 +176,7 @@ PdfVariant::~PdfVariant()
void PdfVariant::Clear()
{
- switch( m_eDataType )
+ switch( GetDataType() )
{
case ePdfDataType_Array:
case ePdfDataType_Reference:
@@ -223,17 +223,17 @@ void PdfVariant::Write( PdfOutputDevice*
/* Check all handles first
*/
- if( (m_eDataType == ePdfDataType_HexString ||
- m_eDataType == ePdfDataType_String ||
- m_eDataType == ePdfDataType_Array ||
- m_eDataType == ePdfDataType_Dictionary ||
- m_eDataType == ePdfDataType_Name ||
- m_eDataType == ePdfDataType_RawData ) && !m_Data.pData )
+ if( (GetDataType() == ePdfDataType_HexString ||
+ GetDataType() == ePdfDataType_String ||
+ GetDataType() == ePdfDataType_Array ||
+ GetDataType() == ePdfDataType_Dictionary ||
+ GetDataType() == ePdfDataType_Name ||
+ GetDataType() == ePdfDataType_RawData ) && !m_Data.pData )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
}
- switch( m_eDataType )
+ switch( GetDataType() )
{
case ePdfDataType_Bool:
{
@@ -347,7 +347,7 @@ const PdfVariant & PdfVariant::operator=
m_eDataType = rhs.m_eDataType;
- switch( m_eDataType )
+ switch( GetDataType() )
{
case ePdfDataType_Array:
{
@@ -433,7 +433,7 @@ bool PdfVariant::operator==( const PdfVa
{
DelayedLoad();
try {
- switch (m_eDataType) {
+ switch (GetDataType()) {
case ePdfDataType_Bool: return GetBool() == rhs.GetBool();
case ePdfDataType_Number: return GetNumber() == rhs.GetNumber();
case ePdfDataType_Real: return GetReal() == rhs.GetReal();
--- src/base/PdfVariant.h.orig 2016-11-18 19:08:56.000000000 +0000
+++ src/base/PdfVariant.h
@@ -141,7 +141,7 @@ class PODOFO_API PdfVariant {
virtual ~PdfVariant();
/** \returns true if this PdfVariant is empty.
- * i.e. m_eDataType == ePdfDataType_Null
+ * i.e. GetDataType() == ePdfDataType_Null
*/
inline bool IsEmpty() const;
@@ -513,7 +513,7 @@ class PODOFO_API PdfVariant {
* required to access the correct member of
* the union UVariant.
*/
- EPdfDataType m_eDataType;
+ uint8_t m_eDataType; // Really EPdfDataType, but C++98 compat forbids
typed enums.
// No touchy. Only for use by PdfVariant's internal tracking of the delayed
// loading state. Use DelayedLoadDone() to test this if you need to.
@@ -564,7 +564,7 @@ bool PdfVariant::IsEmpty() const
{
DelayedLoad();
- return (m_eDataType == ePdfDataType_Null);
+ return (GetDataType() == ePdfDataType_Null);
}
// -----------------------------------------------------
@@ -574,7 +574,7 @@ EPdfDataType PdfVariant::GetDataType() c
{
DelayedLoad();
- return m_eDataType;
+ return (EPdfDataType)m_eDataType;
}
// -----------------------------------------------------
@@ -776,7 +776,7 @@ const PdfArray & PdfVariant::GetArray_No
// Test against eDataType directly not GetDataType() since
// we don't want to trigger a delayed load (and if required one has
// already been triggered).
- if( m_eDataType != ePdfDataType_Array )
+ if( GetDataType() != ePdfDataType_Array )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
}
@@ -804,7 +804,7 @@ PdfArray & PdfVariant::GetArray_NoDL()
// Test against eDataType directly not GetDataType() since
// we don't want to trigger a delayed load (and if required one has
// already been triggered).
- if( m_eDataType != ePdfDataType_Array )
+ if( GetDataType() != ePdfDataType_Array )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
}
@@ -832,7 +832,7 @@ const PdfDictionary & PdfVariant::GetDic
// Test against eDataType directly not GetDataType() since
// we don't want to trigger a delayed load (and if required one has
// already been triggered).
- if( m_eDataType != ePdfDataType_Dictionary )
+ if( GetDataType() != ePdfDataType_Dictionary )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
}
@@ -860,7 +860,7 @@ PdfDictionary & PdfVariant::GetDictionar
// Test against eDataType directly not GetDataType() since
// we don't want to trigger a delayed load (and if required one has
// already been triggered).
- if( m_eDataType != ePdfDataType_Dictionary )
+ if( GetDataType() != ePdfDataType_Dictionary )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
}
@@ -934,7 +934,7 @@ bool PdfVariant::IsDirty() const
if( m_bDirty )
return m_bDirty;
- switch( m_eDataType )
+ switch( GetDataType() )
{
case ePdfDataType_Array:
case ePdfDataType_Dictionary:
@@ -967,7 +967,7 @@ void PdfVariant::SetDirty( bool bDirty )
if( !m_bDirty )
{
// Propogate new dirty state to subclasses
- switch( m_eDataType )
+ switch( GetDataType() )
{
case ePdfDataType_Array:
case ePdfDataType_Dictionary:
@@ -999,7 +999,7 @@ inline void PdfVariant::SetImmutable(boo
{
m_bImmutable = bImmutable;
- switch( m_eDataType )
+ switch( GetDataType() )
{
case ePdfDataType_Array:
case ePdfDataType_Dictionary:
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users