fix director + abstract + constructors, reported by Brian Kelley
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6478 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c600268775
commit
114c703acd
9 changed files with 258 additions and 38 deletions
|
|
@ -1,4 +1,4 @@
|
|||
%module(directors="1") director_abstract
|
||||
%module(directors="1",dirprot="1") director_abstract
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
|
|
@ -17,36 +17,122 @@ public:
|
|||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() = 0;
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() = 0;
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
%feature("director") Example1;
|
||||
%feature("director");
|
||||
|
||||
%inline %{
|
||||
class Example1
|
||||
class Example0
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
int xsize, ysize;
|
||||
int fontsize;
|
||||
int fontdim[23];
|
||||
int xsize, ysize;
|
||||
|
||||
public:
|
||||
|
||||
Example0(int x, int y)
|
||||
: xsize(x), ysize(y) { }
|
||||
|
||||
Example0() { }
|
||||
|
||||
public:
|
||||
Example1()
|
||||
: xsize(200), ysize(200) { }
|
||||
virtual ~Example0() {}
|
||||
|
||||
int GetXSize() const { return xsize; }
|
||||
|
||||
// pure virtual methods that must be overridden
|
||||
virtual int Color(unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual ~Example1() {}
|
||||
|
||||
int GetXSize() const { return xsize; }
|
||||
|
||||
// pure virtual methods that must be overridden
|
||||
virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0;
|
||||
static int get_color(Example0 *ptr, unsigned char r,
|
||||
unsigned char g, unsigned char b) {
|
||||
return ptr->Color(r, g, b);
|
||||
}
|
||||
};
|
||||
|
||||
class Example1
|
||||
{
|
||||
protected:
|
||||
int xsize, ysize;
|
||||
|
||||
public:
|
||||
|
||||
Example1(int x, int y)
|
||||
: xsize(x), ysize(y) { }
|
||||
|
||||
Example1() { }
|
||||
|
||||
public:
|
||||
virtual ~Example1() {}
|
||||
|
||||
int GetXSize() const { return xsize; }
|
||||
|
||||
// pure virtual methods that must be overridden
|
||||
virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0;
|
||||
|
||||
static int get_color(Example1 *ptr, unsigned char r,
|
||||
unsigned char g, unsigned char b) {
|
||||
return ptr->Color(r, g, b);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Example2
|
||||
{
|
||||
protected:
|
||||
int xsize, ysize;
|
||||
|
||||
protected:
|
||||
Example2(int x, int y)
|
||||
: xsize(x), ysize(y) { }
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Example2() {}
|
||||
|
||||
int GetXSize() const { return xsize; }
|
||||
|
||||
// pure virtual methods that must be overridden
|
||||
virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0;
|
||||
|
||||
static int get_color(Example2 *ptr, unsigned char r,
|
||||
unsigned char g, unsigned char b) {
|
||||
return ptr->Color(r, g, b);
|
||||
}
|
||||
};
|
||||
|
||||
namespace ns
|
||||
{
|
||||
template <class T>
|
||||
class Example3
|
||||
{
|
||||
public:
|
||||
Example3()
|
||||
{
|
||||
}
|
||||
|
||||
Example3(int x, int y) { }
|
||||
|
||||
virtual ~Example3() {}
|
||||
|
||||
// pure virtual methods that must be overridden
|
||||
virtual int Color(unsigned char r, unsigned char g, unsigned char b) = 0;
|
||||
|
||||
static int get_color(Example3 *ptr, unsigned char r,
|
||||
unsigned char g, unsigned char b) {
|
||||
return ptr->Color(r, g, b);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%template(Example3_i) ns::Example3<int>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue