From 800ebd6a78ee4e1454cc31138f58d1a4829bb91b Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Tue, 23 Mar 2004 01:12:06 +0000 Subject: [PATCH] added template test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5790 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/attributetest.i | 27 ++++++++++++++++++- .../test-suite/python/attributetest_runme.py | 9 +++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/python/attributetest.i b/Examples/test-suite/python/attributetest.i index aac4b977e..c4cb7e1b5 100644 --- a/Examples/test-suite/python/attributetest.i +++ b/Examples/test-suite/python/attributetest.i @@ -5,9 +5,11 @@ %attribute(A, int, a, get_a, set_a); %attribute_ref(A, int, b); +%attribute_ref(Param, int, value); + %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 { @@ -46,5 +48,28 @@ int _b; int _c; }; + + template + struct Param + { + Param(C v) : _v(v) + { + } + + const int& value() const + { + return _v; + } + + int& value() + { + return _v; + } + private: + C _v; + }; } +%template(Param_i) Param; + + diff --git a/Examples/test-suite/python/attributetest_runme.py b/Examples/test-suite/python/attributetest_runme.py index 9f9fb7454..cdcac18e4 100644 --- a/Examples/test-suite/python/attributetest_runme.py +++ b/Examples/test-suite/python/attributetest_runme.py @@ -11,6 +11,7 @@ if aa.a != 3: if aa.b != 2: + print aa.b raise RuntimeError aa.b = 5 if aa.b != 5: @@ -26,3 +27,11 @@ if aa.c != 3: #aa.c = 5 #if aa.c != 3: # raise RuntimeError + +pi = attributetest.Param_i(7) +if pi.value != 7: + raise RuntimeError + +pi.value=3 +if pi.value != 3: + raise RuntimeError