Debian Codegraph @

test cases/frameworks/1 boost/python_module.cpp

raw
1 #define PY_SSIZE_T_CLEAN
2 #include <Python.h>
3 #include <boost/python.hpp>
4
5 struct World
6 {
7 void set(std::string msg) { this->msg = msg; }
8 std::string greet() { return msg; }
9 std::string version() { return std::to_string(PY_MAJOR_VERSION) + "." + std::to_string(PY_MINOR_VERSION); }
10 std::string msg;
11 };
12
13
14 BOOST_PYTHON_MODULE(MOD_NAME)
15 {
16 using namespace boost::python;
17 class_<World>("World")
18 .def("greet", &World::greet)
19 .def("set", &World::set)
20 .def("version", &World::version)
21 ;
22 }