Fix C enum forward declarations in some target languages (notably Java)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13030 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d6cef9337f
commit
73b0431fbc
8 changed files with 119 additions and 2 deletions
|
|
@ -1664,6 +1664,8 @@ int Language::enumvalueDeclaration(Node *n) {
|
|||
|
||||
int Language::enumforwardDeclaration(Node *n) {
|
||||
(void) n;
|
||||
if (GetFlag(n, "enumMissing"))
|
||||
enumDeclaration(n); // Generate an empty enum in target language
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -3156,7 +3158,9 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
n = Swig_symbol_clookup(base, stab);
|
||||
if (!n)
|
||||
break;
|
||||
if (Strcmp(nodeType(n), "enum") == 0)
|
||||
if (Equal(nodeType(n), "enum"))
|
||||
break;
|
||||
if (Equal(nodeType(n), "enumforward") && GetFlag(n, "enumMissing"))
|
||||
break;
|
||||
n = parentNode(n);
|
||||
if (!n)
|
||||
|
|
|
|||
|
|
@ -886,7 +886,22 @@ class TypePass:private Dispatcher {
|
|||
|
||||
// Use enumDeclaration() to do all the hard work.
|
||||
// Note that no children can be emitted in a forward declaration as there aren't any.
|
||||
return enumDeclaration(n);
|
||||
int result = enumDeclaration(n);
|
||||
if (result == SWIG_OK) {
|
||||
// Detect when the real enum matching the forward enum declaration has not been parsed/declared
|
||||
SwigType *ty = SwigType_typedef_resolve_all(Getattr(n, "type"));
|
||||
Replaceall(ty, "enum ", "");
|
||||
Node *nn = Swig_symbol_clookup(ty, 0);
|
||||
|
||||
String *nodetype = nn ? nodeType(nn) : 0;
|
||||
if (nodetype) {
|
||||
if (Equal(nodetype, "enumforward")) {
|
||||
SetFlag(nn, "enumMissing");
|
||||
} // if a real enum was declared this would be an "enum" node type
|
||||
}
|
||||
Delete(ty);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue