X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/db301e681f78550c6a852fc0ce00537c5f930fa2..fc71d09b42c69406f1b5da07cef9924807557a23:/wxPython/src/helpers.cpp diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index aa4ebd2986..694c5f4780 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -49,7 +49,7 @@ //---------------------------------------------------------------------- -#if PYTHON_API_VERSION <= 1007 && wxUSE_UNICODE +#if PYTHON_API_VERSION < 1009 && wxUSE_UNICODE #error Python must support Unicode to use wxWindows Unicode #endif @@ -421,10 +421,10 @@ void wxPyApp::_BootstrapApp() goto error; } - // On wxGTK the locale will be changed to match the system settings, but - // Python needs to have LC_NUMERIC set to "C" in order for the floating - // point conversions and such to work right. -#if defined(__WXGTK__) && PYTHON_API_VERSION <= 1012 + // On wxGTK the locale will be changed to match the system settings, + // but Python before 2.4 needs to have LC_NUMERIC set to "C" in order + // for the floating point conversions and such to work right. +#if defined(__WXGTK__) && PY_VERSION_HEX < 0x02040000 setlocale(LC_NUMERIC, "C"); #endif @@ -1184,7 +1184,8 @@ bool wxPyInputStream::eof() { } wxPyInputStream::~wxPyInputStream() { - /* do nothing */ + if (m_wxis) + delete m_wxis; } @@ -1385,7 +1386,7 @@ PyObject* wxPyCBInputStream::getMethod(PyObject* py, char* name) { } -size_t wxPyCBInputStream::GetSize() const { +wxFileOffset wxPyCBInputStream::GetLength() const { wxPyCBInputStream* self = (wxPyCBInputStream*)this; // cast off const if (m_seek && m_tell) { wxFileOffset temp = self->OnSysTell(); @@ -1394,7 +1395,7 @@ size_t wxPyCBInputStream::GetSize() const { return ret; } else - return 0; + return wxInvalidOffset; } @@ -1429,14 +1430,20 @@ size_t wxPyCBInputStream::OnSysWrite(const void *buffer, size_t bufsize) { return 0; } + wxFileOffset wxPyCBInputStream::OnSysSeek(wxFileOffset off, wxSeekMode mode) { bool blocked = wxPyBeginBlockThreads(); -#if defined( __WINCE__) || defined(_LARGE_FILES) || wxHAS_HUGE_FILES - // wxFileOffset is a 64-bit value... - PyObject* arglist = Py_BuildValue("(Li)", off, mode); -#else - PyObject* arglist = Py_BuildValue("(ii)", off, mode); -#endif + PyObject* arglist = PyTuple_New(2); + + if (sizeof(wxFileOffset) > sizeof(long)) + // wxFileOffset is a 64-bit value... + PyTuple_SET_ITEM(arglist, 0, PyLong_FromLongLong(off)); + else + PyTuple_SET_ITEM(arglist, 0, PyInt_FromLong(off)); + + PyTuple_SET_ITEM(arglist, 1, PyInt_FromLong(mode)); + + PyObject* result = PyEval_CallObject(m_seek, arglist); Py_DECREF(arglist); Py_XDECREF(result); @@ -1452,11 +1459,9 @@ wxFileOffset wxPyCBInputStream::OnSysTell() const { Py_DECREF(arglist); wxFileOffset o = 0; if (result != NULL) { -#if defined( __WINCE__) || defined(_LARGE_FILES) || wxHAS_HUGE_FILES if (PyLong_Check(result)) o = PyLong_AsLongLong(result); else -#endif o = PyInt_AsLong(result); Py_DECREF(result); };