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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  14 #pragma implementation "xti.h" 
  17 // For compilers that support precompilation, includes "wx.h". 
  18 #include "wx/wxprec.h" 
  26 #include "wx/object.h" 
  29 #if wxUSE_EXTENDED_RTTI 
  32 #include "wx/xml/xml.h" 
  33 #include "wx/tokenzr.h" 
  37 #include "wx/beforestd.h" 
  41 #include "wx/afterstd.h" 
  45 // ---------------------------------------------------------------------------- 
  47 // ---------------------------------------------------------------------------- 
  49 wxEnumData::wxEnumData( wxEnumMemberData
* data 
) 
  52     for ( m_count 
= 0; m_members
[m_count
].m_name 
; m_count
++) 
  56 bool wxEnumData::HasEnumMemberValue(const wxChar 
*name
, int *value
) const 
  59     for (i 
= 0; m_members
[i
].m_name 
; i
++ ) 
  61         if (!wxStrcmp(name
, m_members
[i
].m_name
)) 
  64                 *value 
= m_members
[i
].m_value
; 
  71 int wxEnumData::GetEnumMemberValue(const wxChar 
*name
) const 
  74     for (i 
= 0; m_members
[i
].m_name 
; i
++ ) 
  76         if (!wxStrcmp(name
, m_members
[i
].m_name
)) 
  78             return m_members
[i
].m_value
; 
  84 const wxChar 
*wxEnumData::GetEnumMemberName(int value
) const 
  87     for (i 
= 0; m_members
[i
].m_name 
; i
++) 
  88         if (value 
== m_members
[i
].m_value
) 
  89             return m_members
[i
].m_name
; 
  91     return wxEmptyString 
; 
  94 int wxEnumData::GetEnumMemberValueByIndex( int idx 
) const 
  96     // we should cache the count in order to avoid out-of-bounds errors 
  97     return m_members
[idx
].m_value 
; 
 100 const wxChar 
* wxEnumData::GetEnumMemberNameByIndex( int idx 
) const 
 102     // we should cache the count in order to avoid out-of-bounds errors 
 103     return m_members
[idx
].m_name 
; 
 106 // ---------------------------------------------------------------------------- 
 108 // ---------------------------------------------------------------------------- 
 109 // ---------------------------------------------------------------------------- 
 111 // ---------------------------------------------------------------------------- 
 113 // streamer specializations 
 114 // for all built-in types 
 118 template<> void wxStringReadValue(const wxString 
&s 
, bool &data 
) 
 121     wxSscanf(s
, _T("%d"), &intdata 
) ; 
 122     data 
= (bool)intdata 
; 
 125 template<> void wxStringWriteValue(wxString 
&s 
, const bool &data 
) 
 127     s 
= wxString::Format(_T("%d"), data 
) ; 
 132 template<> void wxStringReadValue(const wxString 
&s 
, char &data 
) 
 135     wxSscanf(s
, _T("%d"), &intdata 
) ; 
 136     data 
= char(intdata
) ; 
 139 template<> void wxStringWriteValue(wxString 
&s 
, const char &data 
) 
 141     s 
= wxString::Format(_T("%d"), data 
) ; 
 146 template<> void wxStringReadValue(const wxString 
&s 
, unsigned char &data 
) 
 149     wxSscanf(s
, _T("%d"), &intdata 
) ; 
 150     data 
= (unsigned char)(intdata
) ; 
 153 template<> void wxStringWriteValue(wxString 
&s 
, const unsigned char &data 
) 
 155     s 
= wxString::Format(_T("%d"), data 
) ; 
 160 template<> void wxStringReadValue(const wxString 
&s 
, int &data 
) 
 162     wxSscanf(s
, _T("%d"), &data 
) ; 
 165 template<> void wxStringWriteValue(wxString 
&s 
, const int &data 
) 
 167     s 
= wxString::Format(_T("%d"), data 
) ; 
 172 template<> void wxStringReadValue(const wxString 
&s 
, unsigned int &data 
) 
 174     wxSscanf(s
, _T("%d"), &data 
) ; 
 177 template<> void wxStringWriteValue(wxString 
&s 
, const unsigned int &data 
) 
 179     s 
