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

@ -1,6 +1,11 @@
Version 1.3.41 (in progress)
============================
2009-10-23: wsfulton
Fix seg fault when using a named nested template instantiation using %template(name)
within a class. A warning that these are not supported is now issued plus processing
continues as if no name was given.
2009-10-20: wsfulton
[Python] Fix std::vector<const T*>. This would previously compile, but not run correctly.

View file

@ -411,6 +411,8 @@ example.i(4): Syntax error in input.
<li>320. Explicit template instantiation ignored.
<li>321. <em>identifier</em> conflicts with a built-in name.
<li>322. Redundant redeclaration of '<em>name</em>'.
<li>323. Recursive scope inheritance of '<em>name</em>'.
<li>324. Named nested template instantiations not supported. Processing as if no name was given to %template().
<li>350. operator new ignored.
<li>351. operator delete ignored.
<li>352. operator+ ignored.

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 *>;

View file

@ -84,6 +84,7 @@
#define WARN_PARSE_BUILTIN_NAME 321
#define WARN_PARSE_REDUNDANT 322
#define WARN_PARSE_REC_INHERITANCE 323
#define WARN_PARSE_NESTED_TEMPLATE 324
#define WARN_IGNORE_OPERATOR_NEW 350 /* new */
#define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */