added template test
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5790 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e6711328a6
commit
800ebd6a78
2 changed files with 35 additions and 1 deletions
|
|
@ -5,9 +5,11 @@
|
||||||
%attribute(A, int, a, get_a, set_a);
|
%attribute(A, int, a, get_a, set_a);
|
||||||
%attribute_ref(A, int, b);
|
%attribute_ref(A, int, b);
|
||||||
|
|
||||||
|
%attribute_ref(Param<int>, int, value);
|
||||||
|
|
||||||
|
|
||||||
%attribute(A, int, c, get_c); /* read-only */
|
%attribute(A, int, c, get_c); /* read-only */
|
||||||
%attribute_ref(A, int, d, b); /* different attribute name 'd' */
|
%attribute_ref(A, int, b, d); /* different attribute name 'd' */
|
||||||
|
|
||||||
%inline
|
%inline
|
||||||
{
|
{
|
||||||
|
|
@ -46,5 +48,28 @@
|
||||||
int _b;
|
int _b;
|
||||||
int _c;
|
int _c;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class C>
|
||||||
|
struct Param
|
||||||
|
{
|
||||||
|
Param(C v) : _v(v)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const int& value() const
|
||||||
|
{
|
||||||
|
return _v;
|
||||||
|
}
|
||||||
|
|
||||||
|
int& value()
|
||||||
|
{
|
||||||
|
return _v;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
C _v;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%template(Param_i) Param<int>;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ if aa.a != 3:
|
||||||
|
|
||||||
|
|
||||||
if aa.b != 2:
|
if aa.b != 2:
|
||||||
|
print aa.b
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
aa.b = 5
|
aa.b = 5
|
||||||
if aa.b != 5:
|
if aa.b != 5:
|
||||||
|
|
@ -26,3 +27,11 @@ if aa.c != 3:
|
||||||
#aa.c = 5
|
#aa.c = 5
|
||||||
#if aa.c != 3:
|
#if aa.c != 3:
|
||||||
# raise RuntimeError
|
# raise RuntimeError
|
||||||
|
|
||||||
|
pi = attributetest.Param_i(7)
|
||||||
|
if pi.value != 7:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
pi.value=3
|
||||||
|
if pi.value != 3:
|
||||||
|
raise RuntimeError
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue