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 /////////////////////////////////////////////////////////////////////////////
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/xml/xml.h"
29 #include "wx/tokenzr.h"
30 #include "wx/xtistrm.h"
31 #include "wx/txtstrm.h"
33 #if wxUSE_EXTENDED_RTTI
40 struct wxWriter::wxWriterInternal
42 map
< const wxObject
* , int > m_writtenObjects
;
48 m_data
= new wxWriterInternal
;
49 m_data
->m_nextId
= 0 ;
57 struct wxWriter::wxWriterInternalPropertiesData
59 map
< string
, int > m_writtenProperties
;
62 void wxWriter::WriteObject(const wxObject
*object
, const wxClassInfo
*classInfo
, wxPersister
*persister
, const wxString
&name
)
64 if ( persister
->BeforeWriteObject( object
, classInfo
, name
) )
66 int oid
= m_data
->m_nextId
++ ;
67 m_data
->m_writtenObjects
[object
] = oid
;
68 DoBeginWriteObject( object
, classInfo
, oid
, name
) ;
69 wxWriterInternalPropertiesData data
;
70 WriteAllProperties( object
, classInfo
, persister
, &data
) ;
71 DoEndWriteObject( object
, classInfo
, oid
, name
) ;
75 void wxWriter::WriteAllProperties( const wxObject
* obj
, const wxClassInfo
* ci
, wxPersister
*persister
, wxWriterInternalPropertiesData
* data
)
77 const wxPropertyInfo
*pi
= ci
->GetFirstProperty() ;
80 if ( data
->m_writtenProperties
.find( pi
->GetName() ) == data
->m_writtenProperties
.end() )
82 data
->m_writtenProperties
[ pi
->GetName() ] = 1 ;
83 const wxClassTypeInfo
* cti
= dynamic_cast< const wxClassTypeInfo
* > ( pi
->GetTypeInfo() ) ;
86 const wxClassInfo
* pci
= cti
->GetClassInfo() ;
87 wxxVariant value
= pi
->GetAccessor()->GetProperty(obj
) ;
88 if ( persister
->BeforeWritePropertyAsObject( obj
, ci
, pi
, value
) )
90 wxObject
*vobj
= pci
->VariantToInstance( value
) ;
91 bool embeddedObject
= cti
->GetKind() == wxT_OBJECT
;
93 if ( vobj
== NULL
|| IsObjectKnown( vobj
) )
95 DoWriteObjectReference( obj
, ci
, vobj
, pci
, GetObjectID(vobj
) , pi
) ;
99 int oid
= m_data
->m_nextId
++ ;
100 if ( !embeddedObject
)
101 m_data
->m_writtenObjects
[vobj
] = oid
;
103 DoBeginWriteParamAsObject( obj
, ci
, vobj
, pci
, oid
, pi
) ;
106 wxWriterInternalPropertiesData data
;
107 WriteAllProperties( vobj
, pci
, persister
, &data
) ;
109 DoEndWriteParamAsObject( obj
, ci
, vobj
, pci
, oid
, pi
) ;
115 const wxDelegateTypeInfo
* dti
= dynamic_cast< const wxDelegateTypeInfo
* > ( pi
->GetTypeInfo() ) ;
118 const wxObject
* sink
= NULL
;
119 const wxHandlerInfo
*handler
= NULL
;
120 if ( persister
->BeforeWriteDelegate( obj
, ci
, pi
, sink
, handler
) )
122 if ( sink
!= NULL
&& handler
!= NULL
)
124 wxASSERT_MSG( IsObjectKnown( sink
) , wxT("Streaming delegates for not already streamed objects not yet supported") ) ;
125 DoWriteDelegate( obj
, ci
, pi
, sink
, GetObjectID( sink
) , sink
->GetClassInfo() , handler
) ;
131 wxxVariant value
= pi
->GetAccessor()->GetProperty(obj
) ;
132 if ( persister
->BeforeWriteProperty( obj
, ci
, pi
, value
) )
134 DoWriteProperty( obj
, ci
, pi
, value
) ;
141 const wxClassInfo
** parents
= ci
->GetParents() ;
142 for ( int i
= 0 ; parents
[i
] ; ++ i
)
144 WriteAllProperties( obj
, parents
[i
] , persister
, data
) ;
148 int wxWriter::GetObjectID(const wxObject
*obj
)
150 if ( !IsObjectKnown( obj
) )
151 return wxInvalidObjectID
;
153 return m_data
->m_writtenObjects
[obj
] ;
156 bool wxWriter::IsObjectKnown( const wxObject
*obj
)
158 return m_data
->m_writtenObjects
.find( obj
) != m_data
->m_writtenObjects
.end() ;
165 // convenience functions
167 void wxXmlAddContentToNode( wxXmlNode
* node
, const wxString
& data
)
169 node
->AddChild(new wxXmlNode(wxXML_TEXT_NODE
, "value", data
) );
172 wxString
wxXmlGetContentFromNode( wxXmlNode
*node
)
174 if ( node
->GetChildren() )
175 return node
->GetChildren()->GetContent() ;
177 return wxEmptyString
;
180 struct wxXmlWriter::wxXmlWriterInternal
183 wxXmlNode
*m_current
;
184 vector
< wxXmlNode
* > m_objectStack
;
187 wxXmlWriter::wxXmlWriter( wxXmlNode
* rootnode
)
189 m_data
= new wxXmlWriterInternal() ;
190 m_data
->m_root
= rootnode
;
191 m_data
->m_current
= rootnode
;
194 wxXmlWriter::~wxXmlWriter()
199 // start of writing the root object
200 void wxXmlWriter::DoBeginWriteObject(const wxObject
*WXUNUSED(object
), const wxClassInfo
*classInfo
, int objectID
, const wxString
&name
)
203 onode
= new wxXmlNode(wxXML_ELEMENT_NODE
, name
);
204 onode
->AddProperty(wxString("class"), wxString(classInfo
->GetClassName()));
205 onode
->AddProperty(wxString("id"), wxString::Format( "%d" , objectID
) );
207 m_data
->m_current
->AddChild(onode
) ;
208 m_data
->m_objectStack
.push_back( m_data
->m_current
) ;
209 m_data
->m_current
= onode
;
212 // end of writing the root object
213 void wxXmlWriter::DoEndWriteObject(const wxObject
*WXUNUSED(object
), const wxClassInfo
*WXUNUSED(classInfo
), int WXUNUSED(objectID
) , const wxString
&WXUNUSED(name
) )
215 m_data
->m_current
= m_data
->m_objectStack
.back() ;
216 m_data
->m_objectStack
.pop_back() ;
219 // writes a property in the stream format
220 void wxXmlWriter::DoWriteProperty( const wxObject
*WXUNUSED(obj
), const wxClassInfo
* WXUNUSED(classInfo
) , const wxPropertyInfo
*pi
, wxxVariant
&value
)
223 pnode
= new wxXmlNode(wxXML_ELEMENT_NODE
, pi
->GetName() );
224 wxXmlAddContentToNode( pnode
,value
.GetAsString() ) ;
225 m_data
->m_current
->AddChild(pnode
);
228 void wxXmlWriter::DoBeginWriteParamAsObject(const wxObject
*WXUNUSED(parentObject
), const wxClassInfo
*WXUNUSED(parentClassInfo
), const wxObject
*WXUNUSED(valueObject
),
229 const wxClassInfo
*valueObjectClassInfo
, int valueObjectID
, const wxPropertyInfo
*propInfo
)
232 onode
= new wxXmlNode(wxXML_ELEMENT_NODE
, propInfo
->GetName());
233 onode
->AddProperty(wxString("class"), wxString(valueObjectClassInfo
->GetClassName()));
234 onode
->AddProperty(wxString("id"), wxString::Format( "%d" , valueObjectID
) );
235 m_data
->m_current
->AddChild(onode
) ;
236 m_data
->m_objectStack
.push_back( m_data
->m_current
) ;
237 m_data
->m_current
= onode
;
240 // insert an object reference to an already written object
241 void wxXmlWriter::DoWriteObjectReference(const wxObject
*WXUNUSED(parentObject
), const wxClassInfo
*WXUNUSED(parentClassInfo
), const wxObject
*valueObject
,
242 const wxClassInfo
*valueObjectClassInfo
, int valueObjectID
, const wxPropertyInfo
*propInfo
)
245 onode
= new wxXmlNode(wxXML_ELEMENT_NODE
, propInfo
->GetName());
246 onode
->AddProperty(wxString("class"), wxString(valueObjectClassInfo
->GetClassName()));
247 if ( valueObject
== NULL
)
249 wxXmlNode
* nullnode
= new wxXmlNode(wxXML_TEXT_NODE
, wxEmptyString
, "null");
250 onode
->AddChild(nullnode
);
254 onode
->AddProperty(wxString("id"), wxString::Format( "%d" , valueObjectID
) );
257 m_data
->m_current
->AddChild(onode
) ;
260 void wxXmlWriter::DoEndWriteParamAsObject(const wxObject
*WXUNUSED(parentObject
), const wxClassInfo
*WXUNUSED(parentClassInfo
), const wxObject
*WXUNUSED(valueObject
),
261 const wxClassInfo
*WXUNUSED(valueObjectClassInfo
), int WXUNUSED(valueObjectID
) , const wxPropertyInfo
*WXUNUSED(propInfo
) )
263 m_data
->m_current
= m_data
->m_objectStack
.back() ;
264 m_data
->m_objectStack
.pop_back() ;
268 // writes a delegate in the stream format
269 void wxXmlWriter::DoWriteDelegate( const wxObject
*WXUNUSED(object
), const wxClassInfo
* WXUNUSED(classInfo
) , const wxPropertyInfo
*pi
,
270 const wxObject
*eventSink
, int sinkObjectID
, const wxClassInfo
* WXUNUSED(eventSinkClassInfo
) , const wxHandlerInfo
* handlerInfo
)
272 if ( eventSink
!= NULL
&& handlerInfo
!= NULL
)
275 pnode
= new wxXmlNode(wxXML_ELEMENT_NODE
, pi
->GetName() );
277 s
.Printf(wxT("%d.%s"), sinkObjectID
, handlerInfo
->GetName() ) ;
278 wxXmlAddContentToNode( pnode
,s
) ;
279 m_data
->m_current
->AddChild(pnode
);
283 // ----------------------------------------------------------------------------
284 // reading objects in
285 // ----------------------------------------------------------------------------
287 struct wxReader::wxReaderInternal
289 map
<int,wxClassInfo
*> m_classInfos
;
294 m_data
= new wxReaderInternal
;
297 wxReader::~wxReader()
302 wxClassInfo
* wxReader::GetObjectClassInfo(int objectID
)
304 assert( m_data
->m_classInfos
.find(objectID
) != m_data
->m_classInfos
.end() );
305 return m_data
->m_classInfos
[objectID
] ;
308 void wxReader::SetObjectClassInfo(int objectID
, wxClassInfo
*classInfo
)
310 assert( m_data
->m_classInfos
.find(objectID
) == m_data
->m_classInfos
.end() ) ;
311 m_data
->m_classInfos
[objectID
] = classInfo
;
314 bool wxReader::HasObjectClassInfo( int objectID
)
316 return m_data
->m_classInfos
.find(objectID
) != m_data
->m_classInfos
.end() ;
320 // ----------------------------------------------------------------------------
322 // ----------------------------------------------------------------------------
325 Reading components has not to be extended for components
326 as properties are always sought by typeinfo over all levels
327 and create params are always toplevel class only
330 int wxXmlReader::ReadComponent(wxXmlNode
*node
, wxDepersister
*callbacks
)
333 wxClassInfo
*classInfo
;
335 wxxVariant
*createParams
;
336 int *createParamOids
;
337 const wxClassInfo
** createClassInfos
;
341 children
= node
->GetChildren();
342 if (!node
->GetPropVal("class", &className
))
344 // No class name. Eek. FIXME: error handling
345 return wxInvalidObjectID
;
347 classInfo
= wxClassInfo::FindClass(className
);
348 if (children
&& children
->GetType() == wxXML_TEXT_NODE
)
350 assert( wxXmlGetContentFromNode(node
) == "null" ) ;
351 // this must be a NULL component reference. We just bail out
352 return wxNullObjectID
;
355 wxString ObjectIdString
;
356 if (!node
->GetPropVal("id", &ObjectIdString
))
358 // No object id. Eek. FIXME: error handling
359 return wxInvalidObjectID
;
362 objectID
= atoi( ObjectIdString
.c_str() ) ;
363 // is this object already has been streamed in, return it here
364 if ( HasObjectClassInfo( objectID
) )
367 // new object, start with allocation
368 // first make the object know to our internal registry
369 SetObjectClassInfo( objectID
, classInfo
) ;
371 callbacks
->AllocateObject(objectID
, classInfo
);
374 // stream back the Create parameters first
375 createParams
= new wxxVariant
[ classInfo
->GetCreateParamCount() ] ;
376 createParamOids
= new int[classInfo
->GetCreateParamCount() ] ;
377 createClassInfos
= new const wxClassInfo
*[classInfo
->GetCreateParamCount() ] ;
379 typedef map
<string
, wxXmlNode
*> PropertyNodes
;
380 typedef vector
<string
> PropertyNames
;
382 PropertyNodes propertyNodes
;
383 PropertyNames propertyNames
;
387 propertyNames
.push_back( children
->GetName().c_str() ) ;
388 propertyNodes
[children
->GetName().c_str()] = children
;
389 children
= children
->GetNext() ;
392 for ( int i
= 0 ; i
<classInfo
->GetCreateParamCount() ; ++i
)
394 const wxChar
* paramName
= classInfo
->GetCreateParamName(i
) ;
395 PropertyNodes::iterator propiter
= propertyNodes
.find( paramName
) ;
396 const wxPropertyInfo
* pi
= classInfo
->FindPropertyInfo( paramName
) ;
397 // if we don't have the value of a create param set in the xml
398 // we use the default value
399 if ( propiter
!= propertyNodes
.end() )
401 wxXmlNode
* prop
= propiter
->second
;
402 if ( pi
->GetTypeInfo()->IsObjectType() )
404 createParamOids
[i
] = ReadComponent( prop
, callbacks
) ;
405 createClassInfos
[i
] = dynamic_cast<const wxClassTypeInfo
*>(pi
->GetTypeInfo())->GetClassInfo() ;
409 createParamOids
[i
] = wxInvalidObjectID
;
410 createParams
[i
] = ReadValue( prop
, pi
->GetAccessor() ) ;
411 createClassInfos
[i
] = NULL
;
414 for ( size_t j
= 0 ; j
< propertyNames
.size() ; ++j
)
416 if ( propertyNames
[j
] == paramName
)
418 propertyNames
[j
] = "" ;
425 createParams
[i
] = pi
->GetDefaultValue() ;
429 // got the parameters. Call the Create method
430 callbacks
->CreateObject(objectID
, classInfo
,
431 classInfo
->GetCreateParamCount(),
432 createParams
, createParamOids
, createClassInfos
);
434 // now stream in the rest of the properties, in the sequence their properties were written in the xml
435 for ( size_t j
= 0 ; j
< propertyNames
.size() ; ++j
)
437 if ( propertyNames
[j
].length() )
439 PropertyNodes::iterator propiter
= propertyNodes
.find( propertyNames
[j
] ) ;
440 if ( propiter
!= propertyNodes
.end() )
442 wxXmlNode
* prop
= propiter
->second
;
443 const wxPropertyInfo
* pi
= classInfo
->FindPropertyInfo( propertyNames
[j
].c_str() ) ;
444 if ( pi
->GetTypeInfo()->IsObjectType() )
446 int valueId
= ReadComponent( prop
, callbacks
) ;
449 if ( valueId
!= wxInvalidObjectID
)
451 callbacks
->SetPropertyAsObject( objectID
, classInfo
, pi
, valueId
) ;
452 if ( pi
->GetTypeInfo()->GetKind() == wxT_OBJECT
&& valueId
!= wxNullObjectID
)
453 callbacks
->DestroyObject( valueId
, GetObjectClassInfo( valueId
) ) ;
457 else if ( pi
->GetTypeInfo()->IsDelegateType() )
459 wxString resstring
= wxXmlGetContentFromNode(prop
) ;
460 wxInt32 pos
= resstring
.Find('.') ;
461 assert( pos
!= wxNOT_FOUND
) ;
462 int sinkOid
= atol(resstring
.Left(pos
)) ;
463 wxString handlerName
= resstring
.Mid(pos
+1) ;
464 wxClassInfo
* sinkClassInfo
= GetObjectClassInfo( sinkOid
) ;
467 callbacks
->SetConnect( objectID
, classInfo
, dynamic_cast<const wxDelegateTypeInfo
*>(pi
->GetTypeInfo()) , sinkClassInfo
,
468 sinkClassInfo
->FindHandlerInfo(handlerName
) , sinkOid
) ;
474 callbacks
->SetProperty( objectID
, classInfo
,pi
, ReadValue( prop
, pi
->GetAccessor() ) ) ;
480 delete[] createParams
;
481 delete[] createParamOids
;
482 delete[] createClassInfos
;
487 wxxVariant
wxXmlReader::ReadValue(wxXmlNode
*node
,
488 wxPropertyAccessor
*accessor
)
490 return accessor
->ReadValue(wxXmlGetContentFromNode( node
) ) ;
493 int wxXmlReader::ReadObject(wxDepersister
*callbacks
)
495 return ReadComponent( m_parent
, callbacks
) ;
498 // ----------------------------------------------------------------------------
499 // depersisting to memory
500 // ----------------------------------------------------------------------------
502 struct wxRuntimeDepersister::wxRuntimeDepersisterInternal
504 map
<int,wxObject
*> m_objects
;
506 void SetObject(int objectID
, wxObject
*obj
)
508 assert( m_objects
.find(objectID
) == m_objects
.end() ) ;
509 m_objects
[objectID
] = obj
;
511 wxObject
* GetObject( int objectID
)
513 if ( objectID
== wxNullObjectID
)
516 assert( m_objects
.find(objectID
) != m_objects
.end() ) ;
517 return m_objects
[objectID
] ;
521 wxRuntimeDepersister::wxRuntimeDepersister()
523 m_data
= new wxRuntimeDepersisterInternal() ;
526 wxRuntimeDepersister::~wxRuntimeDepersister()
531 void wxRuntimeDepersister::AllocateObject(int objectID
, wxClassInfo
*classInfo
)
534 O
= classInfo
->CreateObject();
535 m_data
->SetObject(objectID
, O
);
538 void wxRuntimeDepersister::CreateObject(int objectID
,
539 const wxClassInfo
*classInfo
,
543 const wxClassInfo
**objectClassInfos
)
546 o
= m_data
->GetObject(objectID
);
547 for ( int i
= 0 ; i
< paramCount
; ++i
)
549 if ( objectIdValues
[i
] != wxInvalidObjectID
)
552 o
= m_data
->GetObject(objectIdValues
[i
]);
553 params
[i
] = objectClassInfos
[i
]->InstanceToVariant(o
) ;
556 classInfo
->Create(o
, paramCount
, params
);
559 void wxRuntimeDepersister::DestroyObject(int objectID
, wxClassInfo
*WXUNUSED(classInfo
))
562 o
= m_data
->GetObject(objectID
);
566 void wxRuntimeDepersister::SetProperty(int objectID
,
567 const wxClassInfo
*WXUNUSED(classInfo
),
568 const wxPropertyInfo
* propertyInfo
,
569 const wxxVariant
&value
)
572 o
= m_data
->GetObject(objectID
);
573 propertyInfo
->GetAccessor()->SetProperty( o
, value
) ;
576 void wxRuntimeDepersister::SetPropertyAsObject(int objectID
,
577 const wxClassInfo
*WXUNUSED(classInfo
),
578 const wxPropertyInfo
* propertyInfo
,
582 o
= m_data
->GetObject(objectID
);
583 valo
= m_data
->GetObject(valueObjectId
);
584 propertyInfo
->GetAccessor()->SetProperty( o
,
585 (dynamic_cast<const wxClassTypeInfo
*>(propertyInfo
->GetTypeInfo()))->GetClassInfo()->InstanceToVariant(valo
) ) ;
588 void wxRuntimeDepersister::SetConnect(int eventSourceObjectID
,
589 const wxClassInfo
*WXUNUSED(eventSourceClassInfo
),
590 const wxDelegateTypeInfo
*delegateInfo
,
591 const wxClassInfo
*WXUNUSED(eventSinkClassInfo
) ,
592 const wxHandlerInfo
* handlerInfo
,
593 int eventSinkObjectID
)
595 wxWindow
*ehsource
= dynamic_cast< wxWindow
* >( m_data
->GetObject( eventSourceObjectID
) ) ;
596 wxEvtHandler
*ehsink
= dynamic_cast< wxEvtHandler
*>(m_data
->GetObject(eventSinkObjectID
) ) ;
598 if ( ehsource
&& ehsink
)
600 ehsource
->Connect( ehsource
->GetId() , delegateInfo
->GetEventType() ,
601 handlerInfo
->GetEventFunction() , NULL
/*user data*/ ,
606 wxObject
*wxRuntimeDepersister::GetObject(int objectID
)
608 return m_data
->GetObject( objectID
) ;
612 // ----------------------------------------------------------------------------
613 // depersisting to code
614 // ----------------------------------------------------------------------------
616 struct wxCodeDepersister::wxCodeDepersisterInternal
618 map
<int,string
> m_objectNames
;
620 void SetObjectName(int objectID
, const wxString
&name
)
622 assert( m_objectNames
.find(objectID
) == m_objectNames
.end() ) ;
623 m_objectNames
[objectID
] = (const char *)name
;
625 wxString
GetObjectName( int objectID
)
627 if ( objectID
== wxNullObjectID
)
630 assert( m_objectNames
.find(objectID
) != m_objectNames
.end() ) ;
631 return wxString( m_objectNames
[objectID
].c_str() ) ;
635 wxCodeDepersister::wxCodeDepersister(wxTextOutputStream
*out
)
638 m_data
= new wxCodeDepersisterInternal
;
641 wxCodeDepersister::~wxCodeDepersister()
646 void wxCodeDepersister::AllocateObject(int objectID
, wxClassInfo
*classInfo
)
648 wxString objectName
= wxString::Format( "LocalObject_%d" , objectID
) ;
649 m_fp
->WriteString( wxString::Format( "\t%s *%s = new %s;\n",
650 classInfo
->GetClassName(),
652 classInfo
->GetClassName()) );
653 m_data
->SetObjectName( objectID
, objectName
) ;
656 void wxCodeDepersister::DestroyObject(int objectID
, wxClassInfo
*WXUNUSED(classInfo
))
658 m_fp
->WriteString( wxString::Format( "\tdelete %s;\n",
659 m_data
->GetObjectName( objectID
) ) );
662 wxString
wxCodeDepersister::ValueAsCode( const wxxVariant
¶m
)
665 const wxTypeInfo
* type
= param
.GetTypeInfo() ;
666 if ( type
->GetKind() == wxT_CUSTOM
)
668 const wxCustomTypeInfo
* cti
= dynamic_cast<const wxCustomTypeInfo
*>(type
) ;
669 wxASSERT_MSG( cti
, wxT("Internal error, illegal wxCustomTypeInfo") ) ;
670 value
.Printf( "%s(%s)",cti
->GetTypeName(),param
.GetAsString() );
672 else if ( type
->GetKind() == wxT_STRING
)
674 value
.Printf( "\"%s\"",param
.GetAsString() );
678 value
.Printf( "%s", param
.GetAsString() );
683 void wxCodeDepersister::CreateObject(int objectID
,
684 const wxClassInfo
*WXUNUSED(classInfo
),
688 const wxClassInfo
**WXUNUSED(objectClassInfos
)
692 m_fp
->WriteString( wxString::Format( "\t%s->Create(", m_data
->GetObjectName(objectID
) ) );
693 for (i
= 0; i
< paramCount
; i
++)
695 if ( objectIDValues
[i
] != wxInvalidObjectID
)
696 m_fp
->WriteString( wxString::Format( "%s", m_data
->GetObjectName( objectIDValues
[i
] ) ) );
699 m_fp
->WriteString( wxString::Format( "%s", ValueAsCode(params
[i
]) ) );
701 if (i
< paramCount
- 1)
702 m_fp
->WriteString( ", ");
704 m_fp
->WriteString( ");\n");
707 void wxCodeDepersister::SetProperty(int objectID
,
708 const wxClassInfo
*WXUNUSED(classInfo
),
709 const wxPropertyInfo
* propertyInfo
,
710 const wxxVariant
&value
)
712 m_fp
->WriteString( wxString::Format( "\t%s->%s(%s);\n",
713 m_data
->GetObjectName(objectID
),
714 propertyInfo
->GetAccessor()->GetSetterName(),
715 ValueAsCode(value
)) );
718 void wxCodeDepersister::SetPropertyAsObject(int objectID
,
719 const wxClassInfo
*WXUNUSED(classInfo
),
720 const wxPropertyInfo
* propertyInfo
,
723 if ( propertyInfo
->GetTypeInfo()->GetKind() == wxT_OBJECT
)
724 m_fp
->WriteString( wxString::Format( "\t%s->%s(*%s);\n",
725 m_data
->GetObjectName(objectID
),
726 propertyInfo
->GetAccessor()->GetSetterName(),
727 m_data
->GetObjectName( valueObjectId
) ) );
729 m_fp
->WriteString( wxString::Format( "\t%s->%s(%s);\n",
730 m_data
->GetObjectName(objectID
),
731 propertyInfo
->GetAccessor()->GetSetterName(),
732 m_data
->GetObjectName( valueObjectId
) ) );
735 void wxCodeDepersister::SetConnect(int eventSourceObjectID
,
736 const wxClassInfo
*WXUNUSED(eventSourceClassInfo
),
737 const wxDelegateTypeInfo
*delegateInfo
,
738 const wxClassInfo
*eventSinkClassInfo
,
739 const wxHandlerInfo
* handlerInfo
,
740 int eventSinkObjectID
)
742 wxString ehsource
= m_data
->GetObjectName( eventSourceObjectID
) ;
743 wxString ehsink
= m_data
->GetObjectName(eventSinkObjectID
) ;
744 wxString ehsinkClass
= eventSinkClassInfo
->GetClassName() ;
745 int eventType
= delegateInfo
->GetEventType() ;
746 wxString handlerName
= handlerInfo
->GetName() ;
748 m_fp
->WriteString( wxString::Format( "\t%s->Connect( %s->GetId() , %d , (wxObjectEventFunction)(wxEventFunction) & %s::%s , NULL , %s ) ;" ,
749 ehsource
, ehsource
, eventType
, ehsinkClass
, handlerName
, ehsink
) );