summaryrefslogtreecommitdiff
path: root/Examples/lua
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2018-05-03 19:20:42 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2018-05-04 20:02:13 +0100
commitc9a10eb7266e8c411541a00af2806e068850f58e (patch)
tree21fce5ef4335bc0c070ac5ee4cfb6b2d79cc9ba7 /Examples/lua
parent4e0b2f1402217bb9ea864833c5bbdaad82450709 (diff)
downloadswig-c9a10eb7266e8c411541a00af2806e068850f58e.tar.gz
Examples update to support C++17: exception specification throw removal
Diffstat (limited to 'Examples/lua')
-rw-r--r--Examples/lua/exception/example.h27
-rw-r--r--Examples/lua/exception/example.i6
2 files changed, 12 insertions, 21 deletions
diff --git a/Examples/lua/exception/example.h b/Examples/lua/exception/example.h
index ea3b4fc63..bc744cda7 100644
--- a/Examples/lua/exception/example.h
+++ b/Examples/lua/exception/example.h
@@ -1,6 +1,6 @@
/* File : example.h */
-#include <string>
+#include <string.h>
#ifndef SWIG
struct A {
};
@@ -16,34 +16,26 @@ public:
char msg[256];
};
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-#if __GNUC__ >= 7
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11
-#endif
-
class Test {
public:
- int simple() throw(int) {
+ int simple() {
throw(37);
return 1;
}
- int message() throw(const char *) {
+ int message() {
throw("I died.");
return 1;
}
- int hosed() throw(Exc) {
+ int hosed() {
throw(Exc(42,"Hosed"));
return 1;
}
- int unknown() throw(A*) {
+ int unknown() {
static A a;
throw &a;
return 1;
}
- int multi(int x) throw(int, const char *, Exc) {
+ int multi(int x) {
if (x == 1) throw(37);
if (x == 2) throw("Bleah!");
if (x == 3) throw(Exc(42,"No-go-diggy-die"));
@@ -51,10 +43,3 @@ public:
}
};
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-#if __GNUC__ >= 7
- #pragma GCC diagnostic pop
-#endif
-
diff --git a/Examples/lua/exception/example.i b/Examples/lua/exception/example.i
index 6187f8eff..a6b43837d 100644
--- a/Examples/lua/exception/example.i
+++ b/Examples/lua/exception/example.i
@@ -12,6 +12,12 @@
// note: only works if Exc is copyable
%apply SWIGTYPE EXCEPTION_BY_VAL {Exc};
+%catches(int) Test::simple();
+%catches(const char *) Test::message();
+%catches(Exc) Test::hosed();
+%catches(A*) Test::unknown();
+%catches(int, const char *, Exc) Test::multi(int x);
+
/* Let's just grab the original header file here */
%include "example.h"