Director exceptions now derive from std::exception
This commit is contained in:
parent
af6bee1e8c
commit
cc650e692e
10 changed files with 104 additions and 73 deletions
|
|
@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.0 (in progress)
|
Version 3.0.0 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2014-01-20: wsfulton
|
||||||
|
Director exceptions (Swig::DirectorException) now derive from std::exception
|
||||||
|
and hence provide the what() method. In Python and Ruby, this replaces the now
|
||||||
|
deprecated DirectorException::getMessage() method.
|
||||||
|
|
||||||
2014-01-16: wsfulton
|
2014-01-16: wsfulton
|
||||||
[PHP] Fix compilation error in ZTS mode (64 bit windows) due to incorrect placement
|
[PHP] Fix compilation error in ZTS mode (64 bit windows) due to incorrect placement
|
||||||
of TSRMLS_FETCH() in SWIG_Php_GetModule() as reported by Mark Dawson-Butterworth.
|
of TSRMLS_FETCH() in SWIG_Php_GetModule() as reported by Mark Dawson-Butterworth.
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
/* Director base class - not currently used in C# directors */
|
/* Director base class - not currently used in C# directors */
|
||||||
|
|
@ -16,7 +17,7 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Base class for director exceptions */
|
/* Base class for director exceptions */
|
||||||
class DirectorException {
|
class DirectorException : public std::exception {
|
||||||
protected:
|
protected:
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
|
|
||||||
|
|
@ -27,16 +28,16 @@ namespace Swig {
|
||||||
DirectorException(const std::string &msg) : swig_msg(msg) {
|
DirectorException(const std::string &msg) : swig_msg(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& what() const {
|
virtual ~DirectorException() throw() {
|
||||||
return swig_msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DirectorException() {
|
const char *what() const throw() {
|
||||||
|
return swig_msg.c_str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Pure virtual method exception */
|
/* Pure virtual method exception */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException {
|
class DirectorPureVirtualException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
|
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
|
|
||||||
|
|
@ -17,28 +18,25 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Base class for director exceptions.
|
// Base class for director exceptions.
|
||||||
class DirectorException {
|
class DirectorException : public std::exception {
|
||||||
protected:
|
protected:
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DirectorException(const char *msg) : swig_msg(msg) {
|
|
||||||
}
|
|
||||||
|
|
||||||
DirectorException(const std::string &msg) : swig_msg(msg) {
|
DirectorException(const std::string &msg) : swig_msg(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& what() const {
|
virtual ~DirectorException() throw() {
|
||||||
return swig_msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DirectorException() {
|
const char *what() const throw() {
|
||||||
|
return swig_msg.c_str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Exception which is thrown when attempting to call a pure virtual method
|
// Exception which is thrown when attempting to call a pure virtual method
|
||||||
// from D code thorugh the director layer.
|
// from D code through the director layer.
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException {
|
class DirectorPureVirtualException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
|
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* director.swg
|
* director.swg
|
||||||
*
|
*
|
||||||
* This file contains support for director classes that proxy
|
* This file contains support for director classes so that Java proxy
|
||||||
* method calls from C++ to Java extensions.
|
* methods can be called from C++.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION)
|
#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION)
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,47 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* director.swg
|
* director.swg
|
||||||
*
|
*
|
||||||
* This file contains support for director classes that proxy
|
* This file contains support for director classes so that Ocaml proxy
|
||||||
* method calls from C++ to Ocaml extensions.
|
* methods can be called from C++.
|
||||||
*
|
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||||
|
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
/* base class for director exceptions */
|
/* base class for director exceptions */
|
||||||
class DirectorException {
|
class DirectorException : public std::exception {
|
||||||
protected:
|
protected:
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DirectorException(const char *msg="") {
|
DirectorException(const char *msg="") : swig_msg(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getMessage() const {
|
virtual ~DirectorException() throw() {
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *what() const throw() {
|
||||||
return swig_msg.c_str();
|
return swig_msg.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DirectorException() {
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* type mismatch in the return value from a python method call */
|
/* type mismatch in the return value from a Ocaml method call */
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorException {
|
class DirectorTypeMismatchException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorTypeMismatchException(const char *msg="") {
|
DirectorTypeMismatchException(const char *msg="") : DirectorException(msg) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* any python exception that occurs during a director method call */
|
/* any Ocaml exception that occurs during a director method call */
|
||||||
class DirectorMethodException : public Swig::DirectorException {};
|
class DirectorMethodException : public DirectorException {};
|
||||||
|
|
||||||
/* attempt to call a pure virtual method via a director method */
|
/* attempt to call a pure virtual method via a director method */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException {
|
class DirectorPureVirtualException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *msg="") {
|
DirectorPureVirtualException(const char *msg="") : DirectorException(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(const char *msg) {
|
static void raise(const char *msg) {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
namespace Swig {
|
namespace Swig {
|
||||||
|
|
||||||
class Director {
|
class Director {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* director.swg
|
* director.swg
|
||||||
*
|
*
|
||||||
* This file contains support for director classes that proxy
|
* This file contains support for director classes so that Perl proxy
|
||||||
* method calls from C++ to Perl extensions.
|
* methods can be called from C++.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifndef SWIG_DIRECTOR_PERL_HEADER_
|
#ifndef SWIG_DIRECTOR_PERL_HEADER_
|
||||||
|
|
@ -138,14 +138,13 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* base class for director exceptions */
|
/* base class for director exceptions */
|
||||||
class DirectorException {
|
class DirectorException : public std::exception {
|
||||||
public:
|
public:
|
||||||
virtual const char *getMessage() const = 0;
|
|
||||||
virtual SV *getNative() const = 0;
|
virtual SV *getNative() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* exceptions emitted by Perl */
|
/* exceptions emitted by Perl */
|
||||||
class DirectorMethodException : public Swig::DirectorException {
|
class DirectorMethodException : public DirectorException {
|
||||||
protected:
|
protected:
|
||||||
SV *err;
|
SV *err;
|
||||||
public:
|
public:
|
||||||
|
|
@ -153,11 +152,7 @@ namespace Swig {
|
||||||
SvREFCNT_inc(err);
|
SvREFCNT_inc(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
~DirectorMethodException() {
|
const char *what() const throw() {
|
||||||
SvREFCNT_dec(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *getMessage() const {
|
|
||||||
return SvPV_nolen(err);
|
return SvPV_nolen(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,15 +164,19 @@ namespace Swig {
|
||||||
throw DirectorMethodException(sv);
|
throw DirectorMethodException(sv);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* exceptions emitted by wrap code */
|
/* exceptions emitted by wrap code */
|
||||||
class DirectorWrapException : public Swig::DirectorException {
|
class DirectorWrapException : public DirectorException {
|
||||||
protected:
|
protected:
|
||||||
std::string msg;
|
std::string msg;
|
||||||
DirectorWrapException(const char *str) : msg(str) {
|
DirectorWrapException(const char *str) : msg(str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual const char *getMessage() const {
|
virtual ~DirectorWrapException() throw() {
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *what() const throw() {
|
||||||
return msg.c_str();
|
return msg.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,10 +185,11 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorWrapException {
|
class DirectorTypeMismatchException : public DirectorWrapException {
|
||||||
public:
|
public:
|
||||||
DirectorTypeMismatchException(const char *str) : DirectorWrapException(str) {
|
DirectorTypeMismatchException(const char *str) : DirectorWrapException(str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(const char *type, const char *msg) {
|
static void raise(const char *type, const char *msg) {
|
||||||
std::string err = std::string(type);
|
std::string err = std::string(type);
|
||||||
err += ": ";
|
err += ": ";
|
||||||
|
|
@ -198,12 +198,13 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DirectorPureVirtualException : public Swig::DirectorWrapException {
|
class DirectorPureVirtualException : public DirectorWrapException {
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *name)
|
DirectorPureVirtualException(const char *name)
|
||||||
: DirectorWrapException("SWIG director pure virtual method called: ") {
|
: DirectorWrapException("SWIG director pure virtual method called: ") {
|
||||||
msg += name;
|
msg += name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(const char *name) {
|
static void raise(const char *name) {
|
||||||
throw DirectorPureVirtualException(name);
|
throw DirectorPureVirtualException(name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* director.swg
|
* director.swg
|
||||||
*
|
*
|
||||||
* This file contains support for director classes that proxy
|
* This file contains support for director classes so that PHP proxy
|
||||||
* method calls from C++ to PHP extensions.
|
* methods can be called from C++.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifndef SWIG_DIRECTOR_PHP_HEADER_
|
#ifndef SWIG_DIRECTOR_PHP_HEADER_
|
||||||
#define SWIG_DIRECTOR_PHP_HEADER_
|
#define SWIG_DIRECTOR_PHP_HEADER_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -122,7 +123,7 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* base class for director exceptions */
|
/* base class for director exceptions */
|
||||||
class DirectorException {
|
class DirectorException : public std::exception {
|
||||||
protected:
|
protected:
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
public:
|
public:
|
||||||
|
|
@ -135,13 +136,20 @@ namespace Swig {
|
||||||
SWIG_ErrorMsg() = swig_msg.c_str();
|
SWIG_ErrorMsg() = swig_msg.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~DirectorException() throw() {
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *what() const throw() {
|
||||||
|
return swig_msg.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
static void raise(int code, const char *hdr, const char *msg TSRMLS_DC) {
|
static void raise(int code, const char *hdr, const char *msg TSRMLS_DC) {
|
||||||
throw DirectorException(code, hdr, msg TSRMLS_CC);
|
throw DirectorException(code, hdr, msg TSRMLS_CC);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* attempt to call a pure virtual method via a director method */
|
/* attempt to call a pure virtual method via a director method */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException {
|
class DirectorPureVirtualException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *msg TSRMLS_DC)
|
DirectorPureVirtualException(const char *msg TSRMLS_DC)
|
||||||
: DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC) {
|
: DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC) {
|
||||||
|
|
@ -151,8 +159,9 @@ namespace Swig {
|
||||||
throw DirectorPureVirtualException(msg TSRMLS_CC);
|
throw DirectorPureVirtualException(msg TSRMLS_CC);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* any php exception that occurs during a director method call */
|
/* any php exception that occurs during a director method call */
|
||||||
class DirectorMethodException : public Swig::DirectorException
|
class DirectorMethodException : public DirectorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectorMethodException(const char *msg TSRMLS_DC)
|
DirectorMethodException(const char *msg TSRMLS_DC)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* director.swg
|
* director.swg
|
||||||
*
|
*
|
||||||
* This file contains support for director classes that proxy
|
* This file contains support for director classes so that Python proxy
|
||||||
* method calls from C++ to Python extensions.
|
* methods can be called from C++.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifndef SWIG_DIRECTOR_PYTHON_HEADER_
|
#ifndef SWIG_DIRECTOR_PYTHON_HEADER_
|
||||||
|
|
@ -173,7 +173,7 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* base class for director exceptions */
|
/* base class for director exceptions */
|
||||||
class DirectorException {
|
class DirectorException : public std::exception {
|
||||||
protected:
|
protected:
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
public:
|
public:
|
||||||
|
|
@ -184,12 +184,20 @@ namespace Swig {
|
||||||
swig_msg += msg;
|
swig_msg += msg;
|
||||||
}
|
}
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
PyErr_SetString(error, getMessage());
|
PyErr_SetString(error, what());
|
||||||
}
|
}
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~DirectorException() throw() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deprecated, use what() instead */
|
||||||
const char *getMessage() const {
|
const char *getMessage() const {
|
||||||
|
return what();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *what() const throw() {
|
||||||
return swig_msg.c_str();
|
return swig_msg.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,7 +218,7 @@ namespace Swig {
|
||||||
throw;
|
throw;
|
||||||
} catch (DirectorException& e) {
|
} catch (DirectorException& e) {
|
||||||
std::cerr << "SWIG Director exception caught:" << std::endl
|
std::cerr << "SWIG Director exception caught:" << std::endl
|
||||||
<< e.getMessage() << std::endl;
|
<< e.what() << std::endl;
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
std::cerr << "std::exception caught: "<< e.what() << std::endl;
|
std::cerr << "std::exception caught: "<< e.what() << std::endl;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
@ -243,14 +251,14 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* type mismatch in the return value from a python method call */
|
/* type mismatch in the return value from a python method call */
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorException {
|
class DirectorTypeMismatchException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorTypeMismatchException(PyObject *error, const char *msg="")
|
DirectorTypeMismatchException(PyObject *error, const char *msg="")
|
||||||
: Swig::DirectorException(error, "SWIG director type mismatch", msg) {
|
: DirectorException(error, "SWIG director type mismatch", msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorTypeMismatchException(const char *msg="")
|
DirectorTypeMismatchException(const char *msg="")
|
||||||
: Swig::DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg) {
|
: DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(PyObject *error, const char *msg) {
|
static void raise(PyObject *error, const char *msg) {
|
||||||
|
|
@ -263,7 +271,7 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* any python exception that occurs during a director method call */
|
/* any python exception that occurs during a director method call */
|
||||||
class DirectorMethodException : public Swig::DirectorException {
|
class DirectorMethodException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorMethodException(const char *msg = "")
|
DirectorMethodException(const char *msg = "")
|
||||||
: DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) {
|
: DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) {
|
||||||
|
|
@ -275,7 +283,7 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* attempt to call a pure virtual method via a director method */
|
/* attempt to call a pure virtual method via a director method */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException {
|
class DirectorPureVirtualException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *msg = "")
|
DirectorPureVirtualException(const char *msg = "")
|
||||||
: DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg) {
|
: DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg) {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* director.swg
|
* director.swg
|
||||||
*
|
*
|
||||||
* This file contains support for director classes that proxy
|
* This file contains support for director classes so that Ruby proxy
|
||||||
* method calls from C++ to Ruby extensions.
|
* methods can be called from C++.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <exception>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||||
|
|
@ -108,7 +109,7 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Base class for director exceptions */
|
/* Base class for director exceptions */
|
||||||
class DirectorException {
|
class DirectorException : public std::exception {
|
||||||
protected:
|
protected:
|
||||||
VALUE swig_error;
|
VALUE swig_error;
|
||||||
std::string swig_msg;
|
std::string swig_msg;
|
||||||
|
|
@ -130,6 +131,9 @@ namespace Swig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~DirectorException() throw() {
|
||||||
|
}
|
||||||
|
|
||||||
VALUE getType() const {
|
VALUE getType() const {
|
||||||
return CLASS_OF(swig_error);
|
return CLASS_OF(swig_error);
|
||||||
}
|
}
|
||||||
|
|
@ -138,11 +142,13 @@ namespace Swig {
|
||||||
return swig_error;
|
return swig_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Deprecated, use what() instead */
|
||||||
const std::string& getMessage() const {
|
const std::string& getMessage() const {
|
||||||
return swig_msg;
|
return swig_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DirectorException() {
|
const char *what() const throw() {
|
||||||
|
return swig_msg.c_str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -154,7 +160,7 @@ namespace Swig {
|
||||||
throw;
|
throw;
|
||||||
} catch (DirectorException& e) {
|
} catch (DirectorException& e) {
|
||||||
std::cerr << "SWIG Director exception caught:" << std::endl
|
std::cerr << "SWIG Director exception caught:" << std::endl
|
||||||
<< e.getMessage() << std::endl;
|
<< e.what() << std::endl;
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
std::cerr << "std::exception caught: "<< e.what() << std::endl;
|
std::cerr << "std::exception caught: "<< e.what() << std::endl;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
@ -184,14 +190,14 @@ namespace Swig {
|
||||||
|
|
||||||
|
|
||||||
/* Type mismatch in the return value from a Ruby method call */
|
/* Type mismatch in the return value from a Ruby method call */
|
||||||
class DirectorTypeMismatchException : public Swig::DirectorException {
|
class DirectorTypeMismatchException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorTypeMismatchException(VALUE error, const char *msg="")
|
DirectorTypeMismatchException(VALUE error, const char *msg="")
|
||||||
: Swig::DirectorException(error, "SWIG director type mismatch", msg) {
|
: DirectorException(error, "SWIG director type mismatch", msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorTypeMismatchException(const char *msg="")
|
DirectorTypeMismatchException(const char *msg="")
|
||||||
: Swig::DirectorException(rb_eTypeError, "SWIG director type mismatch", msg) {
|
: DirectorException(rb_eTypeError, "SWIG director type mismatch", msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(VALUE error, const char *msg) {
|
static void raise(VALUE error, const char *msg) {
|
||||||
|
|
@ -204,14 +210,14 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Any Ruby exception that occurs during a director method call */
|
/* Any Ruby exception that occurs during a director method call */
|
||||||
class DirectorMethodException : public Swig::DirectorException {
|
class DirectorMethodException : public DirectorException {
|
||||||
public:
|
public:
|
||||||
DirectorMethodException(VALUE error)
|
DirectorMethodException(VALUE error)
|
||||||
: Swig::DirectorException(error) {
|
: DirectorException(error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorMethodException(const char *msg = "")
|
DirectorMethodException(const char *msg = "")
|
||||||
: Swig::DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) {
|
: DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void raise(VALUE error) {
|
static void raise(VALUE error) {
|
||||||
|
|
@ -220,7 +226,7 @@ namespace Swig {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Attempted to call a pure virtual method via a director method */
|
/* Attempted to call a pure virtual method via a director method */
|
||||||
class DirectorPureVirtualException : public Swig::DirectorException
|
class DirectorPureVirtualException : public DirectorException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectorPureVirtualException(const char *msg = "")
|
DirectorPureVirtualException(const char *msg = "")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue