enum fixes for the typesystem
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5845 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c146a39d2e
commit
ef291371d5
1 changed files with 20 additions and 13 deletions
|
|
@ -475,10 +475,11 @@ SwigType_find_scope(Typetab *s, String *nameprefix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* SwigType_typedef_resolve()
|
* typedef_resolve()
|
||||||
*
|
*
|
||||||
* Resolves a typedef and returns a new type string. Returns 0 if there is no
|
* Resolves a typedef and returns a new type string. Returns 0 if there is no
|
||||||
* typedef mapping. base is a name without qualification.
|
* typedef mapping. base is a name without qualification.
|
||||||
|
* Internal function.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static Typetab *resolved_scope = 0;
|
static Typetab *resolved_scope = 0;
|
||||||
|
|
@ -524,6 +525,10 @@ typedef_resolve(Typetab *s, String *base) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* SwigType_typedef_resolve()
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
SwigType *SwigType_typedef_resolve(SwigType *t) {
|
SwigType *SwigType_typedef_resolve(SwigType *t) {
|
||||||
String *base;
|
String *base;
|
||||||
String *type = 0;
|
String *type = 0;
|
||||||
|
|
@ -555,7 +560,7 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
|
||||||
|
|
||||||
base = SwigType_base(t);
|
base = SwigType_base(t);
|
||||||
|
|
||||||
/* Printf(stdout,"base = '%s'\n", base); */
|
/* Printf(stdout,"base = '%s' t='%s'\n", base, t); */
|
||||||
|
|
||||||
if (SwigType_issimple(base)) {
|
if (SwigType_issimple(base)) {
|
||||||
s = current_scope;
|
s = current_scope;
|
||||||
|
|
@ -576,7 +581,7 @@ SwigType *SwigType_typedef_resolve(SwigType *t) {
|
||||||
if (Swig_scopename_check(base)) {
|
if (Swig_scopename_check(base)) {
|
||||||
/* A qualified name. */
|
/* A qualified name. */
|
||||||
nameprefix = Swig_scopename_prefix(base);
|
nameprefix = Swig_scopename_prefix(base);
|
||||||
/* Printf(stdout,"nameprefix = '%s'\n", nameprefix);*/
|
/* Printf(stdout,"nameprefix = '%s'\n", nameprefix); */
|
||||||
if (nameprefix) {
|
if (nameprefix) {
|
||||||
/* Name had a prefix on it. See if we can locate the proper scope for it */
|
/* Name had a prefix on it. See if we can locate the proper scope for it */
|
||||||
s = SwigType_find_scope(s,nameprefix);
|
s = SwigType_find_scope(s,nameprefix);
|
||||||
|
|
@ -767,6 +772,7 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
||||||
SwigType *n;
|
SwigType *n;
|
||||||
SwigType *r;
|
SwigType *r;
|
||||||
|
|
||||||
|
/* Check to see if the typedef resolve has been done before by checking the cache */
|
||||||
if (!typedef_all_cache) {
|
if (!typedef_all_cache) {
|
||||||
typedef_all_cache = NewHash();
|
typedef_all_cache = NewHash();
|
||||||
}
|
}
|
||||||
|
|
@ -774,11 +780,15 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
||||||
if (r) {
|
if (r) {
|
||||||
return Copy(r);
|
return Copy(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Recursively resolve the typedef */
|
||||||
r = NewString(t);
|
r = NewString(t);
|
||||||
while ((n = SwigType_typedef_resolve(r))) {
|
while ((n = SwigType_typedef_resolve(r))) {
|
||||||
Delete(r);
|
Delete(r);
|
||||||
r = n;
|
r = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add the typedef to the cache for next time it is looked up */
|
||||||
{
|
{
|
||||||
String *key;
|
String *key;
|
||||||
SwigType *rr = Copy(r);
|
SwigType *rr = Copy(r);
|
||||||
|
|
@ -803,7 +813,6 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
|
||||||
List *elements;
|
List *elements;
|
||||||
String *result;
|
String *result;
|
||||||
int i,len;
|
int i,len;
|
||||||
|
|
||||||
if (!typedef_qualified_cache) typedef_qualified_cache = NewHash();
|
if (!typedef_qualified_cache) typedef_qualified_cache = NewHash();
|
||||||
result = Getattr(typedef_qualified_cache,t);
|
result = Getattr(typedef_qualified_cache,t);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
@ -820,7 +829,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
|
||||||
if (!SwigType_istemplate(e)) {
|
if (!SwigType_istemplate(e)) {
|
||||||
String *isenum = 0;
|
String *isenum = 0;
|
||||||
if (SwigType_isenum(e)) {
|
if (SwigType_isenum(e)) {
|
||||||
isenum = e;
|
isenum = NewString("enum ");
|
||||||
e = NewString(Char(e)+5);
|
e = NewString(Char(e)+5);
|
||||||
}
|
}
|
||||||
resolved_scope = 0;
|
resolved_scope = 0;
|
||||||
|
|
@ -830,11 +839,6 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
|
||||||
if (qname) {
|
if (qname) {
|
||||||
Insert(e,0,"::");
|
Insert(e,0,"::");
|
||||||
Insert(e,0,qname);
|
Insert(e,0,qname);
|
||||||
if (isenum) {
|
|
||||||
Clear(isenum);
|
|
||||||
Printf(isenum, "enum %s", e);
|
|
||||||
Delete(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Swig_scopename_check(e)) {
|
if (Swig_scopename_check(e)) {
|
||||||
|
|
@ -855,7 +859,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
|
||||||
/* It's a bare name. It's entirely possible, that the
|
/* It's a bare name. It's entirely possible, that the
|
||||||
name is part of a namespace. We'll check this by unrolling
|
name is part of a namespace. We'll check this by unrolling
|
||||||
out of the current scope */
|
out of the current scope */
|
||||||
|
|
||||||
Typetab *cs = current_scope;
|
Typetab *cs = current_scope;
|
||||||
while (cs) {
|
while (cs) {
|
||||||
String *qs = SwigType_scope_name(cs);
|
String *qs = SwigType_scope_name(cs);
|
||||||
|
|
@ -874,7 +878,10 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isenum) e = isenum;
|
|
||||||
|
if (isenum) {
|
||||||
|
Insert(e,0,isenum);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Template. We need to qualify template parameters as well as the template itself */
|
/* Template. We need to qualify template parameters as well as the template itself */
|
||||||
|
|
@ -890,7 +897,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t)
|
||||||
pi = First(parms);
|
pi = First(parms);
|
||||||
while ((p = pi.item)) {
|
while ((p = pi.item)) {
|
||||||
String *qt = SwigType_typedef_qualified(p);
|
String *qt = SwigType_typedef_qualified(p);
|
||||||
if ((Strcmp(qt,p) == 0)) { /* && (!Swig_scopename_check(qt))) { */
|
if ((Strcmp(qt,p) == 0)) { /* && (!Swig_scopename_check(qt))) */
|
||||||
/* No change in value. It is entirely possible that the parameter is an integer value.
|
/* No change in value. It is entirely possible that the parameter is an integer value.
|
||||||
If there is a symbol table associated with this scope, we're going to check for this */
|
If there is a symbol table associated with this scope, we're going to check for this */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue