Fix seg fault for some template parameters which have no type, just a default value

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11720 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-11-03 19:52:12 +00:00
commit 57fff12d5f
2 changed files with 17 additions and 3 deletions

View file

@ -2644,6 +2644,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
n = Swig_cparse_template_locate($5,$7,tscope);
/* Patch the argument types to respect namespaces */
Printf(stdout, " p before patching: %s\n", ParmList_str_defaultargs($7));
p = $7;
while (p) {
SwigType *value = Getattr(p,"value");
@ -2669,6 +2670,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
p = nextSibling(p);
}
Printf(stdout, " p after patching: %s\n", ParmList_str_defaultargs($7));
/* Look for the template */
{
@ -2746,6 +2748,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
def_supplied = 1;
}
}
Printf(stdout, " p tempar patching: %s\n", ParmList_str_defaultargs(temparms));
templnode = copy_node(nn);
/* We need to set the node name based on name used to instantiate */

View file

@ -114,6 +114,14 @@ int ParmList_len(ParmList *p) {
return i;
}
/* ---------------------------------------------------------------------
* get_empty_type()
* ---------------------------------------------------------------------- */
static SwigType *get_empty_type() {
return NewStringEmpty();
}
/* ---------------------------------------------------------------------
* ParmList_str()
*
@ -123,7 +131,8 @@ int ParmList_len(ParmList *p) {
String *ParmList_str(ParmList *p) {
String *out = NewStringEmpty();
while (p) {
String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name"));
String *type = Getattr(p, "type");
String *pstr = SwigType_str(type ? type : get_empty_type(), Getattr(p, "name"));
Append(out, pstr);
p = nextSibling(p);
if (p) {
@ -144,7 +153,8 @@ String *ParmList_str_defaultargs(ParmList *p) {
String *out = NewStringEmpty();
while (p) {
String *value = Getattr(p, "value");
String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name"));
String *type = Getattr(p, "type");
String *pstr = SwigType_str(type ? type : get_empty_type(), Getattr(p, "name"));
Append(out, pstr);
if (value) {
Printf(out, "=%s", value);
@ -167,7 +177,8 @@ String *ParmList_str_defaultargs(ParmList *p) {
String *ParmList_protostr(ParmList *p) {
String *out = NewStringEmpty();
while (p) {
String *pstr = SwigType_str(Getattr(p, "type"), 0);
String *type = Getattr(p, "type");
String *pstr = SwigType_str(type ? type : get_empty_type(), 0);
Append(out, pstr);
p = nextSibling(p);
if (p) {