Hi Roman
The problem is that: How export this class?
namespace geometry{
class point_t
{
public:
point_t() {};
protected:
virtual bool ret_bool() { return false; }
};
class point_2 : public point_t
{
public:
point_2() {};
};
}
I put attached the Py++ genereted code and a small test.
My question is, how export this protected virtual function? the way
used in Py++ not work in this case.
Thanks
On Mon, Mar 23, 2009 at 5:57 AM, Roman Yakovenko
<[email protected]> wrote:
> 2009/3/19 Renato Araujo <[email protected]>:
>> Hi guys, I'm working again in my bindings generation and I get a new
>> question about virtual functions.
>>
>> I would like to know how export protected virtual functions with
>> default implementation, because I didn't find any documentation about
>> this and the code generated by Py++ not work in all cases.
>>
>> I have attached the test case on this e-mail, if someone would like to
>> try my implementation.
>
> Do you mind to be more specific?
>
> Can you show the original source code, the generated one and the
> "right\desired" one?
>
> Thanks
>
> --
> Roman Yakovenko
> C++ Python language binding
> http://www.language-binding.net/
> _______________________________________________
> Cplusplus-sig mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
--
Renato Araujo Oliveira Filho
// This file has been generated by Py++.
#include "boost/python.hpp"
#include "properties.hpp"
namespace bp = boost::python;
struct point_t_wrapper : geometry::point_t, bp::wrapper< geometry::point_t > {
point_t_wrapper(geometry::point_t const & arg )
: geometry::point_t( arg )
, bp::wrapper< geometry::point_t >(){
// copy constructor
}
point_t_wrapper( )
: geometry::point_t( )
, bp::wrapper< geometry::point_t >(){
// null constructor
}
virtual bool ret_bool( ){
if( bp::override func_ret_bool = this->get_override( "ret_bool" ) )
return func_ret_bool( );
else
return this->geometry::point_t::ret_bool( );
}
};
struct point_2_wrapper : geometry::point_2, bp::wrapper< geometry::point_2 > {
point_2_wrapper( )
: geometry::point_2( )
, bp::wrapper< geometry::point_2 >(){
// null constructor
}
virtual bool ret_bool( ){
if( bp::override func_ret_bool = this->get_override( "ret_bool" ) )
return func_ret_bool( );
else
return this->geometry::point_t::ret_bool( );
}
};
BOOST_PYTHON_MODULE(properties){
bp::class_< point_t_wrapper >( "point_t", bp::init< >() )
.def(
"ret_bool"
, (bool ( point_t_wrapper::* )( ) )(&point_t_wrapper::ret_bool) );
bp::class_< point_2_wrapper, bp::bases< geometry::point_t >, boost::noncopyable >( "point_2", bp::init< >() )
.def(
"ret_bool"
, (bool ( point_2_wrapper::* )( ) )(&point_2_wrapper::ret_bool) );
}
from properties import *
class test(point_t):
def __init__(self):
point_t.__init__(self)
print "test.__init__"
def ret_bool(self):
ret = point_t.ret_bool(self)
print "test.ret_bool", ret
t = test()
print t.ret_bool()
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig