[C++-sig] Pyste defect or PEBKAC?

paul.bridger paul.bridger at paradise.net.nz
Wed May 26 00:59:53 CEST 2004


I'm using Pyste to wrap up a fairly large C++ library: OGRE 
(www.ogre3d.org) and I've had a problem or two. I'm using MSVC7.1 and 
the latest Boost CVS sources.

The first problem occurred while wrapping an inheritance relationship 
where the Base exposes a virtual method, which returns by const reference.

/* Base.h */
class AnyType {};
class Base
{
public:
	virtual const AnyType& f() {return AnyType();}
};

/* Derived.h */
#include "Base.h"

class Derived : public Base
{};

The pyste recipes are trivial:
Class("Base", "Base.h") # in Base.pyste
Class("Derived", "Derived.h") # in Derived.pyste

Here is the error:
c:\Boost\include\boost-1_31\boost\python\detail\caller.hpp(200): error 
C2027: use of undefined type 
'boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<T>'

And here is the offending code (in default_call_policies.hpp):
namespace detail
{
// for "readable" error messages
   template <class T> struct 
specify_a_return_value_policy_to_wrap_functions_returning
# if defined(__GNUC__) && __GNUC__ >= 3 || defined(__EDG__)
   {}
# endif
   ;
}

I can't advise whether MSVC7.0 has the same requirement, but MSVC7.1 
needs the preprocessor statement to be:
# if defined(__GNUC__) && __GNUC__ >= 3 || defined(__EDG__) || \
(defined(BOOST_MSVC) && _MSC_VER >= 1310)

This resolves the initial error.

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

Unfortunately, this: 
http://www.boost.org/libs/python/doc/v2/faq.html#msvcthrowbug
is not the problem or the solution.

A workaround here is to tell pyste that Base::f is final:
# Base.pyste
b = Class("Base", "Base.h")
final(b.f)

# Derived.pyste
Import("Base.pyste")
Class("Derived", "Derived.h")

Wrappers are nolonger generated, and the issue disappears along with the 
awesome functionality they provide. :)

However, suppressing wrapper generation will not work when the Derived 
class overrides methods.

Any help would be appreciated.

Paul Bridger




More information about the Cplusplus-sig mailing list