Fix for enum forward declarations
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6117 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cf79d771c0
commit
4c02e7cc0e
4 changed files with 42 additions and 1 deletions
|
|
@ -962,7 +962,7 @@ static void new_feature(const char *featurename, String *val, Hash *featureattri
|
|||
%type <node> types_directive template_directive warn_directive ;
|
||||
|
||||
/* C declarations */
|
||||
%type <node> c_declaration c_decl c_decl_tail c_enum_decl c_constructor_decl ;
|
||||
%type <node> c_declaration c_decl c_decl_tail c_enum_decl c_enum_forward_decl c_constructor_decl ;
|
||||
%type <node> enumlist edecl;
|
||||
|
||||
/* C++ declarations */
|
||||
|
|
@ -2172,6 +2172,7 @@ c_declaration : c_decl {
|
|||
}
|
||||
}
|
||||
| c_enum_decl { $$ = $1; }
|
||||
| c_enum_forward_decl { $$ = $1; }
|
||||
|
||||
/* A an extern C type declaration. Does nothing, but is ignored */
|
||||
|
||||
|
|
@ -2296,6 +2297,21 @@ initializer : def_args {
|
|||
;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
enum Name;
|
||||
------------------------------------------------------------ */
|
||||
|
||||
c_enum_forward_decl : storage_class ENUM ID SEMI {
|
||||
SwigType *ty = 0;
|
||||
$$ = new_node("enumforward");
|
||||
ty = NewStringf("enum %s", $3);
|
||||
Setattr($$,"name",$3);
|
||||
Setattr($$,"type",ty);
|
||||
Setattr($$,"sym:weak", "1");
|
||||
add_symbols($$);
|
||||
}
|
||||
;
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
enum { ... }
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ int Dispatcher::emit_one(Node *n) {
|
|||
ret = enumDeclaration(n);
|
||||
} else if (strcmp(tag,"enumitem") == 0) {
|
||||
ret = enumvalueDeclaration(n);
|
||||
} else if (strcmp(tag,"enumforward") == 0) {
|
||||
ret = enumforwardDeclaration(n);
|
||||
} else if (strcmp(tag,"class") == 0) {
|
||||
ret = classDeclaration(n);
|
||||
} else if (strcmp(tag,"classforward") == 0) {
|
||||
|
|
@ -236,6 +238,7 @@ int Dispatcher::cDeclaration(Node *n) { return defaultHandler(n); }
|
|||
int Dispatcher::externDeclaration(Node *n) { return defaultHandler(n); }
|
||||
int Dispatcher::enumDeclaration(Node *n) { return defaultHandler(n); }
|
||||
int Dispatcher::enumvalueDeclaration(Node *n) { return defaultHandler(n); }
|
||||
int Dispatcher::enumforwardDeclaration(Node *n) { return defaultHandler(n); }
|
||||
int Dispatcher::classDeclaration(Node *n) { return defaultHandler(n); }
|
||||
int Dispatcher::templateDeclaration(Node *n) { return defaultHandler(n); }
|
||||
int Dispatcher::classforwardDeclaration(Node *n) { return defaultHandler(n); }
|
||||
|
|
@ -1387,6 +1390,15 @@ int Language::enumvalueDeclaration(Node *n) {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Language::enumforwardDeclaration()
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
int Language::enumforwardDeclaration(Node *n) {
|
||||
(void)n;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::memberconstantHandler()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ class Dispatcher {
|
|||
virtual int externDeclaration(Node *n);
|
||||
virtual int enumDeclaration(Node *n);
|
||||
virtual int enumvalueDeclaration(Node *n);
|
||||
virtual int enumforwardDeclaration(Node *n);
|
||||
virtual int classDeclaration(Node *n);
|
||||
virtual int classforwardDeclaration(Node *n);
|
||||
virtual int constructorDeclaration(Node *n);
|
||||
|
|
@ -148,6 +149,7 @@ public:
|
|||
virtual int externDeclaration(Node *n);
|
||||
virtual int enumDeclaration(Node *n);
|
||||
virtual int enumvalueDeclaration(Node *n);
|
||||
virtual int enumforwardDeclaration(Node *n);
|
||||
virtual int classDeclaration(Node *n);
|
||||
virtual int classforwardDeclaration(Node *n);
|
||||
virtual int constructorDeclaration(Node *n);
|
||||
|
|
|
|||
|
|
@ -795,6 +795,17 @@ class TypePass : private Dispatcher {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* enumforwardDeclaration()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int enumforwardDeclaration(Node *n) {
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* usingDeclaration()
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue