more fixes for template + def args

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6833 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-12-05 10:15:25 +00:00
commit 6b499410dd
17 changed files with 203 additions and 284 deletions

View file

@ -2324,6 +2324,9 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
} else {
int def_supplied = 0;
/* Expand the template */
Node *templ = Swig_symbol_clookup($5,0);
Parm *targs = templ ? Getattr(templ,"templateparms") : 0;
ParmList *temparms;
if (specialized) temparms = CopyParmList($7);
else temparms = CopyParmList(tparms);
@ -2345,6 +2348,21 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
}
Delattr(tp,"value");
}
/* fix default arg values */
if (targs) {
Parm *pi = temparms;
Parm *ti = targs;
String *tv = Getattr(tp,"value");
if (!tv) tv = Getattr(tp,"type");
while(pi != tp) {
String *name = Getattr(ti,"name");
String *value = Getattr(pi,"value");
if (!value) value = Getattr(pi,"type");
Replaceid(tv, name, value);
pi = nextSibling(pi);
ti = nextSibling(ti);
}
}
p = nextSibling(p);
tp = nextSibling(tp);
if (!p && tp) {

View file

@ -297,12 +297,12 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
tydef = Getattr(p,"typedef");
if (name) {
if (!value) {
value = Getattr(p,"type");
valuestr = SwigType_str(value,0);
} else {
valuestr = SwigType_namestr(value);
if (!value) value = Getattr(p,"type");
if (SwigType_istemplate(value)) {
value = Swig_cparse_template_deftype(value, 0);
}
valuestr = SwigType_str(value,0);
assert(value);
/* Need to patch default arguments */
{