2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 16:52:15 +00:00
Files
python/example/abstract.cpp
nobody 9261e2a3d9 This commit was manufactured by cvs2svn to create branch
'boost_python_friend_fixes'.

[SVN r10123]
2001-05-18 15:12:31 +00:00

33 lines
690 B
C++

// Example by Ullrich Koethe
#include "boost/python/class_builder.hpp"
#include <string>
struct Abstract
{
virtual std::string test() = 0;
};
struct Abstract_callback: Abstract
{
Abstract_callback(PyObject * self)
: m_self(self)
{}
std::string test()
{
return boost::python::callback<std::string>::call_method(m_self, "test");
}
PyObject * m_self;
};
BOOST_PYTHON_MODULE_INIT(abstract)
{
boost::python::module_builder a("abstract");
boost::python::class_builder<Abstract, Abstract_callback>
a_class(a, "Abstract");
a_class.def(boost::python::constructor<>()); // wrap a constructor
a_class.def(&Abstract::test, "test");
}