]> git.saurik.com Git - wxWidgets.git/blob - src/common/xtistrm.cpp
gcc /vc6 workarounds
[wxWidgets.git] / src / common / xtistrm.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/xtistrm.cpp
3 // Purpose: streaming runtime metadata information
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 27/07/03
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "xtistrm.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/hash.h"
25 #include "wx/object.h"
26 #endif
27
28 #include "wx/tokenzr.h"
29 #include "wx/xtistrm.h"
30 #include "wx/txtstrm.h"
31 #include "wx/event.h"
32
33 #if wxUSE_EXTENDED_RTTI
34
35 #include "wx/beforestd.h"
36 #include <map>
37 #include <vector>
38 #include <string>
39 #include "wx/afterstd.h"
40
41 using namespace std ;
42
43 struct wxWriter::wxWriterInternal
44 {
45 map< const wxObject* , int > m_writtenObjects ;
46 int m_nextId ;
47 } ;
48
49 wxWriter::wxWriter()
50 {
51 m_data = new wxWriterInternal ;
52 m_data->m_nextId = 0 ;
53 }
54
55 wxWriter::~wxWriter()
56 {
57 delete m_data ;
58 }
59
60 struct wxWriter::wxWriterInternalPropertiesData
61 {
62 char nothing ;
63 } ;
64
65 void wxWriter::ClearObjectContext()
66 {
67 delete m_data ;
68 m_data = new wxWriterInternal() ;
69 m_data->m_nextId = 0 ;
70 }
71
72 void wxWriter::WriteObject(const wxObject *object, const wxClassInfo *classInfo , wxPersister *persister , const wxString &name , wxxVariantArray &metadata )
73 {
74 DoBeginWriteTopLevelEntry( name ) ;
75 WriteObject( object , classInfo , persister , false , metadata) ;
76 DoEndWriteTopLevelEntry( name ) ;
77 }
78
79 void wxWriter::WriteObject(const wxObject *object, const wxClassInfo *classInfo , wxPersister *persister , bool isEmbedded, wxxVariantArray &metadata )
80 {
81 if ( !classInfo->BeforeWriteObject( object , this , persister , metadata) )
82 return ;
83
84 if ( persister->BeforeWriteObject( this , object , classInfo , metadata) )
85 {
86 if ( object == NULL )
87 DoWriteNullObject() ;
88 else if ( IsObjectKnown( object ) )
89 DoWriteRepeatedObject( GetObjectID(object) ) ;
90 else
91 {
92 int oid = m_data->m_nextId++ ;
93 if ( !isEmbedded )
94 m_data->m_writtenObjects[object] = oid ;
95
96 // in case this object is a wxDynamicObject we also have to insert is superclass
97 // instance with the same id, so that object relations are streamed out correctly
98 const wxDynamicObject* dynobj = dynamic_cast<const wxDynamicObject *>( object ) ;
99 if ( !isEmbedded && dynobj )
100 m_data->m_writtenObjects[dynobj->GetSuperClassInstance()] = oid ;
101
102 DoBeginWriteObject( object , classInfo , oid , metadata ) ;
103 wxWriterInternalPropertiesData data ;
104 WriteAllProperties( object , classInfo , persister , &data ) ;
105 DoEndWriteObject( object , classInfo , oid ) ;
106 }
107 persister->AfterWriteObject( this ,object , classInfo ) ;
108 }
109 }
110
111 void wxWriter::FindConnectEntry(const wxEvtHandler * evSource,const wxDelegateTypeInfo* dti, const wxObject* &sink , const wxHandlerInfo *&handler)
112 {
113 wxList *dynamicEvents = evSource->GetDynamicEventTable() ;
114
115 if ( dynamicEvents )
116 {
117 wxList::compatibility_iterator node = dynamicEvents->GetFirst();
118 while (node)
119 {
120 wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
121
122 // find the match
123 if ( entry->m_fn &&
124 (dti->GetEventType() == entry->m_eventType) &&
125 (entry->m_id == -1 ) &&
126 (entry->m_eventSink != NULL ) )
127 {
128 sink = entry->m_eventSink ;
129 const wxClassInfo* sinkClassInfo = sink->GetClassInfo() ;
130 const wxHandlerInfo* sinkHandler = sinkClassInfo->GetFirstHandler() ;
131 while ( sinkHandler )
132 {
133 if ( sinkHandler->GetEventFunction() == entry->m_fn )
134 {
135 handler = sinkHandler ;
136 break ;
137 }
138 sinkHandler = sinkHandler->GetNext() ;
139 }
140 break ;
141 }
142 node = node->GetNext();
143 }
144 }
145 }
146 void wxWriter::WriteAllProperties( const wxObject * obj , const wxClassInfo* ci , wxPersister *persister, wxWriterInternalPropertiesData * data )
147 {
148 wxPropertyInfoMap map ;
149 ci->GetProperties( map ) ;
150 for ( int i = 0 ; i < ci->GetCreateParamCount() ; ++i )
151 {
152 wxString name = ci->GetCreateParamName(i) ;
153 const wxPropertyInfo* prop = map.find(name)->second ;
154 wxASSERT_MSG( prop , wxT("Create Parameter not found in declared RTTI Parameters") ) ;
155 WriteOneProperty( obj , prop->GetDeclaringClass() , prop , persister , data ) ;
156 map.erase( name ) ;
157 }
158
159 for( wxPropertyInfoMap::iterator iter = map.begin() ; iter != map.end() ; ++iter )
160 {
161 const wxPropertyInfo* prop = iter->second ;
162 if ( prop->GetFlags() & wxPROP_OBJECT_GRAPH )
163 {
164 WriteOneProperty( obj , prop->GetDeclaringClass() , prop , persister , data ) ;
165 }
166 }
167
168 for( wxPropertyInfoMap::iterator iter = map.begin() ; iter != map.end() ; ++iter )
169 {
170 const wxPropertyInfo* prop = iter->second ;
171 if ( !(prop->GetFlags() & wxPROP_OBJECT_GRAPH) )
172 {
173 WriteOneProperty( obj , prop->GetDeclaringClass() , prop , persister , data ) ;
174 }
175 }
176 }
177
178 void wxWriter::WriteOneProperty( const wxObject *obj , const wxClassInfo* ci , const wxPropertyInfo* pi , wxPersister *persister , wxWriterInternalPropertiesData *WXUNUSED(data) )
179 {
180 if ( pi->GetFlags() & wxPROP_DONT_STREAM )
181 return ;
182
183 // make sure that we are picking the correct object for accessing the property
184 const wxDynamicObject* dynobj = dynamic_cast< const wxDynamicObject* > (obj ) ;
185 if ( dynobj && (dynamic_cast<const wxDynamicClassInfo*>(ci) == NULL) )
186 obj = dynobj->GetSuperClassInstance() ;
187
188 DoBeginWriteProperty( pi ) ;
189 if ( pi->GetTypeInfo()->GetKind() == wxT_COLLECTION )
190 {
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 )
195 {
196 DoBeginWriteElement() ;
197 wxxVariant value = data[i] ;
198 if ( persister->BeforeWriteProperty( this , pi , value ) )
199 {
200 const wxClassTypeInfo* cti = dynamic_cast< const wxClassTypeInfo* > ( elementType ) ;
201 if ( cti )
202 {
203 const wxClassInfo* pci = cti->GetClassInfo() ;
204 wxObject *vobj = pci->VariantToInstance( value ) ;
205 wxxVariantArray md ;
206 WriteObject( vobj , (vobj ? vobj->GetClassInfo() : pci ) , persister , cti->GetKind()== wxT_OBJECT , md ) ;
207 }
208 else
209 {
210 DoWriteSimpleType( value ) ;
211 }
212 }
213 DoEndWriteElement() ;
214 }
215 }
216 else
217 {
218 const wxDelegateTypeInfo* dti = dynamic_cast< const wxDelegateTypeInfo* > ( pi->GetTypeInfo() ) ;
219 if ( dti )
220 {
221 const wxObject* sink = NULL ;
222 const wxHandlerInfo *handler = NULL ;
223
224 const wxEvtHandler * evSource = dynamic_cast<const wxEvtHandler *>(obj) ;
225 wxASSERT_MSG( evSource , wxT("Illegal Object Class (Non-wxEvtHandler) as Event Source") ) ;
226
227 FindConnectEntry( evSource , dti , sink , handler ) ;
228 if ( persister->BeforeWriteDelegate( this , obj , ci , pi , sink , handler ) )
229 {
230 if ( sink != NULL && handler != NULL )
231 {
232 wxASSERT_MSG( IsObjectKnown( sink ) , wxT("Streaming delegates for not already streamed objects not yet supported") ) ;
233 DoWriteDelegate( obj , ci , pi , sink , GetObjectID( sink ) , sink->GetClassInfo() , handler ) ;
234 }
235 }
236 }
237 else
238 {
239 wxxVariant value ;
240 pi->GetAccessor()->GetProperty(obj, value) ;
241 if ( persister->BeforeWriteProperty( this , pi , value ) )
242 {
243 const wxClassTypeInfo* cti = dynamic_cast< const wxClassTypeInfo* > ( pi->GetTypeInfo() ) ;
244 if ( cti )
245 {
246 const wxClassInfo* pci = cti->GetClassInfo() ;
247 wxObject *vobj = pci->VariantToInstance( value ) ;
248 wxxVariantArray md ;
249 WriteObject( vobj , (vobj ? vobj->GetClassInfo() : pci ) , persister , cti->GetKind()== wxT_OBJECT , md) ;
250 }
251 else
252 {
253 if ( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
254 {
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 ) ;
258 }
259 DoWriteSimpleType( value ) ;
260 }
261 }
262 }
263 }
264 DoEndWriteProperty( pi ) ;
265 }
266
267 int wxWriter::GetObjectID(const wxObject *obj)
268 {
269 if ( !IsObjectKnown( obj ) )
270 return wxInvalidObjectID ;
271
272 return m_data->m_writtenObjects[obj] ;
273 }
274
275 bool wxWriter::IsObjectKnown( const wxObject *obj )
276 {
277 return m_data->m_writtenObjects.find( obj ) != m_data->m_writtenObjects.end() ;
278 }
279
280
281 // ----------------------------------------------------------------------------
282 // reading objects in
283 // ----------------------------------------------------------------------------
284
285 struct wxReader::wxReaderInternal
286 {
287 map<int,wxClassInfo*> m_classInfos;
288 };
289
290 wxReader::wxReader()
291 {
292 m_data = new wxReaderInternal;
293 }
294
295 wxReader::~wxReader()
296 {
297 delete m_data;
298 }
299
300 wxClassInfo* wxReader::GetObjectClassInfo(int objectID)
301 {
302 assert( m_data->m_classInfos.find(objectID) != m_data->m_classInfos.end() );
303 return m_data->m_classInfos[objectID] ;
304 }
305
306 void wxReader::SetObjectClassInfo(int objectID, wxClassInfo *classInfo )
307 {
308 assert( m_data->m_classInfos.find(objectID) == m_data->m_classInfos.end() ) ;
309 m_data->m_classInfos[objectID] = classInfo ;
310 }
311
312 bool wxReader::HasObjectClassInfo( int objectID )
313 {
314 return m_data->m_classInfos.find(objectID) != m_data->m_classInfos.end() ;
315 }
316
317
318 // ----------------------------------------------------------------------------
319 // reading xml in
320 // ----------------------------------------------------------------------------
321
322 /*
323 Reading components has not to be extended for components
324 as properties are always sought by typeinfo over all levels
325 and create params are always toplevel class only
326 */
327
328
329 // ----------------------------------------------------------------------------
330 // depersisting to memory
331 // ----------------------------------------------------------------------------
332
333 struct wxRuntimeDepersister::wxRuntimeDepersisterInternal
334 {
335 map<int,wxObject *> m_objects;
336
337 void SetObject(int objectID, wxObject *obj )
338 {
339 assert( m_objects.find(objectID) == m_objects.end() ) ;
340 m_objects[objectID] = obj ;
341 }
342 wxObject* GetObject( int objectID )
343 {
344 if ( objectID == wxNullObjectID )
345 return NULL ;
346
347 assert( m_objects.find(objectID) != m_objects.end() ) ;
348 return m_objects[objectID] ;
349 }
350 } ;
351
352 wxRuntimeDepersister::wxRuntimeDepersister()
353 {
354 m_data = new wxRuntimeDepersisterInternal() ;
355 }
356
357 wxRuntimeDepersister::~wxRuntimeDepersister()
358 {
359 delete m_data ;
360 }
361
362 void wxRuntimeDepersister::AllocateObject(int objectID, wxClassInfo *classInfo ,
363 wxxVariantArray &WXUNUSED(metadata))
364 {
365 wxObject *O;
366 O = classInfo->CreateObject();
367 m_data->SetObject(objectID, O);
368 }
369
370 void wxRuntimeDepersister::CreateObject(int objectID,
371 const wxClassInfo *classInfo,
372 int paramCount,
373 wxxVariant *params,
374 int *objectIdValues,
375 const wxClassInfo **objectClassInfos ,
376 wxxVariantArray &WXUNUSED(metadata))
377 {
378 wxObject *o;
379 o = m_data->GetObject(objectID);
380 for ( int i = 0 ; i < paramCount ; ++i )
381 {
382 if ( objectIdValues[i] != wxInvalidObjectID )
383 {
384 wxObject *o;
385 o = m_data->GetObject(objectIdValues[i]);
386 // if this is a dynamic object and we are asked for another class
387 // than wxDynamicObject we cast it down manually.
388 wxDynamicObject *dyno = dynamic_cast< wxDynamicObject * > (o) ;
389 if ( dyno!=NULL && (objectClassInfos[i] != dyno->GetClassInfo()) )
390 {
391 o = dyno->GetSuperClassInstance() ;
392 }
393 params[i] = objectClassInfos[i]->InstanceToVariant(o) ;
394 }
395 }
396 classInfo->Create(o, paramCount, params);
397 }
398
399 void wxRuntimeDepersister::DestroyObject(int objectID, wxClassInfo *WXUNUSED(classInfo))
400 {
401 wxObject *o;
402 o = m_data->GetObject(objectID);
403 delete o ;
404 }
405
406 void wxRuntimeDepersister::SetProperty(int objectID,
407 const wxClassInfo *classInfo,
408 const wxPropertyInfo* propertyInfo,
409 const wxxVariant &value)
410 {
411 wxObject *o;
412 o = m_data->GetObject(objectID);
413 classInfo->SetProperty( o , propertyInfo->GetName() , value ) ;
414 }
415
416 void wxRuntimeDepersister::SetPropertyAsObject(int objectID,
417 const wxClassInfo *classInfo,
418 const wxPropertyInfo* propertyInfo,
419 int valueObjectId)
420 {
421 wxObject *o, *valo;
422 o = m_data->GetObject(objectID);
423 valo = m_data->GetObject(valueObjectId);
424 const wxClassInfo* valClassInfo = (dynamic_cast<const wxClassTypeInfo*>(propertyInfo->GetTypeInfo()))->GetClassInfo() ;
425 // if this is a dynamic object and we are asked for another class
426 // than wxDynamicObject we cast it down manually.
427 wxDynamicObject *dynvalo = dynamic_cast< wxDynamicObject * > (valo) ;
428 if ( dynvalo!=NULL && (valClassInfo != dynvalo->GetClassInfo()) )
429 {
430 valo = dynvalo->GetSuperClassInstance() ;
431 }
432
433 classInfo->SetProperty( o , propertyInfo->GetName() , valClassInfo->InstanceToVariant(valo) ) ;
434 }
435
436 void wxRuntimeDepersister::SetConnect(int eventSourceObjectID,
437 const wxClassInfo *WXUNUSED(eventSourceClassInfo),
438 const wxDelegateTypeInfo *delegateInfo ,
439 const wxClassInfo *WXUNUSED(eventSinkClassInfo) ,
440 const wxHandlerInfo* handlerInfo ,
441 int eventSinkObjectID )
442 {
443 wxEvtHandler *ehsource = dynamic_cast< wxEvtHandler* >( m_data->GetObject( eventSourceObjectID ) ) ;
444 wxEvtHandler *ehsink = dynamic_cast< wxEvtHandler *>(m_data->GetObject(eventSinkObjectID) ) ;
445
446 if ( ehsource && ehsink )
447 {
448 ehsource->Connect( -1 , delegateInfo->GetEventType() ,
449 handlerInfo->GetEventFunction() , NULL /*user data*/ ,
450 ehsink ) ;
451 }
452 }
453
454 wxObject *wxRuntimeDepersister::GetObject(int objectID)
455 {
456 return m_data->GetObject( objectID ) ;
457 }
458
459 // adds an element to a property collection
460 void wxRuntimeDepersister::AddToPropertyCollection( int objectID ,
461 const wxClassInfo *classInfo,
462 const wxPropertyInfo* propertyInfo ,
463 const wxxVariant &value)
464 {
465 wxObject *o;
466 o = m_data->GetObject(objectID);
467 classInfo->AddToPropertyCollection( o , propertyInfo->GetName() , value ) ;
468 }
469
470 // sets the corresponding property (value is an object)
471 void wxRuntimeDepersister::AddToPropertyCollectionAsObject(int objectID,
472 const wxClassInfo *classInfo,
473 const wxPropertyInfo* propertyInfo ,
474 int valueObjectId)
475 {
476 wxObject *o, *valo;
477 o = m_data->GetObject(objectID);
478 valo = m_data->GetObject(valueObjectId);
479 const wxCollectionTypeInfo * collectionTypeInfo = dynamic_cast< const wxCollectionTypeInfo * >(propertyInfo->GetTypeInfo() ) ;
480 const wxClassInfo* valClassInfo = (dynamic_cast<const wxClassTypeInfo*>(collectionTypeInfo->GetElementType()))->GetClassInfo() ;
481 // if this is a dynamic object and we are asked for another class
482 // than wxDynamicObject we cast it down manually.
483 wxDynamicObject *dynvalo = dynamic_cast< wxDynamicObject * > (valo) ;
484 if ( dynvalo!=NULL && (valClassInfo != dynvalo->GetClassInfo()) )
485 {
486 valo = dynvalo->GetSuperClassInstance() ;
487 }
488
489 classInfo->AddToPropertyCollection( o , propertyInfo->GetName() , valClassInfo->InstanceToVariant(valo) ) ;
490 }
491
492 // ----------------------------------------------------------------------------
493 // depersisting to code
494 // ----------------------------------------------------------------------------
495
496 struct wxCodeDepersister::wxCodeDepersisterInternal
497 {
498 map<int,string> m_objectNames ;
499
500 void SetObjectName(int objectID, const wxString &name )
501 {
502 assert( m_objectNames.find(objectID) == m_objectNames.end() ) ;
503 m_objectNames[objectID] = (const char *)name;
504 }
505 wxString GetObjectName( int objectID )
506 {
507 if ( objectID == wxNullObjectID )
508 return "NULL" ;
509
510 assert( m_objectNames.find(objectID) != m_objectNames.end() ) ;
511 return wxString( m_objectNames[objectID].c_str() ) ;
512 }
513 } ;
514
515 wxCodeDepersister::wxCodeDepersister(wxTextOutputStream *out)
516 : m_fp(out)
517 {
518 m_data = new wxCodeDepersisterInternal ;
519 }
520
521 wxCodeDepersister::~wxCodeDepersister()
522 {
523 delete m_data ;
524 }
525
526 void wxCodeDepersister::AllocateObject(int objectID, wxClassInfo *classInfo ,
527 wxxVariantArray &WXUNUSED(metadata))
528 {
529 wxString objectName = wxString::Format( "LocalObject_%d" , objectID ) ;
530 m_fp->WriteString( wxString::Format( "\t%s *%s = new %s;\n",
531 classInfo->GetClassName(),
532 objectName.c_str(),
533 classInfo->GetClassName()) );
534 m_data->SetObjectName( objectID , objectName ) ;
535 }
536
537 void wxCodeDepersister::DestroyObject(int objectID, wxClassInfo *WXUNUSED(classInfo))
538 {
539 m_fp->WriteString( wxString::Format( "\tdelete %s;\n",
540 m_data->GetObjectName( objectID).c_str() ) );
541 }
542
543 wxString wxCodeDepersister::ValueAsCode( const wxxVariant &param )
544 {
545 wxString value ;
546 const wxTypeInfo* type = param.GetTypeInfo() ;
547 if ( type->GetKind() == wxT_CUSTOM )
548 {
549 const wxCustomTypeInfo* cti = dynamic_cast<const wxCustomTypeInfo*>(type) ;
550 wxASSERT_MSG( cti , wxT("Internal error, illegal wxCustomTypeInfo") ) ;
551 value.Printf( "%s(%s)",cti->GetTypeName().c_str(),param.GetAsString().c_str() );
552 }
553 else if ( type->GetKind() == wxT_STRING )
554 {
555 value.Printf( "\"%s\"",param.GetAsString().c_str() );
556 }
557 else
558 {
559 value.Printf( "%s", param.GetAsString().c_str() );
560 }
561 return value ;
562 }
563
564 void wxCodeDepersister::CreateObject(int objectID,
565 const wxClassInfo *WXUNUSED(classInfo),
566 int paramCount,
567 wxxVariant *params,
568 int *objectIDValues,
569 const wxClassInfo **WXUNUSED(objectClassInfos) ,
570 wxxVariantArray &WXUNUSED(metadata)
571 )
572 {
573 int i;
574 m_fp->WriteString( wxString::Format( "\t%s->Create(", m_data->GetObjectName(objectID).c_str() ) );
575 for (i = 0; i < paramCount; i++)
576 {
577 if ( objectIDValues[i] != wxInvalidObjectID )
578 m_fp->WriteString( wxString::Format( "%s", m_data->GetObjectName( objectIDValues[i] ).c_str() ) );
579 else
580 {
581 m_fp->WriteString( wxString::Format( "%s", ValueAsCode(params[i]).c_str() ) );
582 }
583 if (i < paramCount - 1)
584 m_fp->WriteString( ", ");
585 }
586 m_fp->WriteString( ");\n");
587 }
588
589 void wxCodeDepersister::SetProperty(int objectID,
590 const wxClassInfo *WXUNUSED(classInfo),
591 const wxPropertyInfo* propertyInfo,
592 const wxxVariant &value)
593 {
594 m_fp->WriteString( wxString::Format( "\t%s->%s(%s);\n",
595 m_data->GetObjectName(objectID).c_str(),
596 propertyInfo->GetAccessor()->GetSetterName().c_str(),
597 ValueAsCode(value).c_str()) );
598 }
599
600 void wxCodeDepersister::SetPropertyAsObject(int objectID,
601 const wxClassInfo *WXUNUSED(classInfo),
602 const wxPropertyInfo* propertyInfo,
603 int valueObjectId)
604 {
605 if ( propertyInfo->GetTypeInfo()->GetKind() == wxT_OBJECT )
606 m_fp->WriteString( wxString::Format( "\t%s->%s(*%s);\n",
607 m_data->GetObjectName(objectID).c_str(),
608 propertyInfo->GetAccessor()->GetSetterName().c_str(),
609 m_data->GetObjectName( valueObjectId).c_str() ) );
610 else
611 m_fp->WriteString( wxString::Format( "\t%s->%s(%s);\n",
612 m_data->GetObjectName(objectID).c_str(),
613 propertyInfo->GetAccessor()->GetSetterName().c_str(),
614 m_data->GetObjectName( valueObjectId).c_str() ) );
615 }
616
617 void wxCodeDepersister::AddToPropertyCollection( int objectID ,
618 const wxClassInfo *WXUNUSED(classInfo),
619 const wxPropertyInfo* propertyInfo ,
620 const wxxVariant &value)
621 {
622 m_fp->WriteString( wxString::Format( "\t%s->%s(%s);\n",
623 m_data->GetObjectName(objectID).c_str(),
624 propertyInfo->GetAccessor()->GetAdderName().c_str(),
625 ValueAsCode(value).c_str()) );
626 }
627
628 // sets the corresponding property (value is an object)
629 void wxCodeDepersister::AddToPropertyCollectionAsObject(int WXUNUSED(objectID),
630 const wxClassInfo *WXUNUSED(classInfo),
631 const wxPropertyInfo* WXUNUSED(propertyInfo) ,
632 int WXUNUSED(valueObjectId))
633 {
634 // TODO
635 }
636
637 void wxCodeDepersister::SetConnect(int eventSourceObjectID,
638 const wxClassInfo *WXUNUSED(eventSourceClassInfo),
639 const wxDelegateTypeInfo *delegateInfo ,
640 const wxClassInfo *eventSinkClassInfo ,
641 const wxHandlerInfo* handlerInfo ,
642 int eventSinkObjectID )
643 {
644 wxString ehsource = m_data->GetObjectName( eventSourceObjectID ) ;
645 wxString ehsink = m_data->GetObjectName(eventSinkObjectID) ;
646 wxString ehsinkClass = eventSinkClassInfo->GetClassName() ;
647 int eventType = delegateInfo->GetEventType() ;
648 wxString handlerName = handlerInfo->GetName() ;
649
650 m_fp->WriteString( wxString::Format( "\t%s->Connect( %s->GetId() , %d , (wxObjectEventFunction)(wxEventFunction) & %s::%s , NULL , %s ) ;" ,
651 ehsource.c_str() , ehsource.c_str() , eventType , ehsinkClass.c_str() , handlerName.c_str() , ehsink.c_str() ) );
652 }
653
654 #include <wx/arrimpl.cpp>
655
656 WX_DEFINE_OBJARRAY(wxxVariantArray);
657
658 #endif