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

@ -42,7 +42,11 @@
/* Simple overload of the output/constant/exception handling */
#define SWIG_AppendOutput(result,obj) SWIG_Ruby_AppendOutput(result, obj)
#define SWIG_SetConstant(name, obj) rb_define_const($module, name, obj)
#define SWIG_Raise(obj, type, desc) rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)))
/* raise */
%define SWIG_Raise(obj, type, desc)
VALUE exc = SWIG_Ruby_ExceptionType(desc, obj);
rb_exc_raise(exc)%enddef
/* Include the unified typemap library */
%include <typemaps/swigtypemaps.swg>