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:
parent
a84f3dfa68
commit
b79ebf39fa
8 changed files with 117 additions and 11 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ extern "C" {
|
|||
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
|
||||
extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
|
||||
|
||||
extern void Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||
extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
|
||||
extern SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab);
|
||||
|
||||
|
|
|
|||
|
|
@ -1669,10 +1669,14 @@ String *Swig_symbol_string_qualify(String *s, Symtab *st) {
|
|||
* Swig_symbol_template_defargs()
|
||||
*
|
||||
* Apply default arg from generic template default args
|
||||
* Returns a parameter list which contains missing default arguments (if any)
|
||||
* Note side effects: parms will also contain the extra parameters in its list
|
||||
* (but only if non-zero).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
void Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl) {
|
||||
ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl) {
|
||||
ParmList *expandedparms = parms;
|
||||
if (Len(parms) < Len(targs)) {
|
||||
Parm *lp = parms;
|
||||
Parm *p = lp;
|
||||
|
|
@ -1713,7 +1717,10 @@ void Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symt
|
|||
}
|
||||
/* Printf(stderr,"value %s %s %s\n",value,ntr,ntq); */
|
||||
cp = NewParm(ntq, 0);
|
||||
set_nextSibling(lp, cp);
|
||||
if (lp)
|
||||
set_nextSibling(lp, cp);
|
||||
else
|
||||
expandedparms = CopyParm(cp);
|
||||
lp = cp;
|
||||
tp = nextSibling(tp);
|
||||
Delete(cp);
|
||||
|
|
@ -1724,6 +1731,7 @@ void Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symt
|
|||
}
|
||||
}
|
||||
}
|
||||
return expandedparms;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -1795,6 +1803,7 @@ SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
|
|||
#endif
|
||||
if (tempn) {
|
||||
ParmList *tnargs = Getattr(tempn, "templateparms");
|
||||
ParmList *expandedparms;
|
||||
Parm *p;
|
||||
Symtab *tsdecl = Getattr(tempn, "sym:symtab");
|
||||
|
||||
|
|
@ -1802,8 +1811,8 @@ SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
|
|||
Printf(stderr, "deftype type %s %s %s\n", tprefix, targs, tsuffix);
|
||||
#endif
|
||||
Append(tprefix, "<(");
|
||||
Swig_symbol_template_defargs(tparms, tnargs, tscope, tsdecl);
|
||||
p = tparms;
|
||||
expandedparms = Swig_symbol_template_defargs(tparms, tnargs, tscope, tsdecl);
|
||||
p = expandedparms;
|
||||
tscope = tsdecl;
|
||||
while (p) {
|
||||
SwigType *ptype = Getattr(p, "type");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue