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
This commit is contained in:
William S Fulton 2009-01-10 01:15:03 +00:00
commit b91631c130
4 changed files with 50 additions and 0 deletions

View file

@ -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.

View file

@ -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) {}
};
}

View file

@ -133,3 +133,11 @@ try:
except:
pass
#Namespace
my = contract.myClass(1)
try:
my = contract.myClass(0)
print "Failed! constructor preassertion"
except:
pass

View file

@ -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;