]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/msw/streams.cpp
corrections to dynamic loading for Darwin
[wxWidgets.git] / wxPython / src / msw / streams.cpp
index fbea578e4582d8b0fbc635873ac5f2e3ee26b2b1..fbd7f643710523cc202dfe2f9786735c0317b589 100644 (file)
@@ -3,7 +3,7 @@
  * 
  * This file was automatically generated by :
  * Simplified Wrapper and Interface Generator (SWIG)
- * Version 1.1 (Build 810)
+ * Version 1.1 (Build 883)
  * 
  * Portions Copyright (c) 1995-1998
  * The University of Utah and The Regents of the University of California.
@@ -41,6 +41,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 extern void SWIG_MakePtr(char *, void *, char *);
 extern void SWIG_RegisterMapping(char *, char *, void *(*)(void *));
 extern char *SWIG_GetPtr(char *, void **, char *);
@@ -58,25 +59,6 @@ extern PyObject *SWIG_newvarlink(void);
 #include <wx/stream.h>
 #include <wx/list.h>
 
-static PyObject* l_output_helper(PyObject* target, PyObject* o) {
-    PyObject*   o2;
-    if (!target) {
-        target = o;
-    } else if (target == Py_None) {
-        Py_DECREF(Py_None);
-        target = o;
-    } else {
-        if (!PyList_Check(target)) {
-            o2 = target;
-            target = PyList_New(0);
-            PyList_Append(target, o2);
-           Py_XDECREF(o2);
-        }
-        PyList_Append(target,o);
-       Py_XDECREF(o);
-    }
-    return target;
-}
 
 static PyObject* t_output_helper(PyObject* target, PyObject* o) {
     PyObject*   o2;
@@ -104,7 +86,11 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
     return target;
 }
 
-static char* wxStringErrorMsg = "string type is required for parameter";
+#if PYTHON_API_VERSION >= 1009
+    static char* wxStringErrorMsg = "String or Unicode type required";
+#else
+    static char* wxStringErrorMsg = "String type required";
+#endif
   // C++
 // definitions of wxStringPtrList and wxPyInputStream
 #include <wx/listimpl.cpp>
@@ -156,14 +142,12 @@ wxString* wxPyInputStream::read(int size) {
         }
 
         // read until EOF
-        wxPy_BEGIN_ALLOW_THREADS;
         while (! wxi->Eof()) {
             wxi->Read(buf, BUFSIZE);
             //*s += wxString(buf, wxi->LastRead());
             s->Append(buf, wxi->LastRead());
         }
         delete buf;
-        wxPy_END_ALLOW_THREADS;
 
         // error check
         if (wxi->LastError() == wxSTREAM_READ_ERROR) {
@@ -180,10 +164,8 @@ wxString* wxPyInputStream::read(int size) {
         }
 
         // read size bytes
-        wxPy_BEGIN_ALLOW_THREADS;
         wxi->Read(s->GetWriteBuf(size+1), size);
         s->UngetWriteBuf(wxi->LastRead());
-        wxPy_END_ALLOW_THREADS;
 
         // error check
         if (wxi->LastError() == wxSTREAM_READ_ERROR) {
@@ -213,11 +195,9 @@ wxString* wxPyInputStream::readline (int size) {
     }
 
     // read until \n or byte limit reached
-    wxPy_BEGIN_ALLOW_THREADS;
     for (i=ch=0; (ch != '\n') && (!wxi->Eof()) && ((size < 0) || (i < size)); i++) {
         *s += ch = wxi->GetC();
     }
-    wxPy_END_ALLOW_THREADS;
 
     // errorcheck
     if (wxi->LastError() == wxSTREAM_READ_ERROR) {
@@ -244,7 +224,6 @@ wxStringPtrList* wxPyInputStream::readlines (int sizehint) {
     }
 
     // read sizehint bytes or until EOF
-    wxPy_BEGIN_ALLOW_THREADS;
     int i;
     for (i=0; (!wxi->Eof()) && ((sizehint < 0) || (i < sizehint));) {
         wxString* s = readline();
@@ -256,7 +235,6 @@ wxStringPtrList* wxPyInputStream::readlines (int sizehint) {
         l->Append(s);
         i = i + s->Length();
     }
-    wxPy_END_ALLOW_THREADS;
 
     // error check
     if (wxi->LastError() == wxSTREAM_READ_ERROR) {
@@ -293,7 +271,7 @@ protected:
         if (bufsize == 0)
             return 0;
 
-        bool doSave = wxPyRestoreThread();
+        wxPyBeginBlockThreads();
         PyObject* arglist = Py_BuildValue("(i)", bufsize);
         PyObject* result = PyEval_CallObject(read, arglist);
         Py_DECREF(arglist);
@@ -311,7 +289,7 @@ protected:
         }
         else
             m_lasterror = wxSTREAM_READ_ERROR;
-        wxPySaveThread(doSave);
+        wxPyEndBlockThreads();
         m_lastcount = o;
         return o;
     }
@@ -322,17 +300,17 @@ protected:
     }
 
     virtual off_t OnSysSeek(off_t off, wxSeekMode mode){
-        bool doSave = wxPyRestoreThread();
+        wxPyBeginBlockThreads();
         PyObject*arglist = Py_BuildValue("(ii)", off, mode);
         PyObject*result = PyEval_CallObject(seek, arglist);
         Py_DECREF(arglist);
         Py_XDECREF(result);
-        wxPySaveThread(doSave);
+        wxPyEndBlockThreads();
         return OnSysTell();
     }
 
     virtual off_t OnSysTell() const{
-        bool doSave = wxPyRestoreThread();
+        wxPyBeginBlockThreads();
         PyObject* arglist = Py_BuildValue("()");
         PyObject* result = PyEval_CallObject(tell, arglist);
         Py_DECREF(arglist);
@@ -341,7 +319,7 @@ protected:
             o = PyInt_AsLong(result);
             Py_DECREF(result);
         };
-        wxPySaveThread(doSave);
+        wxPyEndBlockThreads();
         return o;
     }
 
@@ -351,12 +329,12 @@ protected:
 
 public:
     ~wxPyCBInputStream() {
-        bool doSave = wxPyRestoreThread();
+        wxPyBeginBlockThreads();
         Py_XDECREF(py);
         Py_XDECREF(read);
         Py_XDECREF(seek);
         Py_XDECREF(tell);
-        wxPySaveThread(doSave);
+        wxPyEndBlockThreads();
     }
 
     virtual size_t GetSize() {
@@ -399,8 +377,10 @@ public:
         if (!PyObject_HasAttrString(py, name))
             return NULL;
         PyObject* o = PyObject_GetAttrString(py, name);
-        if (!PyMethod_Check(o) && !PyCFunction_Check(o))
+        if (!PyMethod_Check(o) && !PyCFunction_Check(o)) {
+            Py_DECREF(o);
             return NULL;
+        }
         return o;
     }
 
@@ -425,6 +405,7 @@ static PyObject *_wrap_new_wxInputStream(PyObject *self, PyObject *args, PyObjec
     PyObject * _arg0;
     PyObject * _obj0 = 0;
     char *_kwnames[] = { "p", NULL };
+    char _ptemp[128];
 
     self = self;
     if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:new_wxInputStream",_kwnames,&_obj0)) 
@@ -433,17 +414,18 @@ static PyObject *_wrap_new_wxInputStream(PyObject *self, PyObject *args, PyObjec
   _arg0 = _obj0;
 }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (wxPyInputStream *)new_wxPyInputStream(_arg0);
 
-}{
-    char _ptemp[128];
-    if (_result) {
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
+}    if (_result) {
         SWIG_MakePtr(_ptemp, (char *) _result,"_wxPyInputStream_p");
         _resultobj = Py_BuildValue("s",_ptemp);
+    } else {
+        Py_INCREF(Py_None);
+        _resultobj = Py_None;
     }
-    else
-        _resultobj=0;
-}
     return _resultobj;
 }
 
