aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/tests/test_embed/external_module.cpp
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2020-07-23 08:58:19 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2020-07-23 08:58:19 +0200
commit444e535f000fd7b53dadf6726d5cd29ac34cc75f (patch)
tree1ac675d8f0381de320849294fa70c946f631e7f6 /3rdparty/pybind11/tests/test_embed/external_module.cpp
parente6991ad5dc79f6118838f091cc05f10d3377eb4a (diff)
downloadnextpnr-444e535f000fd7b53dadf6726d5cd29ac34cc75f.tar.gz
nextpnr-444e535f000fd7b53dadf6726d5cd29ac34cc75f.tar.bz2
nextpnr-444e535f000fd7b53dadf6726d5cd29ac34cc75f.zip
Add pybind11 2.5 source
Diffstat (limited to '3rdparty/pybind11/tests/test_embed/external_module.cpp')
-rw-r--r--3rdparty/pybind11/tests/test_embed/external_module.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/3rdparty/pybind11/tests/test_embed/external_module.cpp b/3rdparty/pybind11/tests/test_embed/external_module.cpp
new file mode 100644
index 00000000..e9a6058b
--- /dev/null
+++ b/3rdparty/pybind11/tests/test_embed/external_module.cpp
@@ -0,0 +1,23 @@
+#include <pybind11/pybind11.h>
+
+namespace py = pybind11;
+
+/* Simple test module/test class to check that the referenced internals data of external pybind11
+ * modules aren't preserved over a finalize/initialize.
+ */
+
+PYBIND11_MODULE(external_module, m) {
+ class A {
+ public:
+ A(int value) : v{value} {};
+ int v;
+ };
+
+ py::class_<A>(m, "A")
+ .def(py::init<int>())
+ .def_readwrite("value", &A::v);
+
+ m.def("internals_at", []() {
+ return reinterpret_cast<uintptr_t>(&py::detail::get_internals());
+ });
+}