Exceptions support for C. exception_order test shows how to use type information to achieve correct catching order. Examples cleanup.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10671 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2008-07-17 00:52:11 +00:00
commit 88facfd390
27 changed files with 223 additions and 429 deletions

View file

@ -1,20 +0,0 @@
#include <stdio.h>
#include "c_arguments/c_arguments_proxy.h"
int main(int argc, char **argv) {
A *a = new_A();
A *a1, *a2, *a3;
a1 = foo_1(a);
a2 = foo_2(a);
a3 = foo_3(a);
delete_A(a);
delete_A(a1);
delete_A(a2);
delete_A(a3);
return 0;
}

View file

@ -0,0 +1,65 @@
#include <stdio.h>
#include "exception_order/exception_order_proxy.h"
int main() {
A* a = new_A();
SWIG_try {
A_foo(a);
}
SWIG_catch(E1) {
}
SWIG_catch(SWIG_AnyException) {
fprintf(stderr, "foo: bad exception order\n");
}
SWIG_endtry;
SWIG_try {
A_bar(a);
}
SWIG_catch(E2) {
}
SWIG_catch(SWIG_AnyException) {
fprintf(stderr, "bar: bad exception order\n");
}
SWIG_endtry;
SWIG_try {
A_foobar(a);
}
SWIG_catch(SWIG_AnyException) {
if (strcmp(SWIG_exception.msg, "postcatch unknown") != 0) {
fprintf(stderr, "bad exception order\n");
SWIG_throw_msg(SWIG_exception.klass, SWIG_exception.msg);
}
}
SWIG_endtry;
SWIG_try {
A_barfoo(a, 1);
}
SWIG_catch(E1) {
}
SWIG_catch(SWIG_AnyException) {
fprintf(stderr, "barfoo(1): bad exception order\n");
}
SWIG_endtry;
SWIG_try {
A_barfoo(a, 2);
}
SWIG_catch(E2) {
}
SWIG_catch(SWIG_AnyException) {
fprintf(stderr, "barfoo(2): bad exception order\n");
}
SWIG_endtry;
SWIG_exit(0);
}