Fix #1819847 %template with just one default template parameter

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10189 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2007-12-12 19:00:15 +00:00
commit b79ebf39fa
8 changed files with 117 additions and 11 deletions

View file

@ -2537,7 +2537,8 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
This is closer to the C++ (typedef) behavior.
*/
n = Swig_cparse_template_locate($5,$7,tscope);
Parm *parms = $7;
n = Swig_cparse_template_locate($5,parms,tscope);
/* Patch the argument types to respect namespaces */
p = $7;
@ -2588,7 +2589,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
continue;
} else {
String *tname = Copy($5);
int def_supplied = 0;
int def_supplied = 0;
/* Expand the template */
Node *templ = Swig_symbol_clookup($5,0);
Parm *targs = templ ? Getattr(templ,"templateparms") : 0;
@ -2600,6 +2601,12 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
/* Create typedef's and arguments */
p = $7;
tp = temparms;
if (!p && ParmList_len(p) != ParmList_len(temparms)) {
/* we have no template parameters supplied in %template for a template that has default args*/
p = tp;
def_supplied = 1;
}
while (p) {
String *value = Getattr(p,"value");
if (def_supplied) {

View file

@ -40,7 +40,7 @@ void Swig_cparse_debug_templates(int x) {
}
/* -----------------------------------------------------------------------------
* Swig_cparse_template_expand()
* cparse_template_expand()
*
* Expands a template node into a specialized version. This is done by
* patching typenames and other aspects of the node according to a list of
@ -230,6 +230,10 @@ String *partial_arg(String *s, String *p) {
return newarg;
}
/* -----------------------------------------------------------------------------
* Swig_cparse_template_expand()
* ----------------------------------------------------------------------------- */
int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope) {
List *patchlist, *cpatchlist, *typelist;
String *templateargs;
@ -429,6 +433,7 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
Parm *p;
Parm *parms;
Parm *targs;
ParmList *expandedparms;
tname = Copy(name);
parms = CopyParmList(tparms);
@ -441,12 +446,14 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
Symtab *tsdecl = Getattr(templ, "sym:symtab");
targs = Getattr(templ, "templateparms");
Swig_symbol_template_defargs(parms, targs, tscope, tsdecl);
expandedparms = Swig_symbol_template_defargs(parms, targs, tscope, tsdecl);
} else {
expandedparms = parms;
}
/* reduce the typedef */
p = parms;
p = expandedparms;
while (p) {
SwigType *ty = Getattr(p, "type");
if (ty) {
@ -457,7 +464,7 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
p = nextSibling(p);
}
SwigType_add_template(tname, parms);
SwigType_add_template(tname, expandedparms);
if (template_debug) {
Printf(stdout, "\n%s:%d: template_debug: Searching for %s\n", cparse_file, cparse_line, tname);