Changed enum handling to try and fix C++ enum handling bugs.
Any enum type is now explicitly reduced to an 'int' by SwigType_lstr() and SwigType_ltype(). Also made a few modifications to the handling of 'const' keywords which reduces the amount of casting. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@856 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
feb39b0fd2
commit
8c1045407b
1 changed files with 55 additions and 14 deletions
|
|
@ -283,7 +283,7 @@ List *SwigType_split(SwigType *t) {
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* SwigType_pop()
|
* SwigType_pop()
|
||||||
*
|
*
|
||||||
* Pop off the first type-constructor object and update the type
|
* Pop off the first type-constructor object and updates the type
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *SwigType_pop(SwigType *t)
|
String *SwigType_pop(SwigType *t)
|
||||||
|
|
@ -462,6 +462,14 @@ int SwigType_isconst(SwigType *t) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SwigType_isenum(SwigType *t) {
|
||||||
|
char *c = Char(t);
|
||||||
|
if (strncmp(c,"enum ",5) == 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* SwigType_base()
|
* SwigType_base()
|
||||||
*
|
*
|
||||||
|
|
@ -727,19 +735,26 @@ SwigType_lstr(SwigType *s, const String_or_char *id)
|
||||||
List *elements;
|
List *elements;
|
||||||
int nelements, i;
|
int nelements, i;
|
||||||
int firstarray = 1;
|
int firstarray = 1;
|
||||||
SwigType *td;
|
SwigType *td, *rs, *tc = 0;
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
result = NewString(Char(id));
|
result = NewString(Char(id));
|
||||||
} else {
|
} else {
|
||||||
result = NewString("");
|
result = NewString("");
|
||||||
}
|
}
|
||||||
|
if (SwigType_isconst(s)) {
|
||||||
td = SwigType_typedef_resolve(s);
|
tc = Copy(s);
|
||||||
|
Delete(SwigType_pop(tc));
|
||||||
|
rs = tc;
|
||||||
|
} else {
|
||||||
|
rs = s;
|
||||||
|
}
|
||||||
|
td = SwigType_typedef_resolve(rs);
|
||||||
if ((td) && (SwigType_isconst(td) || SwigType_isarray(td))) {
|
if ((td) && (SwigType_isconst(td) || SwigType_isarray(td))) {
|
||||||
elements = SwigType_split(td);
|
elements = SwigType_split(td);
|
||||||
|
} else if (td && SwigType_isenum(td)) {
|
||||||
|
elements = SwigType_split("int");
|
||||||
} else {
|
} else {
|
||||||
elements = SwigType_split(s);
|
elements = SwigType_split(rs);
|
||||||
}
|
}
|
||||||
if (td) Delete(td);
|
if (td) Delete(td);
|
||||||
nelements = Len(elements);
|
nelements = Len(elements);
|
||||||
|
|
@ -804,6 +819,7 @@ SwigType_lstr(SwigType *s, const String_or_char *id)
|
||||||
element = nextelement;
|
element = nextelement;
|
||||||
}
|
}
|
||||||
Delete(elements);
|
Delete(elements);
|
||||||
|
if (tc) Delete(tc);
|
||||||
return Swig_temp_result(result);
|
return Swig_temp_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -818,17 +834,28 @@ SwigType *
|
||||||
SwigType_ltype(SwigType *s) {
|
SwigType_ltype(SwigType *s) {
|
||||||
String *result;
|
String *result;
|
||||||
String *element, *nextelement;
|
String *element, *nextelement;
|
||||||
SwigType *td;
|
SwigType *td, *rs, *tc = 0;
|
||||||
List *elements;
|
List *elements;
|
||||||
int nelements, i;
|
int nelements, i;
|
||||||
int firstarray = 1;
|
int firstarray = 1;
|
||||||
|
|
||||||
result = NewString("");
|
result = NewString("");
|
||||||
td = SwigType_typedef_resolve(s);
|
|
||||||
|
if (SwigType_isconst(s)) {
|
||||||
|
tc = Copy(s);
|
||||||
|
Delete(SwigType_pop(tc));
|
||||||
|
rs = tc;
|
||||||
|
} else {
|
||||||
|
rs = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
td = SwigType_typedef_resolve(rs);
|
||||||
if ((td) && (SwigType_isconst(td) || SwigType_isarray(td))) {
|
if ((td) && (SwigType_isconst(td) || SwigType_isarray(td))) {
|
||||||
elements = SwigType_split(td);
|
elements = SwigType_split(td);
|
||||||
|
} else if (td && SwigType_isenum(td)) {
|
||||||
|
elements = SwigType_split("int");
|
||||||
} else {
|
} else {
|
||||||
elements = SwigType_split(s);
|
elements = SwigType_split(rs);
|
||||||
}
|
}
|
||||||
if (td) Delete(td);
|
if (td) Delete(td);
|
||||||
nelements = Len(elements);
|
nelements = Len(elements);
|
||||||
|
|
@ -861,6 +888,7 @@ SwigType_ltype(SwigType *s) {
|
||||||
element = nextelement;
|
element = nextelement;
|
||||||
}
|
}
|
||||||
Delete(elements);
|
Delete(elements);
|
||||||
|
if (tc) Delete(tc);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -874,18 +902,30 @@ SwigType_ltype(SwigType *s) {
|
||||||
String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
||||||
String *result, *cast;
|
String *result, *cast;
|
||||||
String *element = 0, *nextelement;
|
String *element = 0, *nextelement;
|
||||||
SwigType *td;
|
SwigType *td, *rs, *tc = 0;
|
||||||
List *elements;
|
List *elements;
|
||||||
int nelements, i;
|
int nelements, i;
|
||||||
int clear = 1;
|
int clear = 1;
|
||||||
int firstarray = 1;
|
int firstarray = 1;
|
||||||
|
|
||||||
result = NewString("");
|
result = NewString("");
|
||||||
td = SwigType_typedef_resolve(s);
|
|
||||||
|
if (SwigType_isconst(s)) {
|
||||||
|
tc = Copy(s);
|
||||||
|
Delete(SwigType_pop(tc));
|
||||||
|
rs = tc;
|
||||||
|
} else {
|
||||||
|
rs = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
td = SwigType_typedef_resolve(rs);
|
||||||
if ((td) && (SwigType_isconst(td) || SwigType_isarray(td))) {
|
if ((td) && (SwigType_isconst(td) || SwigType_isarray(td))) {
|
||||||
elements = SwigType_split(td);
|
elements = SwigType_split(td);
|
||||||
|
} else if (td && SwigType_isenum(td)) {
|
||||||
|
elements = SwigType_split(rs);
|
||||||
|
clear = 0;
|
||||||
} else {
|
} else {
|
||||||
elements = SwigType_split(s);
|
elements = SwigType_split(rs);
|
||||||
}
|
}
|
||||||
if (td) Delete(td);
|
if (td) Delete(td);
|
||||||
nelements = Len(elements);
|
nelements = Len(elements);
|
||||||
|
|
@ -961,6 +1001,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
|
||||||
Append(cast,name);
|
Append(cast,name);
|
||||||
}
|
}
|
||||||
Delete(result);
|
Delete(result);
|
||||||
|
Delete(tc);
|
||||||
return Swig_temp_result(cast);
|
return Swig_temp_result(cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue