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