From 6c887ddefbca8c14451f22f4ab8b927e2e6b62e3 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 7 Jan 2011 17:43:12 +0000 Subject: [PATCH] xti changes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/xtictor.h | 198 +++++++++++++++++++--------------------- include/wx/xtihandler.h | 27 +++--- include/wx/xtiprop.h | 97 ++++++++++---------- include/wx/xtitypes.h | 72 +++++++++------ 4 files changed, 201 insertions(+), 193 deletions(-) diff --git a/include/wx/xtictor.h b/include/wx/xtictor.h index 522aa48d58..d64da61f22 100644 --- a/include/wx/xtictor.h +++ b/include/wx/xtictor.h @@ -17,17 +17,7 @@ #if wxUSE_EXTENDED_RTTI -#include "wx/string.h" -#include "wx/variant.h" - -class WXDLLIMPEXP_BASE wxObject; -class WXDLLIMPEXP_BASE wxClassInfo; -class WXDLLIMPEXP_BASE wxDynamicClassInfo; -class WXDLLIMPEXP_BASE wxHashTable; -class WXDLLIMPEXP_BASE wxHashTable_Node; -class WXDLLIMPEXP_BASE wxObjectRefData; -class WXDLLIMPEXP_BASE wxEvent; -class WXDLLIMPEXP_BASE wxEvtHandler; +#include "wx/xti.h" // ---------------------------------------------------------------------------- // Constructor Bridges @@ -39,7 +29,7 @@ class WXDLLIMPEXP_BASE wxObjectAllocatorAndCreator { public: virtual ~wxObjectAllocatorAndCreator() { } - virtual bool Create(wxObject * &o, wxVariantBase *args) = 0; + virtual bool Create(wxObject * &o, wxAny *args) = 0; }; // a direct constructor bridge calls the operator new for this class and @@ -48,7 +38,7 @@ public: class WXDLLIMPEXP_BASE wxObjectAllocator : public wxObjectAllocatorAndCreator { public: - virtual bool Create(wxObject * &o, wxVariantBase *args) = 0; + virtual bool Create(wxObject * &o, wxAny *args) = 0; }; @@ -61,7 +51,7 @@ public: template struct wxObjectAllocatorAndCreator_0 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *) + bool Create(wxObject * &o, wxAny *) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create(); @@ -70,7 +60,7 @@ struct wxObjectAllocatorAndCreator_0 : public wxObjectAllocatorAndCreator struct wxObjectAllocatorAndCreator_Dummy : public wxObjectAllocatorAndCreator { - bool Create(wxObject *&, wxVariantBase *) + bool Create(wxObject *&, wxAny *) { return true; } @@ -93,7 +83,7 @@ struct wxObjectAllocatorAndCreator_Dummy : public wxObjectAllocatorAndCreator template struct wxDirectConstructorBridge_0 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( ); return o != NULL; @@ -112,11 +102,11 @@ struct wxDirectConstructorBridge_0 : public wxObjectAllocator template struct wxObjectAllocatorAndCreator_1 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0) + (args[0]).As(static_cast(NULL)) ); } }; @@ -132,10 +122,10 @@ struct wxObjectAllocatorAndCreator_1 : public wxObjectAllocatorAndCreator template struct wxDirectConstructorBridge_1 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0) + (args[0]).As(static_cast(NULL)) ); return o != NULL; } @@ -154,12 +144,12 @@ template struct wxObjectAllocatorAndCreator_2 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)) ); } }; @@ -176,11 +166,11 @@ template struct wxDirectConstructorBridge_2 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)) ); return o != NULL; } @@ -199,13 +189,13 @@ template struct wxObjectAllocatorAndCreator_3 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)) ); } }; @@ -222,12 +212,12 @@ template struct wxDirectConstructorBridge_3 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)) ); return o != NULL; } @@ -246,14 +236,14 @@ template struct wxObjectAllocatorAndCreator_4 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)) ); } }; @@ -271,13 +261,13 @@ template struct wxDirectConstructorBridge_4 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)) ); return o != NULL; } @@ -297,15 +287,15 @@ template struct wxObjectAllocatorAndCreator_5 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T4) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)), + (args[4]).As(static_cast(NULL)) ); } }; @@ -323,14 +313,14 @@ template struct wxDirectConstructorBridge_5 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T4) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)), + (args[4]).As(static_cast(NULL)) ); return o != NULL; } @@ -350,16 +340,16 @@ template struct wxObjectAllocatorAndCreator_6 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T4), - args[5].wxTEMPLATED_MEMBER_CALL(Get, T5) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)), + (args[4]).As(static_cast(NULL)), + (args[5]).As(static_cast(NULL)) ); } }; @@ -377,15 +367,15 @@ template struct wxDirectConstructorBridge_6 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T4), - args[5].wxTEMPLATED_MEMBER_CALL(Get, T5) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)), + (args[4]).As(static_cast(NULL)), + (args[5]).As(static_cast(NULL)) ); return o != NULL; } @@ -405,17 +395,17 @@ template struct wxObjectAllocatorAndCreator_7 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T4), - args[5].wxTEMPLATED_MEMBER_CALL(Get, T5), - args[6].wxTEMPLATED_MEMBER_CALL(Get, T6) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)), + (args[4]).As(static_cast(NULL)), + (args[5]).As(static_cast(NULL)), + (args[6]).As(static_cast(NULL)) ); } }; @@ -433,16 +423,16 @@ template struct wxDirectConstructorBridge_7 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T4), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T5), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T6) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)), + (args[4]).As(static_cast(NULL)), + (args[5]).As(static_cast(NULL)), + (args[6]).As(static_cast(NULL)) ); return o != NULL; } @@ -463,18 +453,18 @@ typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, \ typename T6, typename T7> struct wxObjectAllocatorAndCreator_8 : public wxObjectAllocatorAndCreator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { Class *obj = wx_dynamic_cast(Class*, o); return obj->Create( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T4), - args[5].wxTEMPLATED_MEMBER_CALL(Get, T5), - args[6].wxTEMPLATED_MEMBER_CALL(Get, T6), - args[7].wxTEMPLATED_MEMBER_CALL(Get, T7) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)), + (args[4]).As(static_cast(NULL)), + (args[5]).As(static_cast(NULL)), + (args[6]).As(static_cast(NULL)), + (args[7]).As(static_cast(NULL)) ); } }; @@ -493,17 +483,17 @@ typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, \ typename T6, typename T7> struct wxDirectConstructorBridge_8 : public wxObjectAllocator { - bool Create(wxObject * &o, wxVariantBase *args) + bool Create(wxObject * &o, wxAny *args) { o = new Class( - args[0].wxTEMPLATED_MEMBER_CALL(Get, T0), - args[1].wxTEMPLATED_MEMBER_CALL(Get, T1), - args[2].wxTEMPLATED_MEMBER_CALL(Get, T2), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T3), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T4), - args[3].wxTEMPLATED_MEMBER_CALL(Get, T5), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T6), - args[4].wxTEMPLATED_MEMBER_CALL(Get, T7) + (args[0]).As(static_cast(NULL)), + (args[1]).As(static_cast(NULL)), + (args[2]).As(static_cast(NULL)), + (args[3]).As(static_cast(NULL)), + (args[4]).As(static_cast(NULL)), + (args[5]).As(static_cast(NULL)), + (args[6]).As(static_cast(NULL)), + (args[7]).As(static_cast(NULL)) ); return o != NULL; } diff --git a/include/wx/xtihandler.h b/include/wx/xtihandler.h index a7aa7b2cde..2698cbe2c4 100644 --- a/include/wx/xtihandler.h +++ b/include/wx/xtihandler.h @@ -17,18 +17,21 @@ #if wxUSE_EXTENDED_RTTI -#include "wx/string.h" - -class WXDLLIMPEXP_BASE wxObject; -class WXDLLIMPEXP_BASE wxClassInfo; -class WXDLLIMPEXP_BASE wxDynamicClassInfo; -class WXDLLIMPEXP_BASE wxHashTable; -class WXDLLIMPEXP_BASE wxHashTable_Node; -class WXDLLIMPEXP_BASE wxObjectRefData; -class WXDLLIMPEXP_BASE wxEvent; -class WXDLLIMPEXP_BASE wxEvtHandler; - -typedef void (wxObject::*wxObjectEventFunction)(wxEvent&); +#include "wx/xti.h" + +// copied from event.h which cannot be included at this place, TODO MOVE to common file + +class WXDLLIMPEXP_FWD_BASE wxEvent; + +#ifdef __VISUALC__ +#define wxMSVC_FWD_MULTIPLE_BASES __multiple_inheritance +#else +#define wxMSVC_FWD_MULTIPLE_BASES +#endif + +class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler; +typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); +typedef wxEventFunction wxObjectEventFunction; // ---------------------------------------------------------------------------- // Handler Info diff --git a/include/wx/xtiprop.h b/include/wx/xtiprop.h index abd3584ead..6ccc21e737 100644 --- a/include/wx/xtiprop.h +++ b/include/wx/xtiprop.h @@ -17,18 +17,14 @@ #if wxUSE_EXTENDED_RTTI -#include "wx/string.h" -#include "wx/variant.h" -#include "wx/intl.h" -#include "wx/log.h" -#include "wx/xtitypes.h" +#include "wx/xti.h" +#include "wx/any.h" class WXDLLIMPEXP_BASE wxObject; class WXDLLIMPEXP_BASE wxClassInfo; class WXDLLIMPEXP_BASE wxDynamicClassInfo; class WXDLLIMPEXP_BASE wxHashTable; class WXDLLIMPEXP_BASE wxHashTable_Node; -class WXDLLIMPEXP_BASE wxObjectRefData; class WXDLLIMPEXP_BASE wxEvent; class WXDLLIMPEXP_BASE wxEvtHandler; @@ -46,7 +42,7 @@ public: wxPropertySetter( const wxString name ) { m_name = name; } virtual ~wxPropertySetter() {} - virtual void Set( wxObject *object, const wxVariantBase &variantValue ) const = 0; + virtual void Set( wxObject *object, const wxAny &variantValue ) const = 0; const wxString& GetName() const { return m_name; } private: @@ -59,7 +55,7 @@ public: wxPropertyGetter( const wxString name ) { m_name = name; } virtual ~wxPropertyGetter() {} - virtual void Get( const wxObject *object, wxVariantBase& result) const = 0; + virtual void Get( const wxObject *object, wxAny& result) const = 0; const wxString& GetName() const { return m_name; } private: @@ -72,7 +68,7 @@ public: wxPropertyCollectionGetter( const wxString name ) { m_name = name; } virtual ~wxPropertyCollectionGetter() {} - virtual void Get( const wxObject *object, wxVariantBaseArray& result) const = 0; + virtual void Get( const wxObject *object, wxAnyList& result) const = 0; const wxString& GetName() const { return m_name; } private: @@ -80,7 +76,7 @@ private: }; template void WXDLLIMPEXP_BASE \ - wxCollectionToVariantArray( const coll_t& coll, wxVariantBaseArray& result ); + wxCollectionToVariantArray( const coll_t& coll, wxAnyList& result ); class WXDLLIMPEXP_BASE wxPropertyCollectionAdder { @@ -88,29 +84,30 @@ public: wxPropertyCollectionAdder( const wxString name ) { m_name = name; } virtual ~wxPropertyCollectionAdder() {} - virtual void Add( wxObject *object, const wxVariantBase &variantValue ) const= 0; + virtual void Add( wxObject *object, const wxAny &variantValue ) const= 0; const wxString& GetName() const { return m_name; } private: wxString m_name; }; -#define wxPROPERTY_SETTER( property, Klass, valueType, setterMethod ) \ -class wxPropertySetter##property : public wxPropertySetter \ +#define wxPROPERTY_SETTER( property, Klass, valueType, setterMethod ) \ +class wxPropertySetter##property : public wxPropertySetter \ { \ public: \ wxINFUNC_CLASS_TYPE_FIX(Klass) \ wxPropertySetter##property() : wxPropertySetter( wxT(#setterMethod) ) {} \ - virtual ~wxPropertySetter##property() {} \ + virtual ~wxPropertySetter##property() {} \ \ - void Set( wxObject *object, const wxVariantBase &variantValue ) const \ + void Set( wxObject *object, const wxAny &variantValue ) const \ { \ - Klass *obj = dynamic_cast(object); \ - if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \ - obj->setterMethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType)); \ - else \ - obj->setterMethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType*)); \ - } \ + Klass *obj = dynamic_cast(object); \ + valueType tempobj; \ + if ( variantValue.GetAs(&tempobj) ) \ + obj->setterMethod(tempobj); \ + else \ + obj->setterMethod(*wxANY_AS(variantValue, valueType*)); \ + } \ }; #define wxPROPERTY_GETTER( property, Klass, valueType, gettermethod ) \ @@ -121,10 +118,10 @@ public: \ wxPropertyGetter##property() : wxPropertyGetter( wxT(#gettermethod) ) {} \ virtual ~wxPropertyGetter##property() {} \ \ - void Get( const wxObject *object, wxVariantBase &result) const \ + void Get( const wxObject *object, wxAny &result) const \ { \ const Klass *obj = dynamic_cast(object); \ - result = wxVariantBase( obj->gettermethod() ); \ + result = wxAny( obj->gettermethod() ); \ } \ }; @@ -136,13 +133,14 @@ public: \ wxPropertyCollectionAdder##property() : wxPropertyCollectionAdder( wxT(#addermethod) ) {} \ virtual ~wxPropertyCollectionAdder##property() {} \ \ - void Add( wxObject *object, const wxVariantBase &variantValue ) const \ + void Add( wxObject *object, const wxAny &variantValue ) const \ { \ Klass *obj = dynamic_cast(object); \ - if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \ - obj->addermethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType)); \ + valueType tempobj; \ + if ( variantValue.GetAs(&tempobj) ) \ + obj->addermethod(tempobj); \ else \ - obj->addermethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType*)); \ + obj->addermethod(*wxANY_AS(variantValue, valueType*)); \ } \ }; @@ -154,7 +152,7 @@ public: \ wxPropertyCollectionGetter##property() : wxPropertyCollectionGetter( wxT(#gettermethod) ) {} \ virtual ~wxPropertyCollectionGetter##property() {} \ \ - void Get( const wxObject *object, wxVariantBaseArray &result) const \ + void Get( const wxObject *object, wxAnyList &result) const \ { \ const Klass *obj = dynamic_cast(object); \ wxCollectionToVariantArray( obj->gettermethod(), result ); \ @@ -172,7 +170,7 @@ public: virtual ~wxPropertyAccessor() {} // Setting a simple property (non-collection) - virtual void SetProperty(wxObject *object, const wxVariantBase &value) const + virtual void SetProperty(wxObject *object, const wxAny &value) const { if ( m_setter ) m_setter->Set( object, value ); @@ -181,7 +179,7 @@ public: } // Getting a simple property (non-collection) - virtual void GetProperty(const wxObject *object, wxVariantBase &result) const + virtual void GetProperty(const wxObject *object, wxAny &result) const { if ( m_getter ) m_getter->Get( object, result ); @@ -190,7 +188,7 @@ public: } // Adding an element to a collection property - virtual void AddToPropertyCollection(wxObject *object, const wxVariantBase &value) const + virtual void AddToPropertyCollection(wxObject *object, const wxAny &value) const { if ( m_adder ) m_adder->Add( object, value ); @@ -199,7 +197,7 @@ public: } // Getting a collection property - virtual void GetPropertyCollection( const wxObject *obj, wxVariantBaseArray &result) const + virtual void GetPropertyCollection( const wxObject *obj, wxAnyList &result) const { if ( m_collectionGetter ) m_collectionGetter->Get( obj, result); @@ -250,19 +248,19 @@ public: virtual const wxString& GetSetterName() const { return m_setterName; } - virtual void SetProperty(wxObject *object, const wxVariantBase &value) const; - virtual void GetProperty(const wxObject *object, wxVariantBase &value) const; + virtual void SetProperty(wxObject *object, const wxAny &value) const; + virtual void GetProperty(const wxObject *object, wxAny &value) const; // Adding an element to a collection property virtual void AddToPropertyCollection(wxObject *WXUNUSED(object), - const wxVariantBase &WXUNUSED(value)) const + const wxAny &WXUNUSED(value)) const { wxLogError( _("AddToPropertyCollection called on a generic accessor") ); } // Getting a collection property virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj), - wxVariantBaseArray &WXUNUSED(result)) const + wxAnyList &WXUNUSED(result)) const { wxLogError ( _("GetPropertyCollection called on a generic accessor") ); } @@ -312,7 +310,7 @@ public: const wxString& name, const wxString& typeName, wxPropertyAccessor *accessor, - wxVariantBase dv, + wxAny dv, wxPropertyInfoFlags flags = 0, const wxString& helpString = wxEmptyString, const wxString& groupString = wxEmptyString) : @@ -336,7 +334,7 @@ public: const wxString& name, const char* typeName, wxPropertyAccessor *accessor, - wxVariantBase dv, + wxAny dv, wxPropertyInfoFlags flags = 0, const wxString& helpString = wxEmptyString, const wxString& groupString = wxEmptyString) : @@ -359,7 +357,7 @@ public: const wxString& name, wxEventSourceTypeInfo* type, wxPropertyAccessor *accessor, - wxVariantBase dv, + wxAny dv, wxPropertyInfoFlags flags = 0, const wxString& helpString = wxEmptyString, const wxString& groupString = wxEmptyString) : @@ -462,7 +460,7 @@ public: wxPropertyInfo* GetNext() const { return m_next; } // returns the default value of this property, its kind may be wxT_VOID if it is not valid - wxVariantBase GetDefaultValue() const { return m_defaultValue; } + wxAny GetDefaultValue() const { return m_defaultValue; } private: @@ -480,7 +478,7 @@ private: mutable wxTypeInfo* m_collectionElementTypeInfo; wxString m_collectionElementTypeName; wxPropertyAccessor* m_accessor; - wxVariantBase m_defaultValue; + wxAny m_defaultValue; wxPropertyInfoFlags m_flags; wxString m_helpString; wxString m_groupString; @@ -506,7 +504,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, #define wxHIDE_PROPERTY( pname ) \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ - wxT(#pname), typeid(void).name(), NULL, wxVariantBase(), wxPROP_DONT_STREAM, \ + wxT(#pname), typeid(void).name(), NULL, wxAny(), wxPROP_DONT_STREAM, \ wxEmptyString, wxEmptyString ); #define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \ @@ -518,7 +516,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, &_getter##pname, NULL, NULL ); \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ wxT(#pname), typeid(type).name(), &_accessor##pname, \ - wxVariantBase(defaultValue), flags, group, help ); + wxAny(defaultValue), flags, group, help ); #define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue, \ pflags, help, group) \ @@ -530,7 +528,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, &_getter##pname, NULL, NULL ); \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ wxT(#pname), typeid(flags).name(), &_accessor##pname, \ - wxVariantBase(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); + wxAny(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); #define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \ wxPROPERTY_GETTER( pname, class_t, type, getter ) \ @@ -538,7 +536,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ wxT(#pname), typeid(type).name(),&_accessor##pname, \ - wxVariantBase(defaultValue), flags, help, group ); + wxAny(defaultValue), flags, help, group ); #define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue, \ pflags, help, group) \ @@ -547,7 +545,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \ static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \ wxT(#pname), typeid(flags).name(),&_accessor##pname, \ - wxVariantBase(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); + wxAny(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group ); #define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter, \ flags, help, group ) \ @@ -574,13 +572,13 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, #define wxEVENT_PROPERTY( name, eventType, eventClass ) \ static wxEventSourceTypeInfo _typeInfo##name( eventType, CLASSINFO( eventClass ) ); \ static wxPropertyInfo _propertyInfo##name( first,class_t::GetClassInfoStatic(), \ - wxT(#name), &_typeInfo##name, NULL, wxVariantBase() ); + wxT(#name), &_typeInfo##name, NULL, wxAny() ); #define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) \ static wxEventSourceTypeInfo _typeInfo##name( eventType, lastEventType, \ CLASSINFO( eventClass ) ); \ static wxPropertyInfo _propertyInfo##name( first, class_t::GetClassInfoStatic(), \ - wxT(#name), &_typeInfo##name, NULL, wxVariantBase() ); + wxT(#name), &_typeInfo##name, NULL, wxAny() ); // ---------------------------------------------------------------------------- // Implementation Helper for Simple Properties @@ -593,5 +591,8 @@ public: \ void Set##name( type const & p) { m_##name = p; } \ type const & Get##name() const { return m_##name; } +WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxAny, wxStringToAnyHashMap, + class WXDLLIMPEXP_BASE ); + #endif // wxUSE_EXTENDED_RTTI #endif // _XTIPROP_H_ diff --git a/include/wx/xtitypes.h b/include/wx/xtitypes.h index 212fba1951..f13bb7f804 100644 --- a/include/wx/xtitypes.h +++ b/include/wx/xtitypes.h @@ -83,6 +83,11 @@ private: #define wxENUM_MEMBER( v ) { wxT(#v), v }, +/* +WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) \ +WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) \ +*/ + #define wxEND_ENUM( e ) \ { NULL, 0 } }; \ wxEnumData s_enumData##e( s_enumDataMembers##e ); \ @@ -91,10 +96,10 @@ private: { data = (e) s_enumData##e.GetEnumMemberValue(s); } \ template<> void wxStringWriteValue(wxString &s, const e &data ) \ { s = s_enumData##e.GetEnumMemberName((int)data); } \ - void FromLong##e( long data, wxVariantBase& result ) \ - { result = wxVariantBase((e)data); } \ - void ToLong##e( const wxVariantBase& data, long &result ) \ - { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get, e); } \ + void FromLong##e( long data, wxAny& result ) \ + { result = wxAny((e)data); } \ + void ToLong##e( const wxAny& data, long &result ) \ + { result = (long) (data).As(static_cast(NULL)); } \ \ wxTO_STRING_IMP( e ) \ wxFROM_STRING_IMP( e ) \ @@ -180,10 +185,10 @@ void wxSetToString( wxString &s, const wxBitset &data ) { wxSetFromString( s, data ); } \ template<> void wxStringWriteValue( wxString &s, const wxBitset &data ) \ { wxSetToString( s, data ); } \ - void FromLong##SetName( long data, wxVariantBase& result ) \ - { result = wxVariantBase(SetName((unsigned long)data)); } \ - void ToLong##SetName( const wxVariantBase& data, long &result ) \ - { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get, SetName).to_ulong(); } \ + void FromLong##SetName( long data, wxAny& result ) \ + { result = wxAny(SetName((unsigned long)data)); } \ + void ToLong##SetName( const wxAny& data, long &result ) \ + { result = (long) (data).As(static_cast(NULL)).to_ulong(); } \ wxTO_STRING_IMP( SetName ) \ wxFROM_STRING_IMP( SetName ) \ wxEnumTypeInfo s_typeInfo##SetName(wxT_SET, &s_enumData##e, \ @@ -239,6 +244,11 @@ void wxFlagsToString( wxString &s, const e& data ) #define wxFLAGS_MEMBER( v ) { wxT(#v), v }, +/* +WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) \ +WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl) \ +*/ + #define wxEND_FLAGS( e ) \ { NULL, 0 } }; \ wxEnumData s_enumData##e( s_enumDataMembers##e ); \ @@ -247,10 +257,10 @@ void wxFlagsToString( wxString &s, const e& data ) { wxFlagsFromString( s, data ); } \ template<> void wxStringWriteValue( wxString &s, const e& data ) \ { wxFlagsToString( s, data ); } \ - void FromLong##e( long data, wxVariantBase& result ) \ - { result = wxVariantBase(e(data)); } \ - void ToLong##e( const wxVariantBase& data, long &result ) \ - { result = (long) data.wxTEMPLATED_MEMBER_CALL(Get, e).m_data; } \ + void FromLong##e( long data, wxAny& result ) \ + { result = wxAny(e(data)); } \ + void ToLong##e( const wxAny& data, long &result ) \ + { result = (long) (data).As(static_cast(NULL)).m_data; } \ wxTO_STRING_IMP( e ) \ wxFROM_STRING_IMP( e ) \ wxEnumTypeInfo s_typeInfo##e(wxT_SET, &s_enumData##e, \ @@ -278,6 +288,8 @@ enum wxTypeKind wxT_UINT, wxT_LONG, wxT_ULONG, + wxT_LONGLONG, + wxT_ULONGLONG, wxT_FLOAT, wxT_DOUBLE, wxT_STRING, // must be wxString @@ -296,7 +308,7 @@ enum wxTypeKind wxT_LAST_TYPE_KIND = wxT_DELEGATE // sentinel for bad data, asserts, debugging }; -class WXDLLIMPEXP_BASE wxVariantBase; +class WXDLLIMPEXP_BASE wxAny; class WXDLLIMPEXP_BASE wxTypeInfo; WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxTypeInfo*, wxTypeInfoMap, class WXDLLIMPEXP_BASE ); @@ -304,8 +316,8 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxTypeInfo*, wxTypeInfoMap, class WXDLLIMP class WXDLLIMPEXP_BASE wxTypeInfo { public: - typedef void (*wxVariant2StringFnc)( const wxVariantBase& data, wxString &result ); - typedef void (*wxString2VariantFnc)( const wxString& data, wxVariantBase &result ); + typedef void (*wxVariant2StringFnc)( const wxAny& data, wxString &result ); + typedef void (*wxString2VariantFnc)( const wxString& data, wxAny &result ); wxTypeInfo(wxTypeKind kind, wxVariant2StringFnc to = NULL, wxString2VariantFnc from = NULL, @@ -348,8 +360,8 @@ public: // can the content of this type be converted to and from strings ? bool HasStringConverters() const { return m_toString != NULL && m_fromString != NULL; } - // convert a wxVariantBase holding data of this type into a string - void ConvertToString( const wxVariantBase& data, wxString &result ) const + // convert a wxAny holding data of this type into a string + void ConvertToString( const wxAny& data, wxString &result ) const { if ( m_toString ) (*m_toString)( data, result ); @@ -357,8 +369,8 @@ public: wxLogError( wxGetTranslation(_T("String conversions not supported")) ); } - // convert a string into a wxVariantBase holding the corresponding data in this type - void ConvertFromString( const wxString& data, wxVariantBase &result ) const + // convert a string into a wxAny holding the corresponding data in this type + void ConvertFromString( const wxString& data, wxAny &result ) const { if( m_fromString ) (*m_fromString)( data, result ); @@ -368,6 +380,8 @@ public: // statics: + static wxTypeInfo *FindType( const wxString& typeName ); +#if 0 // TODO #if wxUSE_UNICODE static wxTypeInfo *FindType(const char *typeName) { return FindType( wxString::FromAscii(typeName) ); } @@ -381,7 +395,7 @@ public: return FindType( typeName.char_str() ); #endif } - +#endif private: void Register(); void Unregister(); @@ -432,8 +446,8 @@ public: class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo { public: - typedef void (*converterToLong_t)( const wxVariantBase& data, long &result ); - typedef void (*converterFromLong_t)( long data, wxVariantBase &result ); + typedef void (*converterToLong_t)( const wxAny& data, long &result ); + typedef void (*converterFromLong_t)( long data, wxAny &result ); wxEnumTypeInfo( wxTypeKind kind, wxEnumData* enumInfo, wxVariant2StringFnc to, wxString2VariantFnc from, converterToLong_t toLong, @@ -458,8 +472,8 @@ public: #endif const wxEnumData* GetEnumData() const { return m_enumInfo; } - // convert a wxVariantBase holding data of this type into a long - void ConvertToLong( const wxVariantBase& data, long &result ) const + // convert a wxAny holding data of this type into a long + void ConvertToLong( const wxAny& data, long &result ) const { if( m_toLong ) (*m_toLong)( data, result ); @@ -467,8 +481,8 @@ public: wxLogError( wxGetTranslation(_T("Long Conversions not supported")) ); } - // convert a long into a wxVariantBase holding the corresponding data in this type - void ConvertFromLong( long data, wxVariantBase &result ) const + // convert a long into a wxAny holding the corresponding data in this type + void ConvertFromLong( long data, wxAny &result ) const { if( m_fromLong ) (*m_fromLong)( data, result ); @@ -547,7 +561,7 @@ private: int m_lastEventType; }; -template const wxTypeInfo* wxGetTypeInfo( T * ) \ +template const wxTypeInfo* wxGetTypeInfo( T * ) { return wxTypeInfo::FindType(typeid(T).name()); } // this macro is for usage with custom, non-object derived classes and structs, @@ -558,9 +572,9 @@ template const wxTypeInfo* wxGetTypeInfo( T * ) \ wxCustomTypeInfo s_typeInfo##e(typeid(e).name(), &toString, &fromString); #else #define wxCUSTOM_TYPE_INFO( e, toString, fromString ) \ - void ToString##e( const wxVariantBase& data, wxString &result ) \ + void ToString##e( const wxAny& data, wxString &result ) \ { toString(data, result); } \ - void FromString##e( const wxString& data, wxVariantBase &result ) \ + void FromString##e( const wxString& data, wxAny &result ) \ { fromString(data, result); } \ wxCustomTypeInfo s_typeInfo##e(typeid(e).name(), \ &ToString##e, &FromString##e); -- 2.45.2