new %import test for vector
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12633 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
512cf3d12d
commit
fd666c1440
6 changed files with 32 additions and 2 deletions
|
|
@ -516,6 +516,7 @@ C_TEST_CASES += \
|
||||||
MULTI_CPP_TEST_CASES += \
|
MULTI_CPP_TEST_CASES += \
|
||||||
clientdata_prop \
|
clientdata_prop \
|
||||||
imports \
|
imports \
|
||||||
|
import_stl \
|
||||||
packageoption \
|
packageoption \
|
||||||
mod \
|
mod \
|
||||||
template_typedef_import \
|
template_typedef_import \
|
||||||
|
|
|
||||||
2
Examples/test-suite/import_stl.list
Normal file
2
Examples/test-suite/import_stl.list
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
import_stl_a
|
||||||
|
import_stl_b
|
||||||
5
Examples/test-suite/import_stl_a.i
Normal file
5
Examples/test-suite/import_stl_a.i
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
%module import_stl_a
|
||||||
|
|
||||||
|
%include <std_vector.i>
|
||||||
|
%template(VectorInt) std::vector<int>;
|
||||||
|
|
||||||
13
Examples/test-suite/import_stl_b.i
Normal file
13
Examples/test-suite/import_stl_b.i
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
%module import_stl_b
|
||||||
|
|
||||||
|
%import "import_stl_a.i"
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
#include <vector>
|
||||||
|
std::vector<int> process_vector(const std::vector<int>& v) {
|
||||||
|
std::vector<int> v_new = v;
|
||||||
|
v_new.push_back(4);
|
||||||
|
return v_new;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
7
Examples/test-suite/python/import_stl_runme.py
Normal file
7
Examples/test-suite/python/import_stl_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import import_stl_b
|
||||||
|
import import_stl_a
|
||||||
|
|
||||||
|
v_new = import_stl_b.process_vector([1,2,3])
|
||||||
|
if v_new != (1,2,3,4):
|
||||||
|
raise RuntimeError, v_new
|
||||||
|
|
||||||
|
|
@ -129,12 +129,13 @@ namespace swig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
%#if defined(SWIGPYTHON_BUILTIN)
|
||||||
inline PyObject* make_output_iterator_builtin (PyObject *pyself)
|
inline PyObject* make_output_iterator_builtin (PyObject *pyself)
|
||||||
{
|
{
|
||||||
Py_INCREF(pyself);
|
Py_INCREF(pyself);
|
||||||
return pyself;
|
return pyself;
|
||||||
}
|
}
|
||||||
|
%#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,6 +311,7 @@ namespace swig {
|
||||||
return new SwigPyIteratorOpen_T<OutIter>(current, seq);
|
return new SwigPyIteratorOpen_T<OutIter>(current, seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%#if defined(SWIGPYTHON_BUILTIN)
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
inline PyObject* make_output_iterator_builtin_T (PyObject *pyself)
|
inline PyObject* make_output_iterator_builtin_T (PyObject *pyself)
|
||||||
{
|
{
|
||||||
|
|
@ -320,7 +322,7 @@ namespace swig {
|
||||||
SwigPyIterator *iter = make_output_iterator(seq->begin(), seq->begin(), seq->end(), pyself);
|
SwigPyIterator *iter = make_output_iterator(seq->begin(), seq->begin(), seq->end(), pyself);
|
||||||
return SWIG_InternalNewPointerObj(iter, SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN);
|
return SWIG_InternalNewPointerObj(iter, SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN);
|
||||||
}
|
}
|
||||||
|
%#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue