Scarab  v2.9.0
Project 8 C++ Utility Library
Classes | Namespaces | Macros | Functions
embed.h File Reference
#include "pybind11.h"
#include "eval.h"
Include dependency graph for embed.h:

Go to the source code of this file.

Classes

struct  embedded_module
 Python 2.7/3.x compatible version of PyImport_AppendInittab and error checks. More...
 
class  scoped_interpreter
 

Namespaces

 pybind11
 glibc defines I as a macro which breaks things, e.g., boost template names
 
 pybind11::detail
 

Macros

#define PYBIND11_EMBEDDED_MODULE_IMPL(name)
 
#define PYBIND11_EMBEDDED_MODULE(name, variable)
 

Functions

void initialize_interpreter (bool init_signal_handlers=true)
 
void finalize_interpreter ()
 

Macro Definition Documentation

◆ PYBIND11_EMBEDDED_MODULE

#define PYBIND11_EMBEDDED_MODULE (   name,
  variable 
)
Value:
static void PYBIND11_CONCAT(pybind11_init_, name)(pybind11::module &); \
static PyObject PYBIND11_CONCAT(*pybind11_init_wrapper_, 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)
#define PYBIND11_CONCAT(first, second)
Wrapper for Python extension modules.
Definition: pybind11.h:789
#define PYBIND11_TOSTRING(x)

Add a new module to the table of builtins for the interpreter. Must be defined in global scope. The first macro parameter is the name of the module (without quotes). The second parameter is the variable which will be used as the interface to add functions and classes to the module.

.. code-block:: cpp

PYBIND11_EMBEDDED_MODULE(example, m) {

... initialize functions and classes here m.def("foo", []() { return "Hello, World!"; }); }

Definition at line 46 of file embed.h.

◆ PYBIND11_EMBEDDED_MODULE_IMPL

#define PYBIND11_EMBEDDED_MODULE_IMPL (   name)
Value:
extern "C" void pybind11_init_impl_##name() { \
pybind11_init_wrapper_##name(); \
}

Definition at line 25 of file embed.h.