made wxRTTI macros namespace-friendly (patch 799434)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24202 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -86,6 +86,7 @@ All (GUI):
|
|||||||
- bug in wxRect ctor from two [out of order] wxPoints fixed (Steve Cornett)
|
- bug in wxRect ctor from two [out of order] wxPoints fixed (Steve Cornett)
|
||||||
- status text is now restored after wxMenu help is shown in it
|
- status text is now restored after wxMenu help is shown in it
|
||||||
- bug in wxWindow::RemoveEventHandler() fixed (Yingjun Zhang)
|
- bug in wxWindow::RemoveEventHandler() fixed (Yingjun Zhang)
|
||||||
|
- make it possible to use wxRTTI macros with namespaces (Benjamin I. Williams)
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@@ -160,9 +160,10 @@ inline void wxClassInfo::CleanUpClasses() {}
|
|||||||
|
|
||||||
#define DECLARE_DYNAMIC_CLASS(name) \
|
#define DECLARE_DYNAMIC_CLASS(name) \
|
||||||
public: \
|
public: \
|
||||||
static wxClassInfo sm_class##name; \
|
static wxClassInfo ms_classInfo; \
|
||||||
|
static wxObject* wxCreateObject(); \
|
||||||
virtual wxClassInfo *GetClassInfo() const \
|
virtual wxClassInfo *GetClassInfo() const \
|
||||||
{ return &name::sm_class##name; }
|
{ return &name::ms_classInfo; }
|
||||||
|
|
||||||
#define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
|
#define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
|
||||||
DECLARE_NO_ASSIGN_CLASS(name) \
|
DECLARE_NO_ASSIGN_CLASS(name) \
|
||||||
@@ -182,23 +183,23 @@ inline void wxClassInfo::CleanUpClasses() {}
|
|||||||
// Single inheritance with one base class
|
// Single inheritance with one base class
|
||||||
|
|
||||||
#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
|
#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
|
||||||
wxObject* wxConstructorFor##name() \
|
wxObject* name::wxCreateObject() \
|
||||||
{ return new name; } \
|
{ return new name; } \
|
||||||
wxClassInfo name::sm_class##name(wxT(#name), \
|
wxClassInfo name::ms_classInfo(wxT(#name), \
|
||||||
&basename::sm_class##basename, NULL, \
|
&basename::ms_classInfo, NULL, \
|
||||||
(int) sizeof(name), \
|
(int) sizeof(name), \
|
||||||
(wxObjectConstructorFn) wxConstructorFor##name);
|
(wxObjectConstructorFn) name::wxCreateObject);
|
||||||
|
|
||||||
// Multiple inheritance with two base classes
|
// Multiple inheritance with two base classes
|
||||||
|
|
||||||
#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \
|
#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \
|
||||||
wxObject* wxConstructorFor##name() \
|
wxObject* name::wxCreateObject() \
|
||||||
{ return new name; } \
|
{ return new name; } \
|
||||||
wxClassInfo name::sm_class##name(wxT(#name), \
|
wxClassInfo name::ms_classInfo(wxT(#name), \
|
||||||
&basename1::sm_class##basename1, \
|
&basename1::ms_classInfo, \
|
||||||
&basename2::sm_class##basename2, \
|
&basename2::ms_classInfo, \
|
||||||
wxT(#basename2), (int) sizeof(name), \
|
wxT(#basename2), (int) sizeof(name), \
|
||||||
(wxObjectConstructorFn) wxConstructorFor##name);
|
(wxObjectConstructorFn) name::wxCreateObject);
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// for abstract classes
|
// for abstract classes
|
||||||
@@ -207,16 +208,16 @@ inline void wxClassInfo::CleanUpClasses() {}
|
|||||||
// Single inheritance with one base class
|
// Single inheritance with one base class
|
||||||
|
|
||||||
#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \
|
#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \
|
||||||
wxClassInfo name::sm_class##name(wxT(#name), \
|
wxClassInfo name::ms_classInfo(wxT(#name), \
|
||||||
&basename::sm_class##basename, NULL, \
|
&basename::ms_classInfo, NULL, \
|
||||||
(int) sizeof(name), (wxObjectConstructorFn) 0);
|
(int) sizeof(name), (wxObjectConstructorFn) 0);
|
||||||
|
|
||||||
// Multiple inheritance with two base classes
|
// Multiple inheritance with two base classes
|
||||||
|
|
||||||
#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
|
#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
|
||||||
wxClassInfo name::sm_class##name(wxT(#name), \
|
wxClassInfo name::ms_classInfo(wxT(#name), \
|
||||||
&basename1::sm_class##basename1, \
|
&basename1::ms_classInfo, \
|
||||||
&basename2::sm_class##basename2, \
|
&basename2::ms_classInfo, \
|
||||||
(int) sizeof(name), \
|
(int) sizeof(name), \
|
||||||
(wxObjectConstructorFn) 0);
|
(wxObjectConstructorFn) 0);
|
||||||
|
|
||||||
@@ -293,7 +294,7 @@ name##PluginSentinel m_pluginsentinel;
|
|||||||
#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \
|
#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \
|
||||||
IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2)
|
IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2)
|
||||||
|
|
||||||
#define CLASSINFO(name) (&name::sm_class##name)
|
#define CLASSINFO(name) (&name::ms_classInfo)
|
||||||
|
|
||||||
#else // !wxUSE_DYNAMIC_CLASSES
|
#else // !wxUSE_DYNAMIC_CLASSES
|
||||||
|
|
||||||
@@ -325,19 +326,19 @@ name##PluginSentinel m_pluginsentinel;
|
|||||||
|
|
||||||
#endif // wxUSE_DYNAMIC_CLASSES
|
#endif // wxUSE_DYNAMIC_CLASSES
|
||||||
|
|
||||||
#define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::sm_class##className)
|
#define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::ms_classInfo)
|
||||||
|
|
||||||
// Just seems a bit nicer-looking (pretend it's not a macro)
|
// Just seems a bit nicer-looking (pretend it's not a macro)
|
||||||
#define wxIsKindOf(obj, className) obj->IsKindOf(&className::sm_class##className)
|
#define wxIsKindOf(obj, className) obj->IsKindOf(&className::ms_classInfo)
|
||||||
|
|
||||||
// to be replaced by dynamic_cast<> in the future
|
// to be replaced by dynamic_cast<> in the future
|
||||||
#define wxDynamicCast(obj, className) \
|
#define wxDynamicCast(obj, className) \
|
||||||
((className *) wxCheckDynamicCast((wxObject*)(obj), &className::sm_class##className))
|
((className *) wxCheckDynamicCast((wxObject*)(obj), &className::ms_classInfo))
|
||||||
|
|
||||||
// The 'this' pointer is always true, so use this version
|
// The 'this' pointer is always true, so use this version
|
||||||
// to cast the this pointer and avoid compiler warnings.
|
// to cast the this pointer and avoid compiler warnings.
|
||||||
#define wxDynamicCastThis(className) \
|
#define wxDynamicCastThis(className) \
|
||||||
(IsKindOf(&className::sm_class##className) ? (className *)(this) : (className *)0)
|
(IsKindOf(&className::ms_classInfo) ? (className *)(this) : (className *)0)
|
||||||
|
|
||||||
#ifdef HAVE_CONST_CAST
|
#ifdef HAVE_CONST_CAST
|
||||||
#define wxConstCast(obj, className) const_cast<className *>(obj)
|
#define wxConstCast(obj, className) const_cast<className *>(obj)
|
||||||
|
@@ -54,7 +54,7 @@ void wxModule::RegisterModules()
|
|||||||
{
|
{
|
||||||
classInfo = (wxClassInfo *)node->GetData();
|
classInfo = (wxClassInfo *)node->GetData();
|
||||||
if ( classInfo->IsKindOf(CLASSINFO(wxModule)) &&
|
if ( classInfo->IsKindOf(CLASSINFO(wxModule)) &&
|
||||||
(classInfo != (& (wxModule::sm_classwxModule))) )
|
(classInfo != (& (wxModule::ms_classInfo))) )
|
||||||
{
|
{
|
||||||
wxModule* module = (wxModule *)classInfo->CreateObject();
|
wxModule* module = (wxModule *)classInfo->CreateObject();
|
||||||
RegisterModule(module);
|
RegisterModule(module);
|
||||||
|
@@ -68,7 +68,7 @@ const wxClassInfo* wxObject::sm_classParentswxObject[] = { NULL } ;
|
|||||||
wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &wxObject::sm_classwxObject , NULL , NULL , typeid(wxObject*).name() ) ;
|
wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &wxObject::sm_classwxObject , NULL , NULL , typeid(wxObject*).name() ) ;
|
||||||
wxClassTypeInfo s_typeInfowxObject(wxT_OBJECT , &wxObject::sm_classwxObject , NULL , NULL , typeid(wxObject).name() ) ;
|
wxClassTypeInfo s_typeInfowxObject(wxT_OBJECT , &wxObject::sm_classwxObject , NULL , NULL , typeid(wxObject).name() ) ;
|
||||||
#else
|
#else
|
||||||
wxClassInfo wxObject::sm_classwxObject( wxT("wxObject"), 0, 0,
|
wxClassInfo wxObject::ms_classInfo( wxT("wxObject"), 0, 0,
|
||||||
(int) sizeof(wxObject),
|
(int) sizeof(wxObject),
|
||||||
(wxObjectConstructorFn) 0 );
|
(wxObjectConstructorFn) 0 );
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user