Beefed up features test. The C++ code will fail to compile if features are not working as expected.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6662 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b248a54dc8
commit
23413c0edc
1 changed files with 61 additions and 77 deletions
|
|
@ -1,7 +1,7 @@
|
|||
%module features
|
||||
|
||||
|
||||
// This testcase checks that %feature is working for templates and non user supplied constructors/destructors
|
||||
// This testcase checks that %feature is working for templates and non user supplied constructors/destructors and is just generally working
|
||||
|
||||
// If the default %exception is used it will not compile. It shouldn't get used.
|
||||
%exception "this_will_not_compile";
|
||||
|
|
@ -15,14 +15,22 @@ class Simple {};
|
|||
%}
|
||||
|
||||
|
||||
%exception NS::SimpleNS::SimpleNS() "$action /*Simple::Simple*/";
|
||||
%exception NS::SimpleNS::~SimpleNS() "$action /*Simple::~Simple*/";
|
||||
%exception NS::SimpleNS::SimpleNS() "$action /*NS::SimpleNS::SimpleNS*/";
|
||||
%exception NS::SimpleNS::~SimpleNS() "$action /*NS::SimpleNS::~SimpleNS*/";
|
||||
// method tests
|
||||
%exception NS::SimpleNS::method() "_failed_ /*NS::Simple::method() const*/";
|
||||
%exception NS::SimpleNS::method() const "$action /*NS::Simple::method() const*/";
|
||||
%exception NS::SimpleNS::function() "$action /*NS::Simple::function()*/";
|
||||
|
||||
%inline %{
|
||||
namespace NS
|
||||
{
|
||||
|
||||
class SimpleNS {};
|
||||
class SimpleNS {
|
||||
public:
|
||||
void method() const {}
|
||||
void function() {}
|
||||
};
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
@ -54,7 +62,12 @@ template<class T> class SimpleTemplate {
|
|||
%exception Template<int>::Template() "$action /*Template<int>::Template<int>*/";
|
||||
%exception Template<int>::Template(const Template&) "$action /*Template<int>::Template<int>(const Template&)*/";
|
||||
%exception Template<int>::~Template() "$action /*Template<int>::~Template*/";
|
||||
// method tests
|
||||
%exception Template<int>::foo "$action /*Template<int>::foo*/";
|
||||
%exception Template::get "$action /*Template<int>::get*/";
|
||||
%exception Template<int>::set(const int &t) "$action /*Template<int>::set(const int &t)*/";
|
||||
%exception Template<int>::bar(const int &t) "_failed_ /*Template<int>::bar(const int &t) const*/";
|
||||
%exception Template<int>::bar(const int &t) const "$action /*Template<int>::bar(const int &t) const*/";
|
||||
|
||||
%inline %{
|
||||
template<class T> class Template {
|
||||
|
|
@ -64,85 +77,56 @@ public:
|
|||
Template(const Template&){}
|
||||
~Template(){}
|
||||
void foo(){}
|
||||
void bar(const int &t) const {}
|
||||
#ifdef SWIG
|
||||
%extend {
|
||||
T& get(int i) const {
|
||||
throw 1;
|
||||
}
|
||||
void set(const T &t) {}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
%}
|
||||
|
||||
%template(TemplateInt) Template<int>;
|
||||
|
||||
|
||||
%exception {
|
||||
$action // default %exception
|
||||
}
|
||||
|
||||
|
||||
%newobject One::getSquare() const;
|
||||
// Test 5: wildcards
|
||||
%exception Space::WildCards::WildCards() "$action /* Space::WildCards::WildCards() */";
|
||||
%exception Space::WildCards::~WildCards() "$action /* Space::WildCards::WildCards() */";
|
||||
%exception *::incy "_failure_ /* *::incy */";
|
||||
%exception *::incy(int a) "_failure_ /* *::incy(int a) */";
|
||||
%exception *::incy(int a) const "$action /* *::incy(int a) const */";
|
||||
%exception *::wincy(int a) "$action /* *::wincy(int a) */";
|
||||
%exception *::spider "$action /* *::spider */";
|
||||
%exception *::spider(int a) "_failure_ /* *::spider(int a) */";
|
||||
|
||||
%inline %{
|
||||
|
||||
struct Square
|
||||
{
|
||||
Square(int)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct One {
|
||||
Square *getSquare() const { return new Square(10); }
|
||||
};
|
||||
%}
|
||||
|
||||
%newobject Two::getSquare();
|
||||
|
||||
%inline %{
|
||||
struct Two {
|
||||
Square *getSquare() const { return new Square(10); }
|
||||
};
|
||||
|
||||
char *foo() {return 0;}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
||||
%exception std::Vector::get {
|
||||
$action; // get %exception
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T> class Vector {
|
||||
public:
|
||||
void push_back(const T& x) {}
|
||||
#ifdef SWIG
|
||||
%extend {
|
||||
T& get(int i) {
|
||||
throw 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%template(VectorInt) std::Vector<int>;
|
||||
|
||||
|
||||
|
||||
%ignore TROOT::TROOT(const char *name, const char *title, void *initfunc = 0);
|
||||
%inline %{
|
||||
class TROOT {
|
||||
|
||||
public:
|
||||
TROOT()
|
||||
{
|
||||
}
|
||||
|
||||
TROOT(const char *name, const char *title, void *initfunc = 0)
|
||||
{
|
||||
}
|
||||
|
||||
namespace Space {
|
||||
struct WildCards {
|
||||
virtual WildCards* incy(int a) const { return 0; }
|
||||
virtual WildCards* wincy(int a) { return 0; }
|
||||
virtual WildCards* spider(int a) const { return 0; }
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
// Test 6: default arguments
|
||||
%exception Space::Animals::Animals(int a = 0, double d = 0.0) "$action /* Space::Animals::Animals(int a = 0, double d = 0.0) */";
|
||||
%exception Space::Animals::~Animals() "$action /* Space::Animals::~Animals() */";
|
||||
%exception Space::Animals::lions(int a = 0, double d = 0.0) const "$action /* Space::Animals::lions(int a = 0, double d = 0.0) const */";
|
||||
%exception Space::Animals::leopards(int a = 0, double d = 0.0) "$action /* Space::Animals::leopards(int a = 0, double d = 0.0) */";
|
||||
%exception *::cheetahs(int a = 0, double d = 0.0) const "$action /* *::cheetahs(int a = 0, double d = 0.0) const */";
|
||||
%exception *::jackal(int a = 0, double d = 0.0) "$action /* *::jackal(int a = 0, double d = 0.0) */";
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct Animals {
|
||||
Animals(int a = 0, double d = 0.0) {}
|
||||
void* lions(int a = 0, double d = 0.0) const { return 0; }
|
||||
void* leopards(int a = 0, double d = 0.0) { return 0; }
|
||||
int cheetahs(int a = 0, double d = 0.0) const { return 0; }
|
||||
int jackal(int a = 0, double d = 0.0) { return 0; }
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue