Sign in to follow this  
CoMaNdore

*refrased* Derived from exposed class in boost python

Recommended Posts

Hey Refased this post since I kinda dint get any reply's. Hopefully it will be easier to see what I ask about this time :)
// the source code:
class A
{
	public:
		A()
		{
			std::cout << "A()" << std::endl;
			m_Value = 0;
		}

		virtual ~A() { std::cout << "~A()" << std::endl; }

		virtual void foo() = 0;
		virtual int ghey() { return( m_Value ); }
		int m_Value;
};


class B : public A, public wrapper<A>
{
	public:
		B() { std::cout << "B()" << endl; m_Value = 133; }
		virtual ~B() { std::cout << "~B()" << endl; }

		virtual void foo()
		{
			this->get_override( "foo" )();
		}
};

class C : public B, public wrapper
{
	public:
		C() { std::cout << "C()" << endl; }
		virtual ~C() { std::cout << "~C()" << endl; }

		virtual int ghey() { return( m_Value*2 ); }
		int m_Value2;
};
And here is how it is exposed for boost python:
BOOST_PYTHON_MODULE( bpydebug )
{
	class_<B, boost::noncopyable>("B")
		.def( "foo", pure_virtual( &B::foo ) )
		.def_readwrite( "Value", &A::m_Value )
	;

	class_<C, noncopyable, bases >( "C" )
		.def_readwrite( "Value2", &C::m_Value2 )
	;
};
This code works if you uncomment everything in the 'class_' declaration (remove the .def_readwrite part of C). Any idea how to fix this? [Edited by - CoMaNdore on June 8, 2007 10:00:22 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this