]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/my_typemaps.i
htmlhelp.h no longer needed -> removed test in configure
[wxWidgets.git] / wxPython / src / my_typemaps.i
index 249881280c6f2442da7f361c2d655484e0eb9511..2a2b12e23bc2f604a0c7656087d8014b890eee14 100644 (file)
 
 
 //---------------------------------------------------------------------------
-// Tell SWIG to wrap all the wrappers with Python's thread macros
+// Tell SWIG to wrap all the wrappers with our thread protection
 
 %except(python) {
-    wxPy_BEGIN_ALLOW_THREADS;
+    PyThreadState* __tstate = wxPyBeginAllowThreads();
     $function
-    wxPy_END_ALLOW_THREADS;
+    wxPyEndAllowThreads(__tstate);
     if (PyErr_Occurred()) return NULL;
 }
 
     for (i=0; i<len; i++) {
         PyObject* item = PySequence_GetItem($source, i);
         PyObject* str  = PyObject_Str(item);
-        $target->Add(PyString_AsString(item));
+        $target->Add(PyString_AsString(str));
         Py_DECREF(item);
         Py_DECREF(str);
     }
         delete $source;
 }
 
+//---------------------------------------------------------------------------
+// Typemap for wxArrayInt from Python sequence objects
+
+%typemap(python,in) wxArrayInt& {
+    if (! PySequence_Check($source)) {
+        PyErr_SetString(PyExc_TypeError, "Sequence of integers expected.");
+        return NULL;
+    }
+    $target = new wxArrayInt;
+    int i, len=PySequence_Length($source);
+    for (i=0; i<len; i++) {
+        PyObject* item = PySequence_GetItem($source, i);
+        PyObject* number  = PyNumber_Int(item);
+        $target->Add(PyInt_AS_LONG(number));
+        Py_DECREF(item);
+        Py_DECREF(number);
+    }
+}
+
+%typemap(python, freearg) wxArrayInt& {
+    if ($target)
+        delete $source;
+}
+
+
 //---------------------------------------------------------------------------
 // Map T_OUTPUTs for floats to return ints.
 
     $target = t_output_helper($target, o);
 }
 
+
+%typemap(python,ignore) bool *T_OUTPUT(int temp)
+{
+  $target = (bool*)&temp;
+}
+
+%typemap(python,argout) bool *T_OUTPUT
+{
+    PyObject *o;
+    o = PyInt_FromLong((long) (*$source));
+    $target = t_output_helper($target, o);
+}
+
+%typemap(python,ignore) bool  *OUTPUT = bool *T_OUTPUT;
+%typemap(python,argout) bool  *OUTPUT = bool *T_OUTPUT;
+
+
+
+%typemap(python,ignore) byte *T_OUTPUT(int temp)
+{
+  $target = (byte*)&temp;
+}
+
+%typemap(python,argout) byte *T_OUTPUT
+{
+    PyObject *o;
+    o = PyInt_FromLong((long) (*$source));
+    $target = t_output_helper($target, o);
+}
+
+%typemap(python,ignore) byte  *OUTPUT = byte *T_OUTPUT;
+%typemap(python,argout) byte  *OUTPUT = byte *T_OUTPUT;
+
 //---------------------------------------------------------------------------
 // Typemaps to convert return values that are base class pointers
 // to the real derived type, if possible.  See wxPyMake_wxObject in
 %typemap(python, out) wxToolBar*                { $target = wxPyMake_wxObject($source); }
 %typemap(python, out) wxToolBarBase*            { $target = wxPyMake_wxObject($source); }
 %typemap(python, out) wxWindow*                 { $target = wxPyMake_wxObject($source); }
+%typemap(python, out) wxHtmlWindow*             { $target = wxPyMake_wxObject($source); }
 
 %typemap(python, out) wxSizer*                  { $target = wxPyMake_wxSizer($source); }