test-suite support for C++17 (Java): exception specification throw removal
This commit is contained in:
parent
35b792daed
commit
63f7315c8a
2 changed files with 29 additions and 17 deletions
|
|
@ -4,12 +4,6 @@
|
|||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_DIRECTORTHROWS_UNDEF) MyNS::Foo::directorthrows_warning;
|
||||
|
||||
// throw is invalid in C++17 and later, only SWIG to use it
|
||||
#define TESTCASE_THROW(TYPES...) throw(TYPES)
|
||||
%{
|
||||
#define TESTCASE_THROW(TYPES...)
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
// DEFINE exceptions in header section using std::runtime_error
|
||||
|
|
@ -171,6 +165,18 @@ namespace MyNS {
|
|||
%catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Foo::pong;
|
||||
%catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Bar::pong;
|
||||
|
||||
%{
|
||||
// throw is deprecated in C++11 and invalid in C++17 and later
|
||||
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||
#define throw(TYPES...)
|
||||
#else
|
||||
#define throw(TYPES...) throw(TYPES)
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace MyNS {
|
||||
|
|
@ -180,10 +186,10 @@ public:
|
|||
virtual ~Foo() {}
|
||||
// ping java implementation throws a java Exception1 or an Exception2 if excp is 1 or 2.
|
||||
// pong java implementation throws Exception1,Exception2,Unexpected,NullPointerException for 1,2,3,4
|
||||
virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) = 0;
|
||||
virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0;
|
||||
virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0;
|
||||
virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0;
|
||||
virtual std::string directorthrows_warning(int excp) TESTCASE_THROW(double) { return std::string(); }
|
||||
virtual std::string directorthrows_warning(int excp) throw(double) { return std::string(); }
|
||||
};
|
||||
|
||||
// Make a bar from a foo, so a call to Java Bar
|
||||
|
|
@ -192,7 +198,7 @@ public:
|
|||
class Bar {
|
||||
public:
|
||||
Bar(Foo* d) { delegate=d; }
|
||||
virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2)
|
||||
virtual std::string ping(int excp) throw(int,MyNS::Exception2)
|
||||
{
|
||||
return delegate->ping(excp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue