git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2011-01-07 17:29:23 +00:00
parent a26fe24301
commit aa3fcb2f83

View File

@@ -1,244 +1,244 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/wxt2.h // Name: wx/wxt2.h
// Purpose: runtime metadata information (extended class info) // Purpose: runtime metadata information (extended class info)
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: Francesco Montorsi // Modified by: Francesco Montorsi
// Created: 27/07/03 // Created: 27/07/03
// RCS-ID: $Id: xti.h 66555 2011-01-04 08:31:53Z SC $ // RCS-ID: $Id$
// Copyright: (c) 1997 Julian Smart // Copyright: (c) 1997 Julian Smart
// (c) 2003 Stefan Csomor // (c) 2003 Stefan Csomor
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_XTI2H__ #ifndef _WX_XTI2H__
#define _WX_XTI2H__ #define _WX_XTI2H__
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// second part of xti headers, is included from object.h // second part of xti headers, is included from object.h
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_EXTENDED_RTTI #if wxUSE_EXTENDED_RTTI
class WXDLLIMPEXP_BASE wxDynamicObject : public wxObject class WXDLLIMPEXP_BASE wxDynamicObject : public wxObject
{ {
friend class WXDLLIMPEXP_FWD_BASE wxDynamicClassInfo ; friend class WXDLLIMPEXP_FWD_BASE wxDynamicClassInfo ;
public: public:
// instantiates this object with an instance of its superclass // instantiates this object with an instance of its superclass
wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info) ; wxDynamicObject(wxObject* superClassInstance, const wxDynamicClassInfo *info) ;
virtual ~wxDynamicObject(); virtual ~wxDynamicObject();
void SetProperty (const wxChar *propertyName, const wxAny &value); void SetProperty (const wxChar *propertyName, const wxAny &value);
wxAny GetProperty (const wxChar *propertyName) const ; wxAny GetProperty (const wxChar *propertyName) const ;
// get the runtime identity of this object // get the runtime identity of this object
wxClassInfo *GetClassInfo() const wxClassInfo *GetClassInfo() const
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
return (wxClassInfo*) m_classInfo; return (wxClassInfo*) m_classInfo;
#else #else
wxDynamicClassInfo *nonconst = const_cast<wxDynamicClassInfo *>(m_classInfo); wxDynamicClassInfo *nonconst = const_cast<wxDynamicClassInfo *>(m_classInfo);
return static_cast<wxClassInfo *>(nonconst); return static_cast<wxClassInfo *>(nonconst);
#endif #endif
} }
wxObject* GetSuperClassInstance() const wxObject* GetSuperClassInstance() const
{ {
return m_superClassInstance ; return m_superClassInstance ;
} }
private : private :
// removes an existing runtime-property // removes an existing runtime-property
void RemoveProperty( const wxChar *propertyName ) ; void RemoveProperty( const wxChar *propertyName ) ;
// renames an existing runtime-property // renames an existing runtime-property
void RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) ; void RenameProperty( const wxChar *oldPropertyName , const wxChar *newPropertyName ) ;
wxObject *m_superClassInstance ; wxObject *m_superClassInstance ;
const wxDynamicClassInfo *m_classInfo; const wxDynamicClassInfo *m_classInfo;
struct wxDynamicObjectInternal; struct wxDynamicObjectInternal;
wxDynamicObjectInternal *m_data; wxDynamicObjectInternal *m_data;
}; };
#include "wx/xtiprop.h" #include "wx/xtiprop.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxIMPLEMENT class macros for concrete classes // wxIMPLEMENT class macros for concrete classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Single inheritance with one base class // Single inheritance with one base class
#define _DEFAULT_CONSTRUCTOR(name) \ #define _DEFAULT_CONSTRUCTOR(name) \
wxObject* wxConstructorFor##name() \ wxObject* wxConstructorFor##name() \
{ return new name; } { return new name; }
#define _DEFAULT_CONVERTERS(name) \ #define _DEFAULT_CONVERTERS(name) \
wxObject* wxVariantOfPtrToObjectConverter##name ( const wxAny &data ) \ wxObject* wxVariantOfPtrToObjectConverter##name ( const wxAny &data ) \
{ return data.As( (name**)NULL ); } \ { return data.As( (name**)NULL ); } \
wxAny wxObjectToVariantConverter##name ( wxObject *data ) \ wxAny wxObjectToVariantConverter##name ( wxObject *data ) \
{ return wxAny( wx_dynamic_cast(name*, data) ); } { return wxAny( wx_dynamic_cast(name*, data) ); }
#define _TYPEINFO_CLASSES(n, toString, fromString ) \ #define _TYPEINFO_CLASSES(n, toString, fromString ) \
wxClassTypeInfo s_typeInfo##n(wxT_OBJECT, &n::ms_classInfo, \ wxClassTypeInfo s_typeInfo##n(wxT_OBJECT, &n::ms_classInfo, \
toString, fromString, typeid(n).name()); \ toString, fromString, typeid(n).name()); \
wxClassTypeInfo s_typeInfoPtr##n(wxT_OBJECT_PTR, &n::ms_classInfo, \ wxClassTypeInfo s_typeInfoPtr##n(wxT_OBJECT_PTR, &n::ms_classInfo, \
toString, fromString, typeid(n*).name()); toString, fromString, typeid(n*).name());
#define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit, callback) \ #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit, callback) \
_DEFAULT_CONSTRUCTOR(name) \ _DEFAULT_CONSTRUCTOR(name) \
_DEFAULT_CONVERTERS(name) \ _DEFAULT_CONVERTERS(name) \
\ \
const wxClassInfo* name::ms_classParents[] = \ const wxClassInfo* name::ms_classParents[] = \
{ &basename::ms_classInfo, NULL }; \ { &basename::ms_classInfo, NULL }; \
wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \ wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \
wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \ wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \
name::GetPropertiesStatic, name::GetHandlersStatic, name::ms_constructor, \ name::GetPropertiesStatic, name::GetHandlersStatic, name::ms_constructor, \
name::ms_constructorProperties, name::ms_constructorPropertiesCount, \ name::ms_constructorProperties, name::ms_constructorPropertiesCount, \
wxVariantOfPtrToObjectConverter##name, NULL, wxObjectToVariantConverter##name, \ wxVariantOfPtrToObjectConverter##name, NULL, wxObjectToVariantConverter##name, \
callback); callback);
#define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit, callback ) \ #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit, callback ) \
_DEFAULT_CONSTRUCTOR(name) \ _DEFAULT_CONSTRUCTOR(name) \
_DEFAULT_CONVERTERS(name) \ _DEFAULT_CONVERTERS(name) \
void wxVariantToObjectConverter##name ( const wxAny &data, wxObjectFunctor* fn ) \ void wxVariantToObjectConverter##name ( const wxAny &data, wxObjectFunctor* fn ) \
{ (*fn)( &wxANY_AS(data, name) ); } \ { (*fn)( &wxANY_AS(data, name) ); } \
\ \
const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo,NULL }; \ const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo,NULL }; \
wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \ wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \
wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \ wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \
name::GetPropertiesStatic,name::GetHandlersStatic,name::ms_constructor, \ name::GetPropertiesStatic,name::GetHandlersStatic,name::ms_constructor, \
name::ms_constructorProperties, name::ms_constructorPropertiesCount, \ name::ms_constructorProperties, name::ms_constructorPropertiesCount, \
wxVariantOfPtrToObjectConverter##name, wxVariantToObjectConverter##name, \ wxVariantOfPtrToObjectConverter##name, wxVariantToObjectConverter##name, \
wxObjectToVariantConverter##name, callback); wxObjectToVariantConverter##name, callback);
#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename ) \ #define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename ) \
_IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, "", NULL ) \ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, "", NULL ) \
_TYPEINFO_CLASSES(name, NULL, NULL) \ _TYPEINFO_CLASSES(name, NULL, NULL) \
const wxPropertyInfo *name::GetPropertiesStatic() \ const wxPropertyInfo *name::GetPropertiesStatic() \
{ return (wxPropertyInfo*) NULL; } \ { return (wxPropertyInfo*) NULL; } \
const wxHandlerInfo *name::GetHandlersStatic() \ const wxHandlerInfo *name::GetHandlersStatic() \
{ return (wxHandlerInfo*) NULL; } \ { return (wxHandlerInfo*) NULL; } \
wxCONSTRUCTOR_DUMMY( name ) wxCONSTRUCTOR_DUMMY( name )
#define wxIMPLEMENT_DYNAMIC_CLASS( name, basename ) \ #define wxIMPLEMENT_DYNAMIC_CLASS( name, basename ) \
_IMPLEMENT_DYNAMIC_CLASS( name, basename, "", NULL ) \ _IMPLEMENT_DYNAMIC_CLASS( name, basename, "", NULL ) \
_TYPEINFO_CLASSES(name, NULL, NULL) \ _TYPEINFO_CLASSES(name, NULL, NULL) \
wxPropertyInfo *name::GetPropertiesStatic() \ wxPropertyInfo *name::GetPropertiesStatic() \
{ return (wxPropertyInfo*) NULL; } \ { return (wxPropertyInfo*) NULL; } \
wxHandlerInfo *name::GetHandlersStatic() \ wxHandlerInfo *name::GetHandlersStatic() \
{ return (wxHandlerInfo*) NULL; } \ { return (wxHandlerInfo*) NULL; } \
wxCONSTRUCTOR_DUMMY( name ) wxCONSTRUCTOR_DUMMY( name )
#define wxIMPLEMENT_DYNAMIC_CLASS_XTI( name, basename, unit ) \ #define wxIMPLEMENT_DYNAMIC_CLASS_XTI( name, basename, unit ) \
_IMPLEMENT_DYNAMIC_CLASS( name, basename, unit, NULL ) \ _IMPLEMENT_DYNAMIC_CLASS( name, basename, unit, NULL ) \
_TYPEINFO_CLASSES(name, NULL, NULL) _TYPEINFO_CLASSES(name, NULL, NULL)
#define wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name, basename, unit, callback )\ #define wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name, basename, unit, callback )\
_IMPLEMENT_DYNAMIC_CLASS( name, basename, unit, &callback ) \ _IMPLEMENT_DYNAMIC_CLASS( name, basename, unit, &callback ) \
_TYPEINFO_CLASSES(name, NULL, NULL) _TYPEINFO_CLASSES(name, NULL, NULL)
#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name, basename, unit ) \ #define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name, basename, unit ) \
_IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, unit, NULL ) \ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, unit, NULL ) \
_TYPEINFO_CLASSES(name, NULL, NULL) _TYPEINFO_CLASSES(name, NULL, NULL)
#define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name, basename, \ #define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name, basename, \
unit, toString, \ unit, toString, \
fromString ) \ fromString ) \
_IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, unit, NULL ) \ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name, basename, unit, NULL ) \
_TYPEINFO_CLASSES(name, toString, fromString) _TYPEINFO_CLASSES(name, toString, fromString)
// this is for classes that do not derive from wxObject, there are no creators for these // this is for classes that do not derive from wxObject, there are no creators for these
#define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name, unit ) \ #define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name, unit ) \
const wxClassInfo* name::ms_classParents[] = { NULL }; \ const wxClassInfo* name::ms_classParents[] = { NULL }; \
wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \ wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \
wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \ wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \
name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \ name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \
0, 0, 0 ); \ 0, 0, 0 ); \
_TYPEINFO_CLASSES(name, NULL, NULL) _TYPEINFO_CLASSES(name, NULL, NULL)
// this is for subclasses that still do not derive from wxObject // this is for subclasses that still do not derive from wxObject
#define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name, basename, unit ) \ #define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name, basename, unit ) \
const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo, NULL }; \ const wxClassInfo* name::ms_classParents[] = { &basename::ms_classInfo, NULL }; \
wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \ wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \
wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \ wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \
name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \ name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \
0, 0, 0 ); \ 0, 0, 0 ); \
_TYPEINFO_CLASSES(name, NULL, NULL) _TYPEINFO_CLASSES(name, NULL, NULL)
// Multiple inheritance with two base classes // Multiple inheritance with two base classes
#define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit, callback) \ #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit, callback) \
_DEFAULT_CONSTRUCTOR(name) \ _DEFAULT_CONSTRUCTOR(name) \
_DEFAULT_CONVERTERS(name) \ _DEFAULT_CONVERTERS(name) \
\ \
const wxClassInfo* name::ms_classParents[] = \ const wxClassInfo* name::ms_classParents[] = \
{ &basename::ms_classInfo,&basename2::ms_classInfo, NULL }; \ { &basename::ms_classInfo,&basename2::ms_classInfo, NULL }; \
wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \ wxClassInfo name::ms_classInfo(name::ms_classParents, wxT(unit), \
wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \ wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name, \
name::GetPropertiesStatic,name::GetHandlersStatic,name::ms_constructor, \ name::GetPropertiesStatic,name::GetHandlersStatic,name::ms_constructor, \
name::ms_constructorProperties, name::ms_constructorPropertiesCount, \ name::ms_constructorProperties, name::ms_constructorPropertiesCount, \
wxVariantOfPtrToObjectConverter##name, NULL, wxObjectToVariantConverter##name, \ wxVariantOfPtrToObjectConverter##name, NULL, wxObjectToVariantConverter##name, \
callback); callback);
#define wxIMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2) \ #define wxIMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2) \
_IMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2, "", NULL) \ _IMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2, "", NULL) \
_TYPEINFO_CLASSES(name, NULL, NULL) \ _TYPEINFO_CLASSES(name, NULL, NULL) \
wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL; } \ wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL; } \
wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL; } \ wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL; } \
wxCONSTRUCTOR_DUMMY( name ) wxCONSTRUCTOR_DUMMY( name )
#define wxIMPLEMENT_DYNAMIC_CLASS2_XTI( name, basename, basename2, unit) \ #define wxIMPLEMENT_DYNAMIC_CLASS2_XTI( name, basename, basename2, unit) \
_IMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2, unit, NULL) \ _IMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2, unit, NULL) \
_TYPEINFO_CLASSES(name, NULL, NULL) _TYPEINFO_CLASSES(name, NULL, NULL)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxIMPLEMENT class macros for abstract classes // wxIMPLEMENT class macros for abstract classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Single inheritance with one base class // Single inheritance with one base class
#define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \ #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
_DEFAULT_CONVERTERS(name) \ _DEFAULT_CONVERTERS(name) \
\ \
const wxClassInfo* name::ms_classParents[] = \ const wxClassInfo* name::ms_classParents[] = \
{ &basename::ms_classInfo,NULL }; \ { &basename::ms_classInfo,NULL }; \
wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \ wxClassInfo name::ms_classInfo(name::ms_classParents, wxEmptyString, \
wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \ wxT(#name), (int) sizeof(name), (wxObjectConstructorFn) 0, \
name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \ name::GetPropertiesStatic,name::GetHandlersStatic, 0, 0, \
0, wxVariantOfPtrToObjectConverter##name,0, \ 0, wxVariantOfPtrToObjectConverter##name,0, \
wxObjectToVariantConverter##name); \ wxObjectToVariantConverter##name); \
_TYPEINFO_CLASSES(name, NULL, NULL) _TYPEINFO_CLASSES(name, NULL, NULL)
#define wxIMPLEMENT_ABSTRACT_CLASS( name, basename ) \ #define wxIMPLEMENT_ABSTRACT_CLASS( name, basename ) \
_IMPLEMENT_ABSTRACT_CLASS( name, basename ) \ _IMPLEMENT_ABSTRACT_CLASS( name, basename ) \
wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL; } \ wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL; } \
wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL; } wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL; }
// Multiple inheritance with two base classes // Multiple inheritance with two base classes
#define wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ #define wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
wxClassInfo name::ms_classInfo(wxT(#name), wxT(#basename1), \ wxClassInfo name::ms_classInfo(wxT(#name), wxT(#basename1), \
wxT(#basename2), (int) sizeof(name), \ wxT(#basename2), (int) sizeof(name), \
(wxObjectConstructorFn) 0); (wxObjectConstructorFn) 0);
// templated streaming, every type must have their specialization for these methods // templated streaming, every type must have their specialization for these methods
template<typename T> template<typename T>
void wxStringReadValue( const wxString &s, T &data ); void wxStringReadValue( const wxString &s, T &data );
template<typename T> template<typename T>
void wxStringWriteValue( wxString &s, const T &data); void wxStringWriteValue( wxString &s, const T &data);
template<typename T> template<typename T>
void wxToStringConverter( const wxAny &v, wxString &s ) void wxToStringConverter( const wxAny &v, wxString &s )
{ wxStringWriteValue(s, wxANY_AS(v, T)); } { wxStringWriteValue(s, wxANY_AS(v, T)); }
template<typename T> template<typename T>
void wxFromStringConverter( const wxString &s, wxAny &v) void wxFromStringConverter( const wxString &s, wxAny &v)
{ T d; wxStringReadValue(s, d); v = wxAny(d); } { T d; wxStringReadValue(s, d); v = wxAny(d); }
#endif #endif
#endif // _WX_XTIH2__ #endif // _WX_XTIH2__