X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ee7bcb842c244d92d3075819d8dae344088bfa4c..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/common/any.cpp diff --git a/src/common/any.cpp b/src/common/any.cpp index 79aed46067..c8681efec7 100644 --- a/src/common/any.cpp +++ b/src/common/any.cpp @@ -32,33 +32,21 @@ using namespace wxPrivate; +#if wxUSE_VARIANT + //------------------------------------------------------------------------- // wxAnyValueTypeGlobals //------------------------------------------------------------------------- -#if wxUSE_VARIANT - WX_DECLARE_HASH_MAP(wxAnyValueType*, wxVariantDataFactory, wxPointerHash, wxPointerEqual, wxAnyTypeToVariantDataFactoryMap); -#endif - -WX_DECLARE_HASH_SET(wxAnyValueType*, - wxPointerHash, - wxPointerEqual, - wxAnyValueTypePtrSet); - -// -// Helper class to manage wxAnyValueType instances and and other -// related global variables (such as wxAny<->wxVariant type association). // -// NB: We really need to have wxAnyValueType instances allocated -// in heap. They are stored as static template member variables, -// and with them we just can't be too careful (eg. not allocating -// them in heap broke the type identification in GCC). +// Helper class to manage global variables related to type conversion +// between wxAny and wxVariant. // class wxAnyValueTypeGlobals { @@ -68,26 +56,9 @@ public: } ~wxAnyValueTypeGlobals() { - #if wxUSE_VARIANT m_anyToVariant.clear(); - #endif - - wxAnyValueTypePtrSet::iterator it; - for ( it = m_valueTypes.begin(); it != m_valueTypes.end(); ++it ) - { - delete *it; - } - } - - void RegisterValueType(wxAnyValueType* valueType) - { - // Let's store value types in set to prevent deleting the same object - // several times (it may be possible, under certain conditions, that - // the same wxAnyValueType instance gets registered twice) - m_valueTypes.insert(valueType); } -#if wxUSE_VARIANT void PreRegisterAnyToVariant(wxAnyToVariantRegistration* reg) { m_anyToVariantRegs.push_back(reg); @@ -144,19 +115,14 @@ public: // Nothing found return NULL; } -#endif private: - wxAnyValueTypePtrSet m_valueTypes; -#if wxUSE_VARIANT wxAnyTypeToVariantDataFactoryMap m_anyToVariant; wxVector m_anyToVariantRegs; -#endif }; static wxAnyValueTypeGlobals* g_wxAnyValueTypeGlobals = NULL; -#if wxUSE_VARIANT WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplVariantData) @@ -186,7 +152,7 @@ bool wxConvertAnyToVariant(const wxAny& any, wxVariant* variant) if ( any.GetAs(&ll) ) { // NB: Do not use LONG_MAX here. Explicitly using 32-bit - // integer constraint yields more consistent behavior across + // integer constraint yields more consistent behaviour across // builds. if ( ll > wxINT32_MAX || ll < wxINT32_MIN ) *variant = wxLongLong(ll); @@ -239,8 +205,6 @@ bool wxConvertAnyToVariant(const wxAny& any, wxVariant* variant) return true; } -#endif // wxUSE_VARIANT - // // This class is to make sure that wxAnyValueType instances // etc. get freed correctly. We must use a separate wxAnyValueTypeGlobals @@ -259,26 +223,15 @@ public: } virtual void OnExit() { - delete g_wxAnyValueTypeGlobals; - g_wxAnyValueTypeGlobals = NULL; + wxDELETE(g_wxAnyValueTypeGlobals); } private: }; IMPLEMENT_DYNAMIC_CLASS(wxAnyValueTypeGlobalsManager, wxModule) +#endif // wxUSE_VARIANT -//------------------------------------------------------------------------- -// wxAnyValueType -//------------------------------------------------------------------------- - -wxAnyValueType::wxAnyValueType() -{ - if ( !g_wxAnyValueTypeGlobals ) - g_wxAnyValueTypeGlobals = new wxAnyValueTypeGlobals(); - - g_wxAnyValueTypeGlobals->RegisterValueType(this); -} //------------------------------------------------------------------------- // Dynamic conversion member functions @@ -518,7 +471,10 @@ WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplwxString) WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplConstCharPtr) WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplConstWchar_tPtr) +#if wxUSE_DATETIME WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) +#endif // wxUSE_DATETIME + //WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) //WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) @@ -560,6 +516,14 @@ public: return false; } +#if wxUSE_EXTENDED_RTTI + virtual const wxTypeInfo* GetTypeInfo() const + { + wxFAIL_MSG("Null Type Info not available"); + return NULL; + } +#endif + private: }; @@ -568,4 +532,7 @@ WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) wxAnyValueType* wxAnyNullValueType = wxAnyValueTypeImpl::GetInstance(); +#include "wx/listimpl.cpp" +WX_DEFINE_LIST(wxAnyList) + #endif // wxUSE_ANY