add more template+namespaces+matrix cases
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7046 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
035f4af3da
commit
d7a45cd7a1
2 changed files with 77 additions and 0 deletions
71
SWIG/Examples/test-suite/python/template_matrix.i
Normal file
71
SWIG/Examples/test-suite/python/template_matrix.i
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
%module template_matrix
|
||||
%{
|
||||
#include <vector>
|
||||
|
||||
struct pop
|
||||
{
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
|
||||
%inline {
|
||||
namespace simuPOP
|
||||
{
|
||||
struct POP
|
||||
{
|
||||
};
|
||||
|
||||
template<class _POP1, class _POP2 = POP>
|
||||
class Operator
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%template(vectorop) std::vector< simuPOP::Operator<pop> >;
|
||||
|
||||
|
||||
|
||||
namespace simuPOP
|
||||
{
|
||||
%template(baseOperator) Operator<pop>;
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
|
||||
namespace std
|
||||
{
|
||||
%template(vectori) vector<int>;
|
||||
%template(matrixi) vector< vector<int> >;
|
||||
%template(cubei) vector< vector< vector<int> > >;
|
||||
}
|
||||
|
||||
|
||||
|
||||
%inline %{
|
||||
std::vector<int>
|
||||
passVector(const std::vector<int>& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
std::vector< std::vector<int> >
|
||||
passMatrix(const std::vector< std::vector<int> >& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
std::vector< std::vector< std::vector<int> > >
|
||||
passCube(const std::vector< std::vector< std::vector<int> > >& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
6
SWIG/Examples/test-suite/python/template_matrix_runme.py
Normal file
6
SWIG/Examples/test-suite/python/template_matrix_runme.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from template_matrix import *
|
||||
passVector([1,2,3])
|
||||
passMatrix([[1,2],[1,2,3]])
|
||||
passCube([[[1,2],[1,2,3]],[[1,2],[1,2,3]]])
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue