fix for nested template defined out of class (issue #265)
This commit is contained in:
parent
01faf1baf9
commit
274977154f
2 changed files with 34 additions and 4 deletions
|
|
@ -31,10 +31,34 @@ namespace ns {
|
|||
struct Nested1;
|
||||
public:
|
||||
struct Nested2;
|
||||
template <class T> class Abstract;
|
||||
class Real;
|
||||
};
|
||||
struct Outer1::Nested2 {
|
||||
int data;
|
||||
};
|
||||
|
||||
class Class {
|
||||
public:
|
||||
template <class T> class Abstract;
|
||||
class Real;
|
||||
};
|
||||
|
||||
template <class T> class Class::Abstract {
|
||||
public:
|
||||
virtual void Method() = 0;
|
||||
};
|
||||
#endif
|
||||
%}
|
||||
#ifndef __clang__
|
||||
%template(abstract_int) Class::Abstract <int>;
|
||||
#endif
|
||||
%inline %{
|
||||
#ifndef __clang__
|
||||
class Class::Real : public Abstract <int> {
|
||||
public:
|
||||
virtual void Method() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -2504,6 +2504,7 @@ types_directive : TYPES LPAREN parms RPAREN stringbracesemi {
|
|||
template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN valparms GREATERTHAN SEMI {
|
||||
Parm *p, *tp;
|
||||
Node *n;
|
||||
Node *outer_class = currentOuterClass;
|
||||
Symtab *tscope = 0;
|
||||
int specialized = 0;
|
||||
int variadic = 0;
|
||||
|
|
@ -2516,6 +2517,9 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
if (!inclass) {
|
||||
$5 = resolve_create_node_scope($5);
|
||||
}
|
||||
if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) {
|
||||
outer_class = nscope_inner;
|
||||
}
|
||||
|
||||
/*
|
||||
We use the new namespace entry 'nscope' only to
|
||||
|
|
@ -2648,7 +2652,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
Setattr(templnode,"sym:typename","1");
|
||||
}
|
||||
/* for now, nested %template is allowed only in the same scope as the template declaration */
|
||||
if ($3 && !(nnisclass && ((currentOuterClass && (currentOuterClass != Getattr(nn, "nested:outer")))
|
||||
if ($3 && !(nnisclass && ((outer_class && (outer_class != Getattr(nn, "nested:outer")))
|
||||
||(extendmode && current_class && (current_class != Getattr(nn, "nested:outer")))))) {
|
||||
/*
|
||||
Comment this out for 1.3.28. We need to
|
||||
|
|
@ -2677,9 +2681,9 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
Setfile(templnode,cparse_file);
|
||||
Setline(templnode,cparse_line);
|
||||
Delete(temparms);
|
||||
if (currentOuterClass) {
|
||||
if (outer_class && nnisclass) {
|
||||
SetFlag(templnode, "nested");
|
||||
Setattr(templnode, "nested:outer", currentOuterClass);
|
||||
Setattr(templnode, "nested:outer", outer_class);
|
||||
}
|
||||
add_symbols_copy(templnode);
|
||||
|
||||
|
|
@ -4017,7 +4021,9 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN {
|
|||
Swig_symbol_setscope(cscope);
|
||||
Delete(Namespaceprefix);
|
||||
Namespaceprefix = Swig_symbol_qualifiedscopename(0);
|
||||
if (error) $$ = 0;
|
||||
if (error || (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0)) {
|
||||
$$ = 0;
|
||||
}
|
||||
if (currentOuterClass)
|
||||
template_parameters = Getattr(currentOuterClass, "template_parameters");
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue