use static_cast<> for wxStaticCast; updated comment in front of wxDynamicCast()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-03-08 13:09:25 +00:00
parent f303447b5c
commit 73fbb031f5

View File

@@ -304,7 +304,11 @@ name##PluginSentinel m_pluginsentinel;
// 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::ms_classInfo) #define wxIsKindOf(obj, className) obj->IsKindOf(&className::ms_classInfo)
// to be replaced by dynamic_cast<> in the future // this cast does some more checks at compile time as it uses static_cast
// internally
//
// note that it still has different semantics from dynamic_cast<> and so can't
// be replaced by it as long as there are any compilers not supporting it
#define wxDynamicCast(obj, className) \ #define wxDynamicCast(obj, className) \
((className *) wxCheckDynamicCast( \ ((className *) wxCheckDynamicCast( \
wx_const_cast(wxObject *, wx_static_cast(const wxObject *, \ wx_const_cast(wxObject *, wx_static_cast(const wxObject *, \
@@ -314,7 +318,7 @@ name##PluginSentinel m_pluginsentinel;
// 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::ms_classInfo) ? (className *)(this) : (className *)0) (IsKindOf(&className::ms_classInfo) ? (className *)(this) : (className *)0)
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
inline void* wxCheckCast(void *ptr) inline void* wxCheckCast(void *ptr)
@@ -326,7 +330,7 @@ inline void* wxCheckCast(void *ptr)
((className *)wxCheckCast(wxDynamicCast(obj, className))) ((className *)wxCheckCast(wxDynamicCast(obj, className)))
#else // !__WXDEBUG__ #else // !__WXDEBUG__
#define wxStaticCast(obj, className) ((className *)(obj)) #define wxStaticCast(obj, className) wx_static_cast(className *, obj)
#endif // __WXDEBUG__ #endif // __WXDEBUG__