in/out fix

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6283 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-10-02 01:42:01 +00:00
commit ff5136e3a4

View file

@ -1,27 +1,23 @@
/* Helper function to return tuples */ /*
Helper function to return output types, now we need to use a list
instead of a tuple since all the other types
(std::pair,std::vector,std::list,etc) return tuples.
*/
%fragment("t_output_helper","header") %{ %fragment("t_output_helper","header") %{
static PyObject* t_output_helper(PyObject* target, PyObject* o) { static PyObject* t_output_helper(PyObject* target, PyObject* o) {
PyObject* o2;
PyObject* o3;
if (!target) { if (!target) {
target = o; target = o;
} else if (target == Py_None) { } else if (target == Py_None) {
Py_DECREF(Py_None); Py_DECREF(target);
target = o; target = o;
} else { } else {
o2 = target; if (!PyList_Check(target)) {
target = PyTuple_New(1); PyObject *o2 = target;
PyTuple_SetItem(target, 0, o2); target = PyList_New(1);
PyList_SetItem(target, 0, o2);
o3 = PyTuple_New(1); }
PyTuple_SetItem(o3, 0, o); PyList_Append(target,o);
o2 = target;
target = PySequence_Concat(o2, o3);
Py_DECREF(o2);
Py_DECREF(o3);
} }
return target; return target;
} }