= wxString::Format(_T("%d"), data 
) ; 
 184 template<> void wxStringReadValue(const wxString 
&s 
, long &data 
) 
 186     wxSscanf(s
, _T("%ld"), &data 
) ; 
 189 template<> void wxStringWriteValue(wxString 
&s 
, const long &data 
) 
 191     s 
= wxString::Format(_T("%ld"), data 
) ; 
 196 template<> void wxStringReadValue(const wxString 
&s 
, unsigned long &data 
) 
 198     wxSscanf(s
, _T("%ld"), &data 
) ; 
 201 template<> void wxStringWriteValue(wxString 
&s 
, const unsigned long &data 
) 
 203     s 
= wxString::Format(_T("%ld"), data 
) ; 
 208 template<> void wxStringReadValue(const wxString 
&s 
, float &data 
) 
 210     wxSscanf(s
, _T("%f"), &data 
) ; 
 213 template<> void wxStringWriteValue(wxString 
&s 
, const float &data 
) 
 215     s 
= wxString::Format(_T("%f"), data 
) ; 
 220 template<> void wxStringReadValue(const wxString 
&s 
, double &data 
) 
 222     wxSscanf(s
, _T("%lf"), &data 
) ; 
 225 template<> void wxStringWriteValue(wxString 
&s 
, const double &data 
) 
 227     s 
= wxString::Format(_T("%lf"), data 
) ; 
 232 template<> void wxStringReadValue(const wxString 
&s 
, wxString 
&data 
) 
 237 template<> void wxStringWriteValue(wxString 
&s 
, const wxString 
&data 
) 
 245 #if wxUSE_FUNC_TEMPLATE_POINTER 
 246 #define wxBUILTIN_TYPE_INFO( element , type ) \ 
 247     wxBuiltInTypeInfo s_typeInfo##type(element , &wxToStringConverter<type> , &wxFromStringConverter<type> , typeid(type).name()) ; 
 249 #define wxBUILTIN_TYPE_INFO( element , type ) \ 
 250     void _toString##element( const wxxVariant& data , wxString &result ) { wxToStringConverter<type>(data, result); } \ 
 251     void _fromString##element( const wxString& data , wxxVariant &result ) { wxFromStringConverter<type>(data, result); } \ 
 252     wxBuiltInTypeInfo s_typeInfo##type(element , &_toString##element , &_fromString##element , typeid(type).name()) ; 
 255 typedef unsigned char unsigned_char
; 
 256 typedef unsigned int unsigned_int
; 
 257 typedef unsigned long unsigned_long
; 
 259 wxBuiltInTypeInfo 
s_typeInfovoid( wxT_VOID 
, NULL 
, NULL 
, typeid(void).name()); 
 260 wxBUILTIN_TYPE_INFO( wxT_BOOL 
,  bool); 
 261 wxBUILTIN_TYPE_INFO( wxT_CHAR 
,  char); 
 262 wxBUILTIN_TYPE_INFO( wxT_UCHAR 
, unsigned_char
); 
 263 wxBUILTIN_TYPE_INFO( wxT_INT 
, int); 
 264 wxBUILTIN_TYPE_INFO( wxT_UINT 
, unsigned_int
); 
 265 wxBUILTIN_TYPE_INFO( wxT_LONG 
, long); 
 266 wxBUILTIN_TYPE_INFO( wxT_ULONG 
, unsigned_long
); 
 267 wxBUILTIN_TYPE_INFO( wxT_FLOAT 
, float); 
 268 wxBUILTIN_TYPE_INFO( wxT_DOUBLE 
, double); 
 269 wxBUILTIN_TYPE_INFO( wxT_STRING 
, wxString
); 
 272 // this are compiler induced specialization which are never used anywhere 
 274 wxILLEGAL_TYPE_SPECIALIZATION( char const * ) 
 275 wxILLEGAL_TYPE_SPECIALIZATION( char * ) 
 276 wxILLEGAL_TYPE_SPECIALIZATION( unsigned char * ) 
 277 wxILLEGAL_TYPE_SPECIALIZATION( int * ) 
 278 wxILLEGAL_TYPE_SPECIALIZATION( bool * ) 
 279 wxILLEGAL_TYPE_SPECIALIZATION( long * ) 
 280 wxILLEGAL_TYPE_SPECIALIZATION( wxString 
* ) 
 282 wxCOLLECTION_TYPE_INFO( wxString 
, wxArrayString 
) ; 
 284 template<> void wxCollectionToVariantArray( wxArrayString 
const &theArray
, wxxVariantArray 
&value
) 
 286     wxArrayCollectionToVariantArray( theArray 
, value 
) ; 
 289 wxTypeInfoMap 
*wxTypeInfo::ms_typeTable 
= NULL 
; 
 291 wxTypeInfo 
*wxTypeInfo::FindType(const wxChar 
*typeName
) 
 293     wxTypeInfoMap::iterator iter 
= ms_typeTable
->find(typeName
) ; 
 294     wxASSERT_MSG( iter 
!= ms_typeTable
->end() , wxT("lookup for a non-existent type-info") ) ; 
 295     return (wxTypeInfo 
*)iter
->second
; 
 299 wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind 
, wxClassInfo
* classInfo 
, converterToString_t to 
, converterFromString_t from 
, const char *name
) : 
 300 wxTypeInfo( kind 
, to 
, from 
, name
) 
 301 { wxASSERT_MSG( kind 
== wxT_OBJECT_PTR 
|| kind 
== wxT_OBJECT 
, wxT("Illegal Kind for Enum Type")) ; m_classInfo 
= classInfo 
;} 
 304 wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind 
, wxClassInfo
* classInfo 
, converterToString_t to 
, converterFromString_t from 
, const wxString 
&name
) : 
 305 wxTypeInfo( kind 
, to 
, from 
, name
) 
 306 { wxASSERT_MSG( kind 
== wxT_OBJECT_PTR 
|| kind 
== wxT_OBJECT 
, wxT("Illegal Kind for Enum Type")) ; m_classInfo 
= classInfo 
;} 
 308 wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType 
, wxClassInfo
* eventClass 
, converterToString_t to 
, converterFromString_t from 
) : 
 309 wxTypeInfo ( wxT_DELEGATE 
, to 
, from 
, wxEmptyString 
) 
 310 { m_eventClass 
= eventClass 
; m_eventType 
= eventType 
; m_lastEventType 
= -1 ;} 
 312 wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType 
, int lastEventType 
, wxClassInfo
* eventClass 
, converterToString_t to 
, converterFromString_t from 
) : 
 313 wxTypeInfo ( wxT_DELEGATE 
, to 
, from 
, wxEmptyString 
) 
 314 { m_eventClass 
= eventClass 
; m_eventType 
= eventType 
; m_lastEventType 
= lastEventType
; } 
 316 void wxTypeInfo::Register() 
 318     if ( ms_typeTable 
== NULL 
) 
 319         ms_typeTable 
= new wxTypeInfoMap() ; 
 321     if( !m_name
.empty() ) 
 322         (*ms_typeTable
)[m_name
] = this ; 
 325 void wxTypeInfo::Unregister() 
 327     if( !m_name
.empty() ) 
 328         ms_typeTable
->erase(m_name
); 
 331 // removing header dependancy on string tokenizer 
 333 void wxSetStringToArray( const wxString 
&s 
, wxArrayString 
&array 
) 
 335     wxStringTokenizer 
tokenizer(s
, wxT("| \t\n"), wxTOKEN_STRTOK
); 
 338     while (tokenizer
.HasMoreTokens()) 
 340         array
.Add(tokenizer
.GetNextToken()) ; 
 344 // ---------------------------------------------------------------------------- 
 346 // ---------------------------------------------------------------------------- 
 348 wxPropertyInfo::~wxPropertyInfo() 
 350     if ( this == m_itsClass
->m_firstProperty 
) 
 352         m_itsClass
->m_firstProperty 
= m_next
; 
 356         wxPropertyInfo 
*info 
= m_itsClass
->m_firstProperty
; 
 359             if ( info
->m_next 
== this ) 
 361                 info
->m_next 
= m_next
; 
 370 wxHandlerInfo::~wxHandlerInfo() 
 372     if ( this == m_itsClass
->m_firstHandler 
) 
 374         m_itsClass
->m_firstHandler 
= m_next
; 
 378         wxHandlerInfo 
*info 
= m_itsClass
->m_firstHandler
; 
 381             if ( info
->m_next 
== this ) 
 383                 info
->m_next 
= m_next
; 
 392 const wxPropertyAccessor 
*wxClassInfo::FindAccessor(const wxChar 
*PropertyName
) const 
 394     const wxPropertyInfo
* info 
= FindPropertyInfo( PropertyName 
) ; 
 397         return info
->GetAccessor() ; 
 402 wxPropertyInfo 
*wxClassInfo::FindPropertyInfoInThisClass (const wxChar 
*PropertyName
) const 
 404     wxPropertyInfo
* info 
= m_firstProperty 
; 
 408         if ( wxStrcmp( info
->GetName() , PropertyName 
) == 0 ) 
 410         info 
= info
->GetNext() ; 
 416 const wxPropertyInfo 
*wxClassInfo::FindPropertyInfo (const wxChar 
*PropertyName
) const 
 418     const wxPropertyInfo
* info 
= FindPropertyInfoInThisClass( PropertyName 
) ; 
 422     const wxClassInfo
** parents 
= GetParents() ; 
 423     for ( int i 
= 0 ; parents
[i
] ; ++ i 
) 
 425         if ( ( info 
= parents
[i
]->FindPropertyInfo( PropertyName 
) ) != NULL 
) 
 432 wxHandlerInfo 
*wxClassInfo::FindHandlerInfoInThisClass (const wxChar 
*PropertyName
) const 
 434     wxHandlerInfo
* info 
= m_firstHandler 
; 
 438         if ( wxStrcmp( info
->GetName() , PropertyName 
) == 0 ) 
 440         info 
= info
->GetNext() ; 
 446 const wxHandlerInfo 
*wxClassInfo::FindHandlerInfo (const wxChar 
*PropertyName
) const 
 448     const wxHandlerInfo
* info 
= FindHandlerInfoInThisClass( PropertyName 
) ; 
 453     const wxClassInfo
** parents 
= GetParents() ; 
 454     for ( int i 
= 0 ; parents
[i
] ; ++ i 
) 
 456         if ( ( info 
= parents
[i
]->FindHandlerInfo( PropertyName 
) ) != NULL 
) 
 463 wxObjectStreamingCallback 
wxClassInfo::GetStreamingCallback() const 
 465     if ( m_streamingCallback 
) 
 466         return m_streamingCallback 
; 
 468     wxObjectStreamingCallback retval 
= NULL 
; 
 469     const wxClassInfo
** parents 
= GetParents() ; 
 470     for ( int i 
= 0 ; parents
[i
] && retval 
== NULL 
; ++ i 
) 
 472         retval 
= parents
[i
]->GetStreamingCallback() ; 
 477 bool wxClassInfo::BeforeWriteObject( const wxObject 
*obj
, wxWriter 
*streamer 
, wxPersister 
*persister 
, wxxVariantArray 
&metadata
) const 
 479     wxObjectStreamingCallback sb 
= GetStreamingCallback() ; 
 481         return (*sb
)(obj 
, streamer 
, persister 
, metadata 
) ; 
 486 void wxClassInfo::SetProperty(wxObject 
*object
, const wxChar 
*propertyName
, const wxxVariant 
&value
) const 
 488     const wxPropertyAccessor 
*accessor
; 
 490     accessor 
= FindAccessor(propertyName
); 
 491     wxASSERT(accessor
->HasSetter()); 
 492     accessor
->SetProperty( object 
, value 
) ; 
 495 wxxVariant 
wxClassInfo::GetProperty(wxObject 
*object
, const wxChar 
*propertyName
) const 
 497     const wxPropertyAccessor 
*accessor
; 
 499     accessor 
= FindAccessor(propertyName
); 
 500     wxASSERT(accessor
->HasGetter()); 
 502     accessor
->GetProperty(object
,result
); 
 506 wxxVariantArray 
wxClassInfo::GetPropertyCollection(wxObject 
*object
, const wxChar 
*propertyName
) const 
 508     const wxPropertyAccessor 
*accessor
; 
 510     accessor 
= FindAccessor(propertyName
); 
 511     wxASSERT(accessor
->HasGetter()); 
 512     wxxVariantArray result 
; 
 513     accessor
->GetPropertyCollection(object
,result
); 
 517 void wxClassInfo::AddToPropertyCollection(wxObject 
*object
, const wxChar 
*propertyName 
, const wxxVariant
& value
) const 
 519     const wxPropertyAccessor 
*accessor
; 
 521     accessor 
= FindAccessor(propertyName
); 
 522     wxASSERT(accessor
->HasAdder()); 
 523     accessor
->AddToPropertyCollection( object 
, value 
) ; 
 526 // void wxClassInfo::GetProperties( wxPropertyInfoMap &map ) const 
 527 // The map parameter (the name map that is) seems something special 
 528 // to MSVC and so we use a other name. 
 529 void wxClassInfo::GetProperties( wxPropertyInfoMap 
&infomap 
) const 
 531     const wxPropertyInfo 
*pi 
= GetFirstProperty() ; 
 534         if ( infomap
.find( pi
->GetName() ) == infomap
.end() ) 
 535             infomap
[pi
->GetName()] = (wxPropertyInfo
*) pi 
; 
 540     const wxClassInfo
** parents 
= GetParents() ; 
 541     for ( int i 
= 0 ; parents
[i
] ; ++ i 
) 
 543         parents
[i
]->GetProperties( infomap 
) ; 
 551 wxObject
* wxxVariant::GetAsObject() 
 553     const wxClassTypeInfo 
*ti 
= dynamic_cast<const wxClassTypeInfo
*>( m_data
->GetTypeInfo() ) ; 
 555         return ti
->GetClassInfo()->VariantToInstance(*this) ; 
 560 // ---------------------------------------------------------------------------- 
 561 // wxDynamicObject support 
 562 // ---------------------------------------------------------------------------- 
 564 // Dynamic Objects are objects that have a real superclass instance and carry their 
 565 // own attributes in a hash map. Like this it is possible to create the objects and 
 566 // stream them, as if their class information was already available from compiled data 
 568 struct wxDynamicObject::wxDynamicObjectInternal
 
 570     wxDynamicObjectInternal() {} 
 573     map
<wstring
,wxxVariant
> m_properties 
; 
 575     map
<string
,wxxVariant
> m_properties 
; 
 579 typedef list
< wxDynamicObject
* > wxDynamicObjectList 
; 
 581 struct wxDynamicClassInfo::wxDynamicClassInfoInternal
 
 583     wxDynamicObjectList m_dynamicObjects 
; 
 586 // instantiates this object with an instance of its superclass 
 587 wxDynamicObject::wxDynamicObject(wxObject
* superClassInstance
, const wxDynamicClassInfo 
*info
) 
 589     m_superClassInstance 
= superClassInstance 
; 
 591     m_data 
= new wxDynamicObjectInternal 
; 
 594 wxDynamicObject::~wxDynamicObject() 
 596     dynamic_cast<const wxDynamicClassInfo
*>(m_classInfo
)->m_data
->m_dynamicObjects
.remove( this ) ; 
 598     delete m_superClassInstance 
; 
 601 void wxDynamicObject::SetProperty (const wxChar 
*propertyName
, const wxxVariant 
&value
) 
 603     wxASSERT_MSG(m_classInfo
->FindPropertyInfoInThisClass(propertyName
),wxT("Accessing Unknown Property in a Dynamic Object") ) ; 
 604     m_data
->m_properties
[propertyName
] = value 
; 
 607 wxxVariant 
wxDynamicObject::GetProperty (const wxChar 
*propertyName
) const 
 609     wxASSERT_MSG(m_classInfo
->FindPropertyInfoInThisClass(propertyName
),wxT("Accessing Unknown Property in a Dynamic Object") ) ; 
 610     return m_data
->m_properties
[propertyName
] ; 
 613 void wxDynamicObject::RemoveProperty( const wxChar 
*propertyName 
) 
 615     wxASSERT_MSG(m_classInfo
->FindPropertyInfoInThisClass(propertyName
),wxT("Removing Unknown Property in a Dynamic Object") ) ; 
 616     m_data
