Updated Ruby Exception handling. Classes that are specified in throws clauses, or are marked as %exceptionclass, are now inherited from rb_eRuntimeError. This allows instances of these classes to be returned to Ruby as exceptions. Thus if a C++ method throws an instance of MyException, the calling Ruby method will get back a MyException object. To see an example, look at ruby/examples/exception_class.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8353 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Charlie Savage 2006-01-10 19:19:19 +00:00
commit ee63d5276c
3 changed files with 36 additions and 2 deletions

View file

@ -1800,7 +1800,13 @@ public:
Printv(s, tab4, "rb_undef_alloc_func(", klass->vname, ");\n", NIL);
Replaceall(klass->init,"$allocator", s);
Replaceall(klass->init,"$initializer", "");
Replaceall(klass->init,"$super", "rb_cObject");
if (GetFlag(n,"feature:exceptionclass")) {
Replaceall(klass->init,"$super", "rb_eRuntimeError");
}
else {
Replaceall(klass->init,"$super", "rb_cObject");
}
Delete(s);
Printv(f_init,klass->init,NIL);