fix template_deftype to work with functions

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6903 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-12-20 21:16:13 +00:00
commit 38ddd05b30

View file

@ -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,15 +1582,40 @@ 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);
int i;
for (i = 0; i < len; i++) {
String *e = Getitem(elements,i);
if (SwigType_isfunction(e)) {
Iterator pi;
List *parms = SwigType_parmlist(e);
String *s = NewString("f(");
pi = First(parms);
while (pi.item) {
String *pf = SwigType_istemplate(e) ?
Swig_symbol_template_deftype(pi.item,tscope)
: Swig_symbol_type_qualify(pi.item,tscope);
Append(s,pf);
pi = Next(pi);
if (pi.item) {
Append(s,",");
}
Delete(pf);
}
Append(s,").");
Append(result,s);
Delete(s);
} else if (SwigType_istemplate(e)) {
String *prefix = SwigType_prefix(e);
String *base = SwigType_base(e);
String *tprefix = SwigType_templateprefix(base); String *tprefix = SwigType_templateprefix(base);
String *targs = SwigType_templateargs(base); String *targs = SwigType_templateargs(base);
String *tsuffix = SwigType_templatesuffix(base); String *tsuffix = SwigType_templatesuffix(base);
ParmList *tparms = SwigType_function_parms(targs); ParmList *tparms = SwigType_function_parms(targs);
Node *tempn = Swig_symbol_clookup_local(tprefix,tscope); Node *tempn = Swig_symbol_clookup_local(tprefix,tscope);
/* Printf(stderr,"deftype type %s \n", type);*/ /* Printf(stderr,"deftype type %s \n", e);*/
if (tempn) { if (tempn) {
ParmList *tnargs = Getattr(tempn,"templateparms"); ParmList *tnargs = Getattr(tempn,"templateparms");
Parm *p; Parm *p;
@ -1619,9 +1646,9 @@ Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
Append(tprefix,tsuffix); Append(tprefix,tsuffix);
Append(prefix,tprefix); Append(prefix,tprefix);
/* Printf(stderr,"deftype %s %s \n", type, tprefix); */ /* Printf(stderr,"deftype %s %s \n", type, tprefix); */
result = Copy(prefix); Append(result,prefix);
} else { } else {
result = Copy(type); Append(result,e);
} }
Delete(prefix); Delete(prefix);
Delete(base); Delete(base);
@ -1629,6 +1656,11 @@ Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) {
Delete(tsuffix); Delete(tsuffix);
Delete(targs); Delete(targs);
Delete(tparms); Delete(tparms);
} else {
Append(result,e);
}
}
Delete(elements);
return result; return result;
} }