->m_properties
.erase( propertyName 
) ; 
 619 void wxDynamicObject::RenameProperty( const wxChar 
*oldPropertyName 
, const wxChar 
*newPropertyName 
) 
 621     wxASSERT_MSG(m_classInfo
->FindPropertyInfoInThisClass(oldPropertyName
),wxT("Renaming Unknown Property in a Dynamic Object") ) ; 
 622     wxxVariant value 
= m_data
->m_properties
[oldPropertyName
] ; 
 623     m_data
->m_properties
.erase( oldPropertyName 
) ; 
 624     m_data
->m_properties
[newPropertyName
] = value 
; 
 628 // ---------------------------------------------------------------------------- 
 630 // ---------------------------------------------------------------------------- 
 632 wxDynamicClassInfo::wxDynamicClassInfo( const wxChar 
*unitName
, const wxChar 
*className 
, const wxClassInfo
* superClass 
) : 
 633 wxClassInfo( unitName
, className 
, new const wxClassInfo
*[2]) 
 635     GetParents()[0] = superClass 
; 
 636     GetParents()[1] = NULL 
; 
 637     m_data 
= new wxDynamicClassInfoInternal 
; 
 640 wxDynamicClassInfo::~wxDynamicClassInfo() 
 642     delete[] GetParents() ; 
 646 wxObject 
*wxDynamicClassInfo::AllocateObject() const 
 648     wxObject
* parent 
= GetParents()[0]->AllocateObject() ; 
 649     wxDynamicObject 
*obj 
= new wxDynamicObject( parent 
, this ) ; 
 650     m_data
->m_dynamicObjects
.push_back( obj 
) ; 
 654 void wxDynamicClassInfo::Create (wxObject 
*object
, int paramCount
, wxxVariant 
*params
) const 
 656     wxDynamicObject 
*dynobj 
= dynamic_cast< wxDynamicObject 
*>( object 
) ; 
 657     wxASSERT_MSG( dynobj 
, wxT("cannot call wxDynamicClassInfo::Create on an object other than wxDynamicObject") ) ; 
 658     GetParents()[0]->Create( dynobj
->GetSuperClassInstance() , paramCount 
, params 
) ; 
 661 // get number of parameters for constructor 
 662 int wxDynamicClassInfo::GetCreateParamCount() const 
 664     return GetParents()[0]->GetCreateParamCount() ; 
 667 // get i-th constructor parameter 
 668 const wxChar
* wxDynamicClassInfo::GetCreateParamName(int i
) const 
 670     return GetParents()[0]->GetCreateParamName( i 
) ; 
 673 void wxDynamicClassInfo::SetProperty(wxObject 
*object
, const wxChar 
*propertyName
, const wxxVariant 
&value
) const 
 675     wxDynamicObject
