[C++-sig] Pyste defect or PEBKAC?
paul.bridger
paul.bridger at paradise.net.nz
Wed May 26 06:57:48 CEST 2004
paul.bridger wrote:
> The subsequent error which I don't know how to fix is:
> c:\Boost\include\boost-1_31\boost\python\detail\invoke.hpp(89): error
> C2064: term does not evaluate to a function taking 1 arguments
Right, now I understand what is happening. Pyste is failing to
automatically specify the return value policy for virtual methods that
return by const reference. This is not specified for either the base or
the derived class.
Where I have:
/* Base.h */
class AnyType {};
class Base
{
public:
const AnyType& f() {return AnyType();}
virtual const AnyType& v() {return AnyType();}
};
Pyste is generating:
class_< Base, Base_Wrapper >("Base", init< >())
.def(init< const Base& >())
.def("v", &Base::v, &Base_Wrapper::default_v)
.def("f", &Base::f, return_value_policy< copy_const_reference >())
Fixing the export of 'v' works nicely:
.def("v", &Base::v, &Base_Wrapper::default_v), return_value_policy<
copy_const_reference >()
So unless I'm missing some subtlety of C++, Pyste should be either
specifying this default return value policy, or at least warning that it
is not manually specified.
There is another behaviour I've just narrowed down that seems like a
problem to me. When I create a virtual function in a derived class, all
the base class functions are re-exported for the derived class. This is
in contrast to when the derived class is trivial - no base class methods
are re-exported.
Finally...any hints on keeping memory consumption down? I am trying to
wrap a class with >20 methods, and unless I make most of these methods
final, the memory used rapidly climbs above 2GB and my compiler
(msvc7.1) barfs.
Paul
More information about the Cplusplus-sig
mailing list