diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2014-01-20 19:40:52 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2014-01-20 19:40:52 +0000 |
commit | cc650e692e3e1201092d99a34a04e3af11ee2347 (patch) | |
tree | cb9fb079fe0783ad1f740cdba3e2ee4e9f79d53a /Lib/perl5 | |
parent | af6bee1e8c39eb80ad54a021380f2af32902f99b (diff) | |
download | swig-cc650e692e3e1201092d99a34a04e3af11ee2347.tar.gz |
Director exceptions now derive from std::exception
Diffstat (limited to 'Lib/perl5')
-rw-r--r-- | Lib/perl5/director.swg | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/Lib/perl5/director.swg b/Lib/perl5/director.swg index 9fa64e147..a66869725 100644 --- a/Lib/perl5/director.swg +++ b/Lib/perl5/director.swg @@ -1,8 +1,8 @@ /* ----------------------------------------------------------------------------- * director.swg * - * This file contains support for director classes that proxy - * method calls from C++ to Perl extensions. + * This file contains support for director classes so that Perl proxy + * methods can be called from C++. * ----------------------------------------------------------------------------- */ #ifndef SWIG_DIRECTOR_PERL_HEADER_ @@ -138,14 +138,13 @@ namespace Swig { }; /* base class for director exceptions */ - class DirectorException { + class DirectorException : public std::exception { public: - virtual const char *getMessage() const = 0; virtual SV *getNative() const = 0; }; /* exceptions emitted by Perl */ - class DirectorMethodException : public Swig::DirectorException { + class DirectorMethodException : public DirectorException { protected: SV *err; public: @@ -153,11 +152,7 @@ namespace Swig { SvREFCNT_inc(err); } - ~DirectorMethodException() { - SvREFCNT_dec(err); - } - - const char *getMessage() const { + const char *what() const throw() { return SvPV_nolen(err); } @@ -169,15 +164,19 @@ namespace Swig { throw DirectorMethodException(sv); } }; + /* exceptions emitted by wrap code */ - class DirectorWrapException : public Swig::DirectorException { + class DirectorWrapException : public DirectorException { protected: std::string msg; DirectorWrapException(const char *str) : msg(str) { } public: - virtual const char *getMessage() const { + virtual ~DirectorWrapException() throw() { + } + + const char *what() const throw() { return msg.c_str(); } @@ -186,10 +185,11 @@ namespace Swig { } }; - class DirectorTypeMismatchException : public Swig::DirectorWrapException { + class DirectorTypeMismatchException : public DirectorWrapException { public: DirectorTypeMismatchException(const char *str) : DirectorWrapException(str) { } + static void raise(const char *type, const char *msg) { std::string err = std::string(type); err += ": "; @@ -198,12 +198,13 @@ namespace Swig { } }; - class DirectorPureVirtualException : public Swig::DirectorWrapException { + class DirectorPureVirtualException : public DirectorWrapException { public: DirectorPureVirtualException(const char *name) : DirectorWrapException("SWIG director pure virtual method called: ") { msg += name; } + static void raise(const char *name) { throw DirectorPureVirtualException(name); } |