Re: [pygccxml-development] Parameter passing, ownership semantics
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2007-02-19 05:42:00
|
On 2/19/07, Gustavo Carneiro <gjc...@gm...> wrote:
> Even with the name mangling problem, something was not right:
>
> gjc@nazgul:python$ python test-schedule.py
> Traceback (most recent call last):
> File "test-schedule.py ", line 11, in <module>
> Simulator.Schedule_fbf096d706be19b392c1e3fbcd3bf544(t1,
> ev)
> Boost.Python.ArgumentError: Python argument types in
>
> Simulator.Schedule_fbf096d706be19b392c1e3fbcd3bf544(Time,
> MyEvent)
> did not match C++ signature:
> Schedule_fbf096d706be19b392c1e3fbcd3bf544(ns3::Time
> time, std::auto_ptr<ns3::EventImpl> event)
>
> Then I saw something I missed in the unit test, and added this code:
>
> EventImpl = mb.class_('EventImpl')
> EventImpl.held_type = 'std::auto_ptr< %s >' % EventImpl.decl_string
>
> (EventImpl is the type of the argument that is subject to the ownership
> transfer)
>
> But with the above changes the code doesn't compile (errors below). The
> generated source contains:
>
> bp::class_< EventImpl_wrapper, std::auto_ptr< ::ns3::EventImpl >,
> boost::noncopyable >( "EventImpl" )
> .def( bp::init< >() )
>
> The error comes from the ".def( bp::init< >() )" line. Manually
removing
> the "std::auto_ptr< ::ns3::EventImpl >" part from the first line solves
the
> compilation error.
>
> Any hints?
Yes:
1. change "std::auto_ptr< ::ns3::EventImpl >" to
"std::auto_ptr< EventImpl_wrapper >" and add next line to your code:
ei = mb.class_( 'EventImpl' )
ei.add_registration_code(
"boost::python::implicitly_convertible< std::auto_ptr< EventImpl_wrapper
>, std::auto_ptr< ::ns3::EventImpl > >();"
, False )
This should help.
2. If not, please create small standalone test case, which reproduce the
problem.
I will take a look on it.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|