1 /* This file tests a few new contract features.
2 First it checks to make sure the constant aggregation macro
3 %aggregate_check() works. This is defined in swig.swg.
5 Next, it checks to make sure a simple contract works.
6 To support contracts, you need to add a macro to the runtime.
7 For Python, it looks like this:
9 #define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg #expr ); goto fail; } else
11 Note: It is used like this:
12 SWIG_contract_assert(x == 1, "Some kind of error message");
14 Note: Contracts are still experimental. The runtime interface may
15 change in future versions.
20 %include <exception.i>
21 %aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT)
23 %contract move(int x) {
34 int move(int direction) {