minor improvement to testcase

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11715 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-10-24 21:58:06 +00:00
parent 6fc2ce82ea
commit 283fd3c7ec
2 changed files with 13 additions and 3 deletions

View File

@ -21,6 +21,7 @@ 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");
if (template_nested_typemaps.globalInt3(v) != vTypemap) throw new RuntimeException("failed");
}
{
@ -31,6 +32,7 @@ public class template_nested_typemaps_runme {
if (template_nested_typemaps.globalShort1(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalShort2(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalShort3(v) != vTypemap) throw new RuntimeException("failed");
}
}
}

View File

@ -2,12 +2,14 @@
%module template_nested_typemaps
// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods
template <typename T> struct Typemap {
%typemap(in) T {
$1 = -99;
}
};
template <> struct Typemap<short> {
template <> struct Typemap<short> { // Note explicit specialization
%typemap(in) short {
$1 = -77;
}
@ -22,14 +24,14 @@ template <typename T> struct Breeze {
#if defined(SWIG)
%template() Typemap<int>;
#endif
int methodInt2(int s) { return s; } // only this method should pick up the typemap within Typemap<int>
int methodInt2(int s) { return s; } // 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
short methodShort2(short s) { return s; } // should pick up the typemap within Typemap<short>
};
int globalInt2(int s) { return s; }
@ -37,3 +39,9 @@ short globalShort2(short s) { return s; }
%}
%template(BreezeString) Breeze<const char *>;
%inline %{
int globalInt3(int s) { return s; } // should pick up the typemap within Typemap<int>
short globalShort3(short s) { return s; } // should pick up the typemap within Typemap<short>
%}