Go to the documentation of this file.
36 bind_local<NonLocalType, 0>(
m,
"NonLocalType")
46 m.def(
"register_local_external", [
m]() {
47 auto main = py::module_::import(
"pybind11_tests");
49 bind_local<LocalExternal, 7>(
m,
"LocalExternal", py::module_local());
51 throw std::runtime_error(
"test_class not enabled");
57 py::bind_vector<LocalVec>(
m,
"LocalVec");
58 py::bind_map<LocalMap>(
m,
"LocalMap");
60 py::bind_vector<NonLocalVec>(
m,
"NonLocalVec");
61 py::bind_map<NonLocalMap>(
m,
"NonLocalMap");
65 bind_local<NonLocal2, 10>(
m,
"NonLocal2");
66 py::bind_vector<LocalVec2>(
m,
"LocalVec2", py::module_local());
67 py::bind_map<NonLocalMap2>(
m,
"NonLocalMap2", py::module_local(
false));
72 m.def(
"register_mixed_global", [
m]() {
73 bind_local<MixedGlobalLocal, 100>(
m,
"MixedGlobalLocal", py::module_local(
false));
75 m.def(
"register_mixed_local", [
m]() {
76 bind_local<MixedLocalGlobal, 1000>(
m,
"MixedLocalGlobal", py::module_local());
82 m.def(
"local_cpp_types_addr",
86 m.def(
"load_vector_via_caster",
87 [](std::vector<int>
v) {
return std::accumulate(
v.begin(),
v.end(), 0); });
90 m.def(
"return_self", [](
LocalVec *
v) {
return v; });
95 explicit Cat(std::string
name) : Pet(std::move(
name)) {}
97 py::class_<pets::Pet>(
m,
"Pet", py::module_local()).def(
"get_name", &
pets::Pet::name);
99 py::class_<Cat, pets::Pet>(
m,
"Cat").def(py::init<std::string>());
100 m.def(
"pet_name", [](
pets::Pet &
p) {
return p.name(); });
102 py::class_<MixGL>(
m,
"MixGL").def(py::init<int>());
103 m.def(
"get_gl_value", [](
MixGL &o) {
return o.
i + 10; });
105 py::class_<MixGL2>(
m,
"MixGL2").def(py::init<int>());
const std::string & name() const
Annotation for function names.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
bool hasattr(handle obj, handle name)
LocalBase< 0 > LocalType
Registered with py::module_local in both main and secondary modules:
TEST_SUBMODULE(local_bindings, m)
int main(int argc, char **argv)
LocalBase< 4 > MixedLocalGlobal
Mixed: registered local first, then global.
type_map< type_info * > registered_types_cpp
static const Line3 l(Rot3(), 1, 1)
LocalBase< 5 > MixedGlobalLocal
Mixed: global first, then local.
Simple class used to test py::local:
std::vector< LocalType > LocalVec
py::class_< T > bind_local(Args &&...args)
local_internals & get_local_internals()
Works like get_internals, but for things which are locally registered.
Cat(const std::string &_name, Kind _kind=Kind::Cat)
Array< int, Dynamic, 1 > v
_W64 unsigned int uintptr_t
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:07:05