fix template_deftype to work with functions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6903 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f64047eb5c
commit
201b47ae3c
1 changed files with 80 additions and 48 deletions
|
|
@ -1311,11 +1311,13 @@ Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
|
||||||
String *s = NewString("f(");
|
String *s = NewString("f(");
|
||||||
pi = First(parms);
|
pi = First(parms);
|
||||||
while (pi.item) {
|
while (pi.item) {
|
||||||
Append(s,Swig_symbol_type_qualify(pi.item,st));
|
String *pf = Swig_symbol_type_qualify(pi.item,st);
|
||||||
|
Append(s,pf);
|
||||||
pi = Next(pi);
|
pi = Next(pi);
|
||||||
if (pi.item) {
|
if (pi.item) {
|
||||||
Append(s,",");
|
Append(s,",");
|
||||||
}
|
}
|
||||||
|
Delete(pf);
|
||||||
}
|
}
|
||||||
Append(s,").");
|
Append(s,").");
|
||||||
Append(result,s);
|
Append(result,s);
|
||||||
|
|
@ -1580,55 +1582,85 @@ Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *t
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
SwigType*
|
SwigType*
|
||||||
Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
|
Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
|
||||||
String *result = 0;
|
String *result = NewString("");
|
||||||
String *prefix = SwigType_prefix(type);
|
List *elements = SwigType_split(type);
|
||||||
String *base = SwigType_base(type);
|
int len = Len(elements);
|
||||||
String *tprefix = SwigType_templateprefix(base);
|
int i;
|
||||||
String *targs = SwigType_templateargs(base);
|
for (i = 0; i < len; i++) {
|
||||||
String *tsuffix = SwigType_templatesuffix(base);
|
String *e = Getitem(elements,i);
|
||||||
ParmList *tparms = SwigType_function_parms(targs);
|
if (SwigType_isfunction(e)) {
|
||||||
Node *tempn = Swig_symbol_clookup_local(tprefix,tscope);
|
Iterator pi;
|
||||||
/* Printf(stderr,"deftype type %s \n", type);*/
|
List *parms = SwigType_parmlist(e);
|
||||||
if (tempn) {
|
String *s = NewString("f(");
|
||||||
ParmList *tnargs = Getattr(tempn,"templateparms");
|
pi = First(parms);
|
||||||
Parm *p;
|
while (pi.item) {
|
||||||
Symtab *tsdecl = Getattr(tempn,"sym:symtab");
|
String *pf = SwigType_istemplate(e) ?
|
||||||
|
Swig_symbol_template_deftype(pi.item,tscope)
|
||||||
/* Printf(stderr,"deftype type %s %s %s %s\n", tprefix, targs, tsuffix);*/
|
: Swig_symbol_type_qualify(pi.item,tscope);
|
||||||
Append(tprefix,"<(");
|
Append(s,pf);
|
||||||
Swig_symbol_template_defargs(tparms, tnargs,tscope,tsdecl);
|
pi = Next(pi);
|
||||||
p = tparms;
|
if (pi.item) {
|
||||||
while (p) {
|
Append(s,",");
|
||||||
SwigType *ptype = Getattr(p,"type");
|
}
|
||||||
SwigType *ttr = ptype ? ptype : Getattr(p,"value");
|
Delete(pf);
|
||||||
SwigType *ttf = Swig_symbol_type_qualify(ttr,tscope);
|
}
|
||||||
SwigType *ttq = Swig_symbol_template_param_eval(ttf,tscope);
|
Append(s,").");
|
||||||
SwigType *ttd = 0;
|
Append(result,s);
|
||||||
if (SwigType_istemplate(ttq)) {
|
Delete(s);
|
||||||
ttd = Swig_symbol_template_deftype(ttq, tscope);
|
} else if (SwigType_istemplate(e)) {
|
||||||
ttq = ttd;
|
String *prefix = SwigType_prefix(e);
|
||||||
}
|
String *base = SwigType_base(e);
|
||||||
Append(tprefix,ttq);
|
String *tprefix = SwigType_templateprefix(base);
|
||||||
p = nextSibling(p);
|
String *targs = SwigType_templateargs(base);
|
||||||
if (p) Putc(',',tprefix);
|
String *tsuffix = SwigType_templatesuffix(base);
|
||||||
Delete(ttr);
|
ParmList *tparms = SwigType_function_parms(targs);
|
||||||
Delete(ttf);
|
Node *tempn = Swig_symbol_clookup_local(tprefix,tscope);
|
||||||
Delete(ttd);
|
/* Printf(stderr,"deftype type %s \n", e);*/
|
||||||
|
if (tempn) {
|
||||||
|
ParmList *tnargs = Getattr(tempn,"templateparms");
|
||||||
|
Parm *p;
|
||||||
|
Symtab *tsdecl = Getattr(tempn,"sym:symtab");
|
||||||
|
|
||||||
|
/* Printf(stderr,"deftype type %s %s %s %s\n", tprefix, targs, tsuffix);*/
|
||||||
|
Append(tprefix,"<(");
|
||||||
|
Swig_symbol_template_defargs(tparms, tnargs,tscope,tsdecl);
|
||||||
|
p = tparms;
|
||||||
|
while (p) {
|
||||||
|
SwigType *ptype = Getattr(p,"type");
|
||||||
|
SwigType *ttr = ptype ? ptype : Getattr(p,"value");
|
||||||
|
SwigType *ttf = Swig_symbol_type_qualify(ttr,tscope);
|
||||||
|
SwigType *ttq = Swig_symbol_template_param_eval(ttf,tscope);
|
||||||
|
SwigType *ttd = 0;
|
||||||
|
if (SwigType_istemplate(ttq)) {
|
||||||
|
ttd = Swig_symbol_template_deftype(ttq, tscope);
|
||||||
|
ttq = ttd;
|
||||||
|
}
|
||||||
|
Append(tprefix,ttq);
|
||||||
|
p = nextSibling(p);
|
||||||
|
if (p) Putc(',',tprefix);
|
||||||
|
Delete(ttr);
|
||||||
|
Delete(ttf);
|
||||||
|
Delete(ttd);
|
||||||
|
}
|
||||||
|
Append(tprefix,")>");
|
||||||
|
Append(tprefix,tsuffix);
|
||||||
|
Append(prefix,tprefix);
|
||||||
|
/* Printf(stderr,"deftype %s %s \n", type, tprefix); */
|
||||||
|
Append(result,prefix);
|
||||||
|
} else {
|
||||||
|
Append(result,e);
|
||||||
|
}
|
||||||
|
Delete(prefix);
|
||||||
|
Delete(base);
|
||||||
|
Delete(tprefix);
|
||||||
|
Delete(tsuffix);
|
||||||
|
Delete(targs);
|
||||||
|
Delete(tparms);
|
||||||
|
} else {
|
||||||
|
Append(result,e);
|
||||||
}
|
}
|
||||||
Append(tprefix,")>");
|
|
||||||
Append(tprefix,tsuffix);
|
|
||||||
Append(prefix,tprefix);
|
|
||||||
/* Printf(stderr,"deftype %s %s \n", type, tprefix); */
|
|
||||||
result = Copy(prefix);
|
|
||||||
} else {
|
|
||||||
result = Copy(type);
|
|
||||||
}
|
}
|
||||||
Delete(prefix);
|
Delete(elements);
|
||||||
Delete(base);
|
|
||||||
Delete(tprefix);
|
|
||||||
Delete(tsuffix);
|
|
||||||
Delete(targs);
|
|
||||||
Delete(tparms);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue