No real changes, just use const_cast<> instead of C casts.
Replace many comments indicating that the C cast used was really a const_cast<> with the proper cast itself. There is no reason to not use it any longer, all the supported compilers understand it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65861 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -282,7 +282,7 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer,
|
|||||||
const wxString& strEntry)
|
const wxString& strEntry)
|
||||||
{
|
{
|
||||||
m_bChanged = false;
|
m_bChanged = false;
|
||||||
m_pContainer = (wxConfigBase *)pContainer;
|
m_pContainer = const_cast<wxConfigBase *>(pContainer);
|
||||||
|
|
||||||
// the path is everything which precedes the last slash
|
// the path is everything which precedes the last slash
|
||||||
wxString strPath = strEntry.BeforeLast(wxCONFIG_PATH_SEPARATOR);
|
wxString strPath = strEntry.BeforeLast(wxCONFIG_PATH_SEPARATOR);
|
||||||
|
@@ -95,7 +95,7 @@ void wxControlBase::Command(wxCommandEvent& event)
|
|||||||
|
|
||||||
void wxControlBase::InitCommandEvent(wxCommandEvent& event) const
|
void wxControlBase::InitCommandEvent(wxCommandEvent& event) const
|
||||||
{
|
{
|
||||||
event.SetEventObject((wxControlBase *)this); // const_cast
|
event.SetEventObject(const_cast<wxControlBase *>(this));
|
||||||
|
|
||||||
// event.SetId(GetId()); -- this is usuall done in the event ctor
|
// event.SetId(GetId()); -- this is usuall done in the event ctor
|
||||||
|
|
||||||
|
@@ -244,7 +244,7 @@ wxFileOffset wxFFile::Length() const
|
|||||||
wxCHECK_MSG( IsOpened(), wxInvalidOffset,
|
wxCHECK_MSG( IsOpened(), wxInvalidOffset,
|
||||||
wxT("wxFFile::Length(): file is closed!") );
|
wxT("wxFFile::Length(): file is closed!") );
|
||||||
|
|
||||||
wxFFile& self = *(wxFFile *)this; // const_cast
|
wxFFile& self = *const_cast<wxFFile *>(this);
|
||||||
|
|
||||||
wxFileOffset posOld = Tell();
|
wxFileOffset posOld = Tell();
|
||||||
if ( posOld != wxInvalidOffset )
|
if ( posOld != wxInvalidOffset )
|
||||||
|
@@ -415,8 +415,7 @@ wxFileOffset wxFile::Length() const
|
|||||||
|
|
||||||
wxFileOffset iRc = Tell();
|
wxFileOffset iRc = Tell();
|
||||||
if ( iRc != wxInvalidOffset ) {
|
if ( iRc != wxInvalidOffset ) {
|
||||||
// have to use const_cast :-(
|
wxFileOffset iLen = const_cast<wxFile *>(this)->SeekEnd();
|
||||||
wxFileOffset iLen = ((wxFile *)this)->SeekEnd();
|
|
||||||
if ( iLen != wxInvalidOffset ) {
|
if ( iLen != wxInvalidOffset ) {
|
||||||
// restore old position
|
// restore old position
|
||||||
if ( ((wxFile *)this)->Seek(iRc) == wxInvalidOffset ) {
|
if ( ((wxFile *)this)->Seek(iRc) == wxInvalidOffset ) {
|
||||||
|
@@ -1024,7 +1024,7 @@ wxLocale::~wxLocale()
|
|||||||
wxSetLocale(m_pOldLocale);
|
wxSetLocale(m_pOldLocale);
|
||||||
|
|
||||||
wxSetlocale(LC_ALL, m_pszOldLocale);
|
wxSetlocale(LC_ALL, m_pszOldLocale);
|
||||||
free((wxChar *)m_pszOldLocale); // const_cast
|
free(const_cast<char *>(m_pszOldLocale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxMemoryInputStream, wxInputStream)
|
|||||||
wxMemoryInputStream::wxMemoryInputStream(const void *data, size_t len)
|
wxMemoryInputStream::wxMemoryInputStream(const void *data, size_t len)
|
||||||
{
|
{
|
||||||
m_i_streambuf = new wxStreamBuffer(wxStreamBuffer::read);
|
m_i_streambuf = new wxStreamBuffer(wxStreamBuffer::read);
|
||||||
m_i_streambuf->SetBufferIO((void *)data, len); // const_cast
|
m_i_streambuf->SetBufferIO(const_cast<void *>(data), len);
|
||||||
m_i_streambuf->SetIntPosition(0); // seek to start pos
|
m_i_streambuf->SetIntPosition(0); // seek to start pos
|
||||||
m_i_streambuf->Fixed(true);
|
m_i_streambuf->Fixed(true);
|
||||||
|
|
||||||
|
@@ -3227,7 +3227,7 @@ void wxCSConv::CreateConvIfNeeded() const
|
|||||||
{
|
{
|
||||||
if ( m_deferred )
|
if ( m_deferred )
|
||||||
{
|
{
|
||||||
wxCSConv *self = (wxCSConv *)this; // const_cast
|
wxCSConv *self = const_cast<wxCSConv *>(this);
|
||||||
|
|
||||||
// if we don't have neither the name nor the encoding, use the default
|
// if we don't have neither the name nor the encoding, use the default
|
||||||
// encoding for this system
|
// encoding for this system
|
||||||
|
@@ -5892,8 +5892,8 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
|
|
||||||
bool wxGrid::IsCurrentCellReadOnly() const
|
bool wxGrid::IsCurrentCellReadOnly() const
|
||||||
{
|
{
|
||||||
// const_cast
|
wxGridCellAttr*
|
||||||
wxGridCellAttr* attr = ((wxGrid *)this)->GetCellAttr(m_currentCellCoords);
|
attr = const_cast<wxGrid *>(this)->GetCellAttr(m_currentCellCoords);
|
||||||
bool readonly = attr->IsReadOnly();
|
bool readonly = attr->IsReadOnly();
|
||||||
attr->DecRef();
|
attr->DecRef();
|
||||||
|
|
||||||
@@ -7270,7 +7270,7 @@ void wxGrid::CacheAttr(int row, int col, wxGridCellAttr *attr) const
|
|||||||
{
|
{
|
||||||
if ( attr != NULL )
|
if ( attr != NULL )
|
||||||
{
|
{
|
||||||
wxGrid *self = (wxGrid *)this; // const_cast
|
wxGrid * const self = const_cast<wxGrid *>(this);
|
||||||
|
|
||||||
self->ClearAttrCache();
|
self->ClearAttrCache();
|
||||||
self->m_attrCache.row = row;
|
self->m_attrCache.row = row;
|
||||||
@@ -8164,7 +8164,7 @@ void wxGrid::AutoSizeColLabelSize( int col )
|
|||||||
|
|
||||||
wxSize wxGrid::DoGetBestSize() const
|
wxSize wxGrid::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
wxGrid *self = (wxGrid *)this; // const_cast
|
wxGrid * const self = const_cast<wxGrid *>(this);
|
||||||
|
|
||||||
// we do the same as in AutoSize() here with the exception that we don't
|
// we do the same as in AutoSize() here with the exception that we don't
|
||||||
// change the column/row sizes, only calculate them
|
// change the column/row sizes, only calculate them
|
||||||
|
@@ -414,7 +414,7 @@ bool wxBitmap::CopyFromDIB(const wxDIB& dib)
|
|||||||
if ( !hbitmap )
|
if ( !hbitmap )
|
||||||
return false;
|
return false;
|
||||||
#else // ALWAYS_USE_DIB
|
#else // ALWAYS_USE_DIB
|
||||||
HBITMAP hbitmap = ((wxDIB &)dib).Detach(); // const_cast
|
HBITMAP hbitmap = const_cast<wxDIB &>(dib).Detach();
|
||||||
#endif // SOMETIMES_USE_DIB/ALWAYS_USE_DIB
|
#endif // SOMETIMES_USE_DIB/ALWAYS_USE_DIB
|
||||||
|
|
||||||
UnRef();
|
UnRef();
|
||||||
@@ -493,7 +493,7 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// bits should already be in Windows standard format
|
// bits should already be in Windows standard format
|
||||||
data = (char *)bits; // const_cast is harmless
|
data = const_cast<char *>(bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
HBITMAP hbmp = ::CreateBitmap(width, height, 1, depth, data);
|
HBITMAP hbmp = ::CreateBitmap(width, height, 1, depth, data);
|
||||||
|
@@ -785,7 +785,7 @@ bool wxNotebook::InsertPage(size_t nPage,
|
|||||||
if ( !strText.empty() )
|
if ( !strText.empty() )
|
||||||
{
|
{
|
||||||
tcItem.mask |= TCIF_TEXT;
|
tcItem.mask |= TCIF_TEXT;
|
||||||
tcItem.pszText = (wxChar *)strText.wx_str(); // const_cast
|
tcItem.pszText = const_cast<wxChar *>(strText.wx_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// hide the page: unless it is selected, it shouldn't be shown (and if it
|
// hide the page: unless it is selected, it shouldn't be shown (and if it
|
||||||
|
@@ -1180,28 +1180,28 @@ void wxThread::SetPriority(unsigned int prio)
|
|||||||
|
|
||||||
unsigned int wxThread::GetPriority() const
|
unsigned int wxThread::GetPriority() const
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
wxCriticalSectionLocker lock(const_cast<wxCriticalSection &>(m_critsect));
|
||||||
|
|
||||||
return m_internal->GetPriority();
|
return m_internal->GetPriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxThread::GetId() const
|
unsigned long wxThread::GetId() const
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
wxCriticalSectionLocker lock(const_cast<wxCriticalSection &>(m_critsect));
|
||||||
|
|
||||||
return (unsigned long)m_internal->GetId();
|
return (unsigned long)m_internal->GetId();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::IsRunning() const
|
bool wxThread::IsRunning() const
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
wxCriticalSectionLocker lock(const_cast<wxCriticalSection &>(m_critsect));
|
||||||
|
|
||||||
return m_internal->GetState() == STATE_RUNNING;
|
return m_internal->GetState() == STATE_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::IsAlive() const
|
bool wxThread::IsAlive() const
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
wxCriticalSectionLocker lock(const_cast<wxCriticalSection &>(m_critsect));
|
||||||
|
|
||||||
return (m_internal->GetState() == STATE_RUNNING) ||
|
return (m_internal->GetState() == STATE_RUNNING) ||
|
||||||
(m_internal->GetState() == STATE_PAUSED);
|
(m_internal->GetState() == STATE_PAUSED);
|
||||||
@@ -1209,14 +1209,14 @@ bool wxThread::IsAlive() const
|
|||||||
|
|
||||||
bool wxThread::IsPaused() const
|
bool wxThread::IsPaused() const
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
wxCriticalSectionLocker lock(const_cast<wxCriticalSection &>(m_critsect));
|
||||||
|
|
||||||
return m_internal->GetState() == STATE_PAUSED;
|
return m_internal->GetState() == STATE_PAUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::TestDestroy()
|
bool wxThread::TestDestroy()
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
wxCriticalSectionLocker lock(const_cast<wxCriticalSection &>(m_critsect));
|
||||||
|
|
||||||
return m_internal->GetState() == STATE_CANCELED;
|
return m_internal->GetState() == STATE_CANCELED;
|
||||||
}
|
}
|
||||||
|
@@ -1128,14 +1128,14 @@ void wxThread::SetPriority(unsigned int prio)
|
|||||||
|
|
||||||
unsigned int wxThread::GetPriority() const
|
unsigned int wxThread::GetPriority() const
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
wxCriticalSectionLocker lock(const_cast<wxCriticalSection &>(m_critsect));
|
||||||
|
|
||||||
return m_internal->GetPriority();
|
return m_internal->GetPriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxThread::GetId() const
|
unsigned long wxThread::GetId() const
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
wxCriticalSectionLocker lock(const_cast<wxCriticalSection &>(m_critsect));
|
||||||
|
|
||||||
return (unsigned long)m_internal->GetId();
|
return (unsigned long)m_internal->GetId();
|
||||||
}
|
}
|
||||||
|
@@ -581,8 +581,7 @@ wxString wxNativeFontInfo::GetXFontComponent(wxXLFDField field) const
|
|||||||
|
|
||||||
if ( !HasElements() )
|
if ( !HasElements() )
|
||||||
{
|
{
|
||||||
// const_cast
|
if ( !const_cast<wxNativeFontInfo *>(this)->FromXFontName(xFontName) )
|
||||||
if ( !((wxNativeFontInfo *)this)->FromXFontName(xFontName) )
|
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,8 +638,7 @@ wxString wxNativeFontInfo::GetXFontName() const
|
|||||||
elt = wxT('*');
|
elt = wxT('*');
|
||||||
}
|
}
|
||||||
|
|
||||||
// const_cast
|
const_cast<wxNativeFontInfo *>(this)->xFontName << wxT('-') << elt;
|
||||||
((wxNativeFontInfo *)this)->xFontName << wxT('-') << elt;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,8 +656,7 @@ wxNativeFontInfo::SetXFontComponent(wxXLFDField field, const wxString& value)
|
|||||||
|
|
||||||
if ( !HasElements() )
|
if ( !HasElements() )
|
||||||
{
|
{
|
||||||
// const_cast
|
if ( !const_cast<wxNativeFontInfo *>(this)->FromXFontName(xFontName) )
|
||||||
if ( !((wxNativeFontInfo *)this)->FromXFontName(xFontName) )
|
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( wxT("can't set font element for invalid XLFD") );
|
wxFAIL_MSG( wxT("can't set font element for invalid XLFD") );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user