add support for smart pointers + %extend

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6819 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-12-01 11:29:17 +00:00
commit d0fad62e2c
5 changed files with 75 additions and 36 deletions

View file

@ -10,6 +10,8 @@ b = Bar(f)
b.y = 2
if f.y != 2:
print f.y
print b.y
raise RuntimeError
if b.x != f.x:
@ -17,3 +19,6 @@ if b.x != f.x:
if b.z != f.z:
raise RuntimeError
if b.extension() != f.extension():
raise RuntimeError

View file

@ -1,36 +1,43 @@
%module smart_pointer_member
%extend Foo
{
int extension(int i, int j) { return i; }
int extension(int i) { return i; }
int extension() { return 1; }
}
%inline %{
class Foo {
public:
int x[4];
int y;
static const int z;
};
class Bar {
Foo *f;
public:
Bar(Foo *f) : f(f) { }
Foo *operator->() {
class Foo {
public:
int x[4];
int y;
static const int z;
};
class Bar {
Foo *f;
public:
Bar(Foo *f) : f(f) { }
Foo *operator->() {
return f;
}
};
int get_y(Bar *b)
{
return (*b)->y;
}
int get_z(Bar *b)
{
return (*b)->z;
}
}
};
int get_y(Bar *b)
{
return (*b)->y;
}
int get_z(Bar *b)
{
return (*b)->z;
}
%}
%{
const int Foo::z = 3;
%}