add more cases and flag for valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8098 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c23dd13d92
commit
70bb5455a6
2 changed files with 58 additions and 2 deletions
51
SWIG/Examples/test-suite/python/vector.i
Normal file
51
SWIG/Examples/test-suite/python/vector.i
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
%module vector
|
||||
%{
|
||||
#include <vector>
|
||||
%}
|
||||
|
||||
%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...)
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef CTYPE value_type;
|
||||
size_type size() const;
|
||||
vector();
|
||||
%extend {
|
||||
static std::vector<CTYPE > *Repeat(const value_type& value, int count) /*throw (std::out_of_range)*/ {
|
||||
// if (count < 0)
|
||||
// throw std::out_of_range("count");
|
||||
return new std::vector<CTYPE >(count, value);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
namespace std {
|
||||
// primary (unspecialized) class template for std::vector
|
||||
// does not require operator== to be defined
|
||||
template<class T> class vector {
|
||||
SWIG_STD_VECTOR_MINIMUM(T, T)
|
||||
};
|
||||
}
|
||||
|
||||
%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
|
||||
namespace std {
|
||||
template<> class vector<CTYPE > {
|
||||
SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE)
|
||||
};
|
||||
}
|
||||
%enddef
|
||||
|
||||
SWIG_STD_VECTOR_SPECIALIZE(float, float)
|
||||
|
||||
%inline %{
|
||||
typedef float Real;
|
||||
%}
|
||||
|
||||
#if 1
|
||||
//fails
|
||||
namespace std {
|
||||
%template(RealVector) vector<int>;
|
||||
}
|
||||
#else
|
||||
//works
|
||||
%template(RealVector) std::vector<Real>;
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue