aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/python/hello.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/python/hello.cpp')
-rw-r--r--examples/python/hello.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/python/hello.cpp b/examples/python/hello.cpp
new file mode 100644
index 0000000..b7516e4
--- /dev/null
+++ b/examples/python/hello.cpp
@@ -0,0 +1,19 @@
+#include <string>
+
+#include <boost/python.hpp>
+using namespace boost::python;
+
+struct World
+{
+ void set(const std::string& msg) { this->msg = msg; }
+ std::string greet() const { return msg; }
+ std::string msg;
+};
+
+BOOST_PYTHON_MODULE(hello)
+{
+ class_<World>("World")
+ .def("greet", &World::greet)
+ .def("set", &World::set)
+ ;
+}