compilation fixes in WXWIN_COMPATIBILITY_2_2==0 mode

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17702 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-11-04 19:31:59 +00:00
parent c79c41ca66
commit 94bccc31db
16 changed files with 129 additions and 138 deletions

View File

@@ -299,7 +299,7 @@ bool wxDocument::OnSaveDocument(const wxString& file)
if (store.fail() || store.bad())
#else
wxFileOutputStream store( file );
if (store.LastError() != wxSTREAM_NOERROR)
if (store.GetLastError() != wxSTREAM_NO_ERROR)
#endif
{
(void)wxMessageBox(_("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION,
@@ -336,7 +336,7 @@ bool wxDocument::OnOpenDocument(const wxString& file)
if (store.fail() || store.bad())
#else
wxFileInputStream store( file );
if (store.LastError() != wxSTREAM_NOERROR)
if (store.GetLastError() != wxSTREAM_NO_ERROR)
#endif
{
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
@@ -347,8 +347,8 @@ bool wxDocument::OnOpenDocument(const wxString& file)
LoadObject(store);
if ( !store && !store.eof() )
#else
int res = LoadObject(store).LastError();
if ((res != wxSTREAM_NOERROR) &&
int res = LoadObject(store).GetLastError();
if ((res != wxSTREAM_NO_ERROR) &&
(res != wxSTREAM_EOF))
#endif
{
@@ -2215,7 +2215,7 @@ bool wxTransferStreamToFile(wxInputStream& stream, const wxString& filename)
return FALSE;
}
int len = stream.StreamSize();
int len = stream.GetSize();
// TODO: is this the correct test for EOF?
while (stream.TellI() < (len - 1))
{

View File

@@ -90,7 +90,7 @@ wxFSFile* wxZipFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& l
if (right.GetChar(0) == wxT('/')) right = right.Mid(1);
s = new wxZipInputStream(left, right);
if (s && (s->LastError() == wxStream_NOERROR))
if (s && s->IsOk() )
{
return new wxFSFile(s,
left + wxT("#zip:") + right,

View File

@@ -507,7 +507,7 @@ public:
{
delete m_i_socket;
if ( LastError() == wxStream_NOERROR )
if ( IsOk() )
{
// wait for "226 transfer completed"
m_ftp->CheckResult('2');

View File

@@ -634,12 +634,12 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height,
wxUint8 first;
first = aByte;
aByte = stream.GetC();
if ( first == 0 )
if ( first == 0 )
{
if ( aByte == 0 )
{
if ( column > 0 )
column = width;
if ( column > 0 )
column = width;
}
else if ( aByte == 1 )
{
@@ -656,34 +656,34 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height,
}
else
{
int absolute = aByte;
wxUint8 nibble[2] ;
int readBytes = 0 ;
for (int k = 0; k < absolute; k++)
int absolute = aByte;
wxUint8 nibble[2] ;
int readBytes = 0 ;
for (int k = 0; k < absolute; k++)
{
if ( !(k % 2 ) )
{
++readBytes ;
aByte = stream.GetC();
nibble[0] = ( (aByte & 0xF0) >> 4 ) ;
nibble[1] = ( aByte & 0x0F ) ;
}
if ( !(k % 2 ) )
{
++readBytes ;
aByte = stream.GetC();
nibble[0] = ( (aByte & 0xF0) >> 4 ) ;
nibble[1] = ( aByte & 0x0F ) ;
}
ptr[poffset ] = cmap[nibble[k%2]].r;
ptr[poffset + 1] = cmap[nibble[k%2]].g;
ptr[poffset + 2] = cmap[nibble[k%2]].b;
column++;
if ( k % 2 )
linepos++;
}
if ( k % 2 )
linepos++;
}
if ( readBytes & 0x01 )
aByte = stream.GetC();
}
}
}
else
{
wxUint8 nibble[2] ;
nibble[0] = ( (aByte & 0xF0) >> 4 ) ;
nibble[1] = ( aByte & 0x0F ) ;
wxUint8 nibble[2] ;
nibble[0] = ( (aByte & 0xF0) >> 4 ) ;
nibble[1] = ( aByte & 0x0F ) ;
for ( int l = 0; l < first && column < width; l++ )
{
@@ -691,9 +691,9 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height,
ptr[poffset + 1] = cmap[nibble[l%2]].g;
ptr[poffset + 2] = cmap[nibble[l%2]].b;
column++;
if ( l % 2 )
linepos++;
}
if ( l % 2 )
linepos++;
}
}
}
else
@@ -774,63 +774,64 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height,
// linepos += size; seems to be wrong, RR
}
}
}
else if ( bpp == 24 )
{
stream.Read(bbuf, 3);
linepos += 3;
ptr[poffset ] = (unsigned char)bbuf[2];
ptr[poffset + 1] = (unsigned char)bbuf[1];
ptr[poffset + 2] = (unsigned char)bbuf[0];
column++;
}
else if ( bpp == 16 )
{
unsigned char temp;
stream.Read(&aWord, 2);
aWord = wxUINT16_SWAP_ON_BE(aWord);
linepos += 2;
/* use the masks and calculated amonut of shift
}
else if ( bpp == 24 )
{
stream.Read(bbuf, 3);
linepos += 3;
ptr[poffset ] = (unsigned char)bbuf[2];
ptr[poffset + 1] = (unsigned char)bbuf[1];
ptr[poffset + 2] = (unsigned char)bbuf[0];
column++;
}
else if ( bpp == 16 )
{
unsigned char temp;
stream.Read(&aWord, 2);
aWord = wxUINT16_SWAP_ON_BE(aWord);
linepos += 2;
/* use the masks and calculated amonut of shift
to retrieve the color data out of the word. Then
shift it left by (8 - number of bits) such that
the image has the proper dynamic range */
temp = (aWord & rmask) >> rshift << (8-rbits);
ptr[poffset] = temp;
temp = (aWord & gmask) >> gshift << (8-gbits);
ptr[poffset + 1] = temp;
temp = (aWord & bmask) >> bshift << (8-bbits);
ptr[poffset + 2] = temp;
column++;
}
else
{
unsigned char temp;
stream.Read(&aDword, 4);
aDword = wxINT32_SWAP_ON_BE(aDword);
linepos += 4;
temp = (aDword & rmask) >> rshift;
ptr[poffset] = temp;
temp = (aDword & gmask) >> gshift;
ptr[poffset + 1] = temp;
temp = (aDword & bmask) >> bshift;
ptr[poffset + 2] = temp;
column++;
}
}
while ( (linepos < linesize) && (comp != 1) && (comp != 2) )
{
stream.Read(&aByte, 1);
linepos += 1;
if ( stream.LastError() != wxStream_NOERROR )
break;
}
}
if (cmap)
delete[] cmap;
temp = (aWord & rmask) >> rshift << (8-rbits);
ptr[poffset] = temp;
temp = (aWord & gmask) >> gshift << (8-gbits);
ptr[poffset + 1] = temp;
temp = (aWord & bmask) >> bshift << (8-bbits);
ptr[poffset + 2] = temp;
column++;
}
else
{
unsigned char temp;
stream.Read(&aDword, 4);
aDword = wxINT32_SWAP_ON_BE(aDword);
linepos += 4;
temp = (aDword & rmask) >> rshift;
ptr[poffset] = temp;
temp = (aDword & gmask) >> gshift;
ptr[poffset + 1] = temp;
temp = (aDword & bmask) >> bshift;
ptr[poffset + 2] = temp;
column++;
}
}
while ( (linepos < linesize) && (comp != 1) && (comp != 2) )
{
stream.Read(&aByte, 1);
linepos += 1;
if ( !stream )
break;
}
}
image->SetMask(FALSE);
delete[] cmap;
return ( stream.LastError() == wxSTREAM_NO_ERROR || stream.LastError() == wxSTREAM_EOF );
image->SetMask(FALSE);
const wxStreamError err = stream.GetLastError();
return err == wxSTREAM_NO_ERROR || err == wxSTREAM_EOF;
}
bool wxBMPHandler::LoadDib(wxImage *image, wxInputStream& stream,
@@ -1278,7 +1279,7 @@ int wxICOHandler::GetImageCount(wxInputStream& stream)
bool wxICOHandler::DoCanRead(wxInputStream& stream)
{
stream.SeekI(0);
stream.SeekI(0);
unsigned char hdr[4];
if ( !stream.Read(hdr, WXSIZEOF(hdr)) )
return FALSE;

View File

@@ -964,7 +964,7 @@ bool wxImage::SaveFile( const wxString& filename, int type ) const
wxFileOutputStream stream(filename);
if ( stream.LastError() == wxStream_NOERROR )
if ( stream.IsOk() )
{
wxBufferedOutputStream bstream( stream );
return SaveFile(bstream, type);
@@ -981,7 +981,7 @@ bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) con
wxFileOutputStream stream(filename);
if ( stream.LastError() == wxStream_NOERROR )
if ( stream.IsOk() )
{
wxBufferedOutputStream bstream( stream );
return SaveFile(bstream, mimetype);

View File

@@ -107,7 +107,7 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
value=text_stream.Read32();
*ptr++=(unsigned char)value;
if (buf_stream.LastError()!=wxSTREAM_NOERROR)
if ( !buf_stream )
{
if (verbose) wxLogError(_("PNM: File seems truncated."));
return FALSE;
@@ -119,7 +119,8 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
image->SetMask( FALSE );
return (buf_stream.LastError()==wxStream_NOERROR || buf_stream.LastError()==wxStream_EOF);
const wxStreamError err = buf_stream.GetLastError();
return err == wxSTREAM_NO_ERROR || err == wxSTREAM_EOF;
}
bool wxPNMHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool WXUNUSED(verbose) )
@@ -132,7 +133,7 @@ bool wxPNMHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool WXUNUS
text_stream << wxT("P6\n") << image->GetWidth() << wxT(" ") << image->GetHeight() << wxT("\n255\n");
stream.Write(image->GetData(),3*image->GetWidth()*image->GetHeight());
return (stream.LastError()==wxStream_NOERROR);
return stream.IsOk();
}
bool wxPNMHandler::DoCanRead( wxInputStream& stream )

View File

@@ -80,7 +80,7 @@ size_t wxMemoryInputStream::OnSysRead(void *buffer, size_t nbytes)
}
m_i_streambuf->Read(buffer, nbytes);
m_lasterror = wxSTREAM_NOERROR;
m_lasterror = wxSTREAM_NO_ERROR;
return m_i_streambuf->GetIntPosition() - pos;
}

View File

@@ -216,7 +216,7 @@ bool wxResourceTable::DeleteResource(const wxString& name)
bool wxResourceTable::ParseResourceFile( wxInputStream *is )
{
wxExprDatabase db;
int len = is->StreamSize() ;
int len = is->GetSize() ;
bool eof = FALSE;
while ( is->TellI() + 10 < len) // it's a hack because the streams dont support EOF

View File

@@ -44,17 +44,11 @@ wxSocketOutputStream::~wxSocketOutputStream()
size_t wxSocketOutputStream::OnSysWrite(const void *buffer, size_t size)
{
size_t ret;
size_t ret = m_o_socket->Write((const char *)buffer, size).LastCount();
ret = m_o_socket->Write((const char *)buffer, size).LastCount();
if (m_o_socket->Error())
m_lasterror = wxStream_WRITE_ERR;
else
m_lasterror = wxStream_NOERROR;
m_lasterror = m_o_socket->Error() ? wxSTREAM_WRITE_ERROR : wxSTREAM_NO_ERROR;
return ret;
}
// ---------------------------------------------------------------------------
@@ -72,14 +66,9 @@ wxSocketInputStream::~wxSocketInputStream()
size_t wxSocketInputStream::OnSysRead(void *buffer, size_t size)
{
size_t ret;
size_t ret = m_i_socket->Read((char *)buffer, size).LastCount();
ret = m_i_socket->Read((char *)buffer, size).LastCount();
if (m_i_socket->Error())
m_lasterror = wxStream_READ_ERR;
else
m_lasterror = wxStream_NOERROR;
m_lasterror = m_i_socket->Error() ? wxSTREAM_READ_ERROR : wxSTREAM_NO_ERROR;
return ret;
}

View File

@@ -58,7 +58,7 @@
void wxStreamBuffer::SetError(wxStreamError err)
{
if ( m_stream->m_lasterror == wxStream_NOERROR )
if ( m_stream->m_lasterror == wxSTREAM_NO_ERROR )
m_stream->m_lasterror = err;
}
@@ -184,7 +184,7 @@ void wxStreamBuffer::ResetBuffer()
{
if ( m_stream )
{
m_stream->m_lasterror = wxStream_NOERROR;
m_stream->Reset();
m_stream->m_lastcount = 0;
}
@@ -311,7 +311,7 @@ void wxStreamBuffer::PutChar(char c)
if ( !GetDataLeft() && !FlushBuffer() )
{
// we don't
SetError(wxStream_WRITE_ERR);
SetError(wxSTREAM_WRITE_ERROR);
}
else
{
@@ -328,7 +328,7 @@ char wxStreamBuffer::Peek()
if ( !GetDataLeft() )
{
SetError(wxStream_READ_ERR);
SetError(wxSTREAM_READ_ERROR);
return 0;
}
@@ -354,7 +354,7 @@ char wxStreamBuffer::GetChar()
{
if ( !GetDataLeft() )
{
SetError(wxStream_READ_ERR);
SetError(wxSTREAM_READ_ERROR);
c = 0;
}
else
@@ -371,7 +371,7 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size)
{
// lasterror is reset before all new IO calls
if ( m_stream )
m_stream->m_lasterror = wxStream_NOERROR;
m_stream->Reset();
size_t read;
if ( !HasBuffer() )
@@ -400,7 +400,7 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size)
if ( !FillBuffer() )
{
SetError(wxStream_EOF);
SetError(wxSTREAM_EOF);
break;
}
}
@@ -450,7 +450,7 @@ size_t wxStreamBuffer::Write(const void *buffer, size_t size)
wxCHECK_MSG( outStream, 0, _T("should have a stream in wxStreamBuffer") );
// lasterror is reset before all new IO calls
m_stream->m_lasterror = wxStream_NOERROR;
m_stream->Reset();
if ( !HasBuffer() && m_fixed )
{
@@ -481,7 +481,7 @@ size_t wxStreamBuffer::Write(const void *buffer, size_t size)
if ( !FlushBuffer() )
{
SetError(wxStream_WRITE_ERR);
SetError(wxSTREAM_WRITE_ERROR);
break;
}
@@ -634,7 +634,7 @@ off_t wxStreamBuffer::Tell() const
wxStreamBase::wxStreamBase()
{
m_lasterror = wxStream_NOERROR;
m_lasterror = wxSTREAM_NO_ERROR;
m_lastcount = 0;
}
@@ -812,7 +812,7 @@ char wxInputStream::Peek()
{
char c;
Read(&c, sizeof(c));
if (m_lasterror == wxStream_NOERROR)
if (m_lasterror == wxSTREAM_NO_ERROR)
{
Ungetch(c);
return c;
@@ -847,7 +847,7 @@ off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
// I don't know whether it should be put as well in wxFileInputStream::OnSysSeek
if (m_lasterror==wxSTREAM_EOF)
m_lasterror=wxSTREAM_NOERROR;
m_lasterror=wxSTREAM_NO_ERROR;
/* RR: A call to SeekI() will automatically invalidate any previous
call to Ungetch(), otherwise it would be possible to SeekI() to
@@ -1062,7 +1062,7 @@ char wxBufferedInputStream::Peek()
wxInputStream& wxBufferedInputStream::Read(void *buf, size_t size)
{
// reset the error flag
m_lasterror = wxStream_NOERROR;
Reset();
// first read from the already cached data
m_lastcount = GetWBack(buf, size);
@@ -1090,7 +1090,7 @@ off_t wxBufferedInputStream::SeekI(off_t pos, wxSeekMode mode)
// RR: Look at wxInputStream for comments.
if (m_lasterror==wxSTREAM_EOF)
m_lasterror=wxSTREAM_NOERROR;
Reset();
if (m_wback)
{

View File

@@ -1106,7 +1106,7 @@ static long wxDoExecuteWithCapture(const wxString& command,
if ( !is->Eof() && is->IsOk() )
{
wxString line = tis.ReadLine();
if ( is->LastError() )
if ( !*is )
break;
cont = TRUE;
@@ -1117,7 +1117,7 @@ static long wxDoExecuteWithCapture(const wxString& command,
if ( error && !es->Eof() && es->IsOk() )
{
wxString line = tes->ReadLine();
if ( es->LastError() )
if ( !*es )
break;
cont = TRUE;

View File

@@ -235,10 +235,10 @@ size_t wxFFileInputStream::OnSysRead(void *buffer, size_t size)
ret = m_file->Read(buffer, size);
if (m_file->Eof())
m_lasterror = wxStream_EOF;
m_lasterror = wxSTREAM_EOF;
if (ret == wxInvalidOffset)
{
m_lasterror = wxStream_READ_ERR;
m_lasterror = wxSTREAM_READ_ERROR;
ret = 0;
}
@@ -307,9 +307,9 @@ size_t wxFFileOutputStream::OnSysWrite(const void *buffer, size_t size)
{
size_t ret = m_file->Write(buffer, size);
if (m_file->Error())
m_lasterror = wxStream_WRITE_ERR;
m_lasterror = wxSTREAM_WRITE_ERROR;
else
m_lasterror = wxStream_NOERROR;
m_lasterror = wxSTREAM_NO_ERROR;
return ret;
}

View File

@@ -143,7 +143,7 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream)
wxCharBuffer buffer(length);
char *xpm_buffer = (char *)buffer.data();
if ( stream.Read(xpm_buffer, length).LastError() == wxSTREAM_READ_ERROR )
if ( stream.Read(xpm_buffer, length).GetLastError() == wxSTREAM_READ_ERROR )
return wxNullImage;
xpm_buffer[length] = '\0';

View File

@@ -43,12 +43,12 @@ wxZipInputStream::wxZipInputStream(const wxString& archive, const wxString& file
m_Archive = (void*) unzOpen(archive.mb_str());
if (m_Archive == NULL)
{
m_lasterror = wxStream_READ_ERR;
m_lasterror = wxSTREAM_READ_ERROR;
return;
}
if (unzLocateFile((unzFile)m_Archive, file.mb_str(), 0) != UNZ_OK)
{
m_lasterror = wxStream_READ_ERR;
m_lasterror = wxSTREAM_READ_ERROR;
return;
}
@@ -56,7 +56,7 @@ wxZipInputStream::wxZipInputStream(const wxString& archive, const wxString& file
if (unzOpenCurrentFile((unzFile)m_Archive) != UNZ_OK)
{
m_lasterror = wxStream_READ_ERR;
m_lasterror = wxSTREAM_READ_ERROR;
return;
}
m_Size = (size_t)zinfo.uncompressed_size;
@@ -90,7 +90,7 @@ size_t wxZipInputStream::OnSysRead(void *buffer, size_t bufsize)
if ( m_Pos >= (off_t)m_Size )
{
m_lasterror = wxStream_EOF;
m_lasterror = wxSTREAM_EOF;
return 0;
}
@@ -132,7 +132,7 @@ off_t wxZipInputStream::OnSysSeek(off_t seek, wxSeekMode mode)
unzCloseCurrentFile((unzFile)m_Archive);
if (unzOpenCurrentFile((unzFile)m_Archive) != UNZ_OK)
{
m_lasterror = wxStream_READ_ERR;
m_lasterror = wxSTREAM_READ_ERROR;
return m_Pos;
}
toskip = nextpos;

View File

@@ -89,17 +89,17 @@ size_t wxZlibInputStream::OnSysRead(void *buffer, size_t size)
m_inflate->next_in = m_z_buffer;
m_inflate->avail_in = m_parent_i_stream->LastRead();
if (m_parent_i_stream->LastError() != wxStream_NOERROR &&
m_parent_i_stream->LastError() != wxStream_EOF)
wxStreamError err = m_parent_i_stream->GetLastError();
if ( err != wxSTREAM_NO_ERROR && err != wxSTREAM_EOF)
{
m_lasterror = m_parent_i_stream->LastError();
m_lasterror = err;
return 0; // failed to read anything
}
if ( m_inflate->avail_in == 0 )
{
// EOF
m_lasterror = wxStream_EOF;
m_lasterror = wxSTREAM_EOF;
break;
}
}
@@ -210,7 +210,7 @@ size_t wxZlibOutputStream::OnSysWrite(const void *buffer, size_t size)
if (m_deflate->avail_out == 0) {
m_parent_o_stream->Write(m_z_buffer, m_z_size);
if (m_parent_o_stream->LastError() != wxStream_NOERROR)
if ( !*m_parent_o_stream )
return (size - m_deflate->avail_in);
m_deflate->next_out = m_z_buffer;

View File

@@ -418,7 +418,7 @@ size_t wxPipeOutputStream::OnSysWrite(const void *buffer, size_t len)
{
DWORD bytesWritten;
m_lasterror = wxSTREAM_NOERROR;
m_lasterror = wxSTREAM_NO_ERROR;
if ( !::WriteFile(m_hOutput, buffer, len, &bytesWritten, NULL) )
{
m_lasterror = ::GetLastError() == ERROR_BROKEN_PIPE