Hi,

I have a little problem, i can't find a way to call a pure virtual function
from C++ on a Python object taking a specific class object as argument :

// Base Class for a component
class BaseCmp
{
public:
        ~BaseCmp() {};
};

// Base class
class Base
{
public:
        Base() {};
        virtual ~Base() {};
        virtual void testVirtualPure( BaseCmp* pBaseCmp ) = 0;
};

struct BaseWrap : Base, bp::wrapper<Base>
{
        void testVirtualPure( BaseCmp* pBaseCmp )
        {
                this->get_override("testVirtualPure")( pBaseCmp );
        }
};


// Module TestScript
BOOST_PYTHON_MODULE(test)
{
        // BaseCmp Class exposition
        bp::class_<BaseCmp,boost::noncopyable>("BaseCmp", bp::no_init)
                 ;

        // Base Class Wrapper exposition
        bp::class_<BaseWrap, boost::noncopyable>("Base")
                .def( "testVirtualPure", bp::pure_virtual( 
&Base::testVirtualPure ) )
                ;
} 

I need to call my testVirtualPure function from C++ side : 
BaseCmp* bc = BaseCmp();
Base* b = Base();
b->testVirtualPure( bc );

But this causes an error : 
TypeError: No to_python (by-value) converter found for C++ type: class
BaseCmp

Does someone know how i can do  that ?

Thanks a lot
-- 
View this message in context: 
http://www.nabble.com/Calling-python-virtual-function-from-C%2B%2B-tp21711534p21711534.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to