1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/xti.cpp
3 // Purpose: runtime metadata information (extended class info)
4 // Author: Stefan Csomor
8 // Copyright: (c) 1997 Julian Smart
9 // (c) 2003 Stefan Csomor
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // For compilers that support precompilation, includes "wx.h".
14 #include "wx/wxprec.h"
20 #if wxUSE_EXTENDED_RTTI
23 #include "wx/object.h"
29 #include "wx/xml/xml.h"
30 #include "wx/tokenzr.h"
33 #include "wx/beforestd.h"
37 #include "wx/afterstd.h"
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 wxEnumData::wxEnumData( wxEnumMemberData
* data
)
48 for ( m_count
= 0; m_members
[m_count
].m_name
; m_count
++)
52 bool wxEnumData::HasEnumMemberValue(const wxChar
*name
, int *value
) const
55 for (i
= 0; m_members
[i
].m_name
; i
++ )
57 if (!wxStrcmp(name
, m_members
[i
].m_name
))
60 *value
= m_members
[i
].m_value
;
67 int wxEnumData::GetEnumMemberValue(const wxChar
*name
) const
70 for (i
= 0; m_members
[i
].m_name
; i
++ )
72 if (!wxStrcmp(name
, m_members
[i
].m_name
))
74 return m_members
[i
].m_value
;
80 const wxChar
*wxEnumData::GetEnumMemberName(int value
) const
83 for (i
= 0; m_members
[i
].m_name
; i
++)
84 if (value
== m_members
[i
].m_value
)
85 return m_members
[i
].m_name
;
90 int wxEnumData::GetEnumMemberValueByIndex( int idx
) const
92 // we should cache the count in order to avoid out-of-bounds errors
93 return m_members
[idx
].m_value
;
96 const wxChar
* wxEnumData::GetEnumMemberNameByIndex( int idx
) const
98 // we should cache the count in order to avoid out-of-bounds errors
99 return m_members
[idx
].m_name
;
102 // ----------------------------------------------------------------------------
104 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
108 // ----------------------------------------------------------------------------
110 // streamer specializations
111 // for all built-in types
115 template<> void wxStringReadValue(const wxString
&s
, bool &data
)
118 wxSscanf(s
, _T("%d"), &intdata
);
119 data
= (bool)(intdata
!= 0);
122 template<> void wxStringWriteValue(wxString
&s
, const bool &data
)
124 s
= wxString::Format(_T("%d"), data
);
129 template<> void wxStringReadValue(const wxString
&s
, char &data
)
132 wxSscanf(s
, _T("%d"), &intdata
);
133 data
= char(intdata
);
136 template<> void wxStringWriteValue(wxString
&s
, const char &data
)
138 s
= wxString::Format(_T("%d"), data
);
143 template<> void wxStringReadValue(const wxString
&s
, unsigned char &data
)
146 wxSscanf(s
, _T("%d"), &intdata
);
147 data
= (unsigned char)(intdata
);
150 template<> void wxStringWriteValue(wxString
&s
, const unsigned char &data
)
152 s
= wxString::Format(_T("%d"), data
);
157 template<> void wxStringReadValue(const wxString
&s
, int &data
)
159 wxSscanf(s
, _T("%d"), &data
);
162 template<> void wxStringWriteValue(wxString
&s
, const int &data
)
164 s
= wxString::Format(_T("%d"), data
);
169 template<> void wxStringReadValue(const wxString
&s
, unsigned int &data
)
171 wxSscanf(s
, _T("%d"), &data
);
174 template<> void wxStringWriteValue(wxString
&s
, const unsigned int &data
)
176 s
= wxString::Format(_T("%d"), data
);
181 template<> void wxStringReadValue(const wxString
&s
, long &data
)
183 wxSscanf(s
, _T("%ld"), &data
);
186 template<> void wxStringWriteValue(wxString
&s
, const long &data
)
188 s
= wxString::Format(_T("%ld"), data
);
193 template<> void wxStringReadValue(const wxString
&s
, unsigned long &data
)
195 wxSscanf(s
, _T("%ld"), &data
);
198 template<> void wxStringWriteValue(wxString
&s
, const unsigned long &data
)
200 s
= wxString::Format(_T("%ld"), data
);
205 template<> void wxStringReadValue(const wxString
&s
, float &data
)
207 wxSscanf(s
, _T("%f"), &data
);
210 template<> void wxStringWriteValue(wxString
&s
, const float &data
)
212 s
= wxString::Format(_T("%f"), data
);
217 template<> void wxStringReadValue(const wxString
&s
, double &data
)
219 wxSscanf(s
, _T("%lf"), &data
);
222 template<> void wxStringWriteValue(wxString
&s
, const double &data
)
224 s
= wxString::Format(_T("%lf"), data
);
229 template<> void wxStringReadValue(const wxString
&s
, wxString
&data
)
234 template<> void wxStringWriteValue(wxString
&s
, const wxString
&data
)
243 #if wxUSE_FUNC_TEMPLATE_POINTER
244 #define wxBUILTIN_TYPE_INFO( element, type ) \
246 s_typeInfo##type(element, &wxToStringConverter<type>, \
247 &wxFromStringConverter<type>, typeid(type).name());
249 #define wxBUILTIN_TYPE_INFO( element, type ) \
250 void _toString##element( const wxVariantBase& data, wxString &result ) \
251 { wxToStringConverter<type, data, result); } \
252 void _fromString##element( const wxString& data, wxVariantBase &result ) \
253 { wxFromStringConverter<type, data, result); } \
254 wxBuiltInTypeInfo s_typeInfo##type(element, &_toString##element, \
255 &_fromString##element, typeid(type).name());
258 typedef unsigned char unsigned_char
;
259 typedef unsigned int unsigned_int
;
260 typedef unsigned long unsigned_long
;
262 wxBuiltInTypeInfo
s_typeInfovoid( wxT_VOID
, NULL
, NULL
, typeid(void).name());
263 wxBUILTIN_TYPE_INFO( wxT_BOOL
, bool);
264 wxBUILTIN_TYPE_INFO( wxT_CHAR
, char);
265 wxBUILTIN_TYPE_INFO( wxT_UCHAR
, unsigned_char
);
266 wxBUILTIN_TYPE_INFO( wxT_INT
, int);
267 wxBUILTIN_TYPE_INFO( wxT_UINT
, unsigned_int
);
268 wxBUILTIN_TYPE_INFO( wxT_LONG
, long);
269 wxBUILTIN_TYPE_INFO( wxT_ULONG
, unsigned_long
);
270 wxBUILTIN_TYPE_INFO( wxT_FLOAT
, float);
271 wxBUILTIN_TYPE_INFO( wxT_DOUBLE
, double);
272 wxBUILTIN_TYPE_INFO( wxT_STRING
, wxString
);
275 // this are compiler induced specialization which are never used anywhere
277 wxILLEGAL_TYPE_SPECIALIZATION( char const * )
278 wxILLEGAL_TYPE_SPECIALIZATION( char * )
279 wxILLEGAL_TYPE_SPECIALIZATION( unsigned char * )
280 wxILLEGAL_TYPE_SPECIALIZATION( int * )
281 wxILLEGAL_TYPE_SPECIALIZATION( bool * )
282 wxILLEGAL_TYPE_SPECIALIZATION( long * )
283 wxILLEGAL_TYPE_SPECIALIZATION( wxString
* )
285 wxCOLLECTION_TYPE_INFO( wxString
, wxArrayString
);
287 template<> void wxCollectionToVariantArray( wxArrayString
const &theArray
,
288 wxVariantBaseArray
&value
)
290 wxArrayCollectionToVariantArray( theArray
, value
);
293 wxTypeInfoMap
*wxTypeInfo::ms_typeTable
= NULL
;
295 wxTypeInfo
*wxTypeInfo::FindType(const wxChar
*typeName
)
297 wxTypeInfoMap::iterator iter
= ms_typeTable
->find(typeName
);
299 //wxASSERT_MSG( iter != ms_typeTable->end(),
300 // wxT("lookup for a non-existent type-info") );
301 // FM 3/6/2007 - disabled because otherwise
302 // wxPropertyInfo::GetCollectionElementTypeInfo
304 if (iter
== ms_typeTable
->end())
307 return (wxTypeInfo
*)iter
->second
;
311 wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind
, wxClassInfo
* classInfo
,
312 wxVariant2StringFnc to
,
313 wxString2VariantFnc from
,
315 wxTypeInfo( kind
, to
, from
, name
)
317 wxASSERT_MSG( kind
== wxT_OBJECT_PTR
||
319 wxT("Illegal Kind for Enum Type")); m_classInfo
= classInfo
;
323 wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind
, wxClassInfo
* classInfo
,
324 wxVariant2StringFnc to
,
325 wxString2VariantFnc from
,
326 const wxString
&name
) :
327 wxTypeInfo( kind
, to
, from
, name
)
329 wxASSERT_MSG( kind
== wxT_OBJECT_PTR
|| kind
== wxT_OBJECT
,
330 wxT("Illegal Kind for Enum Type")); m_classInfo
= classInfo
;
333 wxEventSourceTypeInfo::wxEventSourceTypeInfo( int eventType
, wxClassInfo
* eventClass
,
334 wxVariant2StringFnc to
,
335 wxString2VariantFnc from
) :
336 wxTypeInfo ( wxT_DELEGATE
, to
, from
, wxEmptyString
)
338 m_eventClass
= eventClass
;
339 m_eventType
= eventType
;
340 m_lastEventType
= -1;
343 wxEventSourceTypeInfo::wxEventSourceTypeInfo( int eventType
, int lastEventType
,
344 wxClassInfo
* eventClass
,
345 wxVariant2StringFnc to
,
346 wxString2VariantFnc from
) :
347 wxTypeInfo ( wxT_DELEGATE
, to
, from
, wxEmptyString
)
349 m_eventClass
= eventClass
;
350 m_eventType
= eventType
;
351 m_lastEventType
= lastEventType
;
354 void wxTypeInfo::Register()
356 if ( ms_typeTable
== NULL
)
357 ms_typeTable
= new wxTypeInfoMap();
359 if( !m_name
.empty() )
360 (*ms_typeTable
)[m_name
] = this;
363 void wxTypeInfo::Unregister()
365 if( !m_name
.empty() )
366 ms_typeTable
->erase(m_name
);
369 // removing header dependancy on string tokenizer
371 void wxSetStringToArray( const wxString
&s
, wxArrayString
&array
)
373 wxStringTokenizer
tokenizer(s
, wxT("| \t\n"), wxTOKEN_STRTOK
);
376 while (tokenizer
.HasMoreTokens())
378 array
.Add(tokenizer
.GetNextToken());
382 // ----------------------------------------------------------------------------
384 // ----------------------------------------------------------------------------
386 void wxPropertyInfo::Insert(wxPropertyInfo
* &iter
)
393 wxPropertyInfo
* i
= iter
;
401 void wxPropertyInfo::Remove()
403 if ( this == m_itsClass
->m_firstProperty
)
405 m_itsClass
->m_firstProperty
= m_next
;
409 wxPropertyInfo
*info
= m_itsClass
->m_firstProperty
;
412 if ( info
->m_next
== this )
414 info
->m_next
= m_next
;
423 // ----------------------------------------------------------------------------
425 // ----------------------------------------------------------------------------
427 void wxHandlerInfo::Insert(wxHandlerInfo
* &iter
)
434 wxHandlerInfo
* i
= iter
;
442 void wxHandlerInfo::Remove()
444 if ( this == m_itsClass
->m_firstHandler
)
446 m_itsClass
->m_firstHandler
= m_next
;
450 wxHandlerInfo
*info
= m_itsClass
->m_firstHandler
;
453 if ( info
->m_next
== this )
455 info
->m_next
= m_next
;
465 // ----------------------------------------------------------------------------
467 // ----------------------------------------------------------------------------
469 bool wxClassInfo::Create(wxObject
*object
, int ParamCount
, wxVariantBase
*Params
) const
471 if ( ParamCount
!= m_constructorPropertiesCount
)
473 // FIXME: shouldn't we just return false and let the caller handle it?
474 wxLogError( _("Illegal Parameter Count for Create Method") );
478 return m_constructor
->Create( object
, Params
);
481 wxObject
*wxClassInfo::ConstructObject(int ParamCount
, wxVariantBase
*Params
) const
483 if ( ParamCount
!= m_constructorPropertiesCount
)
485 // FIXME: shouldn't we just return NULL and let the caller handle this case?
486 wxLogError( _("Illegal Parameter Count for ConstructObject Method") );
490 wxObject
*object
= NULL
;
491 if (!m_constructor
->Create( object
, Params
))
496 bool wxClassInfo::IsKindOf(const wxClassInfo
*info
) const
503 for ( int i
= 0; m_parents
[i
]; ++ i
)
505 if ( m_parents
[i
]->IsKindOf( info
) )
512 const wxPropertyAccessor
*wxClassInfo::FindAccessor(const wxChar
*PropertyName
) const
514 const wxPropertyInfo
* info
= FindPropertyInfo( PropertyName
);
517 return info
->GetAccessor();
522 wxPropertyInfo
*wxClassInfo::FindPropertyInfoInThisClass (const wxChar
*PropertyName
) const
524 wxPropertyInfo
* info
= m_firstProperty
;
528 if ( wxStrcmp( info
->GetName(), PropertyName
) == 0 )
530 info
= info
->GetNext();
536 const wxPropertyInfo
*wxClassInfo::FindPropertyInfo (const wxChar
*PropertyName
) const
538 const wxPropertyInfo
* info
= FindPropertyInfoInThisClass( PropertyName
);
542 const wxClassInfo
** parents
= GetParents();
543 for ( int i
= 0; parents
[i
]; ++ i
)
545 if ( ( info
= parents
[i
]->FindPropertyInfo( PropertyName
) ) != NULL
)
552 wxHandlerInfo
*wxClassInfo::FindHandlerInfoInThisClass (const wxChar
*PropertyName
) const
554 wxHandlerInfo
* info
= m_firstHandler
;
558 if ( wxStrcmp( info
->GetName(), PropertyName
) == 0 )
560 info
= info
->GetNext();
566 const wxHandlerInfo
*wxClassInfo::FindHandlerInfo (const wxChar
*PropertyName
) const
568 const wxHandlerInfo
* info
= FindHandlerInfoInThisClass( PropertyName
);
573 const wxClassInfo
** parents
= GetParents();
574 for ( int i
= 0; parents
[i
]; ++ i
)
576 if ( ( info
= parents
[i
]->FindHandlerInfo( PropertyName
) ) != NULL
)
583 wxObjectStreamingCallback
wxClassInfo::GetStreamingCallback() const
585 if ( m_streamingCallback
)
586 return m_streamingCallback
;
588 wxObjectStreamingCallback retval
= NULL
;
589 const wxClassInfo
** parents
= GetParents();
590 for ( int i
= 0; parents
[i
] && retval
== NULL
; ++ i
)
592 retval
= parents
[i
]->GetStreamingCallback();
597 bool wxClassInfo::BeforeWriteObject( const wxObject
*obj
, wxObjectWriter
*streamer
,
598 wxObjectReaderCallback
*persister
, wxVariantBaseArray
&metadata
) const
600 wxObjectStreamingCallback sb
= GetStreamingCallback();
602 return (*sb
)(obj
, streamer
, persister
, metadata
);
607 void wxClassInfo::SetProperty(wxObject
*object
, const wxChar
*propertyName
,
608 const wxVariantBase
&value
) const
610 const wxPropertyAccessor
*accessor
;
612 accessor
= FindAccessor(propertyName
);
613 wxASSERT(accessor
->HasSetter());
614 accessor
->SetProperty( object
, value
);
617 wxVariantBase
wxClassInfo::GetProperty(wxObject
*object
, const wxChar
*propertyName
) const
619 const wxPropertyAccessor
*accessor
;
621 accessor
= FindAccessor(propertyName
);
622 wxASSERT(accessor
->HasGetter());
623 wxVariantBase result
;
624 accessor
->GetProperty(object
,result
);
628 wxVariantBaseArray
wxClassInfo::GetPropertyCollection(wxObject
*object
,
629 const wxChar
*propertyName
) const
631 const wxPropertyAccessor
*accessor
;
633 accessor
= FindAccessor(propertyName
);
634 wxASSERT(accessor
->HasGetter());
635 wxVariantBaseArray result
;
636 accessor
->GetPropertyCollection(object
,result
);
640 void wxClassInfo::AddToPropertyCollection(wxObject
*object
, const wxChar
*propertyName
,
641 const wxVariantBase
& value
) const
643 const wxPropertyAccessor
*accessor
;
645 accessor
= FindAccessor(propertyName
);
646 wxASSERT(accessor
->HasAdder());
647 accessor
->AddToPropertyCollection( object
, value
);
650 // void wxClassInfo::GetProperties( wxPropertyInfoMap &map ) const
651 // The map parameter (the name map that is) seems something special
652 // to MSVC and so we use a other name.
653 void wxClassInfo::GetProperties( wxPropertyInfoMap
&infomap
) const
655 const wxPropertyInfo
*pi
= GetFirstProperty();
658 if ( infomap
.find( pi
->GetName() ) == infomap
.end() )
659 infomap
[pi
->GetName()] = (wxPropertyInfo
*) pi
;
664 const wxClassInfo
** parents
= GetParents();
665 for ( int i
= 0; parents
[i
]; ++ i
)
667 parents
[i
]->GetProperties( infomap
);
672 // ----------------------------------------------------------------------------
673 // wxDynamicObject support
674 // ----------------------------------------------------------------------------
676 // Dynamic Objects are objects that have a real superclass instance and carry their
677 // own attributes in a hash map. Like this it is possible to create the objects and
678 // stream them, as if their class information was already available from compiled data
680 struct wxDynamicObject::wxDynamicObjectInternal
682 wxDynamicObjectInternal() {}
685 map
<wstring
,wxVariantBase
> m_properties
;
687 map
<string
,wxVariantBase
> m_properties
;
691 typedef list
< wxDynamicObject
* > wxDynamicObjectList
;
693 struct wxDynamicClassInfo::wxDynamicClassInfoInternal
695 wxDynamicObjectList m_dynamicObjects
;
698 // instantiates this object with an instance of its superclass
699 wxDynamicObject::wxDynamicObject(wxObject
* superClassInstance
, const wxDynamicClassInfo
*info
)
701 m_superClassInstance
= superClassInstance
;
703 m_data
= new wxDynamicObjectInternal
;
706 wxDynamicObject::~wxDynamicObject()
708 wx_dynamic_cast(const wxDynamicClassInfo
*, m_classInfo
)->
709 m_data
->m_dynamicObjects
.remove( this );
711 delete m_superClassInstance
;
714 void wxDynamicObject::SetProperty (const wxChar
*propertyName
, const wxVariantBase
&value
)
716 wxASSERT_MSG(m_classInfo
->FindPropertyInfoInThisClass(propertyName
),
717 wxT("Accessing Unknown Property in a Dynamic Object") );
718 m_data
->m_properties
[propertyName
] = value
;
721 wxVariantBase
wxDynamicObject::GetProperty (const wxChar
*propertyName
) const
723 wxASSERT_MSG(m_classInfo
->FindPropertyInfoInThisClass(propertyName
),
724 wxT("Accessing Unknown Property in a Dynamic Object") );
725 return m_data
->m_properties
[propertyName
];
728 void wxDynamicObject::RemoveProperty( const wxChar
*propertyName
)
730 wxASSERT_MSG(m_classInfo
->FindPropertyInfoInThisClass(propertyName
),
731 wxT("Removing Unknown Property in a Dynamic Object") );
732 m_data
->m_properties
.erase( propertyName
);
735 void wxDynamicObject::RenameProperty( const wxChar
*oldPropertyName
,
736 const wxChar
*newPropertyName
)
738 wxASSERT_MSG(m_classInfo
->FindPropertyInfoInThisClass(oldPropertyName
),
739 wxT("Renaming Unknown Property in a Dynamic Object") );
741 wxVariantBase value
= m_data
->m_properties
[oldPropertyName
];
742 m_data
->m_properties
.erase( oldPropertyName
);
743 m_data
->m_properties
[newPropertyName
] = value
;
747 // ----------------------------------------------------------------------------
748 // wxDynamicClassInfo
749 // ----------------------------------------------------------------------------
751 wxDynamicClassInfo::wxDynamicClassInfo( const wxChar
*unitName
,
752 const wxChar
*className
,
753 const wxClassInfo
* superClass
) :
754 wxClassInfo( unitName
, className
, new const wxClassInfo
*[2])
756 GetParents()[0] = superClass
;
757 GetParents()[1] = NULL
;
758 m_data
= new wxDynamicClassInfoInternal
;
761 wxDynamicClassInfo::~wxDynamicClassInfo()
763 delete[] GetParents();
767 wxObject
*wxDynamicClassInfo::AllocateObject() const
769 wxObject
* parent
= GetParents()[0]->AllocateObject();
770 wxDynamicObject
*obj
= new wxDynamicObject( parent
, this );
771 m_data
->m_dynamicObjects
.push_back( obj
);
775 bool wxDynamicClassInfo::Create (wxObject
*object
, int paramCount
, wxVariantBase
*params
) const
777 wxDynamicObject
*dynobj
= wx_dynamic_cast( wxDynamicObject
*, object
);
778 wxASSERT_MSG( dynobj
,
779 wxT("cannot call wxDynamicClassInfo::Create on ")
780 wxT("an object other than wxDynamicObject") );
782 return GetParents()[0]->Create( dynobj
->GetSuperClassInstance(), paramCount
, params
);
785 // get number of parameters for constructor
786 int wxDynamicClassInfo::GetCreateParamCount() const
788 return GetParents()[0]->GetCreateParamCount();
791 // get i-th constructor parameter
792 const wxChar
* wxDynamicClassInfo::GetCreateParamName(int i
) const
794 return GetParents()[0]->GetCreateParamName( i
);
797 void wxDynamicClassInfo::SetProperty(wxObject
*object
, const wxChar
*propertyName
, const wxVariantBase
&value
) const
799 wxDynamicObject
* dynobj
= wx_dynamic_cast(wxDynamicObject
*, object
);
800 wxASSERT_MSG( dynobj
, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
801 if ( FindPropertyInfoInThisClass(propertyName
) )
802 dynobj
->SetProperty( propertyName
, value
);
804 GetParents()[0]->SetProperty( dynobj
->GetSuperClassInstance(), propertyName
, value
);
807 wxVariantBase
wxDynamicClassInfo::GetProperty(wxObject
*object
, const wxChar
*propertyName
) const
809 wxDynamicObject
* dynobj
= wx_dynamic_cast(wxDynamicObject
*, object
);
810 wxASSERT_MSG( dynobj
, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
811 if ( FindPropertyInfoInThisClass(propertyName
) )
812 return dynobj
->GetProperty( propertyName
);
814 return GetParents()[0]->GetProperty( dynobj
->GetSuperClassInstance(), propertyName
);
817 void wxDynamicClassInfo::AddProperty( const wxChar
*propertyName
, const wxTypeInfo
* typeInfo
)
819 new wxPropertyInfo( m_firstProperty
, this, propertyName
, typeInfo
->GetTypeName(), new wxGenericPropertyAccessor( propertyName
), wxVariantBase() );
822 void wxDynamicClassInfo::AddHandler( const wxChar
*handlerName
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
)
824 new wxHandlerInfo( m_firstHandler
, this, handlerName
, address
, eventClassInfo
);
827 // removes an existing runtime-property
828 void wxDynamicClassInfo::RemoveProperty( const wxChar
*propertyName
)
830 for ( wxDynamicObjectList::iterator iter
= m_data
->m_dynamicObjects
.begin(); iter
!= m_data
->m_dynamicObjects
.end(); ++iter
)
831 (*iter
)->RemoveProperty( propertyName
);
832 delete FindPropertyInfoInThisClass(propertyName
);
835 // removes an existing runtime-handler
836 void wxDynamicClassInfo::RemoveHandler( const wxChar
*handlerName
)
838 delete FindHandlerInfoInThisClass(handlerName
);
841 // renames an existing runtime-property
842 void wxDynamicClassInfo::RenameProperty( const wxChar
*oldPropertyName
, const wxChar
*newPropertyName
)
844 wxPropertyInfo
* pi
= FindPropertyInfoInThisClass(oldPropertyName
);
845 wxASSERT_MSG( pi
,wxT("not existing property") );
846 pi
->m_name
= newPropertyName
;
847 wx_dynamic_cast(wxGenericPropertyAccessor
*, pi
->GetAccessor())->RenameProperty( oldPropertyName
, newPropertyName
);
848 for ( wxDynamicObjectList::iterator iter
= m_data
->m_dynamicObjects
.begin(); iter
!= m_data
->m_dynamicObjects
.end(); ++iter
)
849 (*iter
)->RenameProperty( oldPropertyName
, newPropertyName
);
852 // renames an existing runtime-handler
853 void wxDynamicClassInfo::RenameHandler( const wxChar
*oldHandlerName
, const wxChar
*newHandlerName
)
855 wxASSERT_MSG(FindHandlerInfoInThisClass(oldHandlerName
),wxT("not existing handler") );
856 FindHandlerInfoInThisClass(oldHandlerName
)->m_name
= newHandlerName
;
859 // ----------------------------------------------------------------------------
860 // wxGenericPropertyAccessor
861 // ----------------------------------------------------------------------------
863 struct wxGenericPropertyAccessor::wxGenericPropertyAccessorInternal
868 wxGenericPropertyAccessor::wxGenericPropertyAccessor( const wxString
& propertyName
)
869 : wxPropertyAccessor( NULL
, NULL
, NULL
, NULL
)
871 m_data
= new wxGenericPropertyAccessorInternal
;
872 m_propertyName
= propertyName
;
873 m_getterName
= wxT("Get")+propertyName
;
874 m_setterName
= wxT("Set")+propertyName
;
877 wxGenericPropertyAccessor::~wxGenericPropertyAccessor()
882 void wxGenericPropertyAccessor::SetProperty(wxObject
*object
, const wxVariantBase
&value
) const
884 wxDynamicObject
* dynobj
= wx_dynamic_cast(wxDynamicObject
*, object
);
885 wxASSERT_MSG( dynobj
, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
886 dynobj
->SetProperty(m_propertyName
, value
);
889 void wxGenericPropertyAccessor::GetProperty(const wxObject
*object
, wxVariantBase
& value
) const
891 const wxDynamicObject
* dynobj
= wx_dynamic_cast( const wxDynamicObject
* , object
);
892 wxASSERT_MSG( dynobj
, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
893 value
= dynobj
->GetProperty( m_propertyName
);
896 #endif // wxUSE_EXTENDED_RTTI