mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-08 15:29:45 +00:00
Make PYBIND11_MODULE name usable with define (#1082)
This commit is contained in:
@@ -44,11 +44,11 @@
|
||||
}
|
||||
\endrst */
|
||||
#define PYBIND11_EMBEDDED_MODULE(name, variable) \
|
||||
static void pybind11_init_##name(pybind11::module &); \
|
||||
static PyObject *pybind11_init_wrapper_##name() { \
|
||||
auto m = pybind11::module(#name); \
|
||||
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_init_##name(m); \
|
||||
PYBIND11_CONCAT(pybind11_init_, name)(m); \
|
||||
return m.ptr(); \
|
||||
} catch (pybind11::error_already_set &e) { \
|
||||
PyErr_SetString(PyExc_ImportError, e.what()); \
|
||||
@@ -59,8 +59,9 @@
|
||||
} \
|
||||
} \
|
||||
PYBIND11_EMBEDDED_MODULE_IMPL(name) \
|
||||
pybind11::detail::embedded_module name(#name, pybind11_init_impl_##name); \
|
||||
void pybind11_init_##name(pybind11::module &variable)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user