@@ -465,8 +447,11 @@ static PyObject *_wrap_wxInputStream_close(PyObject *self, PyObject *args, PyObj
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         wxInputStream_close(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
@@ -490,8 +475,11 @@ static PyObject *_wrap_wxInputStream_flush(PyObject *self, PyObject *args, PyObj
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         wxInputStream_flush(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
@@ -516,8 +504,11 @@ static PyObject *_wrap_wxInputStream_eof(PyObject *self, PyObject *args, PyObjec
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (bool )wxInputStream_eof(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    _resultobj = Py_BuildValue("i",_result);
     return _resultobj;
 }
@@ -542,15 +533,13 @@ static PyObject *_wrap_wxInputStream_read(PyObject *self, PyObject *args, PyObje
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (wxString *)wxInputStream_read(_arg0,_arg1);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }{
-    if (_result) {
-        _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
-        delete _result;
-    }
-    else
-        _resultobj=0;
+    _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
 }
     return _resultobj;
 }
@@ -575,15 +564,13 @@ static PyObject *_wrap_wxInputStream_readline(PyObject *self, PyObject *args, Py
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (wxString *)wxInputStream_readline(_arg0,_arg1);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }{
-    if (_result) {
-        _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
-        delete _result;
-    }
-    else
-        _resultobj=0;
+    _resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
 }
     return _resultobj;
 }
@@ -608,8 +595,11 @@ static PyObject *_wrap_wxInputStream_readlines(PyObject *self, PyObject *args, P
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (wxStringPtrList *)wxInputStream_readlines(_arg0,_arg1);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }{
     if (_result) {
         _resultobj = PyList_New(_result->GetCount());
@@ -648,8 +638,11 @@ static PyObject *_wrap_wxInputStream_seek(PyObject *self, PyObject *args, PyObje
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         wxInputStream_seek(_arg0,_arg1,_arg2);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
     return _resultobj;
@@ -674,8 +667,11 @@ static PyObject *_wrap_wxInputStream_tell(PyObject *self, PyObject *args, PyObje
         }
     }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         _result = (int )wxInputStream_tell(_arg0);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    _resultobj = Py_BuildValue("i",_result);
     return _resultobj;
 }
@@ -702,15 +698,29 @@ static PyObject *_wrap_wxOutputStream_write(PyObject *self, PyObject *args, PyOb
         }
     }
 {
+#if PYTHON_API_VERSION >= 1009
+    char* tmpPtr; int tmpSize;
+    if (!PyString_Check(_obj1) && !PyUnicode_Check(_obj1)) {
+        PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
+        return NULL;
+    }
+    if (PyString_AsStringAndSize(_obj1, &tmpPtr, &tmpSize) == -1)
+        return NULL;
+    _arg1 = new wxString(tmpPtr, tmpSize);
+#else
     if (!PyString_Check(_obj1)) {
         PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
         return NULL;
     }
-    _arg1 = new wxString(PyString_AsString(_obj1), PyString_Size(_obj1));
+    _arg1 = new wxString(PyString_AS_STRING(_obj1), PyString_GET_SIZE(_obj1));
+#endif
 }
 {
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
         wxOutputStream_write(_arg0,*_arg1);
 
+    wxPyEndAllowThreads(__tstate);
+    if (PyErr_Occurred()) return NULL;
 }    Py_INCREF(Py_None);
     _resultobj = Py_None;
 {
@@ -775,8 +785,6 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
     { "_EBool","_int",0},
     { "_EBool","_wxWindowID",0},
     { "_unsigned_long","_long",0},
-    { "_wxPyInputStream","_class_wxPyInputStream",0},
-    { "_class_wxOutputStream","_wxOutputStream",0},
     { "_signed_int","_wxCoord",0},
     { "_signed_int","_wxPrintQuality",0},
     { "_signed_int","_EBool",0},
@@ -787,7 +795,6 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
     { "_WXTYPE","_unsigned_short",0},
     { "_unsigned_short","_WXTYPE",0},
     { "_unsigned_short","_short",0},
-    { "_class_wxPyInputStream","_wxPyInputStream",0},
     { "_signed_short","_WXTYPE",0},
     { "_signed_short","_short",0},
     { "_unsigned_char","_byte",0},
@@ -835,7 +842,6 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
     { "_wxCoord","_size_t",0},
     { "_wxCoord","_time_t",0},
     { "_wxCoord","_wxPrintQuality",0},
-    { "_wxOutputStream","_class_wxOutputStream",0},
 {0,0,0}};
 
 static PyObject *SWIG_globals;
@@ -847,6 +853,8 @@ SWIGEXPORT(void) initstreamsc() {
         SWIG_globals = SWIG_newvarlink();
         m = Py_InitModule("streamsc", streamscMethods);
         d = PyModule_GetDict(m);
+
+    wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
 {
    int i;
    for (i = 0; _swig_mapping[i].n1; i++)