add template + opaque type test
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5934 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
92e43dda16
commit
da6e5673e8
2 changed files with 36 additions and 0 deletions
7
Examples/test-suite/python/template_opaque_runme.py
Normal file
7
Examples/test-suite/python/template_opaque_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import template_opaque
|
||||
|
||||
v = template_opaque.OpaqueVectorType(10)
|
||||
|
||||
template_opaque.FillVector(v)
|
||||
|
||||
print v[0]
|
||||
29
Examples/test-suite/template_opaque.i
Normal file
29
Examples/test-suite/template_opaque.i
Normal file
|
|
@ -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<OpaqueType> OpaqueVectorType;
|
||||
|
||||
void FillVector(OpaqueVectorType& v)
|
||||
{
|
||||
for (int i = 0; i < v.size(); ++i) {
|
||||
v[i] = OpaqueStruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%template(OpaqueVectorType) std::vector<A::OpaqueType>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue