Bug 1994

Summary: bindings for classes without explicit copy constructors
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: python bindingsAssignee: Gustavo J. A. M. Carneiro <gjcarneiro>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: Linux   

Description Tom Henderson 2014-09-26 12:17:20 UTC
Revision 881 of pybindgen is breaking the compilation of the bindings.

http://bazaar.launchpad.net/~gjc/pybindgen/trunk/revision/881

This revision is about fixing copying issues with classes that have private copy constructors.

However, this version of pybindgen causes an early compilation error in ns-3:

 in convert_c_to_python
    raise CodeGenerationError("Class {0} cannot be copied".format(self.cpp_class.full_name))
pybindgen.typehandlers.base.CodeGenerationError: Class ns3::Ipv4Header cannot be copied

Ipv4Header does not have a private copy constructor or any copy constructor declared (it is using the default copy constructor).
Comment 1 Tom Henderson 2014-09-29 09:39:54 UTC
Rev 885 also fails to compile.  The C++ api is this:

uan-transducer.h (abstract base class):
virtual const ArrivalList &GetArrivalList (void) const = 0;

uan-transducer-hd.h:
virtual const ArrivalList &GetArrivalList (void) const;

where 'ArrivalList' is a std::list<UanPacketArrival>

The bindings are:

    module.add_container('std::list< ns3::UanPacketArrival >', 'ns3::UanPacketArrival', container_type=u'list')

   ## uan-transducer.h (module 'uan'): std::list<ns3::UanPacketArrival, std::allocator<ns3::UanPacketArrival> > const & ns3::UanTransducer::GetArrivalList() const [member function]
    cls.add_method('GetArrivalList',
                   'std::list< ns3::UanPacketArrival > const &',
                   [],
                   is_pure_virtual=True, is_const=True, is_virtual=True)


    ## uan-transducer-hd.h (module 'uan'): std::list<ns3::UanPacketArrival, std::allocator<ns3::UanPacketArrival> > const & ns3::UanTransducerHd::GetArrivalList() const [member function]
    cls.add_method('GetArrivalList',
                   'std::list< ns3::UanPacketArrival > const &',
                   [],
                   is_const=True, is_virtual=True)


which looks OK, but then the compilation error is as follows:


In file included from src/uan/bindings/ns3module.cc:1:0:
src/uan/bindings/ns3module.h:3862:48: error: conflicting return type specified for ‘virtual std::list<ns3::UanPacketArrival> PyNs3UanTransducer__PythonHelper::GetArrivalList() const’
     virtual std::list< ns3::UanPacketArrival > GetArrivalList() const;
                                                ^
In file included from ./ns3/uan-phy.h:30:0,
                 from ./ns3/uan-mac-cw.h:27,
                 from ./ns3/uan-module.h:18,
                 from src/uan/bindings/ns3module.h:78,
                 from src/uan/bindings/ns3module.cc:1:
./ns3/uan-transducer.h:183:30: error:   overriding ‘virtual const ArrivalList& ns3::UanTransducer::GetArrivalList() const’
   virtual const ArrivalList &GetArrivalList (void) const = 0;
Comment 2 Gustavo J. A. M. Carneiro 2014-09-29 10:12:35 UTC
Apologies.  I guess I should have rebuilt ns-3-dev from scratch before declaring victory.  I'll fix it (again) tonight.
Comment 3 Gustavo J. A. M. Carneiro 2014-09-29 17:21:00 UTC
I think this is fixed now.  I tried rebuilding from scratch, and it builds for me.