fixes for %template+member/static methods
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6636 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b6ced827f8
commit
6227611fa7
3 changed files with 65 additions and 2 deletions
|
|
@ -4,9 +4,10 @@
|
||||||
int foo() {
|
int foo() {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
int foo(int x) {
|
int foo(T x) {
|
||||||
return x;
|
return (int)x;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
@ -14,6 +15,9 @@ template<class T>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%template(foo) foo<int>;
|
||||||
|
%template(foo) foo<double>;
|
||||||
|
|
||||||
%template(max) max<int>;
|
%template(max) max<int>;
|
||||||
%template(max) max<double>;
|
%template(max) max<double>;
|
||||||
|
|
||||||
|
|
@ -143,3 +147,52 @@ namespace space {
|
||||||
%template(nsoverload) space::nsoverload<Klass>;
|
%template(nsoverload) space::nsoverload<Klass>;
|
||||||
%template(nsoverload) space::nsoverload<double>;
|
%template(nsoverload) space::nsoverload<double>;
|
||||||
|
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
namespace space
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
struct Foo
|
||||||
|
{
|
||||||
|
void bar(T t1) { }
|
||||||
|
void bar(T t1, T t2) { }
|
||||||
|
void bar(int a, int b, int c) { }
|
||||||
|
};
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
template <class Y>
|
||||||
|
static void fooT(Y y) { }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
struct Bar
|
||||||
|
{
|
||||||
|
void foo(T t1) { }
|
||||||
|
void foo(T t1, T t2) { }
|
||||||
|
void foo(int a, int b, int c) { }
|
||||||
|
template <class Y>
|
||||||
|
void fooT(Y y) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct B
|
||||||
|
{
|
||||||
|
template <class Y>
|
||||||
|
void barT(Y y) { }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%template(Bar_d) Bar<double>;
|
||||||
|
%template(Foo_d) space::Foo<double>;
|
||||||
|
%template(foo) space::A::fooT<double>;
|
||||||
|
%template(foo) space::A::fooT<int>;
|
||||||
|
%template(foo) space::A::fooT<char>;
|
||||||
|
|
||||||
|
%template(foo) B::barT<double>;
|
||||||
|
%template(foo) B::barT<int>;
|
||||||
|
%template(foo) B::barT<char>;
|
||||||
|
|
|
||||||
|
|
@ -140,3 +140,6 @@ if (nsoverload() != 1050):
|
||||||
raise RuntimeError, ("nsoverload(const char *)")
|
raise RuntimeError, ("nsoverload(const char *)")
|
||||||
|
|
||||||
|
|
||||||
|
b = B()
|
||||||
|
|
||||||
|
b.foo(1)
|
||||||
|
|
|
||||||
|
|
@ -806,10 +806,17 @@ static String *resolve_node_scope(String *cname) {
|
||||||
Printf(sname,"::%s",si.item);
|
Printf(sname,"::%s",si.item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!nscope) {
|
||||||
|
nscope = new_node("namespace");
|
||||||
|
Setattr(nscope,"symtab", get_global_scope());
|
||||||
|
}
|
||||||
nscope_inner = Swig_symbol_clookup(sname,0);
|
nscope_inner = Swig_symbol_clookup(sname,0);
|
||||||
Printf(sname,"::%s",base);
|
Printf(sname,"::%s",base);
|
||||||
|
Swig_symbol_setscope(Getattr(nscope_inner,"symtab"));
|
||||||
|
|
||||||
Delete(base);
|
Delete(base);
|
||||||
base = sname;
|
base = sname;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ns2 = new_node("namespace");
|
ns2 = new_node("namespace");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue