2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-27 07:02:15 +00:00

Implemented pure_virtual(...)

[SVN r19774]
This commit is contained in:
Dave Abrahams
2003-08-25 18:44:26 +00:00
parent 87c5e37f5e
commit 7ec78eecbd
5 changed files with 221 additions and 4 deletions

View File

@@ -9,6 +9,7 @@
#include <boost/python/manage_new_object.hpp>
#include <boost/python/reference_existing_object.hpp>
#include <boost/python/call_method.hpp>
#include <boost/python/pure_virtual.hpp>
#include <boost/python/def.hpp>
#include <boost/utility.hpp>
@@ -20,6 +21,27 @@ struct Callback
PyObject* mSelf;
};
struct P
{
virtual ~P(){}
virtual std::string f() = 0;
};
struct PCallback : P, Callback
{
PCallback (PyObject* self) : Callback(self) {}
std::string f()
{
return call_method<std::string>(mSelf, "f");
}
};
struct Q : P
{
std::string f() { return "Q::f()"; }
};
struct A
{
virtual ~A(){}
@@ -44,7 +66,7 @@ struct ACallback : A, Callback
struct B : A
{
virtual std::string f() { return "B::f()"; }
virtual std::string f() { return "B::f()"; }
};
struct C : A
@@ -127,6 +149,13 @@ BOOST_PYTHON_MODULE_INIT(polymorphism_ext)
def("factory", factory, return_value_policy<manage_new_object>());
def("call_f", call_f);
class_<P,boost::noncopyable,PCallback>("P")
.def("f", pure_virtual(&P::f))
;
class_<Q, bases<P> >("Q")
;
}
//#include "module_tail.cpp"