* dynobj 
= dynamic_cast< wxDynamicObject 
* >( object 
) ; 
 676     wxASSERT_MSG( dynobj 
, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ; 
 677     if ( FindPropertyInfoInThisClass(propertyName
) ) 
 678         dynobj
->SetProperty( propertyName 
, value 
) ; 
 680         GetParents()[0]->SetProperty( dynobj
->GetSuperClassInstance() , propertyName 
, value 
) ; 
 683 wxxVariant 
wxDynamicClassInfo::GetProperty(wxObject 
*object
, const wxChar 
*propertyName
) const 
 685     wxDynamicObject
* dynobj 
= dynamic_cast< wxDynamicObject 
* >( object 
) ; 
 686     wxASSERT_MSG( dynobj 
, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ; 
 687     if ( FindPropertyInfoInThisClass(propertyName
) ) 
 688         return dynobj
->GetProperty( propertyName 
) ; 
 690         return GetParents()[0]->GetProperty( dynobj
->GetSuperClassInstance() , propertyName 
) ; 
 693 void wxDynamicClassInfo::AddProperty( const wxChar 
*propertyName 
, const wxTypeInfo
* typeInfo 
) 
 695     new wxPropertyInfo( m_firstProperty 
, this , propertyName 
, typeInfo
->GetTypeName() , new wxGenericPropertyAccessor( propertyName 
) , wxxVariant() ) ; 
 698 void wxDynamicClassInfo::AddHandler( const wxChar 
*handlerName 
, wxObjectEventFunction address 
, const wxClassInfo
* eventClassInfo 
) 
 700     new wxHandlerInfo( m_firstHandler 
, this , handlerName 
, address 
, eventClassInfo 
) ; 
 703 // removes an existing runtime-property 
 704 void wxDynamicClassInfo::RemoveProperty( const wxChar 
*propertyName 
) 
 706     for ( wxDynamicObjectList::iterator iter 
= m_data
->m_dynamicObjects
.begin() ; iter 
!= m_data
->m_dynamicObjects
.end() ; ++iter 
) 
 707         (*iter
)->RemoveProperty( propertyName 
) ; 
 708     delete FindPropertyInfoInThisClass(propertyName
) ; 
 711 // removes an existing runtime-handler 
 712 void wxDynamicClassInfo::RemoveHandler( const wxChar 
*handlerName 
) 
 714     delete FindHandlerInfoInThisClass(handlerName
) ; 
 717 // renames an existing runtime-property 
 718 void wxDynamicClassInfo::RenameProperty( const wxChar 
*oldPropertyName 
, const wxChar 
*newPropertyName 
) 
 720     wxPropertyInfo
* pi 
= FindPropertyInfoInThisClass(oldPropertyName
) ; 
 721     wxASSERT_MSG( pi 
,wxT("not existing property") ) ; 
 722     pi
->m_name 
= newPropertyName 
; 
 723     dynamic_cast<wxGenericPropertyAccessor
*>(pi
->GetAccessor())->RenameProperty( oldPropertyName 
, newPropertyName 
) ; 
 724     for ( wxDynamicObjectList::iterator iter 
= m_data
->m_dynamicObjects
.begin() ; iter 
!= m_data
->m_dynamicObjects
.end() ; ++iter 
) 
 725         (*iter
)->RenameProperty( oldPropertyName 
, newPropertyName 
) ; 
 728 // renames an existing runtime-handler 
 729 void wxDynamicClassInfo::RenameHandler( const wxChar 
*oldHandlerName 
, const wxChar 
*newHandlerName 
) 
 731     wxASSERT_MSG(FindHandlerInfoInThisClass(oldHandlerName
),wxT("not existing handler") ) ; 
 732     FindHandlerInfoInThisClass(oldHandlerName
)->m_name 
= newHandlerName 
; 
 735 // ---------------------------------------------------------------------------- 
 736 // wxGenericPropertyAccessor 
 737 // ---------------------------------------------------------------------------- 
 739 struct wxGenericPropertyAccessor::wxGenericPropertyAccessorInternal
 
 744 wxGenericPropertyAccessor::wxGenericPropertyAccessor( const wxString
& propertyName 
) 
 745 : wxPropertyAccessor( NULL 
, NULL 
, NULL 
, NULL 
) 
 747     m_data 
= new wxGenericPropertyAccessorInternal 
; 
 748     m_propertyName 
= propertyName 
; 
 749     m_getterName 
= wxT("Get")+propertyName 
; 
 750     m_setterName 
= wxT("Set")+propertyName 
; 
 753 wxGenericPropertyAccessor::~wxGenericPropertyAccessor() 
 757 void wxGenericPropertyAccessor::SetProperty(wxObject 
*object
, const wxxVariant 
&value
) const 
 759     wxDynamicObject
* dynobj 
= dynamic_cast< wxDynamicObject 
* >( object 
) ; 
 760     wxASSERT_MSG( dynobj 
, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ; 
 761     dynobj
->SetProperty(m_propertyName 
, value 
) ; 
 764 void wxGenericPropertyAccessor::GetProperty(const wxObject 
*object
, wxxVariant
& value
) const 
 766     const wxDynamicObject
* dynobj 
= dynamic_cast< const wxDynamicObject 
* >( object 
) ; 
 767     wxASSERT_MSG( dynobj 
, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ; 
 768     value 
= dynobj
->GetProperty( m_propertyName 
) ;