fix %extend+overload error
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6298 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a81bce4fd7
commit
2e9ef019df
3 changed files with 98 additions and 16 deletions
|
|
@ -5,10 +5,11 @@
|
|||
// Before the class
|
||||
|
||||
%extend Foo {
|
||||
Foo(int a) { return new Foo(); }
|
||||
~Foo() { delete self;}
|
||||
int spam(int x) { return x; }
|
||||
int spam(int x, int y) { return x + y ; }
|
||||
Foo(int a) { return new Foo(); }
|
||||
~Foo() { delete self;}
|
||||
int spam(int x) { return x; }
|
||||
int spam(int x, int y) { return x + y ; }
|
||||
int spam(int x, int y,int z) { return x + y ; }
|
||||
};
|
||||
|
||||
%inline %{
|
||||
|
|
@ -26,14 +27,69 @@ public:
|
|||
%inline %{
|
||||
class Bar {
|
||||
public:
|
||||
int spam() { return 1; }
|
||||
int spam(const char* c) { return 2; }
|
||||
Bar() { }
|
||||
int spam() { return 1; }
|
||||
int spam(const char* c) { return 2; }
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
%extend Bar {
|
||||
Bar() { return new Bar(); }
|
||||
~Bar() { delete self;}
|
||||
// int spam(int x) { return x; }
|
||||
Bar(int a) { return new Bar(); }
|
||||
~Bar() { delete self;}
|
||||
int spam() { return 1}
|
||||
int spam(int x) { return x; }
|
||||
int spam(int x, int y) { return x + y ; }
|
||||
int spam(int x, int y,int z) { return x + y ; }
|
||||
};
|
||||
|
||||
|
||||
// testing templates
|
||||
|
||||
// Before the class
|
||||
|
||||
%extend FooT {
|
||||
FooT(int a) { return new FooT<T>(); }
|
||||
~FooT() { delete self;}
|
||||
int spam(int x) { return x; }
|
||||
int spam(int x, int y) { return x + y ; }
|
||||
int spam(int x, int y,int z) { return x + y ; }
|
||||
};
|
||||
|
||||
%inline %{
|
||||
template<class T>
|
||||
class FooT {
|
||||
public:
|
||||
FooT(){}
|
||||
|
||||
int spam() { return 1; }
|
||||
int spam(const char* c) { return 2; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template(FooTi) FooT<int>;
|
||||
|
||||
|
||||
// After the class
|
||||
|
||||
%inline %{
|
||||
template<class T>
|
||||
class BarT {
|
||||
public:
|
||||
BarT() { }
|
||||
int spam() { return 1; }
|
||||
int spam(const char* c) { return 2; }
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
%extend BarT {
|
||||
BarT(int a) { return new BarT<T>(); }
|
||||
~BarT() { delete self;}
|
||||
int spam() { return 1}
|
||||
int spam(int x) { return x; }
|
||||
int spam(int x, int y) { return x + y ; }
|
||||
int spam(int x, int y,int z) { return x + y ; }
|
||||
};
|
||||
|
||||
%template(BarTi) BarT<int>;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,36 @@
|
|||
import extend_placement
|
||||
import types
|
||||
|
||||
foo = extend_placement.Foo()
|
||||
foo = extend_placement.Foo(1)
|
||||
print type(foo)
|
||||
print foo.spam()
|
||||
print foo.spam("hello")
|
||||
foo.spam()
|
||||
foo.spam("hello")
|
||||
foo.spam(1)
|
||||
foo.spam(1,1)
|
||||
foo.spam(1,1,1)
|
||||
|
||||
foo = extend_placement.Foo(1)
|
||||
print type(foo)
|
||||
|
||||
bar = extend_placement.Bar()
|
||||
bar = extend_placement.Bar(1)
|
||||
bar.spam()
|
||||
bar.spam("hello")
|
||||
bar.spam(1)
|
||||
bar.spam(1,1)
|
||||
bar.spam(1,1,1)
|
||||
|
||||
|
||||
foo = extend_placement.FooTi()
|
||||
foo = extend_placement.FooTi(1)
|
||||
foo.spam()
|
||||
foo.spam("hello")
|
||||
foo.spam(1)
|
||||
foo.spam(1,1)
|
||||
foo.spam(1,1,1)
|
||||
|
||||
|
||||
bar = extend_placement.BarTi()
|
||||
bar = extend_placement.BarTi(1)
|
||||
bar.spam()
|
||||
bar.spam("hello")
|
||||
bar.spam(1)
|
||||
bar.spam(1,1)
|
||||
bar.spam(1,1,1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue