Add C++11 alias templates

This commit is contained in:
Lior Goldberg 2016-07-01 16:15:40 +03:00
commit d0fc5b7b5b
6 changed files with 128 additions and 55 deletions

View file

@ -2910,16 +2910,17 @@ c_declaration : c_decl {
add_symbols($$);
}
| TEMPLATE LESSTHAN template_parms GREATERTHAN USING idcolon EQUAL type plain_declarator SEMI {
$$ = new_node("using");
Setattr($$,"name",$6);
/* Convert alias template to a "template" typedef statement */
$$ = new_node("template");
SwigType_push($8,$9.type);
Setattr($$,"uname",$8);
Setattr($$,"type",$8);
Setattr($$,"storage","typedef");
Setattr($$,"name",$6);
Setattr($$,"decl","");
Setattr($$,"templateparms",$3);
Setattr($$,"templatetype","cdecl");
SetFlag($$,"aliastemplate");
add_symbols($$);
SWIG_WARN_NODE_BEGIN($$);
Swig_warning(WARN_CPP11_ALIAS_TEMPLATE, cparse_file, cparse_line, "The 'using' keyword in template aliasing is not fully supported yet.\n");
SWIG_WARN_NODE_END($$);
$$ = 0; /* TODO - ignored for now */
}
;

View file

@ -870,7 +870,7 @@ int Language::cDeclaration(Node *n) {
} else {
// Found an unignored templated method that has an empty template instantiation (%template())
// Ignore it unless it has been %rename'd
if (Strncmp(symname, "__dummy_", 8) == 0) {
if (Strncmp(symname, "__dummy_", 8) == 0 && Cmp(storage, "typedef") != 0) {
SetFlag(n, "feature:ignore");
Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number,
"%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n));

View file

@ -566,6 +566,10 @@ class TypePass:private Dispatcher {
SwigType_typedef_class(rname);
Delete(rname);
/* SwigType_typedef_class(name); */
} else if (Strcmp(ttype, "cdecl") == 0) {
String *rname = SwigType_typedef_resolve_all(name);
SwigType_typedef_class(rname);
Delete(rname);
}
return SWIG_OK;
}