1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/xtistrm.cpp
3 // Purpose: streaming runtime metadata information
4 // Author: Stefan Csomor
8 // Copyright: (c) 2003 Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "xtistrm.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
25 #include "wx/object.h"
28 #include "wx/tokenzr.h"
29 #include "wx/txtstrm.h"
32 #if wxUSE_EXTENDED_RTTI
34 #include "wx/xtistrm.h"
36 #include "wx/beforestd.h"
40 #include "wx/afterstd.h"
44 struct wxWriter::wxWriterInternal
46 map
< const wxObject
* , int > m_writtenObjects
;
52 m_data
= new wxWriterInternal
;
53 m_data
->m_nextId
= 0 ;
61 struct wxWriter::wxWriterInternalPropertiesData
66 void wxWriter::ClearObjectContext()
69 m_data
= new wxWriterInternal() ;
70 m_data
->m_nextId
= 0 ;
73 void wxWriter::WriteObject(const wxObject
*object
, const wxClassInfo
*classInfo
, wxPersister
*persister
, const wxString
&name
, wxxVariantArray
&metadata
)
75 DoBeginWriteTopLevelEntry( name
) ;
76 WriteObject( object
, classInfo
, persister
, false , metadata
) ;
77 DoEndWriteTopLevelEntry( name
) ;
80 void wxWriter::WriteObject(const wxObject
*object
, const wxClassInfo
*classInfo
, wxPersister
*persister
, bool isEmbedded
, wxxVariantArray
&metadata
)
82 if ( !classInfo
->BeforeWriteObject( object
, this , persister
, metadata
) )
85 if ( persister
->BeforeWriteObject( this , object
, classInfo
, metadata
) )
89 else if ( IsObjectKnown( object
) )
90 DoWriteRepeatedObject( GetObjectID(object
) ) ;
93 int oid
= m_data
->m_nextId
++ ;
95 m_data
->m_writtenObjects
[object
] = oid
;
97 // in case this object is a wxDynamicObject we also have to insert is superclass
98 // instance with the same id, so that object relations are streamed out correctly
99 const wxDynamicObject
* dynobj
= dynamic_cast<const wxDynamicObject
*>( object
) ;
100 if ( !isEmbedded
&& dynobj
)
101 m_data
->m_writtenObjects
[dynobj
->GetSuperClassInstance()] = oid
;
103 DoBeginWriteObject( object
, classInfo
, oid
, metadata
) ;
104 wxWriterInternalPropertiesData data
;
105 WriteAllProperties( object
, classInfo
, persister
, &data
) ;
106 DoEndWriteObject( object
, classInfo
, oid
) ;
108 persister
->AfterWriteObject( this ,object
, classInfo
) ;
112 void wxWriter::FindConnectEntry(const wxEvtHandler
* evSource
,const wxDelegateTypeInfo
* dti
, const wxObject
* &sink
, const wxHandlerInfo
*&handler
)
114 wxList
*dynamicEvents
= evSource
->GetDynamicEventTable() ;
118 wxList::compatibility_iterator node
= dynamicEvents
->GetFirst();
121 wxDynamicEventTableEntry
*entry
= (wxDynamicEventTableEntry
*)node
->GetData();
125 (dti
->GetEventType() == entry
->m_eventType
) &&
126 (entry
->m_id
== -1 ) &&
127 (entry
->m_eventSink
!= NULL
) )
129 sink
= entry
->m_eventSink
;
130 const wxClassInfo
* sinkClassInfo
= sink
->GetClassInfo() ;
131 const wxHandlerInfo
* sinkHandler
= sinkClassInfo
->GetFirstHandler() ;
132 while ( sinkHandler
)
134 if ( sinkHandler
->GetEventFunction() == entry
->m_fn
)
136 handler
= sinkHandler
;
139 sinkHandler
= sinkHandler
->GetNext() ;
143 node
= node
->GetNext();
147 void wxWriter::WriteAllProperties( const wxObject
* obj
, const wxClassInfo
* ci
, wxPersister
*persister
, wxWriterInternalPropertiesData
* data
)
149 wxPropertyInfoMap map
;
150 ci
->GetProperties( map
) ;
151 for ( int i
= 0 ; i
< ci
->GetCreateParamCount() ; ++i
)
153 wxString name
= ci
->GetCreateParamName(i
) ;
154 const wxPropertyInfo
* prop
= map
.find(name
)->second
;
155 wxASSERT_MSG( prop
, wxT("Create Parameter not found in declared RTTI Parameters") ) ;
156 WriteOneProperty( obj
, prop
->GetDeclaringClass() , prop
, persister
, data
) ;
160 for( wxPropertyInfoMap::iterator iter
= map
.begin() ; iter
!= map
.end() ; ++iter
)
162 const wxPropertyInfo
* prop
= iter
->second
;
163 if ( prop
->GetFlags() & wxPROP_OBJECT_GRAPH
)
165 WriteOneProperty( obj
, prop
->GetDeclaringClass() , prop
, persister
, data
) ;
169 for( wxPropertyInfoMap::iterator iter
= map
.begin() ; iter
!= map
.end() ; ++iter
)
171 const wxPropertyInfo
* prop
= iter
->second
;
172 if ( !(prop
->GetFlags() & wxPROP_OBJECT_GRAPH
) )
174 WriteOneProperty( obj
, prop
->GetDeclaringClass() , prop
, persister
, data
) ;
179 void wxWriter::WriteOneProperty( const wxObject
*obj
, const wxClassInfo
* ci
, const wxPropertyInfo
* pi
, wxPersister
*persister
, wxWriterInternalPropertiesData
*WXUNUSED(data
) )
181 if ( pi
->GetFlags() & wxPROP_DONT_STREAM
)
184 // make sure that we are picking the correct object for accessing the property
185 const wxDynamicObject
* dynobj
= dynamic_cast< const wxDynamicObject
* > (obj
) ;
186 if ( dynobj
&& (dynamic_cast<const wxDynamicClassInfo
*>(ci
) == NULL
) )
187 obj
= dynobj
->GetSuperClassInstance() ;
189 if ( pi
->GetTypeInfo()->GetKind() == wxT_COLLECTION
)
191 wxxVariantArray data
;
192 pi
->GetAccessor()->GetPropertyCollection(obj
, data
) ;
193 const wxTypeInfo
* elementType
= dynamic_cast< const wxCollectionTypeInfo
* >( pi
->GetTypeInfo() )->GetElementType() ;
194 for ( size_t i
= 0 ; i
< data
.GetCount() ; ++i
)
197 DoBeginWriteProperty( pi
) ;
199 DoBeginWriteElement() ;
200 wxxVariant value
= data
[i
] ;
201 if ( persister
->BeforeWriteProperty( this , pi
, value
) )
203 const wxClassTypeInfo
* cti
= dynamic_cast< const wxClassTypeInfo
* > ( elementType
) ;
206 const wxClassInfo
* pci
= cti
->GetClassInfo() ;
207 wxObject
*vobj
= pci
->VariantToInstance( value
) ;
209 WriteObject( vobj
, (vobj
? vobj
->GetClassInfo() : pci
) , persister
, cti
->GetKind()== wxT_OBJECT
, md
) ;
213 DoWriteSimpleType( value
) ;
216 DoEndWriteElement() ;
217 if ( i
== data
.GetCount() - 1 )
218 DoEndWriteProperty( pi
) ;
223 const wxDelegateTypeInfo
* dti
= dynamic_cast< const wxDelegateTypeInfo
* > ( pi
->GetTypeInfo() ) ;
226 const wxObject
* sink
= NULL
;
227 const wxHandlerInfo
*handler
= NULL
;
229 const wxEvtHandler
* evSource
= dynamic_cast<const wxEvtHandler
*>(obj
) ;
230 wxASSERT_MSG( evSource
, wxT("Illegal Object Class (Non-wxEvtHandler) as Event Source") ) ;
232 FindConnectEntry( evSource
, dti
, sink
, handler
) ;
233 if ( persister
->BeforeWriteDelegate( this , obj
, ci
, pi
, sink
, handler
) )
235 if ( sink
!= NULL
&& handler
!= NULL
)
237 DoBeginWriteProperty( pi
) ;
238 wxASSERT_MSG( IsObjectKnown( sink
) , wxT("Streaming delegates for not already streamed objects not yet supported") ) ;
239 DoWriteDelegate( obj
, ci
, pi
, sink
, GetObjectID( sink
) , sink
->GetClassInfo() , handler
) ;
240 DoEndWriteProperty( pi
) ;
247 pi
->GetAccessor()->GetProperty(obj
, value
) ;
249 // avoid streaming out void objects
250 if( value
.IsEmpty() )
253 if ( pi
->GetFlags() & wxPROP_ENUM_STORE_LONG
)
255 const wxEnumTypeInfo
*eti
= dynamic_cast<const wxEnumTypeInfo
*>( pi
->GetTypeInfo() ) ;
256 wxASSERT_MSG( eti
, wxT("Type must have enum - long conversion") ) ;
257 eti
->ConvertFromLong( value
.Get
<long>() , value
) ;
260 // avoid streaming out default values
261 if ( pi
->GetTypeInfo()->HasStringConverters() && !pi
->GetDefaultValue().IsEmpty() )
263 if ( value
.GetAsString() == pi
->GetDefaultValue().GetAsString() )
267 // avoid streaming out null objects
268 const wxClassTypeInfo
* cti
= dynamic_cast< const wxClassTypeInfo
* > ( pi
->GetTypeInfo() ) ;
270 if ( cti
&& value
.GetAsObject() == NULL
)
273 if ( persister
->BeforeWriteProperty( this , pi
, value
) )
275 DoBeginWriteProperty( pi
) ;
278 const wxClassInfo
* pci
= cti
->GetClassInfo() ;
279 wxObject
*vobj
= pci
->VariantToInstance( value
) ;
280 if ( vobj
&& pi
->GetTypeInfo()->HasStringConverters() )
282 wxString stringValue
;
283 cti
->ConvertToString( value
, stringValue
) ;
284 wxxVariant
convertedValue(stringValue
) ;
285 DoWriteSimpleType( convertedValue
) ;
290 WriteObject( vobj
, (vobj
? vobj
->GetClassInfo() : pci
) , persister
, cti
->GetKind()== wxT_OBJECT
, md
) ;
295 DoWriteSimpleType( value
) ;
297 DoEndWriteProperty( pi
) ;
303 int wxWriter::GetObjectID(const wxObject
*obj
)
305 if ( !IsObjectKnown( obj
) )
306 return wxInvalidObjectID
;
308 return m_data
->m_writtenObjects
[obj
] ;
311 bool wxWriter::IsObjectKnown( const wxObject
*obj
)
313 return m_data
->m_writtenObjects
.find( obj
) != m_data
->m_writtenObjects
.end() ;
317 // ----------------------------------------------------------------------------
318 // reading objects in
319 // ----------------------------------------------------------------------------
321 struct wxReader::wxReaderInternal
323 map
<int,wxClassInfo
*> m_classInfos
;
328 m_data
= new wxReaderInternal
;
331 wxReader::~wxReader()
336 wxClassInfo
* wxReader::GetObjectClassInfo(int objectID
)
338 assert( m_data
->m_classInfos
.find(objectID
) != m_data
->m_classInfos
.end() );
339 return m_data
->m_classInfos
[objectID
] ;
342 void wxReader::SetObjectClassInfo(int objectID
, wxClassInfo
*classInfo
)
344 assert( m_data
->m_classInfos
.find(objectID
) == m_data
->m_classInfos
.end() ) ;
345 m_data
->m_classInfos
[objectID
] = classInfo
;
348 bool wxReader::HasObjectClassInfo( int objectID
)
350 return m_data
->m_classInfos
.find(objectID
) != m_data
->m_classInfos
.end() ;
354 // ----------------------------------------------------------------------------
356 // ----------------------------------------------------------------------------
359 Reading components has not to be extended for components
360 as properties are always sought by typeinfo over all levels
361 and create params are always toplevel class only
365 // ----------------------------------------------------------------------------
366 // depersisting to memory
367 // ----------------------------------------------------------------------------
369 struct wxRuntimeDepersister::wxRuntimeDepersisterInternal
371 map
<int,wxObject
*> m_objects
;
373 void SetObject(int objectID
, wxObject
*obj
)
375 assert( m_objects
.find(objectID
) == m_objects
.end() ) ;
376 m_objects
[objectID
] = obj
;
378 wxObject
* GetObject( int objectID
)
380 if ( objectID
== wxNullObjectID
)
383 assert( m_objects
.find(objectID
) != m_objects
.end() ) ;
384 return m_objects
[objectID
] ;
388 wxRuntimeDepersister::wxRuntimeDepersister()
390 m_data
= new wxRuntimeDepersisterInternal() ;
393 wxRuntimeDepersister::~wxRuntimeDepersister()
398 void wxRuntimeDepersister::AllocateObject(int objectID
, wxClassInfo
*classInfo
,
399 wxxVariantArray
&WXUNUSED(metadata
))
402 O
= classInfo
->CreateObject();
403 m_data
->SetObject(objectID
, O
);
406 void wxRuntimeDepersister::CreateObject(int objectID
,
407 const wxClassInfo
*classInfo
,
411 const wxClassInfo
**objectClassInfos
,
412 wxxVariantArray
&WXUNUSED(metadata
))
415 o
= m_data
->GetObject(objectID
);
416 for ( int i
= 0 ; i
< paramCount
; ++i
)
418 if ( objectIdValues
[i
] != wxInvalidObjectID
)
421 o
= m_data
->GetObject(objectIdValues
[i
]);
422 // if this is a dynamic object and we are asked for another class
423 // than wxDynamicObject we cast it down manually.
424 wxDynamicObject
*dyno
= dynamic_cast< wxDynamicObject
* > (o
) ;
425 if ( dyno
!=NULL
&& (objectClassInfos
[i
] != dyno
->GetClassInfo()) )
427 o
= dyno
->GetSuperClassInstance() ;
429 params
[i
] = objectClassInfos
[i
]->InstanceToVariant(o
) ;
432 classInfo
->Create(o
, paramCount
, params
);
435 void wxRuntimeDepersister::ConstructObject(int objectID
,
436 const wxClassInfo
*classInfo
,
440 const wxClassInfo
**objectClassInfos
,
441 wxxVariantArray
&WXUNUSED(metadata
))
444 for ( int i
= 0 ; i
< paramCount
; ++i
)
446 if ( objectIdValues
[i
] != wxInvalidObjectID
)
449 o
= m_data
->GetObject(objectIdValues
[i
]);
450 // if this is a dynamic object and we are asked for another class
451 // than wxDynamicObject we cast it down manually.
452 wxDynamicObject
*dyno
= dynamic_cast< wxDynamicObject
* > (o
) ;
453 if ( dyno
!=NULL
&& (objectClassInfos
[i
] != dyno
->GetClassInfo()) )
455 o
= dyno
->GetSuperClassInstance() ;
457 params
[i
] = objectClassInfos
[i
]->InstanceToVariant(o
) ;
460 o
= classInfo
->ConstructObject(paramCount
, params
);
461 m_data
->SetObject(objectID
, o
);
465 void wxRuntimeDepersister::DestroyObject(int objectID
, wxClassInfo
*WXUNUSED(classInfo
))
468 o
= m_data
->GetObject(objectID
);
472 void wxRuntimeDepersister::SetProperty(int objectID
,
473 const wxClassInfo
*classInfo
,
474 const wxPropertyInfo
* propertyInfo
,
475 const wxxVariant
&value
)
478 o
= m_data
->GetObject(objectID
);
479 classInfo
->SetProperty( o
, propertyInfo
->GetName() , value
) ;
482 void wxRuntimeDepersister::SetPropertyAsObject(int objectID
,
483 const wxClassInfo
*classInfo
,
484 const wxPropertyInfo
* propertyInfo
,
488 o
= m_data
->GetObject(objectID
);
489 valo
= m_data
->GetObject(valueObjectId
);
490 const wxClassInfo
* valClassInfo
= (dynamic_cast<const wxClassTypeInfo
*>(propertyInfo
->GetTypeInfo()))->GetClassInfo() ;
491 // if this is a dynamic object and we are asked for another class
492 // than wxDynamicObject we cast it down manually.
493 wxDynamicObject
*dynvalo
= dynamic_cast< wxDynamicObject
* > (valo
) ;
494 if ( dynvalo
!=NULL
&& (valClassInfo
!= dynvalo
->GetClassInfo()) )
496 valo
= dynvalo
->GetSuperClassInstance() ;
499 classInfo
->SetProperty( o
, propertyInfo
->GetName() , valClassInfo
->InstanceToVariant(valo
) ) ;
502 void wxRuntimeDepersister::SetConnect(int eventSourceObjectID
,
503 const wxClassInfo
*WXUNUSED(eventSourceClassInfo
),
504 const wxDelegateTypeInfo
*delegateInfo
,
505 const wxClassInfo
*WXUNUSED(eventSinkClassInfo
) ,
506 const wxHandlerInfo
* handlerInfo
,
507 int eventSinkObjectID
)
509 wxEvtHandler
*ehsource
= dynamic_cast< wxEvtHandler
* >( m_data
->GetObject( eventSourceObjectID
) ) ;
510 wxEvtHandler
*ehsink
= dynamic_cast< wxEvtHandler
*>(m_data
->GetObject(eventSinkObjectID
) ) ;
512 if ( ehsource
&& ehsink
)
514 if( delegateInfo
->GetLastEventType() == -1 )
516 ehsource
->Connect( -1 , delegateInfo
->GetEventType() ,
517 handlerInfo
->GetEventFunction() , NULL
/*user data*/ ,
522 for ( wxEventType iter
= delegateInfo
->GetEventType() ; iter
<= delegateInfo
->GetLastEventType() ; ++iter
)
524 ehsource
->Connect( -1 , iter
,
525 handlerInfo
->GetEventFunction() , NULL
/*user data*/ ,
533 wxObject
*wxRuntimeDepersister::GetObject(int objectID
)
535 return m_data
->GetObject( objectID
) ;
538 // adds an element to a property collection
539 void wxRuntimeDepersister::AddToPropertyCollection( int objectID
,
540 const wxClassInfo
*classInfo
,
541 const wxPropertyInfo
* propertyInfo
,
542 const wxxVariant
&value
)
545 o
= m_data
->GetObject(objectID
);
546 classInfo
->AddToPropertyCollection( o
, propertyInfo
->GetName() , value
) ;
549 // sets the corresponding property (value is an object)
550 void wxRuntimeDepersister::AddToPropertyCollectionAsObject(int objectID
,
551 const wxClassInfo
*classInfo
,
552 const wxPropertyInfo
* propertyInfo
,
556 o
= m_data
->GetObject(objectID
);
557 valo
= m_data
->GetObject(valueObjectId
);
558 const wxCollectionTypeInfo
* collectionTypeInfo
= dynamic_cast< const wxCollectionTypeInfo
* >(propertyInfo
->GetTypeInfo() ) ;
559 const wxClassInfo
* valClassInfo
= (dynamic_cast<const wxClassTypeInfo
*>(collectionTypeInfo
->GetElementType()))->GetClassInfo() ;
560 // if this is a dynamic object and we are asked for another class
561 // than wxDynamicObject we cast it down manually.
562 wxDynamicObject
*dynvalo
= dynamic_cast< wxDynamicObject
* > (valo
) ;
563 if ( dynvalo
!=NULL
&& (valClassInfo
!= dynvalo
->GetClassInfo()) )
565 valo
= dynvalo
->GetSuperClassInstance() ;
568 classInfo
->AddToPropertyCollection( o
, propertyInfo
->GetName() , valClassInfo
->InstanceToVariant(valo
) ) ;
571 // ----------------------------------------------------------------------------
572 // depersisting to code
573 // ----------------------------------------------------------------------------
575 struct wxCodeDepersister::wxCodeDepersisterInternal
578 map
<int,wstring
> m_objectNames
;
580 map
<int,string
> m_objectNames
;
583 void SetObjectName(int objectID
, const wxString
&name
)
585 assert( m_objectNames
.find(objectID
) == m_objectNames
.end() ) ;
586 m_objectNames
[objectID
] = (const wxChar
*)name
;
588 wxString
GetObjectName( int objectID
)
590 if ( objectID
== wxNullObjectID
)
593 assert( m_objectNames
.find(objectID
) != m_objectNames
.end() ) ;
594 return wxString( m_objectNames
[objectID
].c_str() ) ;
598 wxCodeDepersister::wxCodeDepersister(wxTextOutputStream
*out
)
601 m_data
= new wxCodeDepersisterInternal
;
604 wxCodeDepersister::~wxCodeDepersister()
609 void wxCodeDepersister::AllocateObject(int objectID
, wxClassInfo
*classInfo
,
610 wxxVariantArray
&WXUNUSED(metadata
))
612 wxString objectName
= wxString::Format( wxT("LocalObject_%d") , objectID
) ;
613 m_fp
->WriteString( wxString::Format( wxT("\t%s *%s = new %s;\n"),
614 classInfo
->GetClassName(),
616 classInfo
->GetClassName()) );
617 m_data
->SetObjectName( objectID
, objectName
) ;
620 void wxCodeDepersister::DestroyObject(int objectID
, wxClassInfo
*WXUNUSED(classInfo
))
622 m_fp
->WriteString( wxString::Format( wxT("\tdelete %s;\n"),
623 m_data
->GetObjectName( objectID
).c_str() ) );
626 wxString
wxCodeDepersister::ValueAsCode( const wxxVariant
¶m
)
629 const wxTypeInfo
* type
= param
.GetTypeInfo() ;
630 if ( type
->GetKind() == wxT_CUSTOM
)
632 const wxCustomTypeInfo
* cti
= dynamic_cast<const wxCustomTypeInfo
*>(type
) ;
633 wxASSERT_MSG( cti
, wxT("Internal error, illegal wxCustomTypeInfo") ) ;
634 value
.Printf( wxT("%s(%s)"), cti
->GetTypeName().c_str(),param
.GetAsString().c_str() );
636 else if ( type
->GetKind() == wxT_STRING
)
638 value
.Printf( wxT("\"%s\""),param
.GetAsString().c_str() );
642 value
.Printf( wxT("%s"), param
.GetAsString().c_str() );
647 void wxCodeDepersister::CreateObject(int objectID
,
648 const wxClassInfo
*WXUNUSED(classInfo
),
652 const wxClassInfo
**WXUNUSED(objectClassInfos
) ,
653 wxxVariantArray
&WXUNUSED(metadata
)
657 m_fp
->WriteString( wxString::Format( wxT("\t%s->Create("), m_data
->GetObjectName(objectID
).c_str() ) );
658 for (i
= 0; i
< paramCount
; i
++)
660 if ( objectIDValues
[i
] != wxInvalidObjectID
)
661 m_fp
->WriteString( wxString::Format( wxT("%s"), m_data
->GetObjectName( objectIDValues
[i
] ).c_str() ) );
664 m_fp
->WriteString( wxString::Format( wxT("%s"), ValueAsCode(params
[i
]).c_str() ) );
666 if (i
< paramCount
- 1)
667 m_fp
->WriteString( wxT(", "));
669 m_fp
->WriteString( wxT(");\n") );
672 void wxCodeDepersister::ConstructObject(int objectID
,
673 const wxClassInfo
*classInfo
,
677 const wxClassInfo
**WXUNUSED(objectClassInfos
) ,
678 wxxVariantArray
&WXUNUSED(metadata
)
681 wxString objectName
= wxString::Format( wxT("LocalObject_%d") , objectID
) ;
682 m_fp
->WriteString( wxString::Format( wxT("\t%s *%s = new %s("),
683 classInfo
->GetClassName(),
685 classInfo
->GetClassName()) );
686 m_data
->SetObjectName( objectID
, objectName
) ;
689 for (i
= 0; i
< paramCount
; i
++)
691 if ( objectIDValues
[i
] != wxInvalidObjectID
)
692 m_fp
->WriteString( wxString::Format( wxT("%s"), m_data
->GetObjectName( objectIDValues
[i
] ).c_str() ) );
695 m_fp
->WriteString( wxString::Format( wxT("%s"), ValueAsCode(params
[i
]).c_str() ) );
697 if (i
< paramCount
- 1)
698 m_fp
->WriteString( wxT(", ") );
700 m_fp
->WriteString( wxT(");\n") );
703 void wxCodeDepersister::SetProperty(int objectID
,
704 const wxClassInfo
*WXUNUSED(classInfo
),
705 const wxPropertyInfo
* propertyInfo
,
706 const wxxVariant
&value
)
708 m_fp
->WriteString( wxString::Format( wxT("\t%s->%s(%s);\n"),
709 m_data
->GetObjectName(objectID
).c_str(),
710 propertyInfo
->GetAccessor()->GetSetterName().c_str(),
711 ValueAsCode(value
).c_str()) );
714 void wxCodeDepersister::SetPropertyAsObject(int objectID
,
715 const wxClassInfo
*WXUNUSED(classInfo
),
716 const wxPropertyInfo
* propertyInfo
,
719 if ( propertyInfo
->GetTypeInfo()->GetKind() == wxT_OBJECT
)
720 m_fp
->WriteString( wxString::Format( wxT("\t%s->%s(*%s);\n"),
721 m_data
->GetObjectName(objectID
).c_str(),
722 propertyInfo
->GetAccessor()->GetSetterName().c_str(),
723 m_data
->GetObjectName( valueObjectId
).c_str() ) );
725 m_fp
->WriteString( wxString::Format( wxT("\t%s->%s(%s);\n"),
726 m_data
->GetObjectName(objectID
).c_str(),
727 propertyInfo
->GetAccessor()->GetSetterName().c_str(),
728 m_data
->GetObjectName( valueObjectId
).c_str() ) );
731 void wxCodeDepersister::AddToPropertyCollection( int objectID
,
732 const wxClassInfo
*WXUNUSED(classInfo
),
733 const wxPropertyInfo
* propertyInfo
,
734 const wxxVariant
&value
)
736 m_fp
->WriteString( wxString::Format( wxT("\t%s->%s(%s);\n"),
737 m_data
->GetObjectName(objectID
).c_str(),
738 propertyInfo
->GetAccessor()->GetAdderName().c_str(),
739 ValueAsCode(value
).c_str()) );
742 // sets the corresponding property (value is an object)
743 void wxCodeDepersister::AddToPropertyCollectionAsObject(int WXUNUSED(objectID
),
744 const wxClassInfo
*WXUNUSED(classInfo
),
745 const wxPropertyInfo
* WXUNUSED(propertyInfo
) ,
746 int WXUNUSED(valueObjectId
))
751 void wxCodeDepersister::SetConnect(int eventSourceObjectID
,
752 const wxClassInfo
*WXUNUSED(eventSourceClassInfo
),
753 const wxDelegateTypeInfo
*delegateInfo
,
754 const wxClassInfo
*eventSinkClassInfo
,
755 const wxHandlerInfo
* handlerInfo
,
756 int eventSinkObjectID
)
758 wxString ehsource
= m_data
->GetObjectName( eventSourceObjectID
) ;
759 wxString ehsink
= m_data
->GetObjectName(eventSinkObjectID
) ;
760 wxString ehsinkClass
= eventSinkClassInfo
->GetClassName() ;
761 int eventType
= delegateInfo
->GetEventType() ;
762 wxString handlerName
= handlerInfo
->GetName() ;
764 m_fp
->WriteString( wxString::Format( wxT("\t%s->Connect( %s->GetId() , %d , (wxObjectEventFunction)(wxEventFunction) & %s::%s , NULL , %s ) ;") ,
765 ehsource
.c_str() , ehsource
.c_str() , eventType
, ehsinkClass
.c_str() , handlerName
.c_str() , ehsink
.c_str() ) );
768 #include <wx/arrimpl.cpp>
770 WX_DEFINE_OBJARRAY(wxxVariantArray
);