added and documented wx_const/static_cast<>

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-04-16 10:30:07 +00:00
parent 4d4f4290ea
commit f29fe16932
4 changed files with 59 additions and 19 deletions

View File

@@ -235,6 +235,8 @@ the corresponding topic.
\helpref{wxWakeUpIdle}{wxwakeupidle}\\ \helpref{wxWakeUpIdle}{wxwakeupidle}\\
\helpref{wxWriteResource}{wxwriteresource}\\ \helpref{wxWriteResource}{wxwriteresource}\\
\helpref{wxYield}{wxyield}\\ \helpref{wxYield}{wxyield}\\
\helpref{wx\_const\_cast}{wxconstcastraw}\\
\helpref{wx\_static\_cast}{wxstaticcastraw}\\
\helpref{\_}{underscore}\\ \helpref{\_}{underscore}\\
\helpref{\_T}{underscoret} \helpref{\_T}{underscoret}
@@ -3289,6 +3291,7 @@ supports {\it const\_cast} or into an old, C-style cast, otherwise.
\wxheading{See also} \wxheading{See also}
\helpref{wx\_const\_cast}{wxconstcastraw}\\
\helpref{wxDynamicCast}{wxdynamiccast}\\ \helpref{wxDynamicCast}{wxdynamiccast}\\
\helpref{wxStaticCast}{wxstaticcast} \helpref{wxStaticCast}{wxstaticcast}
@@ -3376,10 +3379,42 @@ This macro checks that the cast is valid in debug mode (an assert failure will
result if {\tt wxDynamicCast(ptr, classname) == NULL}) and then returns the result if {\tt wxDynamicCast(ptr, classname) == NULL}) and then returns the
result of executing an equivalent of {\tt static\_cast<classname *>(ptr)}. result of executing an equivalent of {\tt static\_cast<classname *>(ptr)}.
\wxheading{See also}
\helpref{wx\_static\_cast}{wxstaticcastraw}\\
\helpref{wxDynamicCast}{wxdynamiccast}\\ \helpref{wxDynamicCast}{wxdynamiccast}\\
\helpref{wxConstCast}{wxconstcast} \helpref{wxConstCast}{wxconstcast}
\membersection{wx\_const\_cast}\label{wxconstcastraw}
\func{T}{wx\_const\_cast}{T, x}
Same as \texttt{const\_cast<T>(x)} if the compiler supports const cast or
\texttt{(T)x} for old compilers. Unlike \helpref{wxConstCast}{wxconstcast},
the cast it to the type \arg{T} and not to \texttt{T *} and also the order of
arguments is the same as for the standard cast.
\wxheading{See also}
\helpref{wx\_static\_cast}{wxstaticcastraw}\\
\membersection{wx\_static\_cast}\label{wxstaticcastraw}
\func{T}{wx\_static\_cast}{T, x}
Same as \texttt{static\_cast<T>(x)} if the compiler supports static cast or
\texttt{(T)x} for old compilers. Unlike \helpref{wxStaticCast}{wxstaticcast},
there are no checks being done and the meaning of the macro arguments is exactly
the same as for the standard static cast, i.e. \arg{T} is the full type name and
star is not appended to it.
\wxheading{See also}
\helpref{wx\_const\_cast}{wxconstcastraw}\\
\section{Log functions}\label{logfunctions} \section{Log functions}\label{logfunctions}

View File

@@ -1,12 +1,12 @@
/** /**
* Name: defs.h * Name: defs.h
* Purpose: Declarations/definitions common to all wx source files * Purpose: Declarations/definitions common to all wx source files
* Author: Julian Smart and others * Author: Julian Smart and others
* Modified by: Ryan Norton (Converted to C) * Modified by: Ryan Norton (Converted to C)
* Created: 01/02/97 * Created: 01/02/97
* RCS-ID: $Id$ * RCS-ID: $Id$
* Copyright: (c) * Copyright: (c)
* Licence: wxWindows licence * Licence: wxWindows licence
*/ */
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
@@ -24,7 +24,7 @@
#include "wx/platform.h" #include "wx/platform.h"
/* RN - only double-check the environment when building in C++ /* RN - only double-check the environment when building in C++
Shouldn't configure pass the environment to all sub-libs too? */ Shouldn't configure pass the environment to all sub-libs too? */
#ifdef __cplusplus #ifdef __cplusplus
/* Make sure the environment is set correctly */ /* Make sure the environment is set correctly */
@@ -283,12 +283,21 @@ typedef int wxWindowID;
#endif #endif
#endif /* HAVE_CXX_CASTS */ #endif /* HAVE_CXX_CASTS */
#ifdef HAVE_CONST_CAST #ifdef HAVE_STATIC_CAST
#define wxConstCast(obj, className) const_cast<className *>(obj) #define wx_static_cast(t, x) static_cast<t>(x)
#else #else
#define wxConstCast(obj, className) ((className *)(obj)) #define wx_static_cast(t, x) ((t)(x))
#endif #endif
#ifdef HAVE_CONST_CAST
#define wx_const_cast(t, x) const_cast<t>(x)
#else
#define wx_const_cast(t, x) ((t)(x))
#endif
/* for consistency with wxStatic/DynamicCast defined in wx/object.h */
#define wxConstCast(obj, className) wx_const_cast(className *, obj)
#ifndef HAVE_STD_WSTRING #ifndef HAVE_STD_WSTRING
#if defined(__VISUALC__) && (__VISUALC__ >= 1100) #if defined(__VISUALC__) && (__VISUALC__ >= 1100)
/* VC++ 6.0 and 5.0 have std::wstring (what about earlier versions?) */ /* VC++ 6.0 and 5.0 have std::wstring (what about earlier versions?) */
@@ -744,7 +753,7 @@ typedef wxUint32 wxDword;
#define wxLongLongSuffix l #define wxLongLongSuffix l
#define wxLongLongFmtSpec _T("l") #define wxLongLongFmtSpec _T("l")
#define wxLongLongIsLong #define wxLongLongIsLong
#elif (defined(__VISUALC__) && defined(__WIN32__)) #elif (defined(__VISUALC__) && defined(__WIN32__))
#define wxLongLong_t __int64 #define wxLongLong_t __int64
#define wxLongLongSuffix i64 #define wxLongLongSuffix i64
#define wxLongLongFmtSpec _T("I64") #define wxLongLongFmtSpec _T("I64")
@@ -756,7 +765,7 @@ typedef wxUint32 wxDword;
#define wxLongLong_t __int64 #define wxLongLong_t __int64
#define wxLongLongSuffix i64 #define wxLongLongSuffix i64
#define wxLongLongFmtSpec _T("Ld") #define wxLongLongFmtSpec _T("Ld")
#elif defined(__DIGITALMARS__) #elif defined(__DIGITALMARS__)
#define wxLongLong_t __int64 #define wxLongLong_t __int64
#define wxLongLongSuffix LL #define wxLongLongSuffix LL
#define wxLongLongFmtSpec _T("ll") #define wxLongLongFmtSpec _T("ll")

View File

@@ -57,11 +57,7 @@ typedef int wxEventType;
// this is used to make the event table entry type safe, so that for an event // this is used to make the event table entry type safe, so that for an event
// handler only a function with proper parameter list can be given. // handler only a function with proper parameter list can be given.
#ifdef HAVE_STATIC_CAST #define wxStaticCastEvent(type, val) wx_static_cast(type, val)
#define wxStaticCastEvent(type, val) static_cast<type>(val)
#else
#define wxStaticCastEvent(type, val) ((type)(val))
#endif
// in previous versions of wxWindows the event types used to be constants // in previous versions of wxWindows the event types used to be constants
// which created difficulties with custom/user event types definition // which created difficulties with custom/user event types definition

View File

@@ -544,7 +544,7 @@ public:
// get the runtime identity of this object // get the runtime identity of this object
wxClassInfo *GetClassInfo() const wxClassInfo *GetClassInfo() const
{ {
return const_cast<wxClassInfo*>((const wxClassInfo*)m_classInfo); return wx_const_cast(wxClassInfo *, m_classInfo);
} }
wxObject* GetSuperClassInstance() const wxObject* GetSuperClassInstance() const