From b502f4fc5aa70e6d16d10787514f0e80d8562a63 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Nov 2009 08:04:01 +0000 Subject: [PATCH] Fix usage of nested template classes within templated classes so that compileable code is generated. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11737 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 +++++- Examples/test-suite/template_nested.i | 19 +++++++++++++++++++ Source/Swig/stype.c | 8 +++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6cfdc012a..58742c56f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,13 +1,17 @@ Version 1.3.41 (in progress) ============================ +2009-11-13: wsfulton + Fix usage of nested template classes within templated classes so that compileable code + is generated. + 2009-11-13: olly [php] Fix place where class prefix (as specified with -prefix) wasn't being used. Patch from gverbruggen in SF#2892647. 2009-11-12: wsfulton Fix usage of nested template classes so that compileable code is generated - the nested - template class is now treated like a normal nested classes that is as an opaque type + template class is now treated like a normal nested classes, that is, as an opaque type unless the nestedworkaround feature is used. 2009-11-12: wsfulton diff --git a/Examples/test-suite/template_nested.i b/Examples/test-suite/template_nested.i index 86b9230ae..1bb1c686a 100644 --- a/Examples/test-suite/template_nested.i +++ b/Examples/test-suite/template_nested.i @@ -6,8 +6,20 @@ %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterClass::Inner2; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate1; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate2; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate3; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedStruct; +namespace ns { +template struct ForwardTemplate; +} +%{ +namespace ns { + template struct ForwardTemplate { + void tmethod(T t) {} + }; +} +%} + %inline %{ namespace ns { @@ -80,10 +92,17 @@ namespace ns { void hohum() {} }; UU hohum(UU u) { return u; } + template struct NestedInnerTemplate3 : public NestedInnerTemplate2 { + void hohum() {} + }; struct NestedStruct { NestedStruct() {} void hohum() {} }; + NestedInnerTemplate1 useNestedInnerTemplate1(const NestedInnerTemplate1& inner) { return inner; } + NestedInnerTemplate2 useNestedInnerTemplate2(const NestedInnerTemplate2& inner) { return inner; } + NestedInnerTemplate3 useNestedInnerTemplate3(const NestedInnerTemplate3& inner) { return inner; } + NestedStruct useNestedStruct(const NestedStruct& inner) { return inner; } }; } diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 8a7700bec..aa5d448a3 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -525,7 +525,13 @@ String *SwigType_namestr(const SwigType *t) { Putc(' ', r); Putc('>', r); suffix = SwigType_templatesuffix(t); - Append(r, suffix); + if (Len(suffix) > 0) { + String *suffix_namestr = SwigType_namestr(suffix); + Append(r, suffix_namestr); + Delete(suffix_namestr); + } else { + Append(r, suffix); + } Delete(suffix); Delete(p); return r;