From e2bb89ccb394d1739c249bfc763a5d47fac3d0bd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 21 Apr 2016 01:32:49 +0200 Subject: [PATCH] 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. --- Examples/test-suite/c/Makefile.in | 1 - Source/Modules/c.cxx | 21 ++++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/c/Makefile.in b/Examples/test-suite/c/Makefile.in index 5e4a30365..261832ec9 100644 --- a/Examples/test-suite/c/Makefile.in +++ b/Examples/test-suite/c/Makefile.in @@ -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 \ diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx index 134b4289f..0d38fe085 100644 --- a/Source/Modules/c.cxx +++ b/Source/Modules/c.cxx @@ -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; + } } }