Replace unknown enums with int in the wrappers

An enum can be declared outside of the code wrapped by SWIG, just use int
instead of it then.
This commit is contained in:
Vadim Zeitlin 2016-04-21 01:32:49 +02:00
commit e2bb89ccb3
2 changed files with 14 additions and 8 deletions

View file

@ -27,7 +27,6 @@ CPP_TEST_CASES := \
# The following tests are currently broken and need to be fixed.
FAILING_C_TESTS := \
arrays \
enum_missing \
funcptr \
function_typedef \
lextype \

View file

@ -1363,14 +1363,21 @@ ready:
Delete(type_str);
type_str = int_type_str;
} else {
// Don't bother with checking if type is representable in C if we're wrapping C and not C++ anyhow: of course it is.
if (CPlusPlus) {
if (SwigType_isreference(type))
return NIL;
scoped_dohptr btype(SwigType_base(type));
if (SwigType_isenum(btype)) {
// Enums are special as they can be unknown, i.e. not wrapped by SWIG. In this case we just use int instead.
if (!enumLookup(btype)) {
Replaceall(type_str, btype, "int");
}
} else {
// Don't bother with checking if type is representable in C if we're wrapping C and not C++ anyhow: of course it is.
if (CPlusPlus) {
if (SwigType_isreference(type))
return NIL;
scoped_dohptr btype(SwigType_base(type));
if (!SwigType_isbuiltin(btype) && !SwigType_isenum(btype))
return NIL;
if (!SwigType_isbuiltin(btype))
return NIL;
}
}
}