[C++-sig] Re: Boost.Python: few thoughts and questions...
Paul Rudin
paul.rudin at ntlworld.com
Fri Jun 13 06:43:12 CEST 2003
David Abrahams <dave at boost-consulting.com> writes:
> Roman Sulzhyk <roman_sulzhyk at yahoo.com> writes:
>
> > 3. Specifying the set_policy() for virtual functions
> >
> > It appears that the policy setting is ignored for virtual function
> > declarations.
>
> What makes you think so?
>
foo.h is:
____________________
class foo {
public:
virtual foo* bar();
};
_____________________
foo.pyste is:
______________________
foo = AllFromHeader('./foo.h')
set_policy(foo.foo.bar,return_internal_reference())
________________________
then (current cvs) pyste gives you:
______________________________
// Includes ====================================================================
#include <boost/python.hpp>
#include <./foo.h>
// Using =======================================================================
using namespace boost::python;
// Declarations ================================================================
namespace {
struct foo_Wrapper: foo
{
foo_Wrapper(PyObject* self_, const foo & p0):
foo(p0), self(self_) {}
foo_Wrapper(PyObject* self_):
foo(), self(self_) {}
foo * bar() {
return call_method< foo * >(self, "bar");
}
foo * default_bar() {
return foo::bar();
}
PyObject* self;
};
}// namespace
// Module ======================================================================
BOOST_PYTHON_MODULE(foo)
{
class_< foo, foo_Wrapper >("foo", init< >())
.def(init< const foo & >())
.def("bar", &foo::bar, &foo_Wrapper::default_bar)
;
}
______________________________
More information about the Cplusplus-sig
mailing list