Fixed template partial specialization argument expansion bug

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4650 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2003-04-01 19:08:25 +00:00
commit c54a578384
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)) {
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++) {

View file

@ -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); */