Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <boost/python.hpp>
- namespace bp = boost::python;
- struct test
- {
- void one() {}
- void two() {}
- void three() {}
- };
- int main()
- {
- Py_Initialize();
- bp::object main_module = bp::import("__main__");
- bp::object main_namespace = main_module.attr("__dict__");
- {
- bp::class_<test> test_binding = bp::class_<test>("test");
- test_binding.def("one", &test::one);
- test_binding.def("two", &test::two);
- test_binding.def("three", &test::three);
- main_namespace["test"] = test_binding;
- }
- try {
- exec("print dir(test)\n", main_namespace);
- } catch (bp::error_already_set &) {
- PyErr_Print();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement