fixes "flatnested" feature for out-of-scope defined nested classes
This commit is contained in:
parent
6d6cefa791
commit
8bc38dc007
2 changed files with 22 additions and 3 deletions
|
|
@ -26,4 +26,15 @@ namespace ns {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#ifndef __clang__
|
||||||
|
class Outer1 {
|
||||||
|
struct Nested1;
|
||||||
|
public:
|
||||||
|
struct Nested2;
|
||||||
|
};
|
||||||
|
struct Outer1::Nested2 {
|
||||||
|
int data;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -1018,7 +1018,7 @@ static Node *nested_forward_declaration(const char *storage, const char *kind, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetFlag(currentOuterClass, "nested")) {
|
if (!currentOuterClass || !GetFlag(currentOuterClass, "nested")) {
|
||||||
if (nn && Equal(nodeType(nn), "classforward")) {
|
if (nn && Equal(nodeType(nn), "classforward")) {
|
||||||
Node *n = nn;
|
Node *n = nn;
|
||||||
SWIG_WARN_NODE_BEGIN(n);
|
SWIG_WARN_NODE_BEGIN(n);
|
||||||
|
|
@ -3451,8 +3451,14 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
||||||
nscope = Getattr($<node>$, "nested:nscope");
|
nscope = Getattr($<node>$, "nested:nscope");
|
||||||
Delattr($<node>$, "nested:innerscope");
|
Delattr($<node>$, "nested:innerscope");
|
||||||
Delattr($<node>$, "nested:nscope");
|
Delattr($<node>$, "nested:nscope");
|
||||||
if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) /* actual parent class for this class */
|
if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) { /* actual parent class for this class */
|
||||||
Setattr($$, "nested:outer", nscope_inner);
|
Node* forward_declaration = Swig_symbol_clookup_no_inherit(Getattr($<node>$,"name"), Getattr(nscope_inner, "symtab"));
|
||||||
|
if (forward_declaration) {
|
||||||
|
Setattr($<node>$, "access", Getattr(forward_declaration, "access"));
|
||||||
|
}
|
||||||
|
Setattr($<node>$, "nested:outer", nscope_inner);
|
||||||
|
SetFlag($<node>$, "nested");
|
||||||
|
}
|
||||||
if (!currentOuterClass)
|
if (!currentOuterClass)
|
||||||
inclass = 0;
|
inclass = 0;
|
||||||
cscope = Getattr($$, "prev_symtab");
|
cscope = Getattr($$, "prev_symtab");
|
||||||
|
|
@ -3531,6 +3537,8 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
||||||
} else if (nscope_inner) {
|
} else if (nscope_inner) {
|
||||||
/* this is tricky */
|
/* this is tricky */
|
||||||
/* we add the declaration in the original namespace */
|
/* we add the declaration in the original namespace */
|
||||||
|
if (Strcmp(nodeType(nscope_inner), "class") == 0 && cparse_cplusplus && ignore_nested_classes && !GetFlag($$, "feature:flatnested"))
|
||||||
|
$$ = nested_forward_declaration($1, $2, $3, Copy($3), $9);
|
||||||
appendChild(nscope_inner, $$);
|
appendChild(nscope_inner, $$);
|
||||||
Swig_symbol_setscope(Getattr(nscope_inner, "symtab"));
|
Swig_symbol_setscope(Getattr(nscope_inner, "symtab"));
|
||||||
Delete(Namespaceprefix);
|
Delete(Namespaceprefix);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue