Modified how the SWIG_DIRECTOR_EXCEPTION class (and its subclasses) are
implemented for the Ruby module. Now the SWIG_DIRECTOR_EXCEPTION object stores a reference to the Ruby exception instance. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4856 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e59742f9c6
commit
8ee20885b1
2 changed files with 14 additions and 12 deletions
|
|
@ -49,12 +49,12 @@ class SWIG_DIRECTOR_METHOD_EXCEPTION: public SWIG_DIRECTOR_EXCEPTION {};
|
||||||
#ifdef SWIGRUBY
|
#ifdef SWIGRUBY
|
||||||
|
|
||||||
%feature("director:except") {
|
%feature("director:except") {
|
||||||
throw SWIG_DIRECTOR_METHOD_EXCEPTION();
|
throw SWIG_DIRECTOR_METHOD_EXCEPTION($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
%exception {
|
%exception {
|
||||||
try { $action }
|
try { $action }
|
||||||
catch (SWIG_DIRECTOR_EXCEPTION &e) { rb_raise(e.getType(), e.getMessage()); }
|
catch (SWIG_DIRECTOR_EXCEPTION &e) { rb_exc_raise(e.getError()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -25,28 +25,30 @@ struct swig_body_args
|
||||||
/* Base class for director exceptions */
|
/* Base class for director exceptions */
|
||||||
class SWIG_DIRECTOR_EXCEPTION {
|
class SWIG_DIRECTOR_EXCEPTION {
|
||||||
protected:
|
protected:
|
||||||
std::string _msg;
|
VALUE _error;
|
||||||
VALUE _type;
|
|
||||||
protected:
|
protected:
|
||||||
SWIG_DIRECTOR_EXCEPTION(const char* msg="") : _type(rb_eRuntimeError) {}
|
SWIG_DIRECTOR_EXCEPTION(VALUE error=Qnil) : _error(error) {}
|
||||||
public:
|
public:
|
||||||
const char *getMessage() const { return _msg.c_str(); }
|
VALUE getType() const { return CLASS_OF(_error); }
|
||||||
VALUE getType() const { return _type; }
|
VALUE getError() const { return _error; }
|
||||||
virtual ~SWIG_DIRECTOR_EXCEPTION() {}
|
virtual ~SWIG_DIRECTOR_EXCEPTION() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Type mismatch in the return value from a Ruby method call */
|
/* Type mismatch in the return value from a Ruby method call */
|
||||||
class SWIG_DIRECTOR_TYPE_MISMATCH : public SWIG_DIRECTOR_EXCEPTION {
|
class SWIG_DIRECTOR_TYPE_MISMATCH : public SWIG_DIRECTOR_EXCEPTION {
|
||||||
public:
|
public:
|
||||||
SWIG_DIRECTOR_TYPE_MISMATCH(const char* msg="") {
|
SWIG_DIRECTOR_TYPE_MISMATCH(const char *msg="") {
|
||||||
_msg = "Swig director type mismatch: ";
|
VALUE str = rb_str_new2("Swig director type mismatch: ");
|
||||||
_msg += msg;
|
rb_str_concat(str, rb_str_new2(msg));
|
||||||
_type = rb_eTypeError;
|
_error = rb_exc_new3(rb_eTypeError, str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Any Ruby exception that occurs during a director method call */
|
/* Any Ruby exception that occurs during a director method call */
|
||||||
class SWIG_DIRECTOR_METHOD_EXCEPTION : public SWIG_DIRECTOR_EXCEPTION {};
|
class SWIG_DIRECTOR_METHOD_EXCEPTION : public SWIG_DIRECTOR_EXCEPTION {
|
||||||
|
public:
|
||||||
|
SWIG_DIRECTOR_METHOD_EXCEPTION(VALUE error) :SWIG_DIRECTOR_EXCEPTION(error) {}
|
||||||
|
};
|
||||||
|
|
||||||
/* Attempted to call a pure virtual method via a director method */
|
/* Attempted to call a pure virtual method via a director method */
|
||||||
class SWIG_DIRECTOR_PURE_VIRTUAL_EXCEPTION : public SWIG_DIRECTOR_EXCEPTION {};
|
class SWIG_DIRECTOR_PURE_VIRTUAL_EXCEPTION : public SWIG_DIRECTOR_EXCEPTION {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue