From d7a45cd7a100533ac7eef2ef286d9d1e339bc8ec Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Tue, 8 Mar 2005 06:46:15 +0000 Subject: [PATCH] add more template+namespaces+matrix cases git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7046 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/python/template_matrix.i | 71 +++++++++++++++++++ .../python/template_matrix_runme.py | 6 ++ 2 files changed, 77 insertions(+) create mode 100644 SWIG/Examples/test-suite/python/template_matrix.i create mode 100644 SWIG/Examples/test-suite/python/template_matrix_runme.py diff --git a/SWIG/Examples/test-suite/python/template_matrix.i b/SWIG/Examples/test-suite/python/template_matrix.i new file mode 100644 index 000000000..27696542a --- /dev/null +++ b/SWIG/Examples/test-suite/python/template_matrix.i @@ -0,0 +1,71 @@ +%module template_matrix +%{ +#include + + struct pop + { + }; + +%} + +%include "std_vector.i" + + +%inline { +namespace simuPOP +{ + struct POP + { + }; + + template + class Operator + { + }; +} + +} + +%template(vectorop) std::vector< simuPOP::Operator >; + + + +namespace simuPOP +{ + %template(baseOperator) Operator; +} + + +#if 1 + +namespace std +{ +%template(vectori) vector; +%template(matrixi) vector< vector >; +%template(cubei) vector< vector< vector > >; +} + + + +%inline %{ +std::vector +passVector(const std::vector& a) +{ + return a; +} + +std::vector< std::vector > +passMatrix(const std::vector< std::vector >& a) +{ + return a; +} + +std::vector< std::vector< std::vector > > +passCube(const std::vector< std::vector< std::vector > >& a) +{ + return a; +} + +%} + +#endif diff --git a/SWIG/Examples/test-suite/python/template_matrix_runme.py b/SWIG/Examples/test-suite/python/template_matrix_runme.py new file mode 100644 index 000000000..95815a068 --- /dev/null +++ b/SWIG/Examples/test-suite/python/template_matrix_runme.py @@ -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]]]) + +