summaryrefslogtreecommitdiff
path: root/test cases/frameworks/1 boost/python_module.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/frameworks/1 boost/python_module.cpp')
-rw-r--r--test cases/frameworks/1 boost/python_module.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test cases/frameworks/1 boost/python_module.cpp b/test cases/frameworks/1 boost/python_module.cpp
new file mode 100644
index 000000000..a0f010b51
--- /dev/null
+++ b/test cases/frameworks/1 boost/python_module.cpp
@@ -0,0 +1,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)
+ ;
+}