1 #ifndef CT_CYTHON_FUNC_WRAPPER
2 #define CT_CYTHON_FUNC_WRAPPER
9 typedef double(*callback_wrapper)(double,
void*,
void**);
16 CallbackError(
void* type,
void* value) :
17 m_type((PyObject*) type),
18 m_value((PyObject*) value)
29 Func1Py(callback_wrapper callback,
void* pyobj) :
34 double eval(
double t)
const {
35 void* err[2] = {0, 0};
36 double y = m_callback(t, m_pyobj, err);
38 throw CallbackError(err[0], err[1]);
44 callback_wrapper m_callback;
52 inline int translate_exception()
55 if (!PyErr_Occurred()) {
60 }
catch (CallbackError& exn) {
62 PyErr_SetObject(exn.m_type, exn.m_value);
63 }
catch (
const std::out_of_range& exn) {
64 PyErr_SetString(PyExc_IndexError, exn.what());
65 }
catch (
const std::exception& exn) {
66 PyErr_SetString(PyExc_Exception, exn.what());
68 PyErr_SetString(PyExc_Exception,
"Unknown exception");
virtual doublereal eval(doublereal t) const
Evaluate the function.
Base class for 'functor' classes that evaluate a function of one variable.
Base class for exceptions thrown by Cantera classes.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...