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:
parent
678abc58fb
commit
16b8caa3de
4 changed files with 37 additions and 9 deletions
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 *>;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -535,6 +535,8 @@ static void add_symbols_copy(Node *n) {
|
|||
|
||||
add_oldname = Getattr(n,"sym:name");
|
||||
if ((add_oldname) || (Getattr(n,"sym:needs_symtab"))) {
|
||||
int old_inclass = -1;
|
||||
Node *old_current_class = 0;
|
||||
if (add_oldname) {
|
||||
DohIncref(add_oldname);
|
||||
/* Disable this, it prevents %rename to work with templates */
|
||||
|
|
@ -564,7 +566,9 @@ static void add_symbols_copy(Node *n) {
|
|||
Namespaceprefix = Swig_symbol_qualifiedscopename(0);
|
||||
}
|
||||
if (strcmp(cnodeType,"class") == 0) {
|
||||
old_inclass = inclass;
|
||||
inclass = 1;
|
||||
old_current_class = current_class;
|
||||
current_class = n;
|
||||
if (Strcmp(Getattr(n,"kind"),"class") == 0) {
|
||||
cplus_mode = CPLUS_PRIVATE;
|
||||
|
|
@ -591,8 +595,8 @@ static void add_symbols_copy(Node *n) {
|
|||
add_oldname = 0;
|
||||
}
|
||||
if (strcmp(cnodeType,"class") == 0) {
|
||||
inclass = 0;
|
||||
current_class = 0;
|
||||
inclass = old_inclass;
|
||||
current_class = old_current_class;
|
||||
}
|
||||
} else {
|
||||
if (strcmp(cnodeType,"extend") == 0) {
|
||||
|
|
@ -2752,7 +2756,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
} else {
|
||||
Setattr(templnode,"sym:typename","1");
|
||||
}
|
||||
if ($3) {
|
||||
if ($3 && !inclass) {
|
||||
/*
|
||||
Comment this out for 1.3.28. We need to
|
||||
re-enable it later but first we need to
|
||||
|
|
@ -2770,8 +2774,11 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
Swig_cparse_template_expand(templnode,nname,temparms,tscope);
|
||||
Setattr(templnode,"sym:name",nname);
|
||||
Delete(nname);
|
||||
Setattr(templnode,"feature:onlychildren",
|
||||
"typemap,typemapitem,typemapcopy,typedef,types,fragment");
|
||||
Setattr(templnode,"feature:onlychildren", "typemap,typemapitem,typemapcopy,typedef,types,fragment");
|
||||
|
||||
if ($3) {
|
||||
Swig_warning(WARN_PARSE_NESTED_TEMPLATE, cparse_file, cparse_line, "Named nested template instantiations not supported. Processing as if no name was given to %%template().\n");
|
||||
}
|
||||
}
|
||||
Delattr(templnode,"templatetype");
|
||||
Setattr(templnode,"template",nn);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue