Python: re-scan API; unblock python threads during Simulator::Run; new pybindgen brings improved thread safety for virtual methods.
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Tue Aug 05 19:42:53 2008 +0100 (19 months ago)
changeset 3511eb17407147c3
parent 3508 7a3c6148c22d
child 3512 e7504020e45b
Python: re-scan API; unblock python threads during Simulator::Run; new pybindgen brings improved thread safety for virtual methods.
bindings/python/ns3_module_csma.py
bindings/python/ns3_module_helper.py
bindings/python/ns3_module_simulator.py
bindings/python/ns3modulescan.py
bindings/python/wscript
     1.1 --- a/bindings/python/ns3_module_csma.py	Mon Aug 04 17:44:53 2008 -0700
     1.2 +++ b/bindings/python/ns3_module_csma.py	Tue Aug 05 19:42:53 2008 +0100
     1.3 @@ -13,8 +13,8 @@
     1.4      module.add_class('CsmaChannel', parent=root_module['ns3::Channel'])
     1.5      ## csma-net-device.h: ns3::CsmaNetDevice [class]
     1.6      module.add_class('CsmaNetDevice', parent=root_module['ns3::NetDevice'])
     1.7 -    ## csma-net-device.h: ns3::CsmaNetDevice::CsmaEncapsulationMode [enumeration]
     1.8 -    module.add_enum('CsmaEncapsulationMode', ['ETHERNET_V1', 'IP_ARP', 'RAW', 'LLC'], outer_class=root_module['ns3::CsmaNetDevice'])
     1.9 +    ## csma-net-device.h: ns3::CsmaNetDevice::EncapsulationMode [enumeration]
    1.10 +    module.add_enum('EncapsulationMode', ['ETHERNET_V1', 'IP_ARP', 'RAW', 'LLC'], outer_class=root_module['ns3::CsmaNetDevice'])
    1.11      
    1.12      ## Register a nested module for the namespace internal
    1.13      
    1.14 @@ -250,6 +250,32 @@
    1.15      cls.add_method('SetAddress', 
    1.16                     'void', 
    1.17                     [param('ns3::Mac48Address', 'addr')])
    1.18 +    ## csma-net-device.h: void ns3::CsmaNetDevice::SetMaxPayloadLength(uint16_t maxPayloadLength) [member function]
    1.19 +    cls.add_method('SetMaxPayloadLength', 
    1.20 +                   'void', 
    1.21 +                   [param('uint16_t', 'maxPayloadLength')])
    1.22 +    ## csma-net-device.h: uint16_t ns3::CsmaNetDevice::GetMaxPayloadLength() const [member function]
    1.23 +    cls.add_method('GetMaxPayloadLength', 
    1.24 +                   'uint16_t', 
    1.25 +                   [], 
    1.26 +                   is_const=True)
    1.27 +    ## csma-net-device.h: void ns3::CsmaNetDevice::SetMacMtu(uint16_t mtu) [member function]
    1.28 +    cls.add_method('SetMacMtu', 
    1.29 +                   'void', 
    1.30 +                   [param('uint16_t', 'mtu')])
    1.31 +    ## csma-net-device.h: uint16_t ns3::CsmaNetDevice::GetMacMtu() const [member function]
    1.32 +    cls.add_method('GetMacMtu', 
    1.33 +                   'uint16_t', 
    1.34 +                   [], 
    1.35 +                   is_const=True)
    1.36 +    ## csma-net-device.h: void ns3::CsmaNetDevice::SetEncapsulationMode(ns3::CsmaNetDevice::EncapsulationMode mode) [member function]
    1.37 +    cls.add_method('SetEncapsulationMode', 
    1.38 +                   'void', 
    1.39 +                   [param('ns3::CsmaNetDevice::EncapsulationMode', 'mode')])
    1.40 +    ## csma-net-device.h: ns3::CsmaNetDevice::EncapsulationMode ns3::CsmaNetDevice::GetEncapsulationMode() [member function]
    1.41 +    cls.add_method('GetEncapsulationMode', 
    1.42 +                   'ns3::CsmaNetDevice::EncapsulationMode', 
    1.43 +                   [])
    1.44      ## csma-net-device.h: void ns3::CsmaNetDevice::SetName(std::string const name) [member function]
    1.45      cls.add_method('SetName', 
    1.46                     'void', 
    1.47 @@ -275,11 +301,6 @@
    1.48                     'ns3::Ptr< ns3::Channel >', 
    1.49                     [], 
    1.50                     is_const=True, is_virtual=True)
    1.51 -    ## csma-net-device.h: ns3::Address ns3::CsmaNetDevice::GetAddress() const [member function]
    1.52 -    cls.add_method('GetAddress', 
    1.53 -                   'ns3::Address', 
    1.54 -                   [], 
    1.55 -                   is_const=True, is_virtual=True)
    1.56      ## csma-net-device.h: bool ns3::CsmaNetDevice::SetMtu(uint16_t const mtu) [member function]
    1.57      cls.add_method('SetMtu', 
    1.58                     'bool', 
    1.59 @@ -290,6 +311,11 @@
    1.60                     'uint16_t', 
    1.61                     [], 
    1.62                     is_const=True, is_virtual=True)
    1.63 +    ## csma-net-device.h: ns3::Address ns3::CsmaNetDevice::GetAddress() const [member function]
    1.64 +    cls.add_method('GetAddress', 
    1.65 +                   'ns3::Address', 
    1.66 +                   [], 
    1.67 +                   is_const=True, is_virtual=True)
    1.68      ## csma-net-device.h: bool ns3::CsmaNetDevice::IsLinkUp() const [member function]
    1.69      cls.add_method('IsLinkUp', 
    1.70                     'bool', 
     2.1 --- a/bindings/python/ns3_module_helper.py	Mon Aug 04 17:44:53 2008 -0700
     2.2 +++ b/bindings/python/ns3_module_helper.py	Tue Aug 05 19:42:53 2008 +0100
     2.3 @@ -137,6 +137,21 @@
     2.4      cls.add_method('InstallAll', 
     2.5                     'void', 
     2.6                     [])
     2.7 +    ## mobility-helper.h: static void ns3::MobilityHelper::EnableAscii(std::ostream & os, uint32_t nodeid) [member function]
     2.8 +    cls.add_method('EnableAscii', 
     2.9 +                   'void', 
    2.10 +                   [param('std::ostream&', 'os'), param('uint32_t', 'nodeid')], 
    2.11 +                   is_static=True)
    2.12 +    ## mobility-helper.h: static void ns3::MobilityHelper::EnableAscii(std::ostream & os, ns3::NodeContainer n) [member function]
    2.13 +    cls.add_method('EnableAscii', 
    2.14 +                   'void', 
    2.15 +                   [param('std::ostream&', 'os'), param('ns3::NodeContainer', 'n')], 
    2.16 +                   is_static=True)
    2.17 +    ## mobility-helper.h: static void ns3::MobilityHelper::EnableAsciiAll(std::ostream & os) [member function]
    2.18 +    cls.add_method('EnableAsciiAll', 
    2.19 +                   'void', 
    2.20 +                   [param('std::ostream&', 'os')], 
    2.21 +                   is_static=True)
    2.22      return
    2.23  
    2.24  def register_Ns3InternetStackHelper_methods(root_module, cls):
     3.1 --- a/bindings/python/ns3_module_simulator.py	Mon Aug 04 17:44:53 2008 -0700
     3.2 +++ b/bindings/python/ns3_module_simulator.py	Tue Aug 05 19:42:53 2008 +0100
     3.3 @@ -346,7 +346,7 @@
     3.4      cls.add_method('EnableLogTo', 
     3.5                     'void', 
     3.6                     [param('char *', 'filename', transfer_ownership=False, is_const=True)], 
     3.7 -                   is_static=True)
     3.8 +                   is_static=True, deprecated=True)
     3.9      ## simulator.h: static void ns3::Simulator::Destroy() [member function]
    3.10      cls.add_method('Destroy', 
    3.11                     'void', 
    3.12 @@ -366,7 +366,7 @@
    3.13      cls.add_method('Run', 
    3.14                     'void', 
    3.15                     [], 
    3.16 -                   is_static=True)
    3.17 +                   is_static=True, unblock_threads=True)
    3.18      ## simulator.h: static void ns3::Simulator::Stop() [member function]
    3.19      cls.add_method('Stop', 
    3.20                     'void', 
     4.1 --- a/bindings/python/ns3modulescan.py	Mon Aug 04 17:44:53 2008 -0700
     4.2 +++ b/bindings/python/ns3modulescan.py	Tue Aug 05 19:42:53 2008 +0100
     4.3 @@ -148,6 +148,13 @@
     4.4              and pygccxml_definition.name.startswith('Schedule'):
     4.5          global_annotations['ignore'] = None
     4.6  
     4.7 +    # unblock python threads for Simulator::Run
     4.8 +    if isinstance(pygccxml_definition, member_function_t) \
     4.9 +            and pygccxml_definition.parent.name == 'Simulator' \
    4.10 +            and pygccxml_definition.name == 'Run':
    4.11 +        global_annotations['unblock_threads'] = True
    4.12 +
    4.13 +
    4.14      ## classes
    4.15      if isinstance(pygccxml_definition, class_t):
    4.16          # no need for helper classes to allow subclassing in Python, I think...
     5.1 --- a/bindings/python/wscript	Mon Aug 04 17:44:53 2008 -0700
     5.2 +++ b/bindings/python/wscript	Tue Aug 05 19:42:53 2008 +0100
     5.3 @@ -21,7 +21,7 @@
     5.4      os.environ['PYTHONPATH'] = LOCAL_PYBINDGEN_PATH
     5.5  
     5.6  ## https://launchpad.net/pybindgen/
     5.7 -REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 526)
     5.8 +REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 530)
     5.9  REQUIRED_PYGCCXML_VERSION = (0, 9, 5)
    5.10  
    5.11