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
|
|
@ -9,6 +9,7 @@
|
||||||
~Foo() { delete self;}
|
~Foo() { delete self;}
|
||||||
int spam(int x) { return x; }
|
int spam(int x) { return x; }
|
||||||
int spam(int x, int y) { return x + y ; }
|
int spam(int x, int y) { return x + y ; }
|
||||||
|
int spam(int x, int y,int z) { return x + y ; }
|
||||||
};
|
};
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
@ -26,6 +27,7 @@ public:
|
||||||
%inline %{
|
%inline %{
|
||||||
class Bar {
|
class Bar {
|
||||||
public:
|
public:
|
||||||
|
Bar() { }
|
||||||
int spam() { return 1; }
|
int spam() { return 1; }
|
||||||
int spam(const char* c) { return 2; }
|
int spam(const char* c) { return 2; }
|
||||||
};
|
};
|
||||||
|
|
@ -33,7 +35,61 @@ public:
|
||||||
|
|
||||||
|
|
||||||
%extend Bar {
|
%extend Bar {
|
||||||
Bar() { return new Bar(); }
|
Bar(int a) { return new Bar(); }
|
||||||
~Bar() { delete self;}
|
~Bar() { delete self;}
|
||||||
// int spam(int x) { return x; }
|
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 extend_placement
|
||||||
import types
|
|
||||||
|
|
||||||
|
foo = extend_placement.Foo()
|
||||||
foo = extend_placement.Foo(1)
|
foo = extend_placement.Foo(1)
|
||||||
print type(foo)
|
foo.spam()
|
||||||
print foo.spam()
|
foo.spam("hello")
|
||||||
print 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)
|
||||||
|
|
|
||||||
|
|
@ -2520,6 +2520,7 @@ cpp_class_decl :
|
||||||
Setattr($$,"allows_typedef","1");
|
Setattr($$,"allows_typedef","1");
|
||||||
/* Check for pure-abstract class */
|
/* Check for pure-abstract class */
|
||||||
Setattr($$,"abstract", pure_abstract($7));
|
Setattr($$,"abstract", pure_abstract($7));
|
||||||
|
appendChild($$,$7);
|
||||||
|
|
||||||
/* This bit of code merges in a previously defined %extend directive (if any) */
|
/* This bit of code merges in a previously defined %extend directive (if any) */
|
||||||
if (extendhash) {
|
if (extendhash) {
|
||||||
|
|
@ -2535,7 +2536,6 @@ cpp_class_decl :
|
||||||
if (!classes) classes = NewHash();
|
if (!classes) classes = NewHash();
|
||||||
Setattr(classes,Swig_symbol_qualifiedscopename(0),$$);
|
Setattr(classes,Swig_symbol_qualifiedscopename(0),$$);
|
||||||
|
|
||||||
appendChild($$,$7);
|
|
||||||
p = $9;
|
p = $9;
|
||||||
if (p) {
|
if (p) {
|
||||||
set_nextSibling($$,p);
|
set_nextSibling($$,p);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue