Removed last vestiges of enums being handled as integers in the core.

New attribute, 'enumtype' -> needed when obtaining an enumitem value via a wrapper method - it contains the type of the enum so that an instance of this enum can be declared.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6774 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-11-28 18:57:40 +00:00
commit 7803f9d220

View file

@ -767,27 +767,54 @@ class TypePass : private Dispatcher {
String *name = Getattr(n,"name");
if (name) {
// Correct the name to contain the fully qualified scopename
String *scope = 0;
// Add a typedef to the type table so that we can use 'enum Name' as well as just 'Name'
if (nsname || inclass) {
String *nname = 0;
// But first correct the name and tdname to contain the fully qualified scopename
if (nsname && inclass) {
nname = NewStringf("%s::%s::%s", nsname, Getattr(inclass,"name"), name);
scope = NewStringf("%s::%s", nsname, Getattr(inclass,"name"));
} else if (nsname) {
nname = NewStringf("%s::%s", nsname, name);
scope = NewStringf("%s", nsname);
} else if (inclass) {
nname = NewStringf("%s::%s", Getattr(inclass,"name"), name);
scope = NewStringf("%s", Getattr(inclass,"name"));
}
String *nname = NewStringf("%s::%s", scope, name);
Setattr(n,"name",nname);
String *tdname = Getattr(n,"tdname");
if (tdname) {
tdname = NewStringf("%s::%s", scope, tdname);
Setattr(n,"tdname",tdname);
}
SwigType *t = NewStringf("enum %s", nname);
SwigType_typedef(t,name);
Delete(nname);
} else {
SwigType *t = NewStringf("enum %s", name);
SwigType_typedef(t,name);
}
Delete(scope);
}
String *tdname = Getattr(n,"tdname");
String *unnamed = Getattr(n,"unnamed");
String *storage = Getattr(n,"storage");
// Construct enumtype - for declaring an enum of this type with SwigType_ltype() etc
String *enumtype = 0;
if (unnamed && tdname && (Cmp(storage,"typedef") == 0)) {
enumtype = Copy(Getattr(n,"tdname"));
} else if (name) {
enumtype = NewStringf("%s%s", CPlusPlus ? "" : "enum ", Getattr(n,"name"));
} else {
// anonymous enums
enumtype = Copy(Getattr(n,"type"));
}
Setattr(n,"enumtype",enumtype);
emit_children(n);
return SWIG_OK;
}