summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2009-01-10 01:15:03 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2009-01-10 01:15:03 +0000
commitb91631c1305d695f1844b1bfdc5ccf809eedb045 (patch)
treeaf1bd5a898864760eda2eda57a04563dc54afb89
parent63369773503eaf0c76c797182a06395ce5bdb961 (diff)
downloadswig-b91631c1305d695f1844b1bfdc5ccf809eedb045.tar.gz
Patch #1992756 from Colin McDonald - %contract not working for classes in namespace
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11049 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--CHANGES.current4
-rw-r--r--Examples/test-suite/contract.i30
-rw-r--r--Examples/test-suite/python/contract_runme.py8
-rw-r--r--Source/Modules/contract.cxx8
4 files changed, 50 insertions, 0 deletions
diff --git a/CHANGES.current b/CHANGES.current
index 7eed740b9..0124e6e76 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -1,6 +1,10 @@
Version 1.3.37 (30 December 2008)
=================================
+2009-01-10: wsfulton
+ Patch #1992756 from Colin McDonald - %contract not working for classes
+ in namespace
+
2009-01-05: olly
Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source
code and remove documentation of them.
diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i
index a5732105b..b979ef19e 100644
--- a/Examples/test-suite/contract.i
+++ b/Examples/test-suite/contract.i
@@ -201,3 +201,33 @@ struct E {
};
%}
+
+// Namespace
+
+%{
+namespace myNames {
+
+class myClass
+{
+ public:
+ myClass(int i) {}
+};
+
+}
+%}
+
+namespace myNames {
+
+%contract myClass::myClass( int i ) {
+require:
+ i > 0;
+}
+
+class myClass
+{
+ public:
+ myClass(int i) {}
+};
+
+}
+
diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py
index 9ded5bb5b..905bf1196 100644
--- a/Examples/test-suite/python/contract_runme.py
+++ b/Examples/test-suite/python/contract_runme.py
@@ -133,3 +133,11 @@ try:
except:
pass
+#Namespace
+my = contract.myClass(1)
+try:
+ my = contract.myClass(0)
+ print "Failed! constructor preassertion"
+except:
+ pass
+
diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx
index 9bf8decf6..518dc2997 100644
--- a/Source/Modules/contract.cxx
+++ b/Source/Modules/contract.cxx
@@ -46,6 +46,7 @@ public:
int extendDirective(Node *n);
int importDirective(Node *n);
int includeDirective(Node *n);
+ int namespaceDeclaration(Node *n);
int classDeclaration(Node *n);
virtual int top(Node *n);
};
@@ -320,16 +321,23 @@ int Contracts::constructorDeclaration(Node *n) {
int Contracts::externDeclaration(Node *n) {
return emit_children(n);
}
+
int Contracts::extendDirective(Node *n) {
return emit_children(n);
}
+
int Contracts::importDirective(Node *n) {
return emit_children(n);
}
+
int Contracts::includeDirective(Node *n) {
return emit_children(n);
}
+int Contracts::namespaceDeclaration(Node *n) {
+ return emit_children(n);
+}
+
int Contracts::classDeclaration(Node *n) {
int ret = SWIG_OK;
InClass = 1;