Lines Matching refs:Pet

923     py::class_<Pet>(m, "Pet")
925 .def_readonly("name", &Pet::name);
930 m.def("create_pet", [](std::string name) { return new Pet(name); });
934 >>> from module1 import Pet
936 >>> pet1 = Pet("Kitty")
956 py::class<pets::Pet>(m, "Pet")
957 .def("name", &pets::Pet::name);
960 py::class<Dog, pets::Pet>(m, "Dog")
968 py::class<pets::Pet>(m, "Pet")
969 .def("get_name", &pets::Pet::name);
972 py::class<Cat, pets::Pet>(m, "Cat")
981 ImportError: generic_type: type "Pet" is already registered!
989 // Pet binding in dogs.cpp:
990 py::class<pets::Pet>(m, "Pet", py::module_local())
991 .def("name", &pets::Pet::name);
995 // Pet binding in cats.cpp:
996 py::class<pets::Pet>(m, "Pet", py::module_local())
997 .def("get_name", &pets::Pet::name);
999 This makes the Python-side ``dogs.Pet`` and ``cats.Pet`` into distinct classes,
1001 ``dogs`` module that casts or returns a ``Pet`` instance will result in a
1002 ``dogs.Pet`` Python instance, while C++ code in the ``cats`` module will result
1003 in a ``cats.Pet`` Python instance.
1006 or cast a ``Pet`` instance to Python (unless they also provide their own local
1013 modules above) it will be callable with either a ``dogs.Pet`` or ``cats.Pet``
1018 m.def("pet_name", [](const pets::Pet &pet) { return pet.name(); });
1167 is, returning a Pet to Python produces a Python object that knows it's
1168 wrapping a Dog, if Pet has virtual methods and pybind11 knows about
1169 Dog and this Pet is in fact a Dog. Sometimes, you might want to
1179 struct Pet { // Not polymorphic: has no virtual methods
1183 Pet(PetKind _kind) : kind(_kind) {}
1185 struct Dog : Pet {
1186 Dog() : Pet(PetKind::Dog) {}
1192 template<> struct polymorphic_type_hook<Pet> {
1193 static const void *get(const Pet *src, const std::type_info*& type) {