support of typemaps + template + template def args
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6808 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ff2e0cc85e
commit
2d686c0a84
4 changed files with 92 additions and 27 deletions
|
|
@ -58,6 +58,7 @@ extern int need_redefined_warn(Node* a, Node* b, int InClass);
|
|||
|
||||
/* templ.c */
|
||||
extern void Swig_cparse_template_defargs(Parm *parms, Parm *targs, Symtab *tscope);
|
||||
extern String* Swig_cparse_template_deftype(SwigType *type, Symtab *tscope);
|
||||
extern int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope);
|
||||
extern Node *Swig_cparse_template_locate(String *name, ParmList *tparms, Symtab *tscope);
|
||||
extern void Swig_cparse_debug_templates(int);
|
||||
|
|
|
|||
|
|
@ -3301,25 +3301,8 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para
|
|||
Delete(targs);
|
||||
} else {
|
||||
/* Need to resolve exact specialization name */
|
||||
/* This needs to be rewritten */
|
||||
ParmList *tparms;
|
||||
String *fname;
|
||||
Parm *p;
|
||||
fname = SwigType_templateprefix(tname);
|
||||
tparms = SwigType_function_parms(tname);
|
||||
/* add default args from generic template */
|
||||
Swig_cparse_template_defargs(tparms, Getattr(tempn,"templateparms"),0);
|
||||
Append(fname,"<(");
|
||||
p = tparms;
|
||||
while (p){
|
||||
SwigType *type = Getattr(p,"type");
|
||||
SwigType *ttr = Swig_symbol_typedef_reduce(type ? type : Getattr(p,"value") ,0);
|
||||
ttr = Swig_symbol_type_qualify(ttr,0);
|
||||
Append(fname,ttr);
|
||||
p = nextSibling(p);
|
||||
if (p) Putc(',',fname);
|
||||
}
|
||||
Append(fname,")>");
|
||||
String *fname = Swig_cparse_template_deftype(tname,0);
|
||||
Swig_symbol_cadd(fname,$$);
|
||||
}
|
||||
} else if ($$) {
|
||||
|
|
|
|||
|
|
@ -428,6 +428,59 @@ Swig_cparse_template_defargs(Parm *parms, Parm *targs, Symtab *tscope) {
|
|||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_cparse_template_deftype()
|
||||
*
|
||||
* Apply default args to generic template type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
String*
|
||||
Swig_cparse_template_deftype(SwigType *type, Symtab *tscope) {
|
||||
String *prefix = SwigType_prefix(type);
|
||||
String *base = SwigType_base(type);
|
||||
String *tprefix = SwigType_templateprefix(base);
|
||||
String *targs = SwigType_templateargs(base);
|
||||
String *tsuffix = SwigType_templatesuffix(base);
|
||||
ParmList *tparms = SwigType_function_parms(targs);
|
||||
Node *tempn = Swig_symbol_clookup_local(tprefix,tscope);
|
||||
if (tempn) {
|
||||
ParmList *tnargs = Getattr(tempn,"templateparms");
|
||||
Parm *p;
|
||||
/* Printf(stderr,"deftype type %s %s %s\n", tprefix, targs, tsuffix);*/
|
||||
Append(tprefix,"<(");
|
||||
Swig_cparse_template_defargs(tparms, tnargs,tscope);
|
||||
p = tparms;
|
||||
while (p) {
|
||||
SwigType *ptype = Getattr(p,"type");
|
||||
SwigType *ttr = Swig_symbol_typedef_reduce(ptype ? ptype : Getattr(p,"value") ,tscope);
|
||||
SwigType *ttq = Swig_symbol_type_qualify(ttr,tscope);
|
||||
if (SwigType_istemplate(ttq)) {
|
||||
SwigType *t = Swig_cparse_template_deftype(ttq, tscope);
|
||||
Delete(ttq);
|
||||
ttq = t;
|
||||
}
|
||||
Append(tprefix,ttq);
|
||||
p = nextSibling(p);
|
||||
if (p) Putc(',',tprefix);
|
||||
Delete(ttr);
|
||||
Delete(ttq);
|
||||
}
|
||||
Append(tprefix,")>");
|
||||
Append(tprefix,tsuffix);
|
||||
Append(prefix,tprefix);
|
||||
/* Printf(stderr,"deftype default %s \n", tprefix); */
|
||||
type = Copy(prefix);
|
||||
} else {
|
||||
type = Copy(type);
|
||||
}
|
||||
|
||||
Delete(prefix);
|
||||
Delete(base);
|
||||
Delete(tprefix);
|
||||
Delete(tsuffix);
|
||||
Delete(targs);
|
||||
Delete(tparms);
|
||||
return type;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* template_locate()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue