From dad66b6ee62c1bc943bdbf37729e05f3e520d856 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Thu, 27 May 2004 11:44:33 +0000 Subject: [PATCH] add template + opaque type test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5934 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../python/template_opaque_runme.py | 7 +++++ SWIG/Examples/test-suite/template_opaque.i | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 SWIG/Examples/test-suite/python/template_opaque_runme.py create mode 100644 SWIG/Examples/test-suite/template_opaque.i diff --git a/SWIG/Examples/test-suite/python/template_opaque_runme.py b/SWIG/Examples/test-suite/python/template_opaque_runme.py new file mode 100644 index 000000000..c4eb2f090 --- /dev/null +++ b/SWIG/Examples/test-suite/python/template_opaque_runme.py @@ -0,0 +1,7 @@ +import template_opaque + +v = template_opaque.OpaqueVectorType(10) + +template_opaque.FillVector(v) + +print v[0] diff --git a/SWIG/Examples/test-suite/template_opaque.i b/SWIG/Examples/test-suite/template_opaque.i new file mode 100644 index 000000000..4c981652e --- /dev/null +++ b/SWIG/Examples/test-suite/template_opaque.i @@ -0,0 +1,29 @@ +%module template_opaque +%include std_vector.i + +%{ + namespace A + { + struct OpaqueStruct + { + }; + } +%} + + +%inline { +namespace A { + struct OpaqueStruct; + typedef struct OpaqueStruct OpaqueType; + typedef std::vector OpaqueVectorType; + + void FillVector(OpaqueVectorType& v) + { + for (int i = 0; i < v.size(); ++i) { + v[i] = OpaqueStruct(); + } + } +} +} + +%template(OpaqueVectorType) std::vector;