From 8805dbab72812a326c121cc7fdefe82620595b1a Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 4 Sep 2003 01:12:11 +0000 Subject: [PATCH 1/1] macro naming changes, delegate api calls getting property info, object info exposed for beforewriteobject git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23375 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datetime.cpp | 2 +- src/common/fontmap.cpp | 102 ++++++++++++++++++++-------------------- src/common/gdicmn.cpp | 4 +- src/common/xti.cpp | 64 +++++++++++++++++++++---- src/common/xtistrm.cpp | 22 +++++---- src/common/xtixml.cpp | 2 +- 6 files changed, 121 insertions(+), 75 deletions(-) diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 45e40a6624..c671694698 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -94,7 +94,7 @@ template<> void wxStringWriteValue(wxString &s , const wxDateTime &data ) s = data.Format(wxT("%Y-%m-%d %H:%M:%S")) ; } -WX_CUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter , wxFromStringConverter) +wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter , wxFromStringConverter) #endif diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index dc352cb054..ccf61230d9 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -56,57 +56,57 @@ #if wxUSE_EXTENDED_RTTI -WX_BEGIN_ENUM( wxFontEncoding ) - WX_ENUM_MEMBER( wxFONTENCODING_SYSTEM ) - WX_ENUM_MEMBER( wxFONTENCODING_DEFAULT ) - - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_1 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_2 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_3 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_4 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_5 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_6 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_7 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_8 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_9 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_10 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_11 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_12 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_13 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_14 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_15 ) - WX_ENUM_MEMBER( wxFONTENCODING_ISO8859_MAX ) - WX_ENUM_MEMBER( wxFONTENCODING_KOI8 ) - WX_ENUM_MEMBER( wxFONTENCODING_ALTERNATIVE ) - WX_ENUM_MEMBER( wxFONTENCODING_BULGARIAN ) - WX_ENUM_MEMBER( wxFONTENCODING_CP437 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP850 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP852 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP855 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP866 ) - - WX_ENUM_MEMBER( wxFONTENCODING_CP874 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP932 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP936 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP949 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP950 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP1250 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP1251 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP1252 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP1253 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP1254 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP1255 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP1256 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP1257 ) - WX_ENUM_MEMBER( wxFONTENCODING_CP12_MAX ) - WX_ENUM_MEMBER( wxFONTENCODING_UTF7 ) - WX_ENUM_MEMBER( wxFONTENCODING_UTF8 ) - WX_ENUM_MEMBER( wxFONTENCODING_GB2312 ) - WX_ENUM_MEMBER( wxFONTENCODING_BIG5 ) - WX_ENUM_MEMBER( wxFONTENCODING_SHIFT_JIS ) - WX_ENUM_MEMBER( wxFONTENCODING_EUC_JP ) - WX_ENUM_MEMBER( wxFONTENCODING_UNICODE ) -WX_END_ENUM( wxFontEncoding ) +wxBEGIN_ENUM( wxFontEncoding ) + wxENUM_MEMBER( wxFONTENCODING_SYSTEM ) + wxENUM_MEMBER( wxFONTENCODING_DEFAULT ) + + wxENUM_MEMBER( wxFONTENCODING_ISO8859_1 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_2 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_3 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_4 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_5 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_6 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_7 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_8 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_9 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_10 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_11 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_12 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_13 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_14 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_15 ) + wxENUM_MEMBER( wxFONTENCODING_ISO8859_MAX ) + wxENUM_MEMBER( wxFONTENCODING_KOI8 ) + wxENUM_MEMBER( wxFONTENCODING_ALTERNATIVE ) + wxENUM_MEMBER( wxFONTENCODING_BULGARIAN ) + wxENUM_MEMBER( wxFONTENCODING_CP437 ) + wxENUM_MEMBER( wxFONTENCODING_CP850 ) + wxENUM_MEMBER( wxFONTENCODING_CP852 ) + wxENUM_MEMBER( wxFONTENCODING_CP855 ) + wxENUM_MEMBER( wxFONTENCODING_CP866 ) + + wxENUM_MEMBER( wxFONTENCODING_CP874 ) + wxENUM_MEMBER( wxFONTENCODING_CP932 ) + wxENUM_MEMBER( wxFONTENCODING_CP936 ) + wxENUM_MEMBER( wxFONTENCODING_CP949 ) + wxENUM_MEMBER( wxFONTENCODING_CP950 ) + wxENUM_MEMBER( wxFONTENCODING_CP1250 ) + wxENUM_MEMBER( wxFONTENCODING_CP1251 ) + wxENUM_MEMBER( wxFONTENCODING_CP1252 ) + wxENUM_MEMBER( wxFONTENCODING_CP1253 ) + wxENUM_MEMBER( wxFONTENCODING_CP1254 ) + wxENUM_MEMBER( wxFONTENCODING_CP1255 ) + wxENUM_MEMBER( wxFONTENCODING_CP1256 ) + wxENUM_MEMBER( wxFONTENCODING_CP1257 ) + wxENUM_MEMBER( wxFONTENCODING_CP12_MAX ) + wxENUM_MEMBER( wxFONTENCODING_UTF7 ) + wxENUM_MEMBER( wxFONTENCODING_UTF8 ) + wxENUM_MEMBER( wxFONTENCODING_GB2312 ) + wxENUM_MEMBER( wxFONTENCODING_BIG5 ) + wxENUM_MEMBER( wxFONTENCODING_SHIFT_JIS ) + wxENUM_MEMBER( wxFONTENCODING_EUC_JP ) + wxENUM_MEMBER( wxFONTENCODING_UNICODE ) +wxEND_ENUM( wxFontEncoding ) #endif // ---------------------------------------------------------------------------- diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 69ddd20986..b72b94f86d 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -79,7 +79,7 @@ template<> void wxStringWriteValue(wxString &s , const wxPoint &data ) s = wxString::Format(wxT("%d,%d"), data.x , data.y ) ; } -WX_CUSTOM_TYPE_INFO(wxPoint, wxToStringConverter , wxFromStringConverter) +wxCUSTOM_TYPE_INFO(wxPoint, wxToStringConverter , wxFromStringConverter) template<> void wxStringReadValue(const wxString &s , wxSize &data ) { @@ -91,7 +91,7 @@ template<> void wxStringWriteValue(wxString &s , const wxSize &data ) s = wxString::Format(wxT("%d,%d"), data.x , data.y ) ; } -WX_CUSTOM_TYPE_INFO(wxSize, wxToStringConverter , wxFromStringConverter) +wxCUSTOM_TYPE_INFO(wxSize, wxToStringConverter , wxFromStringConverter) #endif diff --git a/src/common/xti.cpp b/src/common/xti.cpp index dfb09212ee..5e1779399c 100644 --- a/src/common/xti.cpp +++ b/src/common/xti.cpp @@ -255,15 +255,15 @@ wxBuiltInTypeInfo s_typeInfowxString( wxT_STRING , &wxToStringConverter void wxCollectionToVariantArray( wxArrayString const &theArray, wxxVariantArray &value) { @@ -546,13 +546,31 @@ wxObject* wxxVariant::GetAsObject() // own attributes in a hash map. Like this it is possible to create the objects and // stream them, as if their class information was already available from compiled data +// can't keep the attributes in a hash map, because if someone renames a property in +// the class info, then things go potty later on when we try to iterate through +// the property values by name. +struct wxDynamicProperty__ +{ +#if wxUSE_UNICODE + wstring name; +#else + string name; +#endif + wxxVariant value; + wxDynamicProperty__ *next; +}; + struct wxDynamicObject::wxDynamicObjectInternal { + wxDynamicObjectInternal() : m_properties(NULL) {} + wxDynamicProperty__ *m_properties; +#if 0 #if wxUSE_UNICODE map m_properties ; #else map m_properties ; #endif +#endif } ; // instantiates this object with an instance of its superclass @@ -572,13 +590,39 @@ wxDynamicObject::~wxDynamicObject() void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxxVariant &value) { wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ; - m_data->m_properties[propertyName] = value ; + wxDynamicProperty__ *prop; + prop = m_data->m_properties; + while (prop) + { + if (!strcmp(prop->name.c_str(), propertyName)) + { + prop->value = value; + return; + } + prop = prop->next; + } + prop = new wxDynamicProperty__; + prop->name = propertyName; + prop->value = value; + prop->next = m_data->m_properties; + m_data->m_properties = prop; +// m_data->m_properties[propertyName] = value ; } wxxVariant wxDynamicObject::GetProperty (const wxChar *propertyName) const { wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ; - return m_data->m_properties[propertyName] ; + wxDynamicProperty__ *prop; + prop = m_data->m_properties; + while (prop) + { + if (!strcmp(prop->name.c_str(), propertyName)) + return prop->value; + prop = prop->next; + } + // FIXME: needs to return something a little more sane here. + return wxxVariant(); +// return m_data->m_properties[propertyName] ; } // ---------------------------------------------------------------------------- diff --git a/src/common/xtistrm.cpp b/src/common/xtistrm.cpp index 0c3b09a079..015b8a28e3 100644 --- a/src/common/xtistrm.cpp +++ b/src/common/xtistrm.cpp @@ -198,7 +198,7 @@ void wxWriter::WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , c DoBeginWriteElement() ; wxxVariant value = data[i] ; - if ( persister->BeforeWriteProperty( this , pi , value ) ) + if ( persister->BeforeWriteProperty( this , obj, pi , value ) ) { const wxClassTypeInfo* cti = dynamic_cast< const wxClassTypeInfo* > ( elementType ) ; if ( cti ) @@ -270,7 +270,7 @@ void wxWriter::WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , c if ( cti && value.GetAsObject() == NULL ) return ; - if ( persister->BeforeWriteProperty( this , pi , value ) ) + if ( persister->BeforeWriteProperty( this , obj, pi , value ) ) { DoBeginWriteProperty( pi ) ; if ( cti ) @@ -501,7 +501,7 @@ void wxRuntimeDepersister::SetPropertyAsObject(int objectID, void wxRuntimeDepersister::SetConnect(int eventSourceObjectID, const wxClassInfo *WXUNUSED(eventSourceClassInfo), - const wxDelegateTypeInfo *delegateInfo , + const wxPropertyInfo *delegateInfo , const wxClassInfo *WXUNUSED(eventSinkClassInfo) , const wxHandlerInfo* handlerInfo , int eventSinkObjectID ) @@ -511,22 +511,22 @@ void wxRuntimeDepersister::SetConnect(int eventSourceObjectID, if ( ehsource && ehsink ) { - if( delegateInfo->GetLastEventType() == -1 ) + const wxDelegateTypeInfo *delegateTypeInfo = dynamic_cast(delegateInfo->GetTypeInfo()); + if( delegateTypeInfo && delegateTypeInfo->GetLastEventType() == -1 ) { - ehsource->Connect( -1 , delegateInfo->GetEventType() , + ehsource->Connect( -1 , delegateTypeInfo->GetEventType() , handlerInfo->GetEventFunction() , NULL /*user data*/ , ehsink ) ; } else { - for ( wxEventType iter = delegateInfo->GetEventType() ; iter <= delegateInfo->GetLastEventType() ; ++iter ) + for ( wxEventType iter = delegateTypeInfo->GetEventType() ; iter <= delegateTypeInfo->GetLastEventType() ; ++iter ) { ehsource->Connect( -1 , iter , handlerInfo->GetEventFunction() , NULL /*user data*/ , ehsink ) ; } - } - + } } } @@ -750,7 +750,7 @@ void wxCodeDepersister::AddToPropertyCollectionAsObject(int WXUNUSED(objectID), void wxCodeDepersister::SetConnect(int eventSourceObjectID, const wxClassInfo *WXUNUSED(eventSourceClassInfo), - const wxDelegateTypeInfo *delegateInfo , + const wxPropertyInfo *delegateInfo , const wxClassInfo *eventSinkClassInfo , const wxHandlerInfo* handlerInfo , int eventSinkObjectID ) @@ -758,7 +758,9 @@ void wxCodeDepersister::SetConnect(int eventSourceObjectID, wxString ehsource = m_data->GetObjectName( eventSourceObjectID ) ; wxString ehsink = m_data->GetObjectName(eventSinkObjectID) ; wxString ehsinkClass = eventSinkClassInfo->GetClassName() ; - int eventType = delegateInfo->GetEventType() ; + const wxDelegateTypeInfo *delegateTypeInfo = dynamic_cast(delegateInfo->GetTypeInfo()); + wxASSERT_MSG(delegateTypeInfo, "delegate has no type info"); + int eventType = delegateTypeInfo->GetEventType() ; wxString handlerName = handlerInfo->GetName() ; m_fp->WriteString( wxString::Format( wxT("\t%s->Connect( %s->GetId() , %d , (wxObjectEventFunction)(wxEventFunction) & %s::%s , NULL , %s ) ;") , diff --git a/src/common/xtixml.cpp b/src/common/xtixml.cpp index d21e748721..08a895415a 100644 --- a/src/common/xtixml.cpp +++ b/src/common/xtixml.cpp @@ -438,7 +438,7 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) wxString handlerName = resstring.Mid(pos+1) ; wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid ) ; - callbacks->SetConnect( objectID , classInfo , dynamic_cast(pi->GetTypeInfo()) , sinkClassInfo , + callbacks->SetConnect( objectID , classInfo , pi , sinkClassInfo , sinkClassInfo->FindHandlerInfo(handlerName) , sinkOid ) ; } -- 2.45.2