Fix enums in the type system
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5849 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d19287dc1f
commit
1472f009ea
1 changed files with 31 additions and 24 deletions
|
|
@ -34,7 +34,8 @@ struct normal_node {
|
||||||
|
|
||||||
static normal_node *patch_list = 0;
|
static normal_node *patch_list = 0;
|
||||||
|
|
||||||
class TypePass : public Dispatcher {
|
/* Singleton class - all non-static methods in this class are private */
|
||||||
|
class TypePass : private Dispatcher {
|
||||||
Node *inclass;
|
Node *inclass;
|
||||||
Node *module;
|
Node *module;
|
||||||
int importmode;
|
int importmode;
|
||||||
|
|
@ -42,18 +43,13 @@ class TypePass : public Dispatcher {
|
||||||
Hash *classhash;
|
Hash *classhash;
|
||||||
List *normalize;
|
List *normalize;
|
||||||
|
|
||||||
|
TypePass() {
|
||||||
|
}
|
||||||
|
|
||||||
/* Normalize a type. Replaces type with fully qualified version */
|
/* Normalize a type. Replaces type with fully qualified version */
|
||||||
|
|
||||||
void normalize_type(SwigType *ty) {
|
void normalize_type(SwigType *ty) {
|
||||||
SwigType *qty;
|
SwigType *qty;
|
||||||
/*qty = Swig_symbol_type_qualify(ty,0);*/
|
|
||||||
/* if (SwigType_istemplate(ty)) {
|
|
||||||
qty = Swig_symbol_type_qualify(ty,0);
|
|
||||||
Clear(ty);
|
|
||||||
Append(ty,qty);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (CPlusPlus) {
|
if (CPlusPlus) {
|
||||||
Replaceall(ty,"struct ","");
|
Replaceall(ty,"struct ","");
|
||||||
Replaceall(ty,"union ","");
|
Replaceall(ty,"union ","");
|
||||||
|
|
@ -318,8 +314,6 @@ class TypePass : public Dispatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
* top()
|
* top()
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
@ -743,20 +737,29 @@ public:
|
||||||
|
|
||||||
virtual int enumDeclaration(Node *n) {
|
virtual int enumDeclaration(Node *n) {
|
||||||
String *name = Getattr(n,"name");
|
String *name = Getattr(n,"name");
|
||||||
String *uname = Getattr(n,"unnamed");
|
|
||||||
if (name) {
|
if (name) {
|
||||||
SwigType *t;
|
// Correct the name to contain the fully qualified scopename
|
||||||
if (uname) {
|
// Add a typedef to the type table so that we can use 'enum Name' as well as just 'Name'
|
||||||
t = NewStringf("enum %s", uname);
|
if (nsname || inclass) {
|
||||||
if (checkAttribute(n,"storage","typedef")) {
|
String *nname = 0;
|
||||||
SwigType_typedef(t,name);
|
if (nsname && inclass) {
|
||||||
|
nname = NewStringf("%s::%s::%s", nsname, Getattr(inclass,"name"), name);
|
||||||
|
} else if (nsname) {
|
||||||
|
nname = NewStringf("%s::%s", nsname, name);
|
||||||
|
} else if (inclass) {
|
||||||
|
nname = NewStringf("%s::%s", Getattr(inclass,"name"), name);
|
||||||
}
|
}
|
||||||
|
Setattr(n,"name",nname);
|
||||||
|
SwigType *t = NewStringf("enum %s", nname);
|
||||||
|
SwigType_typedef(t,name);
|
||||||
|
Delete(nname);
|
||||||
} else {
|
} else {
|
||||||
t = NewStringf("enum %s", name);
|
SwigType *t = NewStringf("enum %s", name);
|
||||||
SwigType_typedef(t,name);
|
SwigType_typedef(t,name);
|
||||||
}
|
}
|
||||||
Delete(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_children(n);
|
emit_children(n);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -977,13 +980,17 @@ public:
|
||||||
}
|
}
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void pass(Node *n) {
|
||||||
|
TypePass t;
|
||||||
|
t.top(n);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Swig_process_types(Node *n) {
|
void Swig_process_types(Node *n) {
|
||||||
if (!n) return;
|
if (!n) return;
|
||||||
TypePass *t = new TypePass;
|
TypePass::pass(n);
|
||||||
t->top(n);
|
|
||||||
delete t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue