Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
d81d11a6
Commit
d81d11a6
authored
Sep 13, 2017
by
tzh1043
Committed by
Dean Moldovan
Sep 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make PYBIND11_MODULE name usable with define (#1082)
parent
9f82370e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
include/pybind11/detail/common.h
+5
-4
include/pybind11/embed.h
+7
-6
No files found.
include/pybind11/detail/common.h
View file @
d81d11a6
...
...
@@ -205,6 +205,7 @@ extern "C" {
#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
#define PYBIND11_STRINGIFY(x) #x
#define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
#define PYBIND11_CONCAT(first, second) first##second
/** \rst
***Deprecated in favor of PYBIND11_MODULE***
...
...
@@ -267,7 +268,7 @@ extern "C" {
}
\endrst */
#define PYBIND11_MODULE(name, variable) \
static void
pybind11_init_##name(pybind11::module &);
\
static void
PYBIND11_CONCAT(pybind11_init_, name)(pybind11::module &);
\
PYBIND11_PLUGIN_IMPL(name) { \
int major, minor; \
if (sscanf(Py_GetVersion(), "%i.%i", &major, &minor) != 2) { \
...
...
@@ -281,9 +282,9 @@ extern "C" {
major, minor); \
return nullptr; \
} \
auto m = pybind11::module(
#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()); \
...
...
@@ -293,7 +294,7 @@ extern "C" {
return nullptr; \
} \
} \
void
pybind11_init_##name
(pybind11::module &variable)
void
PYBIND11_CONCAT(pybind11_init_, name)
(pybind11::module &variable)
NAMESPACE_BEGIN
(
PYBIND11_NAMESPACE
)
...
...
include/pybind11/embed.h
View file @
d81d11a6
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment