From 6227611fa731aa4129b2829a6b5c841d25a56cce Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 3 Nov 2004 00:59:38 +0000 Subject: [PATCH] fixes for %template+member/static methods git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6636 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/overload_template.i | 57 ++++++++++++++++++- .../python/overload_template_runme.py | 3 + Source/CParse/parser.y | 7 +++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/overload_template.i b/Examples/test-suite/overload_template.i index 17414cd45..4121763cf 100644 --- a/Examples/test-suite/overload_template.i +++ b/Examples/test-suite/overload_template.i @@ -4,9 +4,10 @@ int foo() { return 3; } + template - int foo(int x) { - return x; + int foo(T x) { + return (int)x; } template @@ -14,6 +15,9 @@ template %} +%template(foo) foo; +%template(foo) foo; + %template(max) max; %template(max) max; @@ -143,3 +147,52 @@ namespace space { %template(nsoverload) space::nsoverload; %template(nsoverload) space::nsoverload; + +%inline %{ + namespace space + { + template + struct Foo + { + void bar(T t1) { } + void bar(T t1, T t2) { } + void bar(int a, int b, int c) { } + }; + struct A + { + template + static void fooT(Y y) { } + + }; + + } + template + struct Bar + { + void foo(T t1) { } + void foo(T t1, T t2) { } + void foo(int a, int b, int c) { } + template + void fooT(Y y) { } + }; + + + struct B + { + template + void barT(Y y) { } + + }; + +%} + + +%template(Bar_d) Bar; +%template(Foo_d) space::Foo; +%template(foo) space::A::fooT; +%template(foo) space::A::fooT; +%template(foo) space::A::fooT; + +%template(foo) B::barT; +%template(foo) B::barT; +%template(foo) B::barT; diff --git a/Examples/test-suite/python/overload_template_runme.py b/Examples/test-suite/python/overload_template_runme.py index 39675105b..bf4bdda11 100644 --- a/Examples/test-suite/python/overload_template_runme.py +++ b/Examples/test-suite/python/overload_template_runme.py @@ -140,3 +140,6 @@ if (nsoverload() != 1050): raise RuntimeError, ("nsoverload(const char *)") +b = B() + +b.foo(1) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 3dca2345b..511d94ae8 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -806,10 +806,17 @@ static String *resolve_node_scope(String *cname) { Printf(sname,"::%s",si.item); } } + if (!nscope) { + nscope = new_node("namespace"); + Setattr(nscope,"symtab", get_global_scope()); + } nscope_inner = Swig_symbol_clookup(sname,0); Printf(sname,"::%s",base); + Swig_symbol_setscope(Getattr(nscope_inner,"symtab")); + Delete(base); base = sname; + break; } ns2 = new_node("namespace");