Fix %template seg fault on some cases of overloading the templated method.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11582 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-08-15 10:40:19 +00:00
parent 5118c399f0
commit d74b680a79
4 changed files with 34 additions and 1 deletions

View File

@ -1,6 +1,10 @@
Version 1.3.40 (in progress)
============================
2009-08-15: wsfulton
Fix %template seg fault on some cases of overloading the templated method.
Bug reported by Jan Kupec.
2009-08-15: wsfulton
[Ruby] Add numerous missing wrapped methods for std::vector<bool> specialization
as reported by Youssef Jones.

View File

@ -32,6 +32,13 @@ public class template_methods_runme {
k.KlassTMethodBool();
b = Klass.KlassStaticTMethodBoolRenamed(true);
Klass.KlassStaticTMethodBool();
//
ComponentProperties cp = new ComponentProperties();
cp.adda("key1", "val1", "key2", 22.2);
cp.adda("key1", "val1", "key2", "val2", "key3", "val3");
cp.adda("key1", 1, "key2", 2, "key3", 3);
}
}

View File

@ -5,6 +5,8 @@
%warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve1<float>();
%warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve3<float>();
%include <std_string.i>
///////////////////
%ignore convolve1<float>(float a);
@ -76,3 +78,23 @@ struct Klass {
%template(KlassTMethodBool) Klass::tmethod<bool>;
%template(KlassStaticTMethodBool) Klass::statictmethod<bool>;
////////////////////////////////////////////////////////////////////////////
%inline %{
class ComponentProperties{
public:
ComponentProperties() {}
~ComponentProperties() {}
template <typename T1> void adda(std::string key, T1 val) {}
template <typename T1, typename T2> void adda(std::string key1, T1 val1, std::string key2, T2 val2) {}
template <typename T1, typename T2, typename T3> void adda(std::string key1, T1 val1, std::string key2, T2 val2, std::string key3, T3 val3) {}
};
%}
%extend ComponentProperties {
%template(adda) adda<std::string, double>;
%template(adda) adda<std::string, std::string, std::string>; // ERROR OCCURS HERE
%template(adda) adda<int, int, int>;
}

View File

@ -2726,7 +2726,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
Parm *ti = targs;
String *tv = Getattr(tp,"value");
if (!tv) tv = Getattr(tp,"type");
while(pi != tp) {
while(pi != tp && ti && pi) {
String *name = Getattr(ti,"name");
String *value = Getattr(pi,"value");
if (!value) value = Getattr(pi,"type");