aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/include/pybind11/embed.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/pybind11/include/pybind11/embed.h')
-rw-r--r--3rdparty/pybind11/include/pybind11/embed.h51
1 files changed, 25 insertions, 26 deletions
diff --git a/3rdparty/pybind11/include/pybind11/embed.h b/3rdparty/pybind11/include/pybind11/embed.h
index f814c783..204aaf98 100644
--- a/3rdparty/pybind11/include/pybind11/embed.h
+++ b/3rdparty/pybind11/include/pybind11/embed.h
@@ -45,29 +45,28 @@
});
}
\endrst */
-#define PYBIND11_EMBEDDED_MODULE(name, variable) \
- static void PYBIND11_CONCAT(pybind11_init_, name)(pybind11::module &); \
- static PyObject PYBIND11_CONCAT(*pybind11_init_wrapper_, name)() { \
- auto m = pybind11::module(PYBIND11_TOSTRING(name)); \
- try { \
- PYBIND11_CONCAT(pybind11_init_, name)(m); \
- return m.ptr(); \
- } catch (pybind11::error_already_set &e) { \
- PyErr_SetString(PyExc_ImportError, e.what()); \
- return nullptr; \
- } catch (const std::exception &e) { \
- PyErr_SetString(PyExc_ImportError, e.what()); \
- return nullptr; \
- } \
- } \
- PYBIND11_EMBEDDED_MODULE_IMPL(name) \
- pybind11::detail::embedded_module name(PYBIND11_TOSTRING(name), \
- PYBIND11_CONCAT(pybind11_init_impl_, name)); \
- void PYBIND11_CONCAT(pybind11_init_, name)(pybind11::module &variable)
-
-
-NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
-NAMESPACE_BEGIN(detail)
+#define PYBIND11_EMBEDDED_MODULE(name, variable) \
+ static ::pybind11::module_::module_def \
+ PYBIND11_CONCAT(pybind11_module_def_, name); \
+ static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
+ static PyObject PYBIND11_CONCAT(*pybind11_init_wrapper_, name)() { \
+ auto m = ::pybind11::module_::create_extension_module( \
+ PYBIND11_TOSTRING(name), nullptr, \
+ &PYBIND11_CONCAT(pybind11_module_def_, name)); \
+ try { \
+ PYBIND11_CONCAT(pybind11_init_, name)(m); \
+ return m.ptr(); \
+ } PYBIND11_CATCH_INIT_EXCEPTIONS \
+ } \
+ PYBIND11_EMBEDDED_MODULE_IMPL(name) \
+ ::pybind11::detail::embedded_module PYBIND11_CONCAT(pybind11_module_, name) \
+ (PYBIND11_TOSTRING(name), \
+ PYBIND11_CONCAT(pybind11_init_impl_, name)); \
+ void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &variable)
+
+
+PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
+PYBIND11_NAMESPACE_BEGIN(detail)
/// Python 2.7/3.x compatible version of `PyImport_AppendInittab` and error checks.
struct embedded_module {
@@ -86,7 +85,7 @@ struct embedded_module {
}
};
-NAMESPACE_END(detail)
+PYBIND11_NAMESPACE_END(detail)
/** \rst
Initialize the Python interpreter. No other pybind11 or CPython API functions can be
@@ -108,7 +107,7 @@ inline void initialize_interpreter(bool init_signal_handlers = true) {
Py_InitializeEx(init_signal_handlers ? 1 : 0);
// Make .py files in the working directory available by default
- module::import("sys").attr("path").cast<list>().append(".");
+ module_::import("sys").attr("path").cast<list>().append(".");
}
/** \rst
@@ -199,4 +198,4 @@ private:
bool is_valid = true;
};
-NAMESPACE_END(PYBIND11_NAMESPACE)
+PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)