Jason Rhinelander | 7437c69 | 2017-07-28 22:03:44 -0400 | [diff] [blame^] | 1 | #pragma once |
| 2 | #include "pybind11_tests.h" |
| 3 | |
| 4 | /// Simple class used to test py::local: |
| 5 | template <int> class LocalBase { |
| 6 | public: |
| 7 | LocalBase(int i) : i(i) { } |
| 8 | int i = -1; |
| 9 | }; |
| 10 | |
| 11 | /// Registered with py::local in both main and secondary modules: |
| 12 | using LocalType = LocalBase<0>; |
| 13 | /// Registered without py::local in both modules: |
| 14 | using NonLocalType = LocalBase<1>; |
| 15 | /// A second non-local type (for stl_bind tests): |
| 16 | using NonLocal2 = LocalBase<2>; |
| 17 | /// Tests within-module, different-compilation-unit local definition conflict: |
| 18 | using LocalExternal = LocalBase<3>; |
| 19 | |
| 20 | // Simple bindings (used with the above): |
| 21 | template <typename T, int Adjust, typename... Args> |
| 22 | py::class_<T> bind_local(Args && ...args) { |
| 23 | return py::class_<T>(std::forward<Args>(args)...) |
| 24 | .def(py::init<int>()) |
| 25 | .def("get", [](T &i) { return i.i + Adjust; }); |
| 26 | }; |