]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/xti.cpp
naming changes
[wxWidgets.git] / src / common / xti.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/xti.cpp
3// Purpose: runtime metadata information (extended class info
4// Author: Stefan Csomor
5// Modified by:
6// Created: 27/07/03
7// RCS-ID: $Id$
8// Copyright: (c) 1997 Julian Smart
9// (c) 2003 Stefan Csomor
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
14#pragma implementation "xti.h"
15#endif
16
17// For compilers that support precompilation, includes "wx.h".
18#include "wx/wxprec.h"
19
20#ifdef __BORLANDC__
21#pragma hdrstop
22#endif
23
24#ifndef WX_PRECOMP
25#include "wx/hash.h"
26#include "wx/object.h"
27#endif
28
29#if wxUSE_EXTENDED_RTTI
30
31#include "wx/xti.h"
32#include "wx/xml/xml.h"
33#include "wx/tokenzr.h"
34#include "wx/list.h"
35#include <string.h>
36
37#include "wx/beforestd.h"
38#include <map>
39#include <string>
40#include "wx/afterstd.h"
41
42using namespace std ;
43
44// ----------------------------------------------------------------------------
45// Enum Support
46// ----------------------------------------------------------------------------
47
48wxEnumData::wxEnumData( wxEnumMemberData* data )
49{
50 m_members = data ;
51 for ( m_count = 0; m_members[m_count].m_name ; m_count++)
52 {} ;
53}
54
55bool wxEnumData::HasEnumMemberValue(const wxChar *name, int *value) const
56{
57 int i;
58 for (i = 0; m_members[i].m_name ; i++ )
59 {
60 if (!wxStrcmp(name, m_members[i].m_name))
61 {
62 if ( value )
63 *value = m_members[i].m_value;
64 return true ;
65 }
66 }
67 return false ;
68}
69
70int wxEnumData::GetEnumMemberValue(const wxChar *name) const
71{
72 int i;
73 for (i = 0; m_members[i].m_name ; i++ )
74 {
75 if (!wxStrcmp(name, m_members[i].m_name))
76 {
77 return m_members[i].m_value;
78 }
79 }
80 return 0 ;
81}
82
83const wxChar *wxEnumData::GetEnumMemberName(int value) const
84{
85 int i;
86 for (i = 0; m_members[i].m_name ; i++)
87 if (value == m_members[i].m_value)
88 return m_members[i].m_name;
89
90 return wxT("") ;
91}
92
93int wxEnumData::GetEnumMemberValueByIndex( int idx ) const
94{
95 // we should cache the count in order to avoid out-of-bounds errors
96 return m_members[idx].m_value ;
97}
98
99const wxChar * wxEnumData::GetEnumMemberNameByIndex( int idx ) const
100{
101 // we should cache the count in order to avoid out-of-bounds errors
102 return m_members[idx].m_name ;
103}
104
105// ----------------------------------------------------------------------------
106// Type Information
107// ----------------------------------------------------------------------------
108// ----------------------------------------------------------------------------
109// value streaming
110// ----------------------------------------------------------------------------
111
112// streamer specializations
113// for all built-in types
114
115// bool
116
117template<> void wxStringReadValue(const wxString &s , bool &data )
118{
119 int intdata ;
120 wxSscanf(s, _T("%d"), &intdata ) ;
121 data = (bool)intdata ;
122}
123
124template<> void wxStringWriteValue(wxString &s , const bool &data )
125{
126 s = wxString::Format(_T("%d"), data ) ;
127}
128
129// char
130
131template<> void wxStringReadValue(const wxString &s , char &data )
132{
133 int intdata ;
134 wxSscanf(s, _T("%d"), &intdata ) ;
135 data = char(intdata) ;
136}
137
138template<> void wxStringWriteValue(wxString &s , const char &data )
139{
140 s = wxString::Format(_T("%d"), data ) ;
141}
142
143// unsigned char
144
145template<> void wxStringReadValue(const wxString &s , unsigned char &data )
146{
147 int intdata ;
148 wxSscanf(s, _T("%d"), &intdata ) ;
149 data = (unsigned char)(intdata) ;
150}
151
152template<> void wxStringWriteValue(wxString &s , const unsigned char &data )
153{
154 s = wxString::Format(_T("%d"), data ) ;
155}
156
157// int
158
159template<> void wxStringReadValue(const wxString &s , int &data )
160{
161 wxSscanf(s, _T("%d"), &data ) ;
162}
163
164template<> void wxStringWriteValue(wxString &s , const int &data )
165{
166 s = wxString::Format(_T("%d"), data ) ;
167}
168
169// unsigned int
170
171template<> void wxStringReadValue(const wxString &s , unsigned int &data )
172{
173 wxSscanf(s, _T("%d"), &data ) ;
174}
175
176template<> void wxStringWriteValue(wxString &s , const unsigned int &data )
177{
178 s = wxString::Format(_T("%d"), data ) ;
179}
180
181// long
182
183template<> void wxStringReadValue(const wxString &s , long &data )
184{
185 wxSscanf(s, _T("%ld"), &data ) ;
186}
187
188template<> void wxStringWriteValue(wxString &s , const long &data )
189{
190 s = wxString::Format(_T("%ld"), data ) ;
191}
192
193// unsigned long
194
195template<> void wxStringReadValue(const wxString &s , unsigned long &data )
196{
197 wxSscanf(s, _T("%ld"), &data ) ;
198}
199
200template<> void wxStringWriteValue(wxString &s , const unsigned long &data )
201{
202 s = wxString::Format(_T("%ld"), data ) ;
203}
204
205// float
206
207template<> void wxStringReadValue(const wxString &s , float &data )
208{
209 wxSscanf(s, _T("%f"), &data ) ;
210}
211
212template<> void wxStringWriteValue(wxString &s , const float &data )
213{
214 s = wxString::Format(_T("%f"), data ) ;
215}
216
217// double
218
219template<> void wxStringReadValue(const wxString &s , double &data )
220{
221 wxSscanf(s, _T("%lf"), &data ) ;
222}
223
224template<> void wxStringWriteValue(wxString &s , const double &data )
225{
226 s = wxString::Format(_T("%lf"), data ) ;
227}
228
229// wxString
230
231template<> void wxStringReadValue(const wxString &s , wxString &data )
232{
233 data = s ;
234}
235
236template<> void wxStringWriteValue(wxString &s , const wxString &data )
237{
238 s = data ;
239}
240
241// built-ins
242//
243
244wxBuiltInTypeInfo s_typeInfovoid( wxT_VOID , NULL , NULL , typeid(void).name() ) ;
245wxBuiltInTypeInfo s_typeInfobool( wxT_BOOL , &wxToStringConverter<bool> , &wxFromStringConverter<bool>, typeid(bool).name()) ;
246wxBuiltInTypeInfo s_typeInfochar( wxT_CHAR , &wxToStringConverter<char> , &wxFromStringConverter<char>, typeid(char).name()) ;
247wxBuiltInTypeInfo s_typeInfounsignedchar( wxT_UCHAR , &wxToStringConverter< unsigned char > , &wxFromStringConverter<unsigned char>, typeid(unsigned char).name()) ;
248wxBuiltInTypeInfo s_typeInfoint( wxT_INT , &wxToStringConverter<int> , &wxFromStringConverter<int>, typeid(int).name()) ;
249wxBuiltInTypeInfo s_typeInfounsignedint( wxT_UINT , &wxToStringConverter<unsigned int> , &wxFromStringConverter<unsigned int>, typeid(unsigned int).name()) ;
250wxBuiltInTypeInfo s_typeInfolong( wxT_LONG , &wxToStringConverter<long> , &wxFromStringConverter<long>, typeid(long).name()) ;
251wxBuiltInTypeInfo s_typeInfounsignedlong( wxT_ULONG , &wxToStringConverter<unsigned long> , &wxFromStringConverter<unsigned long>, typeid(unsigned long).name()) ;
252wxBuiltInTypeInfo s_typeInfofloat( wxT_FLOAT , &wxToStringConverter<float> , &wxFromStringConverter<float>, typeid(float).name()) ;
253wxBuiltInTypeInfo s_typeInfodouble( wxT_DOUBLE , &wxToStringConverter<double> , &wxFromStringConverter<double>, typeid(double).name()) ;
254wxBuiltInTypeInfo s_typeInfowxString( wxT_STRING , &wxToStringConverter<wxString> , &wxFromStringConverter<wxString>, typeid(wxString).name()) ;
255
256// this are compiler induced specialization which are never used anywhere
257
258WX_ILLEGAL_TYPE_SPECIALIZATION( char const * )
259WX_ILLEGAL_TYPE_SPECIALIZATION( char * )
260WX_ILLEGAL_TYPE_SPECIALIZATION( unsigned char * )
261WX_ILLEGAL_TYPE_SPECIALIZATION( int * )
262WX_ILLEGAL_TYPE_SPECIALIZATION( bool * )
263WX_ILLEGAL_TYPE_SPECIALIZATION( long * )
264WX_ILLEGAL_TYPE_SPECIALIZATION( wxString * )
265
266WX_COLLECTION_TYPE_INFO( wxString , wxArrayString ) ;
267
268template<> void wxCollectionToVariantArray( wxArrayString const &theArray, wxxVariantArray &value)
269{
270 wxArrayCollectionToVariantArray( theArray , value ) ;
271}
272
273wxTypeInfoMap *wxTypeInfo::sm_typeTable = NULL ;
274
275wxTypeInfo *wxTypeInfo::FindType(const wxChar *typeName)
276{
277 wxTypeInfoMap::iterator iter = sm_typeTable->find(typeName) ;
278 wxASSERT_MSG( iter != sm_typeTable->end() , wxT("lookup for a non-existent type-info") ) ;
279 return (wxTypeInfo *)iter->second;
280}
281
282#if wxUSE_UNICODE
283wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const char *name) :
284wxTypeInfo( kind , to , from , name)
285{ wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;}
286#endif
287
288wxClassTypeInfo::wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to , converterFromString_t from , const wxString &name) :
289wxTypeInfo( kind , to , from , name)
290{ wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_classInfo = classInfo ;}
291
292wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) :
293wxTypeInfo ( wxT_DELEGATE , to , from , wxEmptyString )
294{ m_eventClass = eventClass ; m_eventType = eventType ; m_lastEventType = -1 ;}
295
296wxDelegateTypeInfo::wxDelegateTypeInfo( int eventType , int lastEventType , wxClassInfo* eventClass , converterToString_t to , converterFromString_t from ) :
297wxTypeInfo ( wxT_DELEGATE , to , from , wxEmptyString )
298{ m_eventClass = eventClass ; m_eventType = eventType ; m_lastEventType = lastEventType; }
299
300void wxTypeInfo::Register()
301{
302 if ( sm_typeTable == NULL )
303 sm_typeTable = new wxTypeInfoMap() ;
304
305 if( !m_name.IsEmpty() )
306 (*sm_typeTable)[m_name] = this ;
307}
308
309void wxTypeInfo::Unregister()
310{
311 if( !m_name.IsEmpty() )
312 sm_typeTable->erase(m_name);
313}
314
315// removing header dependancy on string tokenizer
316
317void wxSetStringToArray( const wxString &s , wxArrayString &array )
318{
319 wxStringTokenizer tokenizer(s, wxT("| \t\n"), wxTOKEN_STRTOK);
320 wxString flag;
321 array.Clear() ;
322 while (tokenizer.HasMoreTokens())
323 {
324 array.Add(tokenizer.GetNextToken()) ;
325 }
326}
327
328// ----------------------------------------------------------------------------
329// wxClassInfo
330// ----------------------------------------------------------------------------
331
332wxPropertyInfo::~wxPropertyInfo()
333{
334 if ( this == m_itsClass->m_firstProperty )
335 {
336 m_itsClass->m_firstProperty = m_next;
337 }
338 else
339 {
340 wxPropertyInfo *info = m_itsClass->m_firstProperty;
341 while (info)
342 {
343 if ( info->m_next == this )
344 {
345 info->m_next = m_next;
346 break;
347 }
348
349 info = info->m_next;
350 }
351 }
352}
353
354wxHandlerInfo::~wxHandlerInfo()
355{
356 if ( this == m_itsClass->m_firstHandler )
357 {
358 m_itsClass->m_firstHandler = m_next;
359 }
360 else
361 {
362 wxHandlerInfo *info = m_itsClass->m_firstHandler;
363 while (info)
364 {
365 if ( info->m_next == this )
366 {
367 info->m_next = m_next;
368 break;
369 }
370
371 info = info->m_next;
372 }
373 }
374}
375
376const wxPropertyAccessor *wxClassInfo::FindAccessor(const wxChar *PropertyName) const
377{
378 const wxPropertyInfo* info = FindPropertyInfo( PropertyName ) ;
379
380 if ( info )
381 return info->GetAccessor() ;
382
383 return NULL ;
384}
385
386wxPropertyInfo *wxClassInfo::FindPropertyInfoInThisClass (const wxChar *PropertyName) const
387{
388 wxPropertyInfo* info = m_firstProperty ;
389
390 while( info )
391 {
392 if ( wxStrcmp( info->GetName() , PropertyName ) == 0 )
393 return info ;
394 info = info->GetNext() ;
395 }
396
397 return 0;
398}
399
400const wxPropertyInfo *wxClassInfo::FindPropertyInfo (const wxChar *PropertyName) const
401{
402 const wxPropertyInfo* info = FindPropertyInfoInThisClass( PropertyName ) ;
403 if ( info )
404 return info ;
405
406 const wxClassInfo** parents = GetParents() ;
407 for ( int i = 0 ; parents[i] ; ++ i )
408 {
409 if ( ( info = parents[i]->FindPropertyInfo( PropertyName ) ) != NULL )
410 return info ;
411 }
412
413 return 0;
414}
415
416wxHandlerInfo *wxClassInfo::FindHandlerInfoInThisClass (const wxChar *PropertyName) const
417{
418 wxHandlerInfo* info = m_firstHandler ;
419
420 while( info )
421 {
422 if ( wxStrcmp( info->GetName() , PropertyName ) == 0 )
423 return info ;
424 info = info->GetNext() ;
425 }
426
427 return 0;
428}
429
430const wxHandlerInfo *wxClassInfo::FindHandlerInfo (const wxChar *PropertyName) const
431{
432 const wxHandlerInfo* info = FindHandlerInfoInThisClass( PropertyName ) ;
433
434 if ( info )
435 return info ;
436
437 const wxClassInfo** parents = GetParents() ;
438 for ( int i = 0 ; parents[i] ; ++ i )
439 {
440 if ( ( info = parents[i]->FindHandlerInfo( PropertyName ) ) != NULL )
441 return info ;
442 }
443
444 return 0;
445}
446
447wxObjectStreamingCallback wxClassInfo::GetStreamingCallback() const
448{
449 if ( m_streamingCallback )
450 return m_streamingCallback ;
451
452 wxObjectStreamingCallback retval = NULL ;
453 const wxClassInfo** parents = GetParents() ;
454 for ( int i = 0 ; parents[i] && retval == NULL ; ++ i )
455 {
456 retval = parents[i]->GetStreamingCallback() ;
457 }
458 return retval ;
459}
460
461bool wxClassInfo::BeforeWriteObject( const wxObject *obj, wxWriter *streamer , wxPersister *persister , wxxVariantArray &metadata) const
462{
463 wxObjectStreamingCallback sb = GetStreamingCallback() ;
464 if ( sb )
465 return (*sb)(obj , streamer , persister , metadata ) ;
466
467 return true ;
468}
469
470void wxClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxxVariant &value) const
471{
472 const wxPropertyAccessor *accessor;
473
474 accessor = FindAccessor(propertyName);
475 wxASSERT(accessor->HasSetter());
476 accessor->SetProperty( object , value ) ;
477}
478
479wxxVariant wxClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
480{
481 const wxPropertyAccessor *accessor;
482
483 accessor = FindAccessor(propertyName);
484 wxASSERT(accessor->HasGetter());
485 wxxVariant result ;
486 accessor->GetProperty(object,result);
487 return result ;
488}
489
490wxxVariantArray wxClassInfo::GetPropertyCollection(wxObject *object, const wxChar *propertyName) const
491{
492 const wxPropertyAccessor *accessor;
493
494 accessor = FindAccessor(propertyName);
495 wxASSERT(accessor->HasGetter());
496 wxxVariantArray result ;
497 accessor->GetPropertyCollection(object,result);
498 return result ;
499}
500
501void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const
502{
503 const wxPropertyAccessor *accessor;
504
505 accessor = FindAccessor(propertyName);
506 wxASSERT(accessor->HasAdder());
507 accessor->AddToPropertyCollection( object , value ) ;
508}
509
510void wxClassInfo::GetProperties( wxPropertyInfoMap &map ) const
511{
512 const wxPropertyInfo *pi = GetFirstProperty() ;
513 while( pi )
514 {
515 if ( map.find( pi->GetName() ) == map.end() )
516 map[pi->GetName()] = (wxPropertyInfo*) pi ;
517
518 pi = pi->GetNext() ;
519 }
520
521 const wxClassInfo** parents = GetParents() ;
522 for ( int i = 0 ; parents[i] ; ++ i )
523 {
524 parents[i]->GetProperties( map ) ;
525 }
526}
527
528/*
529VARIANT TO OBJECT
530*/
531
532wxObject* wxxVariant::GetAsObject()
533{
534 const wxClassTypeInfo *ti = dynamic_cast<const wxClassTypeInfo*>( m_data->GetTypeInfo() ) ;
535 if ( ti )
536 return ti->GetClassInfo()->VariantToInstance(*this) ;
537 else
538 return NULL ;
539}
540
541// ----------------------------------------------------------------------------
542// wxDynamicObject support
543// ----------------------------------------------------------------------------
544//
545// Dynamic Objects are objects that have a real superclass instance and carry their
546// own attributes in a hash map. Like this it is possible to create the objects and
547// stream them, as if their class information was already available from compiled data
548
549struct wxDynamicObject::wxDynamicObjectInternal
550{
551#if wxUSE_UNICODE
552 map<wstring,wxxVariant> m_properties ;
553#else
554 map<string,wxxVariant> m_properties ;
555#endif
556} ;
557
558// instantiates this object with an instance of its superclass
559wxDynamicObject::wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info)
560{
561 m_superClassInstance = superClassInstance ;
562 m_classInfo = info ;
563 m_data = new wxDynamicObjectInternal ;
564}
565
566wxDynamicObject::~wxDynamicObject()
567{
568 delete m_data ;
569 delete m_superClassInstance ;
570}
571
572void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxxVariant &value)
573{
574 wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
575 m_data->m_properties[propertyName] = value ;
576}
577
578wxxVariant wxDynamicObject::GetProperty (const wxChar *propertyName) const
579{
580 wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),wxT("Accessing Unknown Property in a Dynamic Object") ) ;
581 return m_data->m_properties[propertyName] ;
582}
583
584// ----------------------------------------------------------------------------
585// wxDynamiClassInfo
586// ----------------------------------------------------------------------------
587
588wxDynamicClassInfo::wxDynamicClassInfo( const wxChar *unitName, const wxChar *className , const wxClassInfo* superClass ) :
589wxClassInfo( unitName, className , new const wxClassInfo*[2])
590{
591 GetParents()[0] = superClass ;
592 GetParents()[1] = NULL ;
593}
594
595wxDynamicClassInfo::~wxDynamicClassInfo()
596{
597 delete[] GetParents() ;
598}
599
600wxObject *wxDynamicClassInfo::AllocateObject() const
601{
602 wxObject* parent = GetParents()[0]->AllocateObject() ;
603 return new wxDynamicObject( parent , this ) ;
604}
605
606void wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxxVariant *params) const
607{
608 wxDynamicObject *dynobj = dynamic_cast< wxDynamicObject *>( object ) ;
609 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::Create on an object other than wxDynamicObject") ) ;
610 GetParents()[0]->Create( dynobj->GetSuperClassInstance() , paramCount , params ) ;
611}
612
613// get number of parameters for constructor
614int wxDynamicClassInfo::GetCreateParamCount() const
615{
616 return GetParents()[0]->GetCreateParamCount() ;
617}
618
619// get i-th constructor parameter
620const wxChar* wxDynamicClassInfo::GetCreateParamName(int i) const
621{
622 return GetParents()[0]->GetCreateParamName( i ) ;
623}
624
625void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxxVariant &value) const
626{
627 wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
628 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ;
629 if ( FindPropertyInfoInThisClass(propertyName) )
630 dynobj->SetProperty( propertyName , value ) ;
631 else
632 GetParents()[0]->SetProperty( dynobj->GetSuperClassInstance() , propertyName , value ) ;
633}
634
635wxxVariant wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
636{
637 wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
638 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ;
639 if ( FindPropertyInfoInThisClass(propertyName) )
640 return dynobj->GetProperty( propertyName ) ;
641 else
642 return GetParents()[0]->GetProperty( dynobj->GetSuperClassInstance() , propertyName ) ;
643}
644
645void wxDynamicClassInfo::AddProperty( const wxChar *propertyName , const wxTypeInfo* typeInfo )
646{
647 new wxPropertyInfo( m_firstProperty , this , propertyName , typeInfo->GetTypeName() , new wxGenericPropertyAccessor( propertyName ) , wxxVariant() ) ;
648}
649
650void wxDynamicClassInfo::AddHandler( const wxChar *handlerName , wxObjectEventFunction address , const wxClassInfo* eventClassInfo )
651{
652 new wxHandlerInfo( m_firstHandler , this , handlerName , address , eventClassInfo ) ;
653}
654
655// removes an existing runtime-property
656void wxDynamicClassInfo::RemoveProperty( const wxChar *propertyName )
657{
658 delete FindPropertyInfoInThisClass(propertyName) ;
659}
660
661// removes an existing runtime-handler
662void wxDynamicClassInfo::RemoveHandler( const wxChar *handlerName )
663{
664 delete FindHandlerInfoInThisClass(handlerName) ;
665}
666
667// renames an existing runtime-property
668void wxDynamicClassInfo::RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName )
669{
670 wxPropertyInfo* pi = FindPropertyInfoInThisClass(oldPropertyName) ;
671 wxASSERT_MSG( pi ,wxT("not existing property") ) ;
672 pi->m_name = newPropertyName ;
673 dynamic_cast<wxGenericPropertyAccessor*>(pi->GetAccessor())->RenameProperty( oldPropertyName , newPropertyName ) ;
674}
675
676// renames an existing runtime-handler
677void wxDynamicClassInfo::RenameHandler( const wxChar *oldHandlerName , const wxChar *newHandlerName )
678{
679 wxASSERT_MSG(FindHandlerInfoInThisClass(oldHandlerName),wxT("not existing handler") ) ;
680 FindHandlerInfoInThisClass(oldHandlerName)->m_name = newHandlerName ;
681}
682
683// ----------------------------------------------------------------------------
684// wxGenericPropertyAccessor
685// ----------------------------------------------------------------------------
686
687struct wxGenericPropertyAccessor::wxGenericPropertyAccessorInternal
688{
689 char filler ;
690} ;
691
692wxGenericPropertyAccessor::wxGenericPropertyAccessor( const wxString& propertyName )
693: wxPropertyAccessor( NULL , NULL , NULL , NULL )
694{
695 m_data = new wxGenericPropertyAccessorInternal ;
696 m_propertyName = propertyName ;
697 m_getterName = wxT("Get")+propertyName ;
698 m_setterName = wxT("Set")+propertyName ;
699}
700
701wxGenericPropertyAccessor::~wxGenericPropertyAccessor()
702{
703 delete m_data ;
704}
705void wxGenericPropertyAccessor::SetProperty(wxObject *object, const wxxVariant &value) const
706{
707 wxDynamicObject* dynobj = dynamic_cast< wxDynamicObject * >( object ) ;
708 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ;
709 dynobj->SetProperty(m_propertyName , value ) ;
710}
711
712void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxxVariant& value) const
713{
714 const wxDynamicObject* dynobj = dynamic_cast< const wxDynamicObject * >( object ) ;
715 wxASSERT_MSG( dynobj , wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") ) ;
716 value = dynobj->GetProperty( m_propertyName ) ;
717}
718#endif