summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2008-05-11 20:25:12 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2008-05-11 20:25:12 +0000
commit528ea7a313de6788e171a340aaab5d05fbfe42f3 (patch)
tree0fa651a9778912742d765842f0706c4269e7fab4
parent05a57239d03722f68b3bf93d81868f7c347f90ec (diff)
downloadswig-528ea7a313de6788e171a340aaab5d05fbfe42f3.tar.gz
Fix SF #1943608 - substitution in %contract.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10440 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--CHANGES.current4
-rw-r--r--Examples/test-suite/contract.i16
-rw-r--r--Source/Modules/contract.cxx4
3 files changed, 21 insertions, 3 deletions
diff --git a/CHANGES.current b/CHANGES.current
index 5c2b24b19..9f0f6bff5 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -1,6 +1,10 @@
Version 1.3.36 (in progress)
=============================
+05/11/2008: wsfulton
+ Fix SF #1943608 - $self substitution in %contract, patch submitted by
+ Toon Verstraelen.
+
05/09/2008: olly
[PHP] Fix char * typemaps to work when applied to signed char * and
unsigned char * (uncovered by testcase apply_strings).
diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i
index 4d4b5121a..6ee0a353c 100644
--- a/Examples/test-suite/contract.i
+++ b/Examples/test-suite/contract.i
@@ -176,7 +176,6 @@ public:
};
class D : public C {
- public:
public:
virtual int foo(int a, int b, int c, int d, int e) {
return C::foo(a,b,c,d,e);
@@ -187,3 +186,18 @@ public:
};
%}
+%extend E {
+ %contract manipulate_i(int i) {
+ require:
+ i <= $self->m_i;
+ }
+}
+
+%inline %{
+struct E {
+ int m_i;
+ void manipulate_i(int i) {
+ }
+};
+%}
+
diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx
index fe7403136..9bf8decf6 100644
--- a/Source/Modules/contract.cxx
+++ b/Source/Modules/contract.cxx
@@ -220,14 +220,14 @@ String *Contracts::make_expression(String *s, Node *n) {
/* This function substitutes parameter names for argument names in the
contract specification. Note: it is assumed that the wrapper code
- uses arg1--argn for arguments. */
+ uses arg1 for self and arg2..argn for arguments. */
void Contracts::substitute_parms(String *s, ParmList *p, int method) {
int argnum = 1;
char argname[32];
if (method) {
- Replaceid(s, "self", "arg0");
+ Replaceid(s, "$self", "arg1");
argnum++;
}
while (p) {