Fix seg fault when two or more %template() declarations were made within a class

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11712 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-10-23 05:59:13 +00:00
commit 16b8caa3de
4 changed files with 37 additions and 9 deletions

View file

@ -22,6 +22,16 @@ public class template_nested_typemaps_runme {
if (template_nested_typemaps.globalInt1(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalInt2(v) != v) throw new RuntimeException("failed");
}
{
short v = 88;
short vTypemap = -77;
if (b.methodShort1(v) != v) throw new RuntimeException("failed");
if (b.methodShort2(v) != vTypemap) throw new RuntimeException("failed");
if (template_nested_typemaps.globalShort1(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalShort2(v) != v) throw new RuntimeException("failed");
}
}
}

View file

@ -1,3 +1,5 @@
#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_TEMPLATE
%module template_nested_typemaps
template <typename T> struct Typemap {
@ -5,9 +7,15 @@ template <typename T> struct Typemap {
$1 = -99;
}
};
template <> struct Typemap<short> {
%typemap(in) short {
$1 = -77;
}
};
%inline %{
int globalInt1(int s) { return s; }
short globalShort1(short s) { return s; }
template <typename T> struct Breeze {
int methodInt1(int s) { return s; }
@ -16,9 +24,16 @@ template <typename T> struct Breeze {
#endif
int methodInt2(int s) { return s; } // only this method should pick up the typemap within Typemap<int>
void takeIt(T t) {}
short methodShort1(short s) { return s; }
#if defined(SWIG)
%template(TypemapShort) Typemap<short>; // should issue warning SWIGWARN_PARSE_NESTED_TEMPLATE
#endif
short methodShort2(short s) { return s; } // only this method should pick up the typemap within Typemap<short> - note specialization
};
int globalInt2(int s) { return s; }
short globalShort2(short s) { return s; }
%}
%template(BreezeString) Breeze<const char *>;

View file

@ -119,14 +119,10 @@ template <typename T, int N> struct ThreeParm<T, N, N> { void a3(
//}
%}
#if 0
struct AA { // crashes
#else
namespace AA { // thinks X is in AA namespace
%template(X2) X<int *>;
};
#endif
#endif
#if 0
namespace Space {