Go to the documentation of this file.
6#ifndef OPM_EMBED_MODULE
7#define OPM_EMBED_MODULE
10#include <pybind11/embed.h>
12#define OPM_EMBEDDED_MODULE(name, variable) \
13 static void PYBIND11_CONCAT(pybind11_init_, name)(pybind11::module &); \
14 static PyObject PYBIND11_CONCAT(*pybind11_init_wrapper_, name)() { \
15 auto m = pybind11::module(PYBIND11_TOSTRING(name)); \
17 PYBIND11_CONCAT(pybind11_init_, name)(m); \
19 } catch (pybind11::error_already_set &e) { \
20 PyErr_SetString(PyExc_ImportError, e.what()); \
22 } catch (const std::exception &e) { \
23 PyErr_SetString(PyExc_ImportError, e.what()); \
27 PYBIND11_EMBEDDED_MODULE_IMPL(name) \
28 Opm::embed::python_module name(PYBIND11_TOSTRING(name), \
29 PYBIND11_CONCAT(pybind11_init_impl_, name)); \
30 void PYBIND11_CONCAT(pybind11_init_, name)(pybind11::module &variable)
37#if PY_MAJOR_VERSION >= 3
38 using init_t = PyObject *(*)();
40 using init_t = void (*)();
42 python_module( const char * name, init_t init) {
44 auto result = PyImport_AppendInittab( name, init);
46 pybind11::pybind11_fail( "Insufficient memory to add a new module");
const char *const name Definition: cJSON.h:258
std::vector< double > init(const std::string &kewyord, const TableManager &tables, const Phases &phases, const std::vector< double > &cell_depth, const std::vector< int > &num, const std::vector< int > &endnum)
|