From 5f076c6540b57ca772cdad09429b25e8852682c8 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Tue, 1 Apr 2003 19:08:25 +0000 Subject: [PATCH] Fixed template partial specialization argument expansion bug git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4650 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 6 ++++-- Source/CParse/templ.c | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 2daf8c6b4..fd7a8fd6f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1900,7 +1900,9 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va if (n && (Strcmp(nodeType(n),"template") == 0)) { Parm *tparms = Getattr(n,"templateparms"); - if (!tparms) specialized = 1; + if (!tparms) { + specialized = 1; + } if (!specialized && ((ParmList_len($7) > ParmList_len(tparms)))) { Swig_error(cparse_file, cparse_line, "Too many template parameters. Maximum of %d.\n", ParmList_len(tparms)); } else if (!specialized && ((ParmList_len($7) < ParmList_numrequired(tparms)))) { @@ -2632,7 +2634,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para while (p) { for (i = 0; i < nargs; i++){ pn = Getattr(p,"name"); - if (Strcmp(pn,Getitem(tlist,i)) == 0) { + if (Strcmp(pn,SwigType_base(Getitem(tlist,i))) == 0) { int j; Parm *p1 = tp; for (j = 0; j < i; j++) { diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 8007a6b2c..1a52aaee7 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -214,14 +214,14 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) { if (0) { Parm *p = tparms; while (p) { - Printf(stdout,"tparm: '%s' '%s'\n", Getattr(p,"name"), Getattr(p,"value")); + Printf(stdout,"tparm: '%s' '%s' '%s'\n", Getattr(p,"name"), Getattr(p,"type"), Getattr(p,"value")); p = nextSibling(p); } } /* Printf(stdout,"targs = '%s'\n", templateargs); Printf(stdout,"rname = '%s'\n", rname); - Printf(stdout,"tname = '%s'\n", tname); */ + Printf(stdout,"tname = '%s'\n", tname); */ cparse_template_expand(n,tname, rname, templateargs, patchlist, typelist, cpatchlist); /* Set the name */ @@ -237,6 +237,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) { { Parm *tp = Getattr(n,"templateparms"); Parm *p = tparms; + /* Printf(stdout,"%s\n", ParmList_str(tp)); */ if (tp) { while (p && tp) { @@ -244,6 +245,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) { int sz, i; name = Getattr(tp,"name"); + value = Getattr(p,"value"); tydef = Getattr(p,"typedef"); @@ -254,6 +256,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) { } else { valuestr = SwigType_namestr(value); } + /* Printf(stdout,"valuestr = '%s'\n", valuestr); */ assert(value); /* Need to patch default arguments */ { @@ -275,7 +278,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) { for (i = 0; i < sz; i++) { String *s = Getitem(typelist,i); /* Replace(s,name,value, DOH_REPLACE_ID); */ - /* Printf(stdout,"name = '%s', s = '%s' --> ", name, s); */ + /* Printf(stdout,"name = '%s', s = '%s' --> ", name, s); */ SwigType_typename_replace(s,name,value); SwigType_typename_replace(s,tbase,iname); /* Printf(stdout,"'%s'\n", s); */