pybind11: keep files in tree just for future reference, not properly automated yet

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-02-19 00:00:00 +00:00
parent e33f6d5bf9
commit 756ecea195
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#include <string>
#include <pybind11/pybind11.h>
struct Pet {
Pet(const std::string &name) : name(name) { }
void setName(const std::string &name_) { name = name_; }
const std::string &getName() const { return name; }
std::string name;
};
namespace py = pybind11;
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Pet>(m, "Pet")
.def(py::init<const std::string &>())
.def("setName", &Pet::setName)
.def("getName", &Pet::getName);
return m.ptr();
}