From 7f71c2696f139923fa52a805c5b244773b57177a Mon Sep 17 00:00:00 2001 From: Lyle Johnson Date: Tue, 24 Aug 2004 13:07:55 +0000 Subject: [PATCH] Added some missing throws typemaps for SWIGTYPE and its variants. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6123 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Lib/ruby/rubyswigtype.swg | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/SWIG/Lib/ruby/rubyswigtype.swg b/SWIG/Lib/ruby/rubyswigtype.swg index ada2384ec..72802ff75 100644 --- a/SWIG/Lib/ruby/rubyswigtype.swg +++ b/SWIG/Lib/ruby/rubyswigtype.swg @@ -1,5 +1,4 @@ -/* Typemaps for pointers. Note: the SWIG run-time type checker works - even if a pointer happens to be mapped to a Ruby class */ +/* --- Input typemaps --- */ %typemap(in) SWIGTYPE *, SWIGTYPE [] @@ -113,14 +112,7 @@ %typemap(constant) SWIGTYPE (CLASS::*) "rb_define_const($module, \"$symname\", SWIG_NewPackedObj((void *) &$1, sizeof($type), $1_descriptor));"; -/***************************************************************************** - * - * Inverse argument typemaps are for marshaling C/C++ parameters to call Python - * methods from C++ proxy wrapper classes. - * - *****************************************************************************/ - -/* directorin typemaps */ +/* --- directorin typemaps --- */ /* --- directorout typemaps --- */ %typemap(directorout) SWIGTYPE *, @@ -143,15 +135,11 @@ } /* ------------------------------------------------------------ - * Exception handling + * Exception handling. + * Note that in Ruby, we can only raise an exception class and + * not some arbitrary object as in Python. * ------------------------------------------------------------ */ -%typemap(throws) SWIGTYPE { - $&1_ltype temp = new $1_ltype($1); - if ($&1_descriptor->clientdata) { - rb_exc_raise(rb_exc_new3(((swig_class *) ($&1_descriptor->clientdata))->klass, rb_obj_as_string(SWIG_NewPointerObj(temp, $&1_descriptor, 1)))); - } else { - rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(SWIG_NewPointerObj(temp, $&1_descriptor, 1)))); - } -} +%typemap(throws) SWIGTYPE, SWIGTYPE *, SWIGTYPE [ANY], SWIGTYPE & + "rb_raise(rb_eRuntimeError, \"$1_type\");";