Replace macro with inline function in wxPGPropertyGridIterator-related code

Replace wxPG_ITERATOR_CREATE_MASKS macro with inline function to ensure
type safety.
This commit is contained in:
Artur Wieczorek 2023-12-23 22:23:10 +01:00
parent 6a5b0667b5
commit 5725f0be41
2 changed files with 18 additions and 7 deletions

View file

@ -276,12 +276,21 @@ wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
}; };
inline void wxPGCreateIteratorMasks(int flags, wxPGPropertyFlags& itemExMask, wxPGPropertyFlags& parentExMask)
#define wxPG_ITERATOR_CREATE_MASKS(FLAGS, A, B) \ {
A = static_cast<wxPGPropertyFlags>((FLAGS ^ wxPG_ITERATOR_MASK_OP_ITEM) & \ itemExMask = static_cast<wxPGPropertyFlags>((flags ^ wxPG_ITERATOR_MASK_OP_ITEM) &
wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF); \ wxPG_ITERATOR_MASK_OP_ITEM & 0xFFFF);
B = static_cast<wxPGPropertyFlags>(((FLAGS>>16) ^ wxPG_ITERATOR_MASK_OP_PARENT) & \ parentExMask = static_cast<wxPGPropertyFlags>(((flags >> 16) ^ wxPG_ITERATOR_MASK_OP_PARENT) &
wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF); wxPG_ITERATOR_MASK_OP_PARENT & 0xFFFF);
}
#if WXWIN_COMPATIBILITY_3_2
#ifdef wxPG_MUST_DEPRECATE_MACRO_NAME
#pragma deprecated(wxPG_ITERATOR_CREATE_MASKS)
#endif
#define wxPG_ITERATOR_CREATE_MASKS wxPG_DEPRECATED_MACRO_VALUE(wxPGCreateIteratorMasks,\
"wxPG_ITERATOR_CREATE_MASKS is deprecated. Call wxPGCreateIteratorMasks instead.")
#endif // WXWIN_COMPATIBILITY_3_2
// Base for wxPropertyGridIterator classes. // Base for wxPropertyGridIterator classes.
class WXDLLIMPEXP_PROPGRID wxPropertyGridIteratorBase class WXDLLIMPEXP_PROPGRID wxPropertyGridIteratorBase

View file

@ -47,7 +47,7 @@ void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState* state, int flags
m_property = property; m_property = property;
wxPG_ITERATOR_CREATE_MASKS(flags, m_itemExMask, m_parentExMask) wxPGCreateIteratorMasks(flags, m_itemExMask, m_parentExMask);
// Need to skip first? // Need to skip first?
if ( property && property->HasFlag(m_itemExMask) ) if ( property && property->HasFlag(m_itemExMask) )
@ -401,7 +401,9 @@ wxPGProperty* wxPropertyGridPageState::GetLastItem( int flags )
if ( !m_properties->HasAnyChild() ) if ( !m_properties->HasAnyChild() )
return nullptr; return nullptr;
wxPG_ITERATOR_CREATE_MASKS(flags, wxPGPropertyFlags itemExMask, wxPGPropertyFlags parentExMask) wxPGPropertyFlags itemExMask;
wxPGPropertyFlags parentExMask;
wxPGCreateIteratorMasks(flags, itemExMask, parentExMask);
// First, get last child of last parent if children of 'pwc' should be iterated through // First, get last child of last parent if children of 'pwc' should be iterated through
wxPGProperty* pwc = m_properties->Last(); wxPGProperty* pwc = m_properties->Last();