]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/streams.i
Fixed compilation error
[wxWidgets.git] / wxPython / src / streams.i
index 84020cb3930c8fd28c0915f84671a3eb4b8c8e7d..4426a09a2dcafa165e7c1faf9fc287129b44dbb7 100644 (file)
     if ($source) {
         _ptr = new wxPyInputStream($source);
     }
     if ($source) {
         _ptr = new wxPyInputStream($source);
     }
-    if (_ptr) {
-        char    swigptr[64];
-        SWIG_MakePtr(swigptr, _ptr, "_wxPyInputStream_p");
-
-        PyObject* classobj = PyDict_GetItemString(wxPython_dict, "wxInputStreamPtr");
-        if (! classobj) {
-            Py_INCREF(Py_None);
-            $target = Py_None;
-        } else {
-            PyObject* arg = Py_BuildValue("(s)", swigptr);
-            $target = PyInstance_New(classobj, arg, NULL);
-            Py_DECREF(arg);
-
-            // set ThisOwn
-            PyObject* one = PyInt_FromLong(1);
-            PyObject_SetAttrString($target, "thisown", one);
-            Py_DECREF(one);
-        }
-    } else {
-        Py_INCREF(Py_None);
-        $target = Py_None;
-    }
+    $target = wxPyConstructObject(_ptr, "wxInputStream", TRUE);
 }
 
 //----------------------------------------------------------------------
 }
 
 //----------------------------------------------------------------------
@@ -267,7 +246,7 @@ protected:
         if (bufsize == 0)
             return 0;
 
         if (bufsize == 0)
             return 0;
 
-        bool doSave = wxPyRestoreThread();
+        wxPyTState* state = wxPyBeginBlockThreads();
         PyObject* arglist = Py_BuildValue("(i)", bufsize);
         PyObject* result = PyEval_CallObject(read, arglist);
         Py_DECREF(arglist);
         PyObject* arglist = Py_BuildValue("(i)", bufsize);
         PyObject* result = PyEval_CallObject(read, arglist);
         Py_DECREF(arglist);
@@ -285,7 +264,7 @@ protected:
         }
         else
             m_lasterror = wxSTREAM_READ_ERROR;
         }
         else
             m_lasterror = wxSTREAM_READ_ERROR;
-        wxPySaveThread(doSave);
+        wxPyEndBlockThreads(state);
         m_lastcount = o;
         return o;
     }
         m_lastcount = o;
         return o;
     }
@@ -296,17 +275,17 @@ protected:
     }
 
     virtual off_t OnSysSeek(off_t off, wxSeekMode mode){
     }
 
     virtual off_t OnSysSeek(off_t off, wxSeekMode mode){
-        bool doSave = wxPyRestoreThread();
+        wxPyTState* state = wxPyBeginBlockThreads();
         PyObject*arglist = Py_BuildValue("(ii)", off, mode);
         PyObject*result = PyEval_CallObject(seek, arglist);
         Py_DECREF(arglist);
         Py_XDECREF(result);
         PyObject*arglist = Py_BuildValue("(ii)", off, mode);
         PyObject*result = PyEval_CallObject(seek, arglist);
         Py_DECREF(arglist);
         Py_XDECREF(result);
-        wxPySaveThread(doSave);
+        wxPyEndBlockThreads(state);
         return OnSysTell();
     }
 
     virtual off_t OnSysTell() const{
         return OnSysTell();
     }
 
     virtual off_t OnSysTell() const{
-        bool doSave = wxPyRestoreThread();
+        wxPyTState* state = wxPyBeginBlockThreads();
         PyObject* arglist = Py_BuildValue("()");
         PyObject* result = PyEval_CallObject(tell, arglist);
         Py_DECREF(arglist);
         PyObject* arglist = Py_BuildValue("()");
         PyObject* result = PyEval_CallObject(tell, arglist);
         Py_DECREF(arglist);
@@ -315,7 +294,7 @@ protected:
             o = PyInt_AsLong(result);
             Py_DECREF(result);
         };
             o = PyInt_AsLong(result);
             Py_DECREF(result);
         };
-        wxPySaveThread(doSave);
+        wxPyEndBlockThreads(state);
         return o;
     }
 
         return o;
     }
 
@@ -325,12 +304,12 @@ protected:
 
 public:
     ~wxPyCBInputStream() {
 
 public:
     ~wxPyCBInputStream() {
-        bool doSave = wxPyRestoreThread();
+        wxPyTState* state = wxPyBeginBlockThreads();
         Py_XDECREF(py);
         Py_XDECREF(read);
         Py_XDECREF(seek);
         Py_XDECREF(tell);
         Py_XDECREF(py);
         Py_XDECREF(read);
         Py_XDECREF(seek);
         Py_XDECREF(tell);
-        wxPySaveThread(doSave);
+        wxPyEndBlockThreads(state);
     }
 
     virtual size_t GetSize() {
     }
 
     virtual size_t GetSize() {
@@ -505,3 +484,10 @@ public:
 }
 
 
 }
 
 
+//----------------------------------------------------------------------
+
+%init %{
+    wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
+%}
+
+//----------------------------------------------------------------------