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
This commit is contained in:
Dave Beazley 2003-04-01 19:08:25 +00:00
commit 5f076c6540
2 changed files with 10 additions and 5 deletions

View file

@ -1900,7 +1900,9 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
if (n && (Strcmp(nodeType(n),"template") == 0)) { if (n && (Strcmp(nodeType(n),"template") == 0)) {
Parm *tparms = Getattr(n,"templateparms"); Parm *tparms = Getattr(n,"templateparms");
if (!tparms) specialized = 1; if (!tparms) {
specialized = 1;
}
if (!specialized && ((ParmList_len($7) > ParmList_len(tparms)))) { 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)); 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)))) { } 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) { while (p) {
for (i = 0; i < nargs; i++){ for (i = 0; i < nargs; i++){
pn = Getattr(p,"name"); pn = Getattr(p,"name");
if (Strcmp(pn,Getitem(tlist,i)) == 0) { if (Strcmp(pn,SwigType_base(Getitem(tlist,i))) == 0) {
int j; int j;
Parm *p1 = tp; Parm *p1 = tp;
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {

View file

@ -214,7 +214,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) {
if (0) { if (0) {
Parm *p = tparms; Parm *p = tparms;
while (p) { 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); p = nextSibling(p);
} }
} }
@ -237,6 +237,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) {
{ {
Parm *tp = Getattr(n,"templateparms"); Parm *tp = Getattr(n,"templateparms");
Parm *p = tparms; Parm *p = tparms;
/* Printf(stdout,"%s\n", ParmList_str(tp)); */
if (tp) { if (tp) {
while (p && tp) { while (p && tp) {
@ -244,6 +245,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) {
int sz, i; int sz, i;
name = Getattr(tp,"name"); name = Getattr(tp,"name");
value = Getattr(p,"value"); value = Getattr(p,"value");
tydef = Getattr(p,"typedef"); tydef = Getattr(p,"typedef");
@ -254,6 +256,7 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms) {
} else { } else {
valuestr = SwigType_namestr(value); valuestr = SwigType_namestr(value);
} }
/* Printf(stdout,"valuestr = '%s'\n", valuestr); */
assert(value); assert(value);
/* Need to patch default arguments */ /* Need to patch default arguments */
{ {