Fix seg fault when using a named template instantiation using %template(name) within a class

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11711 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-10-23 05:41:33 +00:00
commit 678abc58fb
6 changed files with 60 additions and 0 deletions

View file

@ -330,6 +330,7 @@ CPP_TEST_CASES += \
template_inherit_abstract \
template_int_const \
template_methods \
template_nested_typemaps \
template_ns \
template_ns2 \
template_ns3 \

View file

@ -0,0 +1,27 @@
import template_nested_typemaps.*;
public class template_nested_typemaps_runme {
static {
try {
System.loadLibrary("template_nested_typemaps");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
BreezeString b = new BreezeString();
{
int v = 88;
short vTypemap = -99;
if (b.methodInt1(v) != v) throw new RuntimeException("failed");
if (b.methodInt2(v) != vTypemap) throw new RuntimeException("failed");
if (template_nested_typemaps.globalInt1(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalInt2(v) != v) throw new RuntimeException("failed");
}
}
}

View file

@ -0,0 +1,24 @@
%module template_nested_typemaps
template <typename T> struct Typemap {
%typemap(in) T {
$1 = -99;
}
};
%inline %{
int globalInt1(int s) { return s; }
template <typename T> struct Breeze {
int methodInt1(int s) { return s; }
#if defined(SWIG)
%template() Typemap<int>;
#endif
int methodInt2(int s) { return s; } // only this method should pick up the typemap within Typemap<int>
void takeIt(T t) {}
};
int globalInt2(int s) { return s; }
%}
%template(BreezeString) Breeze<const char *>;