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); }