X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8cfc5426cf50da368022813a04e29cf8ec5478a4..af01f1ba0d697c07173f436ab661b4c833258a91:/include/wx/object.h?ds=inline diff --git a/include/wx/object.h b/include/wx/object.h index f6b11f8594..69e3796842 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -171,8 +171,13 @@ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \ // to be replaced by dynamic_cast<> in the future #define wxDynamicCast(obj, className) \ - ((obj) && ((obj)->IsKindOf(&className::sm_class##className)) \ - ? (className *)(obj) \ + (className *) wxCheckDynamicCast((wxObject*)(obj), &className::sm_class##className) + +// The 'this' pointer is always true, so use this version to cast the this +// pointer and avoid compiler warnings. +#define wxDynamicCastThis(className) \ + (IsKindOf(&className::sm_class##className) \ + ? (className *)(this) \ : (className *)0) #define wxConstCast(obj, className) ((className *)(obj)) @@ -191,6 +196,7 @@ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \ #endif // Debug/!Debug // Unfortunately Borland seems to need this include. +#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT) #ifdef __BORLANDC__ #if wxUSE_IOSTREAMH #include @@ -198,6 +204,7 @@ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \ #include #endif #endif +#endif class WXDLLEXPORT wxObjectRefData; @@ -212,8 +219,6 @@ class WXDLLEXPORT wxObject virtual ~wxObject(void); virtual wxClassInfo *GetClassInfo(void) const { return &sm_classwxObject; } - wxObject *Clone(void) const; - virtual void CopyObject(wxObject& object_dest) const; bool IsKindOf(wxClassInfo *info) const; @@ -247,7 +252,7 @@ class WXDLLEXPORT wxObject #endif // Debug & memory tracing #if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT) - virtual void Dump(ostream& str); + virtual void Dump(wxSTD ostream& str); #endif #if wxUSE_SERIAL @@ -288,6 +293,11 @@ private: int m_count; }; +inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo) +{ + return obj && obj->GetClassInfo()->IsKindOf(classInfo) ? obj : 0; +} + #ifdef __WXDEBUG__ #ifndef WXDEBUG_NEW #define WXDEBUG_NEW new(__TFILE__,__LINE__)