xti changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66630 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2011-01-07 17:49:18 +00:00
parent 44370b509e
commit e765d7ee73
14 changed files with 328 additions and 188 deletions

View File

@ -516,6 +516,14 @@ public:
return false;
}
#if wxUSE_EXTENDED_RTTI
virtual const wxTypeInfo* GetTypeInfo() const
{
wxFAIL_MSG("Null Type Info not available");
return NULL;
}
#endif
private:
};

View File

@ -32,6 +32,11 @@ IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(wxBitmap,WXDLLEXPORT)
IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(wxIcon,WXDLLEXPORT)
#endif
#if wxUSE_EXTENDED_RTTI
//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxBitmap>)
//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxIcon>)
#endif
// ----------------------------------------------------------------------------
// wxBitmapBase
// ----------------------------------------------------------------------------

View File

@ -59,7 +59,7 @@ wxFROM_STRING_IMP( wxColour )
wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( wxColour, wxObject, \
"wx/colour.h", &wxTO_STRING( wxColour ), &wxFROM_STRING( wxColour ))
//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxColour>)
wxBEGIN_PROPERTIES_TABLE(wxColour)
wxREADONLY_PROPERTY( Red, unsigned char, Red, wxEMPTY_PARAMETER_VALUE, \
0 /*flags*/, wxT("Helpstring"), wxT("group"))

View File

@ -76,37 +76,39 @@ extern const char *wxDumpFont(const wxFont *font)
// ----------------------------------------------------------------------------
wxBEGIN_ENUM( wxFontFamily )
wxENUM_MEMBER( wxDEFAULT )
wxENUM_MEMBER( wxDECORATIVE )
wxENUM_MEMBER( wxROMAN )
wxENUM_MEMBER( wxSCRIPT )
wxENUM_MEMBER( wxSWISS )
wxENUM_MEMBER( wxMODERN )
wxENUM_MEMBER( wxTELETYPE )
wxENUM_MEMBER( wxFONTFAMILY_DEFAULT )
wxENUM_MEMBER( wxFONTFAMILY_DECORATIVE )
wxENUM_MEMBER( wxFONTFAMILY_ROMAN )
wxENUM_MEMBER( wxFONTFAMILY_SCRIPT )
wxENUM_MEMBER( wxFONTFAMILY_SWISS )
wxENUM_MEMBER( wxFONTFAMILY_MODERN )
wxENUM_MEMBER( wxFONTFAMILY_TELETYPE )
wxEND_ENUM( wxFontFamily )
wxBEGIN_ENUM( wxFontStyle )
wxENUM_MEMBER( wxNORMAL )
wxENUM_MEMBER( wxITALIC )
wxENUM_MEMBER( wxSLANT )
wxENUM_MEMBER( wxFONTSTYLE_NORMAL )
wxENUM_MEMBER( wxFONTSTYLE_ITALIC )
wxENUM_MEMBER( wxFONTSTYLE_SLANT )
wxEND_ENUM( wxFontStyle )
wxBEGIN_ENUM( wxFontWeight )
wxENUM_MEMBER( wxNORMAL )
wxENUM_MEMBER( wxLIGHT )
wxENUM_MEMBER( wxBOLD )
wxENUM_MEMBER( wxFONTWEIGHT_NORMAL )
wxENUM_MEMBER( wxFONTWEIGHT_LIGHT )
wxENUM_MEMBER( wxFONTWEIGHT_BOLD )
wxEND_ENUM( wxFontWeight )
wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI(wxFont, wxGDIObject, "wx/font.h")
//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxFont>)
wxBEGIN_PROPERTIES_TABLE(wxFont)
wxPROPERTY( Size,int, SetPointSize, GetPointSize, 12, 0 /*flags*/, \
wxT("Helpstring"), wxT("group"))
wxPROPERTY( Family, int , SetFamily, GetFamily, (int)wxDEFAULT, \
wxPROPERTY( Family, wxFontFamily , SetFamily, GetFamily, (wxFontFamily)wxDEFAULT, \
0 /*flags*/, wxT("Helpstring"), wxT("group")) // wxFontFamily
wxPROPERTY( Style, int, SetStyle, GetStyle, (int)wxNORMAL, 0 /*flags*/, \
wxPROPERTY( Style, wxFontStyle, SetStyle, GetStyle, (wxFontStyle)wxNORMAL, 0 /*flags*/, \
wxT("Helpstring"), wxT("group")) // wxFontStyle
wxPROPERTY( Weight, int, SetWeight, GetWeight, (int)wxNORMAL, 0 /*flags*/, \
wxPROPERTY( Weight, wxFontWeight, SetWeight, GetWeight, (wxFontWeight)wxNORMAL, 0 /*flags*/, \
wxT("Helpstring"), wxT("group")) // wxFontWeight
wxPROPERTY( Underlined, bool, SetUnderlined, GetUnderlined, false, 0 /*flags*/, \
wxT("Helpstring"), wxT("group"))
@ -116,7 +118,7 @@ wxPROPERTY( Encoding, wxFontEncoding, SetEncoding, GetEncoding, \
wxFONTENCODING_DEFAULT, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
wxEND_PROPERTIES_TABLE()
wxCONSTRUCTOR_6( wxFont, int, Size, int, Family, int, Style, int, Weight, \
wxCONSTRUCTOR_6( wxFont, int, Size, wxFontFamily, Family, wxFontStyle, Style, wxFontWeight, Weight, \
bool, Underlined, wxString, Face )
wxEMPTY_HANDLERS_TABLE(wxFont)

View File

@ -21,9 +21,9 @@
#include "wx/ipcbase.h"
IMPLEMENT_CLASS(wxServerBase, wxObject)
IMPLEMENT_CLASS(wxClientBase, wxObject)
IMPLEMENT_CLASS(wxConnectionBase, wxObject)
wxIMPLEMENT_ABSTRACT_CLASS(wxServerBase, wxObject)
wxIMPLEMENT_ABSTRACT_CLASS(wxClientBase, wxObject)
wxIMPLEMENT_ABSTRACT_CLASS(wxConnectionBase, wxObject)
wxConnectionBase::wxConnectionBase(void *buffer, size_t bytes)
: m_buffer((char *)buffer),

View File

@ -65,9 +65,9 @@ wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxMenu, wxEvtHandler, "wx/menu.h")
wxCOLLECTION_TYPE_INFO( wxMenuItem *, wxMenuItemList ) ;
template<> void wxCollectionToVariantArray( wxMenuItemList const &theList,
wxVariantBaseArray &value)
wxAnyList &value)
{
wxListCollectionToVariantArray<wxMenuItemList::compatibility_iterator>( theList, value ) ;
wxListCollectionToAnyList<wxMenuItemList::compatibility_iterator>( theList, value ) ;
}
wxBEGIN_PROPERTIES_TABLE(wxMenu)
@ -97,7 +97,7 @@ wxEND_FLAGS( wxMenuBarStyle )
// the negative id would lead the window (its superclass !) to
// vetoe streaming out otherwise
bool wxMenuBarStreamingCallback( const wxObject *WXUNUSED(object), wxObjectWriter *,
wxObjectReaderCallback *, wxVariantBaseArray & )
wxObjectWriterCallback *, const wxStringToAnyHashMap & )
{
return true;
}
@ -122,9 +122,9 @@ wxCONSTRUCTOR_2( wxMenuInfo, wxMenu*, Menu, wxString, Title )
wxCOLLECTION_TYPE_INFO( wxMenuInfo *, wxMenuInfoList ) ;
template<> void wxCollectionToVariantArray( wxMenuInfoList const &theList,
wxVariantBaseArray &value)
wxAnyList &value)
{
wxListCollectionToVariantArray<wxMenuInfoList::compatibility_iterator>( theList, value ) ;
wxListCollectionToAnyList<wxMenuInfoList::compatibility_iterator>( theList, value ) ;
}
wxBEGIN_PROPERTIES_TABLE(wxMenuBar)
@ -136,6 +136,25 @@ wxEMPTY_HANDLERS_TABLE(wxMenuBar)
wxCONSTRUCTOR_DUMMY( wxMenuBar )
const wxMenuInfoList& wxMenuBarBase::GetMenuInfos() const
{
wxMenuInfoList* list = const_cast< wxMenuInfoList* > (& m_menuInfos);
WX_CLEAR_LIST( wxMenuInfoList, *list);
for (size_t i = 0 ; i < GetMenuCount(); ++i)
{
wxMenuInfo* info = new wxMenuInfo();
info->Create( GetMenu(i), GetMenuLabel(i));
list->Append(info);
}
return m_menuInfos;
}
/*
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxMenu**>)
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxMenuItem**>)
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxMenuBar**>)
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxMenuInfo**>)
*/
#else
// IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
// IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxWindow)
@ -150,7 +169,7 @@ wxCONSTRUCTOR_DUMMY( wxMenuBar )
#if wxUSE_EXTENDED_RTTI
bool wxMenuItemStreamingCallback( const wxObject *object, wxObjectWriter *,
wxObjectReaderCallback *, wxVariantBaseArray & )
wxObjectWriterCallback *, const wxStringToAnyHashMap & )
{
const wxMenuItem * mitem = wx_dynamic_cast(const wxMenuItem*, object);
if ( mitem->GetMenu() && !mitem->GetMenu()->GetTitle().empty() )
@ -164,6 +183,8 @@ bool wxMenuItemStreamingCallback( const wxObject *object, wxObjectWriter *,
return true;
}
#endif
wxBEGIN_ENUM( wxItemKind )
wxENUM_MEMBER( wxITEM_SEPARATOR )
wxENUM_MEMBER( wxITEM_NORMAL )
@ -179,7 +200,7 @@ wxPROPERTY( Parent, wxMenu*, SetMenu, GetMenu, wxEMPTY_PARAMETER_VALUE, \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
wxPROPERTY( Id, int, SetId, GetId, wxEMPTY_PARAMETER_VALUE, \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
wxPROPERTY( Text, wxString, SetText, GetText, wxString(), \
wxPROPERTY( ItemLabel, wxString, SetItemLabel, GetItemLabel, wxString(), \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
wxPROPERTY( Help, wxString, SetHelp, GetHelp, wxString(), \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
@ -187,11 +208,11 @@ wxREADONLY_PROPERTY( Kind, wxItemKind, GetKind, wxEMPTY_PARAMETER_VALUE, \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
wxPROPERTY( SubMenu, wxMenu*, SetSubMenu, GetSubMenu, wxEMPTY_PARAMETER_VALUE, \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
wxPROPERTY( Enabled, bool, Enable, IsEnabled, wxVariantBase((bool)true), \
wxPROPERTY( Enabled, bool, Enable, IsEnabled, wxAny((bool)true), \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
wxPROPERTY( Checked, bool, Check, IsChecked, wxVariantBase((bool)false), \
wxPROPERTY( Checked, bool, Check, IsChecked, wxAny((bool)false), \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
wxPROPERTY( Checkable, bool, SetCheckable, IsCheckable, wxVariantBase((bool)false), \
wxPROPERTY( Checkable, bool, SetCheckable, IsCheckable, wxAny((bool)false), \
0 /*flags*/, wxT("Helpstring"), wxT("group") )
wxEND_PROPERTIES_TABLE()
@ -199,9 +220,6 @@ wxEMPTY_HANDLERS_TABLE(wxMenuItem)
wxDIRECT_CONSTRUCTOR_6( wxMenuItem, wxMenu*, Parent, int, Id, wxString, \
Text, wxString, Help, wxItemKind, Kind, wxMenu*, SubMenu )
#else
//IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
#endif
// ----------------------------------------------------------------------------
// wxMenuItemBase

View File

@ -30,7 +30,7 @@
WX_DEFINE_LIST(wxModuleList)
IMPLEMENT_CLASS(wxModule, wxObject)
wxIMPLEMENT_ABSTRACT_CLASS(wxModule, wxObject)
wxModuleList wxModule::m_modules;

View File

@ -93,13 +93,11 @@ wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject, "wx/notebook.h" )
wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo *, wxNotebookPageInfoList );
#if wxUSE_EXTENDED_RTTI
template<> void wxCollectionToVariantArray( wxNotebookPageInfoList const &theList,
wxVariantBaseArray &value)
wxAnyList &value)
{
wxListCollectionToVariantArray<wxNotebookPageInfoList::compatibility_iterator>( theList, value );
wxListCollectionToAnyList<wxNotebookPageInfoList::compatibility_iterator>( theList, value );
}
#endif
wxBEGIN_PROPERTIES_TABLE(wxNotebook)
wxEVENT_PROPERTY( PageChanging, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, wxNotebookEvent )
@ -134,6 +132,7 @@ wxEMPTY_HANDLERS_TABLE(wxNotebookPageInfo)
wxCONSTRUCTOR_4( wxNotebookPageInfo, wxNotebookPage*, Page, \
wxString, Text, bool, Selected, int, ImageId )
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxNotebookPageInfo**>)
// XTI accessors:
void wxNotebookBase::AddPageInfo( wxNotebookPageInfo* info )

View File

@ -44,21 +44,20 @@
#if wxUSE_EXTENDED_RTTI
const wxClassInfo* wxObject::ms_classParents[] = { NULL } ;
wxObject* wxVariantToObjectConverterwxObject ( wxxVariant &data )
{ return data.wxTEMPLATED_MEMBER_CALL(Get , wxObject*) ; }
wxObject* wxVariantOfPtrToObjectConverterwxObject ( wxxVariant &data )
{ return &data.wxTEMPLATED_MEMBER_CALL(Get , wxObject) ; }
wxxVariant wxObjectToVariantConverterwxObject ( wxObject *data )
{ return wxxVariant( dynamic_cast<wxObject*> (data) ) ; }
wxObject* wxVariantOfPtrToObjectConverterwxObject ( const wxAny &data )
{ return wxANY_AS(data, wxObject*); }
wxAny wxObjectToVariantConverterwxObject ( wxObject *data )
{ return wxAny( dynamic_cast<wxObject*> (data) ) ; }
wxClassInfo wxObject::ms_classInfo(ms_classParents , wxEmptyString , wxT("wxObject"),
(int) sizeof(wxObject), \
(wxObjectConstructorFn) 0 ,
NULL,NULL,0 , 0 ,
0 , wxVariantOfPtrToObjectConverterwxObject , wxVariantToObjectConverterwxObject , wxObjectToVariantConverterwxObject);
template<> void wxStringReadValue(const wxString & , wxObject * & ){ wxFAIL_MSG("unreachable"); }
0 , wxVariantOfPtrToObjectConverterwxObject , 0 , wxObjectToVariantConverterwxObject);
template<> void wxStringWriteValue(wxString & , wxObject* const & ){ wxFAIL_MSG("unreachable"); }
template<> void wxStringReadValue(const wxString & , wxObject & ){ wxFAIL_MSG("unreachable"); }
template<> void wxStringWriteValue(wxString & , wxObject const & ){ wxFAIL_MSG("unreachable"); }
wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &wxObject::ms_classInfo , NULL , NULL , typeid(wxObject*).name() ) ;
wxClassTypeInfo s_typeInfowxObject(wxT_OBJECT , &wxObject::ms_classInfo , NULL , NULL , typeid(wxObject).name() ) ;
#else

View File

@ -70,7 +70,7 @@ wxFLAGS_MEMBER(wxSP_ARROW_KEYS)
wxFLAGS_MEMBER(wxSP_WRAP)
wxEND_FLAGS( wxSpinCtrlStyle )
wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxSpinCtrl, wxControl, "wx/spinbut.h")
wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxSpinCtrl, wxControl, "wx/spinctrl.h")
wxBEGIN_PROPERTIES_TABLE(wxSpinCtrl)
wxEVENT_RANGE_PROPERTY( Spin, wxEVT_SCROLL_TOP, wxEVT_SCROLL_CHANGED, wxSpinEvent )

View File

@ -127,8 +127,9 @@ END_EVENT_TABLE()
// separately otherwise chaos occurs. Right now easiest is to test for negative ids,
// as windows with negative ids never can be recreated anyway
bool wxWindowStreamingCallback( const wxObject *object, wxObjectWriter *,
wxObjectReaderCallback *, wxVariantBaseArray & )
wxObjectWriterCallback *, const wxStringToAnyHashMap & )
{
const wxWindow * win = wx_dynamic_cast(const wxWindow*, object);
if ( win && win->GetId() < 0 )
@ -144,9 +145,9 @@ wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxWindow, wxWindowBase, "wx/window.h", \
wxCOLLECTION_TYPE_INFO( wxWindow*, wxWindowList );
template<> void wxCollectionToVariantArray( wxWindowList const &theList,
wxVariantBaseArray &value)
wxAnyList &value)
{
wxListCollectionToVariantArray<wxWindowList::compatibility_iterator>( theList, value );
wxListCollectionToAnyList<wxWindowList::compatibility_iterator>( theList, value );
}
wxDEFINE_FLAGS( wxWindowStyle )
@ -215,9 +216,9 @@ wxPROPERTY( BackgroundColour, wxColour, SetBackgroundColour, GetBackgroundColour
wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) // bg
wxPROPERTY( ForegroundColour, wxColour, SetForegroundColour, GetForegroundColour, \
wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) // fg
wxPROPERTY( Enabled, bool, Enable, IsEnabled, wxVariantBase((bool)true), 0 /*flags*/, \
wxPROPERTY( Enabled, bool, Enable, IsEnabled, wxAny((bool)true), 0 /*flags*/, \
wxT("Helpstring"), wxT("group"))
wxPROPERTY( Shown, bool, Show, IsShown, wxVariantBase((bool)true), 0 /*flags*/, \
wxPROPERTY( Shown, bool, Show, IsShown, wxAny((bool)true), 0 /*flags*/, \
wxT("Helpstring"), wxT("group"))
#if 0

View File

@ -28,6 +28,8 @@
#include "wx/xti.h"
#include "wx/xml/xml.h"
#include "wx/tokenzr.h"
#include "wx/range.h"
#include <string.h>
#include "wx/beforestd.h"
@ -200,6 +202,27 @@ template<> void wxStringWriteValue(wxString &s, const unsigned long &data )
s = wxString::Format(_T("%ld"), data );
}
#ifdef wxLongLong_t
template<> void wxStringReadValue(const wxString &s, wxLongLong_t &data )
{
wxSscanf(s, _T("%lld"), &data );
}
template<> void wxStringWriteValue(wxString &s, const wxLongLong_t &data )
{
s = wxString::Format(_T("%lld"), data );
}
template<> void wxStringReadValue(const wxString &s, wxULongLong_t &data )
{
wxSscanf(s, _T("%lld"), &data );
}
template<> void wxStringWriteValue(wxString &s, const wxULongLong_t &data )
{
s = wxString::Format(_T("%lld"), data );
}
#endif
// float
template<> void wxStringReadValue(const wxString &s, float &data )
@ -247,9 +270,9 @@ template<> void wxStringWriteValue(wxString &s, const wxString &data )
&wxFromStringConverter<type>, typeid(type).name());
#else
#define wxBUILTIN_TYPE_INFO( element, type ) \
void _toString##element( const wxVariantBase& data, wxString &result ) \
void _toString##element( const wxAny& data, wxString &result ) \
{ wxToStringConverter<type, data, result); } \
void _fromString##element( const wxString& data, wxVariantBase &result ) \
void _fromString##element( const wxString& data, wxAny &result ) \
{ wxFromStringConverter<type, data, result); } \
wxBuiltInTypeInfo s_typeInfo##type(element, &_toString##element, \
&_fromString##element, typeid(type).name());
@ -271,6 +294,10 @@ wxBUILTIN_TYPE_INFO( wxT_FLOAT, float);
wxBUILTIN_TYPE_INFO( wxT_DOUBLE, double);
wxBUILTIN_TYPE_INFO( wxT_STRING, wxString);
#ifdef wxLongLong_t
wxBUILTIN_TYPE_INFO(wxT_LONGLONG, wxLongLong_t)
wxBUILTIN_TYPE_INFO(wxT_ULONGLONG, wxULongLong_t)
#endif
// this are compiler induced specialization which are never used anywhere
@ -282,17 +309,35 @@ wxILLEGAL_TYPE_SPECIALIZATION( bool * )
wxILLEGAL_TYPE_SPECIALIZATION( long * )
wxILLEGAL_TYPE_SPECIALIZATION( wxString * )
// wxRange
template<> void wxStringReadValue(const wxString &s , wxRange &data)
{
int minValue, maxValue;
wxSscanf(s, wxT("%d,%d"), &minValue , &maxValue);
data = wxRange(minValue, maxValue);
}
template<> void wxStringWriteValue(wxString &s , const wxRange &data)
{
s = wxString::Format(wxT("%d,%d"), data.GetMin() , data.GetMax());
}
wxCUSTOM_TYPE_INFO(wxRange, wxToStringConverter<wxRange> , wxFromStringConverter<wxRange>)
// other types
wxCOLLECTION_TYPE_INFO( wxString, wxArrayString );
template<> void wxCollectionToVariantArray( wxArrayString const &theArray,
wxVariantBaseArray &value)
wxAnyList &value)
{
wxArrayCollectionToVariantArray( theArray, value );
}
wxTypeInfoMap *wxTypeInfo::ms_typeTable = NULL;
wxTypeInfo *wxTypeInfo::FindType(const wxChar *typeName)
wxTypeInfo *wxTypeInfo::FindType(const wxString& typeName)
{
wxTypeInfoMap::iterator iter = ms_typeTable->find(typeName);
@ -418,6 +463,7 @@ void wxPropertyInfo::Remove()
info = info->m_next;
}
}
}
// ----------------------------------------------------------------------------
@ -466,7 +512,7 @@ void wxHandlerInfo::Remove()
// wxClassInfo
// ----------------------------------------------------------------------------
bool wxClassInfo::Create(wxObject *object, int ParamCount, wxVariantBase *Params) const
bool wxClassInfo::Create(wxObject *object, int ParamCount, wxAny *Params) const
{
if ( ParamCount != m_constructorPropertiesCount )
{
@ -478,7 +524,7 @@ bool wxClassInfo::Create(wxObject *object, int ParamCount, wxVariantBase *Params
return m_constructor->Create( object, Params );
}
wxObject *wxClassInfo::ConstructObject(int ParamCount, wxVariantBase *Params) const
wxObject *wxClassInfo::ConstructObject(int ParamCount, wxAny *Params) const
{
if ( ParamCount != m_constructorPropertiesCount )
{
@ -521,7 +567,7 @@ const wxPropertyAccessor *wxClassInfo::FindAccessor(const wxChar *PropertyName)
wxPropertyInfo *wxClassInfo::FindPropertyInfoInThisClass (const wxChar *PropertyName) const
{
wxPropertyInfo* info = m_firstProperty;
wxPropertyInfo* info = GetFirstProperty();
while( info )
{
@ -551,7 +597,7 @@ const wxPropertyInfo *wxClassInfo::FindPropertyInfo (const wxChar *PropertyName)
wxHandlerInfo *wxClassInfo::FindHandlerInfoInThisClass (const wxChar *PropertyName) const
{
wxHandlerInfo* info = m_firstHandler;
wxHandlerInfo* info = GetFirstHandler();
while( info )
{
@ -595,17 +641,17 @@ wxObjectStreamingCallback wxClassInfo::GetStreamingCallback() const
}
bool wxClassInfo::BeforeWriteObject( const wxObject *obj, wxObjectWriter *streamer,
wxObjectReaderCallback *persister, wxVariantBaseArray &metadata) const
wxObjectWriterCallback *writercallback, const wxStringToAnyHashMap &metadata) const
{
wxObjectStreamingCallback sb = GetStreamingCallback();
if ( sb )
return (*sb)(obj, streamer, persister, metadata );
return (*sb)(obj, streamer, writercallback, metadata );
return true;
}
void wxClassInfo::SetProperty(wxObject *object, const wxChar *propertyName,
const wxVariantBase &value) const
const wxAny &value) const
{
const wxPropertyAccessor *accessor;
@ -614,31 +660,31 @@ void wxClassInfo::SetProperty(wxObject *object, const wxChar *propertyName,
accessor->SetProperty( object, value );
}
wxVariantBase wxClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
wxAny wxClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
{
const wxPropertyAccessor *accessor;
accessor = FindAccessor(propertyName);
wxASSERT(accessor->HasGetter());
wxVariantBase result;
wxAny result;
accessor->GetProperty(object,result);
return result;
}
wxVariantBaseArray wxClassInfo::GetPropertyCollection(wxObject *object,
wxAnyList wxClassInfo::GetPropertyCollection(wxObject *object,
const wxChar *propertyName) const
{
const wxPropertyAccessor *accessor;
accessor = FindAccessor(propertyName);
wxASSERT(accessor->HasGetter());
wxVariantBaseArray result;
wxAnyList result;
accessor->GetPropertyCollection(object,result);
return result;
}
void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *propertyName,
const wxVariantBase& value) const
const wxAny& value) const
{
const wxPropertyAccessor *accessor;
@ -668,6 +714,23 @@ void wxClassInfo::GetProperties( wxPropertyInfoMap &infomap ) const
}
}
wxObject* wxClassInfo::AnyToObjectPtr( const wxAny &data) const
{
return m_variantOfPtrToObjectConverter(data);
}
void wxClassInfo::CallOnAny( const wxAny &data, wxObjectFunctor* functor ) const
{
if ( data.GetTypeInfo()->GetKind() == wxT_OBJECT )
return m_variantToObjectConverter(data, functor);
else
return (*functor)(m_variantOfPtrToObjectConverter(data));
}
wxAny wxClassInfo::ObjectPtrToAny( wxObject* obj) const
{
return m_objectToVariantConverter(obj);
}
// ----------------------------------------------------------------------------
// wxDynamicObject support
@ -681,11 +744,7 @@ struct wxDynamicObject::wxDynamicObjectInternal
{
wxDynamicObjectInternal() {}
#if wxUSE_UNICODE
map<wstring,wxVariantBase> m_properties;
#else
map<string,wxVariantBase> m_properties;
#endif
wxStringToAnyHashMap m_properties;
};
typedef list< wxDynamicObject* > wxDynamicObjectList;
@ -711,14 +770,14 @@ wxDynamicObject::~wxDynamicObject()
delete m_superClassInstance;
}
void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxVariantBase &value)
void wxDynamicObject::SetProperty (const wxChar *propertyName, const wxAny &value)
{
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),
wxT("Accessing Unknown Property in a Dynamic Object") );
m_data->m_properties[propertyName] = value;
}
wxVariantBase wxDynamicObject::GetProperty (const wxChar *propertyName) const
wxAny wxDynamicObject::GetProperty (const wxChar *propertyName) const
{
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(propertyName),
wxT("Accessing Unknown Property in a Dynamic Object") );
@ -738,7 +797,7 @@ void wxDynamicObject::RenameProperty( const wxChar *oldPropertyName,
wxASSERT_MSG(m_classInfo->FindPropertyInfoInThisClass(oldPropertyName),
wxT("Renaming Unknown Property in a Dynamic Object") );
wxVariantBase value = m_data->m_properties[oldPropertyName];
wxAny value = m_data->m_properties[oldPropertyName];
m_data->m_properties.erase( oldPropertyName );
m_data->m_properties[newPropertyName] = value;
}
@ -772,7 +831,7 @@ wxObject *wxDynamicClassInfo::AllocateObject() const
return obj;
}
bool wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxVariantBase *params) const
bool wxDynamicClassInfo::Create (wxObject *object, int paramCount, wxAny *params) const
{
wxDynamicObject *dynobj = wx_dynamic_cast( wxDynamicObject *, object );
wxASSERT_MSG( dynobj,
@ -794,7 +853,7 @@ const wxChar* wxDynamicClassInfo::GetCreateParamName(int i) const
return GetParents()[0]->GetCreateParamName( i );
}
void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxVariantBase &value) const
void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyName, const wxAny &value) const
{
wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object);
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
@ -804,7 +863,7 @@ void wxDynamicClassInfo::SetProperty(wxObject *object, const wxChar *propertyNam
GetParents()[0]->SetProperty( dynobj->GetSuperClassInstance(), propertyName, value );
}
wxVariantBase wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
wxAny wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *propertyName) const
{
wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object);
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
@ -816,11 +875,13 @@ wxVariantBase wxDynamicClassInfo::GetProperty(wxObject *object, const wxChar *pr
void wxDynamicClassInfo::AddProperty( const wxChar *propertyName, const wxTypeInfo* typeInfo )
{
new wxPropertyInfo( m_firstProperty, this, propertyName, typeInfo->GetTypeName(), new wxGenericPropertyAccessor( propertyName ), wxVariantBase() );
EnsureInfosInited();
new wxPropertyInfo( m_firstProperty, this, propertyName, typeInfo->GetTypeName(), new wxGenericPropertyAccessor( propertyName ), wxAny() );
}
void wxDynamicClassInfo::AddHandler( const wxChar *handlerName, wxObjectEventFunction address, const wxClassInfo* eventClassInfo )
{
EnsureInfosInited();
new wxHandlerInfo( m_firstHandler, this, handlerName, address, eventClassInfo );
}
@ -879,18 +940,46 @@ wxGenericPropertyAccessor::~wxGenericPropertyAccessor()
delete m_data;
}
void wxGenericPropertyAccessor::SetProperty(wxObject *object, const wxVariantBase &value) const
void wxGenericPropertyAccessor::SetProperty(wxObject *object, const wxAny &value) const
{
wxDynamicObject* dynobj = wx_dynamic_cast(wxDynamicObject*, object);
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
dynobj->SetProperty(m_propertyName, value );
}
void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxVariantBase& value) const
void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxAny& value) const
{
const wxDynamicObject* dynobj = wx_dynamic_cast( const wxDynamicObject * , object );
wxASSERT_MSG( dynobj, wxT("cannot call wxDynamicClassInfo::SetProperty on an object other than wxDynamicObject") );
value = dynobj->GetProperty( m_propertyName );
}
// ----------------------------------------------------------------------------
// wxGenericPropertyAccessor
// ----------------------------------------------------------------------------
wxString wxAnyGetAsString( const wxAny& data)
{
if ( data.IsNull() || data.GetTypeInfo()==NULL )
return wxEmptyString;
wxString s;
data.GetTypeInfo()->ConvertToString(data,s);
return s;
}
const wxObject* wxAnyGetAsObjectPtr( const wxAny& data)
{
if ( !data.IsNull() )
{
const wxClassTypeInfo* ti = wx_dynamic_cast(const wxClassTypeInfo*, data.GetTypeInfo());
if( ti )
return ti->GetClassInfo()->AnyToObjectPtr(data);
}
return NULL;
}
wxObjectFunctor::~wxObjectFunctor()
{};
#endif // wxUSE_EXTENDED_RTTI

View File

@ -73,22 +73,22 @@ void wxObjectWriter::ClearObjectContext()
}
void wxObjectWriter::WriteObject(const wxObject *object, const wxClassInfo *classInfo,
wxObjectReaderCallback *persister, const wxString &name,
wxVariantBaseArray &metadata )
wxObjectWriterCallback *writercallback, const wxString &name,
const wxStringToAnyHashMap &metadata )
{
DoBeginWriteTopLevelEntry( name );
WriteObject( object, classInfo, persister, false, metadata);
WriteObject( object, classInfo, writercallback, false, metadata);
DoEndWriteTopLevelEntry( name );
}
void wxObjectWriter::WriteObject(const wxObject *object, const wxClassInfo *classInfo,
wxObjectReaderCallback *persister, bool isEmbedded,
wxVariantBaseArray &metadata )
wxObjectWriterCallback *writercallback, bool isEmbedded,
const wxStringToAnyHashMap &metadata )
{
if ( !classInfo->BeforeWriteObject( object, this, persister, metadata) )
if ( !classInfo->BeforeWriteObject( object, this, writercallback, metadata) )
return;
if ( persister->BeforeWriteObject( this, object, classInfo, metadata) )
if ( writercallback->BeforeWriteObject( this, object, classInfo, metadata) )
{
if ( object == NULL )
DoWriteNullObject();
@ -108,10 +108,10 @@ void wxObjectWriter::WriteObject(const wxObject *object, const wxClassInfo *clas
DoBeginWriteObject( object, classInfo, oid, metadata );
wxObjectWriterInternalPropertiesData data;
WriteAllProperties( object, classInfo, persister, &data );
WriteAllProperties( object, classInfo, writercallback, &data );
DoEndWriteObject( object, classInfo, oid );
}
persister->AfterWriteObject( this,object, classInfo );
writercallback->AfterWriteObject( this,object, classInfo );
}
}
@ -124,23 +124,22 @@ void wxObjectWriter::FindConnectEntry(const wxEvtHandler * evSource,
if ( dynamicEvents )
{
wxList::compatibility_iterator node = dynamicEvents->GetFirst();
while (node)
for ( wxList::const_iterator node = dynamicEvents->begin(); node != dynamicEvents->end(); ++node )
{
wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)(*node);
// find the match
if ( entry->m_fn &&
(dti->GetEventType() == entry->m_eventType) &&
(entry->m_id == -1 ) &&
(entry->m_eventSink != NULL ) )
(entry->m_fn->GetEvtHandler() != NULL ) )
{
sink = entry->m_eventSink;
sink = entry->m_fn->GetEvtHandler();
const wxClassInfo* sinkClassInfo = sink->GetClassInfo();
const wxHandlerInfo* sinkHandler = sinkClassInfo->GetFirstHandler();
while ( sinkHandler )
{
if ( sinkHandler->GetEventFunction() == entry->m_fn )
if ( sinkHandler->GetEventFunction() == entry->m_fn->GetEvtMethod() )
{
handler = sinkHandler;
break;
@ -149,12 +148,11 @@ void wxObjectWriter::FindConnectEntry(const wxEvtHandler * evSource,
}
break;
}
node = node->GetNext();
}
}
}
void wxObjectWriter::WriteAllProperties( const wxObject * obj, const wxClassInfo* ci,
wxObjectReaderCallback *persister,
wxObjectWriterCallback *writercallback,
wxObjectWriterInternalPropertiesData * data )
{
wxPropertyInfoMap map;
@ -166,7 +164,7 @@ void wxObjectWriter::WriteAllProperties( const wxObject * obj, const wxClassInfo
const wxPropertyInfo* prop = iter == map.end() ? NULL : iter->second;
if ( prop )
{
WriteOneProperty( obj, prop->GetDeclaringClass(), prop, persister, data );
WriteOneProperty( obj, prop->GetDeclaringClass(), prop, writercallback, data );
}
else
{
@ -180,7 +178,7 @@ void wxObjectWriter::WriteAllProperties( const wxObject * obj, const wxClassInfo
const wxPropertyInfo* prop = iter->second;
if ( prop->GetFlags() & wxPROP_OBJECT_GRAPH )
{
WriteOneProperty( obj, prop->GetDeclaringClass(), prop, persister, data );
WriteOneProperty( obj, prop->GetDeclaringClass(), prop, writercallback, data );
}
}
}
@ -190,14 +188,36 @@ void wxObjectWriter::WriteAllProperties( const wxObject * obj, const wxClassInfo
const wxPropertyInfo* prop = iter->second;
if ( !(prop->GetFlags() & wxPROP_OBJECT_GRAPH) )
{
WriteOneProperty( obj, prop->GetDeclaringClass(), prop, persister, data );
WriteOneProperty( obj, prop->GetDeclaringClass(), prop, writercallback, data );
}
}
}
}
class WXDLLIMPEXP_BASE wxObjectPropertyWriter: public wxObjectWriterFunctor
{
public:
wxObjectPropertyWriter(const wxClassTypeInfo* cti,
wxObjectWriterCallback *writercallback,
wxObjectWriter* writer,
wxStringToAnyHashMap &props) :
m_cti(cti),m_persister(writercallback),m_writer(writer),m_props(props)
{}
virtual void operator()(const wxObject *vobj)
{
m_writer->WriteObject( vobj, (vobj ? vobj->GetClassInfo() : m_cti->GetClassInfo() ),
m_persister, m_cti->GetKind()== wxT_OBJECT, m_props );
}
private:
const wxClassTypeInfo* m_cti;
wxObjectWriterCallback *m_persister;
wxObjectWriter* m_writer;
wxStringToAnyHashMap& m_props;
};
void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* ci,
const wxPropertyInfo* pi, wxObjectReaderCallback *persister,
const wxPropertyInfo* pi, wxObjectWriterCallback *writercallback,
wxObjectWriterInternalPropertiesData *WXUNUSED(data) )
{
if ( pi->GetFlags() & wxPROP_DONT_STREAM )
@ -210,39 +230,39 @@ void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* c
if ( pi->GetTypeInfo()->GetKind() == wxT_COLLECTION )
{
wxVariantBaseArray data;
wxAnyList data;
pi->GetAccessor()->GetPropertyCollection(obj, data);
const wxTypeInfo * elementType =
wx_dynamic_cast( const wxCollectionTypeInfo*, pi->GetTypeInfo() )->GetElementType();
for ( size_t i = 0; i < data.GetCount(); ++i )
if ( !data.empty() )
{
if ( i == 0 )
DoBeginWriteProperty( pi );
DoBeginWriteElement();
wxVariantBase value = data[i];
if ( persister->BeforeWriteProperty( this, obj, pi, value ) )
DoBeginWriteProperty( pi );
for ( wxAnyList::const_iterator iter = data.begin(); iter != data.end(); ++iter )
{
const wxClassTypeInfo* cti =
wx_dynamic_cast( const wxClassTypeInfo*, elementType );
if ( cti )
DoBeginWriteElement();
const wxAny* valptr = *iter;
if ( writercallback->BeforeWriteProperty( this, obj, pi, *valptr ) )
{
const wxClassInfo* pci = cti->GetClassInfo();
wxObject *vobj = pci->VariantToInstance( value );
wxVariantBaseArray md;
WriteObject( vobj, (vobj ? vobj->GetClassInfo() : pci ),
persister, cti->GetKind()== wxT_OBJECT, md );
}
else
{
DoWriteSimpleType( value );
const wxClassTypeInfo* cti =
wx_dynamic_cast( const wxClassTypeInfo*, elementType );
if ( cti )
{
wxStringToAnyHashMap md;
wxObjectPropertyWriter pw(cti,writercallback,this, md);
const wxClassInfo* pci = cti->GetClassInfo();
pci->CallOnAny( *valptr, &pw);
}
else
{
DoWriteSimpleType( *valptr );
}
}
DoEndWriteElement();
}
DoEndWriteElement();
if ( i == data.GetCount() - 1 )
DoEndWriteProperty( pi );
}
}
DoEndWriteProperty( pi );
}
}
else
{
const wxEventSourceTypeInfo* dti =
@ -256,7 +276,7 @@ void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* c
if ( evSource )
{
FindConnectEntry( evSource, dti, sink, handler );
if ( persister->BeforeWriteDelegate( this, obj, ci, pi, sink, handler ) )
if ( writercallback->BeforeWriteDelegate( this, obj, ci, pi, sink, handler ) )
{
if ( sink != NULL && handler != NULL )
{
@ -282,11 +302,12 @@ void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* c
}
else
{
wxVariantBase value;
wxAny value;
pi->GetAccessor()->GetProperty(obj, value);
// avoid streaming out void objects
if( value.IsEmpty() )
// TODO Verify
if( value.IsNull() )
return;
if ( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
@ -295,7 +316,7 @@ void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* c
wx_dynamic_cast(const wxEnumTypeInfo*, pi->GetTypeInfo() );
if ( eti )
{
eti->ConvertFromLong( value.wxTEMPLATED_MEMBER_CALL(Get, long), value );
eti->ConvertFromLong( wxANY_AS(value, long ), value );
}
else
{
@ -305,9 +326,9 @@ void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* c
// avoid streaming out default values
if ( pi->GetTypeInfo()->HasStringConverters() &&
!pi->GetDefaultValue().IsEmpty() )
!pi->GetDefaultValue().IsNull() ) // TODO Verify
{
if ( value.GetAsString() == pi->GetDefaultValue().GetAsString() )
if ( wxAnyGetAsString(value) == wxAnyGetAsString(pi->GetDefaultValue()) )
return;
}
@ -315,28 +336,28 @@ void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* c
const wxClassTypeInfo* cti =
wx_dynamic_cast( const wxClassTypeInfo* , pi->GetTypeInfo() );
if ( cti && value.GetAsObject() == NULL )
if ( cti && cti->GetKind() == wxT_OBJECT_PTR && wxAnyGetAsObjectPtr(value) == NULL )
return;
if ( persister->BeforeWriteProperty( this, obj, pi, value ) )
if ( writercallback->BeforeWriteProperty( this, obj, pi, value ) )
{
DoBeginWriteProperty( pi );
if ( cti )
{
const wxClassInfo* pci = cti->GetClassInfo();
wxObject *vobj = pci->VariantToInstance( value );
if ( vobj && pi->GetTypeInfo()->HasStringConverters() )
if ( cti->HasStringConverters() )
{
wxString stringValue;
cti->ConvertToString( value, stringValue );
wxVariantBase convertedValue(stringValue);
wxAny convertedValue(stringValue);
DoWriteSimpleType( convertedValue );
}
else
{
wxVariantBaseArray md;
WriteObject( vobj, (vobj ? vobj->GetClassInfo() : pci ),
persister, cti->GetKind()== wxT_OBJECT, md);
wxStringToAnyHashMap md;
wxObjectPropertyWriter pw(cti,writercallback,this, md);
const wxClassInfo* pci = cti->GetClassInfo();
pci->CallOnAny(value, &pw);
}
}
else
@ -476,7 +497,7 @@ wxObjectRuntimeReaderCallback::~wxObjectRuntimeReaderCallback()
}
void wxObjectRuntimeReaderCallback::AllocateObject(int objectID, wxClassInfo *classInfo,
wxVariantBaseArray &WXUNUSED(metadata))
wxStringToAnyHashMap &WXUNUSED(metadata))
{
wxObject *O;
O = classInfo->CreateObject();
@ -486,10 +507,10 @@ void wxObjectRuntimeReaderCallback::AllocateObject(int objectID, wxClassInfo *cl
void wxObjectRuntimeReaderCallback::CreateObject(int objectID,
const wxClassInfo *classInfo,
int paramCount,
wxVariantBase *params,
wxAny *params,
int *objectIdValues,
const wxClassInfo **objectClassInfos,
wxVariantBaseArray &WXUNUSED(metadata))
wxStringToAnyHashMap &WXUNUSED(metadata))
{
wxObject *o;
o = m_data->GetObject(objectID);
@ -506,7 +527,7 @@ void wxObjectRuntimeReaderCallback::CreateObject(int objectID,
{
o = dyno->GetSuperClassInstance();
}
params[i] = objectClassInfos[i]->InstanceToVariant(o);
params[i] = objectClassInfos[i]->ObjectPtrToAny(o);
}
}
classInfo->Create(o, paramCount, params);
@ -515,10 +536,10 @@ void wxObjectRuntimeReaderCallback::CreateObject(int objectID,
void wxObjectRuntimeReaderCallback::ConstructObject(int objectID,
const wxClassInfo *classInfo,
int paramCount,
wxVariantBase *params,
wxAny *params,
int *objectIdValues,
const wxClassInfo **objectClassInfos,
wxVariantBaseArray &WXUNUSED(metadata))
wxStringToAnyHashMap &WXUNUSED(metadata))
{
wxObject *o;
for ( int i = 0; i < paramCount; ++i )
@ -534,7 +555,7 @@ void wxObjectRuntimeReaderCallback::ConstructObject(int objectID,
{
o = dyno->GetSuperClassInstance();
}
params[i] = objectClassInfos[i]->InstanceToVariant(o);
params[i] = objectClassInfos[i]->ObjectPtrToAny(o);
}
}
o = classInfo->ConstructObject(paramCount, params);
@ -552,7 +573,7 @@ void wxObjectRuntimeReaderCallback::DestroyObject(int objectID, wxClassInfo *WXU
void wxObjectRuntimeReaderCallback::SetProperty(int objectID,
const wxClassInfo *classInfo,
const wxPropertyInfo* propertyInfo,
const wxVariantBase &value)
const wxAny &value)
{
wxObject *o;
o = m_data->GetObject(objectID);
@ -579,7 +600,7 @@ void wxObjectRuntimeReaderCallback::SetPropertyAsObject(int objectID,
}
classInfo->SetProperty( o, propertyInfo->GetName(),
valClassInfo->InstanceToVariant(valo) );
valClassInfo->ObjectPtrToAny(valo) );
}
void wxObjectRuntimeReaderCallback::SetConnect(int eventSourceObjectID,
@ -625,7 +646,7 @@ wxObject *wxObjectRuntimeReaderCallback::GetObject(int objectID)
void wxObjectRuntimeReaderCallback::AddToPropertyCollection( int objectID,
const wxClassInfo *classInfo,
const wxPropertyInfo* propertyInfo,
const wxVariantBase &value)
const wxAny &value)
{
wxObject *o;
o = m_data->GetObject(objectID);
@ -654,12 +675,7 @@ void wxObjectRuntimeReaderCallback::AddToPropertyCollectionAsObject(int objectID
}
classInfo->AddToPropertyCollection( o, propertyInfo->GetName(),
valClassInfo->InstanceToVariant(valo) );
valClassInfo->ObjectPtrToAny(valo) );
}
#if TEST_XVARIANT
#include "wx/arrimpl.cpp"
WX_DEFINE_OBJARRAY(wxVariantBaseArray);
#endif
#endif // wxUSE_EXTENDED_RTTI

View File

@ -13,12 +13,12 @@
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#pragma hdrstop
#endif
#if wxUSE_EXTENDED_RTTI
#include "wx/xtixml.h"
#include "wx/xtistrm.h"
#ifndef WX_PRECOMP
#include "wx/object.h"
@ -30,6 +30,7 @@
#include "wx/tokenzr.h"
#include "wx/txtstrm.h"
#include "wx/xtistrm.h"
#include "wx/xtixml.h"
// STL headers
@ -110,17 +111,19 @@ void wxObjectXmlWriter::DoEndWriteTopLevelEntry( const wxString &WXUNUSED(name)
void wxObjectXmlWriter::DoBeginWriteObject(const wxObject *WXUNUSED(object),
const wxClassInfo *classInfo,
int objectID, wxVariantBaseArray &metadata )
int objectID, const wxStringToAnyHashMap &metadata )
{
wxXmlNode *pnode;
pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("object"));
pnode->AddProperty(wxT("class"), wxString(classInfo->GetClassName()));
pnode->AddProperty(wxT("id"), wxString::Format( wxT("%d"), objectID ) );
for ( size_t i = 0; i < metadata.GetCount(); ++i )
wxStringToAnyHashMap::const_iterator it, en;
for( it = metadata.begin(), en = metadata.end(); it != en; ++it )
{
pnode->AddProperty( metadata[i].GetName(), metadata[i].GetAsString() );
pnode->AddProperty( it->first, wxAnyGetAsString(it->second) );
}
m_data->m_current->AddChild(pnode);
m_data->Push( pnode );
}
@ -132,9 +135,9 @@ void wxObjectXmlWriter::DoEndWriteObject(const wxObject *WXUNUSED(object),
m_data->Pop();
}
void wxObjectXmlWriter::DoWriteSimpleType( wxVariantBase &value )
void wxObjectXmlWriter::DoWriteSimpleType( const wxAny &value )
{
wxXmlAddContentToNode( m_data->m_current,value.GetAsString() );
wxXmlAddContentToNode( m_data->m_current,wxAnyGetAsString(value) );
}
void wxObjectXmlWriter::DoBeginWriteElement()
@ -204,13 +207,13 @@ as properties are always sought by typeinfo over all levels
and create params are always toplevel class only
*/
int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *callbacks)
int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectReaderCallback *callbacks)
{
wxASSERT_MSG( callbacks, wxT("Does not support reading without a Depersistor") );
wxString className;
wxClassInfo *classInfo;
wxVariantBase *createParams;
wxAny *createParams;
int *createParamOids;
const wxClassInfo** createClassInfos;
wxXmlNode *children;
@ -221,7 +224,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
if (!children)
{
// check for a null object or href
if (node->GetPropVal(wxT("href"), &ObjectIdString ) )
if (node->GetAttribute(wxT("href"), &ObjectIdString ) )
{
objectID = atoi( ObjectIdString.ToAscii() );
if ( HasObjectClassInfo( objectID ) )
@ -234,12 +237,12 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
return wxInvalidObjectID;
}
}
if ( !node->GetPropVal(wxT("id"), &ObjectIdString ) )
if ( !node->GetAttribute(wxT("id"), &ObjectIdString ) )
{
return wxNullObjectID;
}
}
if (!node->GetPropVal(wxT("class"), &className))
if (!node->GetAttribute(wxT("class"), &className))
{
// No class name. Eek. FIXME: error handling
return wxInvalidObjectID;
@ -257,7 +260,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
wxLogError(_("objects cannot have XML Text Nodes") );
return wxInvalidObjectID;
}
if (!node->GetPropVal(wxT("id"), &ObjectIdString))
if (!node->GetAttribute(wxT("id"), &ObjectIdString))
{
wxLogError(_("Objects must have an id attribute") );
// No object id. Eek. FIXME: error handling
@ -276,14 +279,14 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
// first make the object know to our internal registry
SetObjectClassInfo( objectID, classInfo );
wxVariantBaseArray metadata;
wxXmlProperty *xp = node->GetProperties();
wxStringToAnyHashMap metadata;
wxXmlProperty *xp = node->GetAttributes();
while ( xp )
{
if ( xp->GetName() != wxString(wxT("class")) &&
xp->GetName() != wxString(wxT("id")) )
{
metadata.Add( new wxVariantBase( xp->GetValue(), xp->GetName() ) );
metadata[xp->GetName()] = wxAny( xp->GetValue() );
}
xp = xp->GetNext();
}
@ -292,7 +295,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
//
// stream back the Create parameters first
createParams = new wxVariantBase[ classInfo->GetCreateParamCount() ];
createParams = new wxAny[ classInfo->GetCreateParamCount() ];
createParamOids = new int[classInfo->GetCreateParamCount() ];
createClassInfos = new const wxClassInfo*[classInfo->GetCreateParamCount() ];
@ -309,7 +312,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
while( children )
{
wxString name;
children->GetPropVal( wxT("name"), &name );
children->GetAttribute( wxT("name"), &name );
propertyNames.push_back( (const wxChar*)name.c_str() );
propertyNodes[(const wxChar*)name.c_str()] = children->GetChildren();
children = children->GetNext();
@ -347,7 +350,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
{
long realval;
eti->ConvertToLong( createParams[i], realval );
createParams[i] = wxVariantBase( realval );
createParams[i] = wxAny( realval );
}
else
{
@ -435,7 +438,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
}
else
{
wxVariantBase elementValue = ReadValue( elementContent, elementType );
wxAny elementValue = ReadValue( elementContent, elementType );
if ( pi->GetAccessor()->HasAdder() )
callbacks->AddToPropertyCollection( objectID, classInfo,pi, elementValue );
}
@ -462,7 +465,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
else
{
wxASSERT( pi->GetTypeInfo()->HasStringConverters() );
wxVariantBase nodeval = ReadValue( prop, pi->GetTypeInfo() );
wxAny nodeval = ReadValue( prop, pi->GetTypeInfo() );
callbacks->SetProperty( objectID, classInfo,pi, nodeval );
}
}
@ -491,7 +494,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
}
else
{
wxVariantBase nodeval = ReadValue( prop, pi->GetTypeInfo() );
wxAny nodeval = ReadValue( prop, pi->GetTypeInfo() );
if( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
{
const wxEnumTypeInfo *eti =
@ -500,7 +503,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
{
long realval;
eti->ConvertToLong( nodeval, realval );
nodeval = wxVariantBase( realval );
nodeval = wxAny( realval );
}
else
{
@ -520,24 +523,24 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
return objectID;
}
wxVariantBase wxObjectXmlReader::ReadValue(wxXmlNode *node,
wxAny wxObjectXmlReader::ReadValue(wxXmlNode *node,
const wxTypeInfo *type )
{
wxString content;
if ( node )
content = node->GetContent();
wxVariantBase result;
wxAny result;
type->ConvertFromString( content, result );
return result;
}
int wxObjectXmlReader::ReadObject( const wxString &name, wxObjectWriterCallback *callbacks)
int wxObjectXmlReader::ReadObject( const wxString &name, wxObjectReaderCallback *callbacks)
{
wxXmlNode *iter = m_parent->GetChildren();
while ( iter )
{
wxString entryName;
if ( iter->GetPropVal(wxT("name"), &entryName) )
if ( iter->GetAttribute(wxT("name"), &entryName) )
{
if ( entryName == name )
return ReadComponent( iter->GetChildren(), callbacks );