Scarab  2.8.1
Project 8 C++ Utility Library
external_module.cpp
Go to the documentation of this file.
1 #include <pybind11/pybind11.h>
2 
3 namespace py = pybind11;
4 
5 /* Simple test module/test class to check that the referenced internals data of external pybind11
6  * modules aren't preserved over a finalize/initialize.
7  */
8 
9 PYBIND11_MODULE(external_module, m) {
10  class A {
11  public:
12  A(int value) : v{value} {};
13  int v;
14  };
15 
16  py::class_<A>(m, "A")
17  .def(py::init<int>())
18  .def_readwrite("value", &A::v);
19 
20  m.def("internals_at", []() {
21  return reinterpret_cast<uintptr_t>(&py::detail::get_internals());
22  });
23 }
glibc defines I as a macro which breaks things, e.g., boost template names
Definition: attr.h:15
PYBIND11_MODULE(external_module, m)
bool typename Extra class_ & def(const char *name_, Func &&f, const Extra &... extra)
Definition: pybind11.h:1110