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, 05 Aug 2008 19:42:53 +0100
changeset 3511 eb17407147c3
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
--- a/bindings/python/ns3_module_csma.py	Mon Aug 04 17:44:53 2008 -0700
+++ b/bindings/python/ns3_module_csma.py	Tue Aug 05 19:42:53 2008 +0100
@@ -13,8 +13,8 @@
     module.add_class('CsmaChannel', parent=root_module['ns3::Channel'])
     ## csma-net-device.h: ns3::CsmaNetDevice [class]
     module.add_class('CsmaNetDevice', parent=root_module['ns3::NetDevice'])
-    ## csma-net-device.h: ns3::CsmaNetDevice::CsmaEncapsulationMode [enumeration]
-    module.add_enum('CsmaEncapsulationMode', ['ETHERNET_V1', 'IP_ARP', 'RAW', 'LLC'], outer_class=root_module['ns3::CsmaNetDevice'])
+    ## csma-net-device.h: ns3::CsmaNetDevice::EncapsulationMode [enumeration]
+    module.add_enum('EncapsulationMode', ['ETHERNET_V1', 'IP_ARP', 'RAW', 'LLC'], outer_class=root_module['ns3::CsmaNetDevice'])
     
     ## Register a nested module for the namespace internal
     
@@ -250,6 +250,32 @@
     cls.add_method('SetAddress', 
                    'void', 
                    [param('ns3::Mac48Address', 'addr')])
+    ## csma-net-device.h: void ns3::CsmaNetDevice::SetMaxPayloadLength(uint16_t maxPayloadLength) [member function]
+    cls.add_method('SetMaxPayloadLength', 
+                   'void', 
+                   [param('uint16_t', 'maxPayloadLength')])
+    ## csma-net-device.h: uint16_t ns3::CsmaNetDevice::GetMaxPayloadLength() const [member function]
+    cls.add_method('GetMaxPayloadLength', 
+                   'uint16_t', 
+                   [], 
+                   is_const=True)
+    ## csma-net-device.h: void ns3::CsmaNetDevice::SetMacMtu(uint16_t mtu) [member function]
+    cls.add_method('SetMacMtu', 
+                   'void', 
+                   [param('uint16_t', 'mtu')])
+    ## csma-net-device.h: uint16_t ns3::CsmaNetDevice::GetMacMtu() const [member function]
+    cls.add_method('GetMacMtu', 
+                   'uint16_t', 
+                   [], 
+                   is_const=True)
+    ## csma-net-device.h: void ns3::CsmaNetDevice::SetEncapsulationMode(ns3::CsmaNetDevice::EncapsulationMode mode) [member function]
+    cls.add_method('SetEncapsulationMode', 
+                   'void', 
+                   [param('ns3::CsmaNetDevice::EncapsulationMode', 'mode')])
+    ## csma-net-device.h: ns3::CsmaNetDevice::EncapsulationMode ns3::CsmaNetDevice::GetEncapsulationMode() [member function]
+    cls.add_method('GetEncapsulationMode', 
+                   'ns3::CsmaNetDevice::EncapsulationMode', 
+                   [])
     ## csma-net-device.h: void ns3::CsmaNetDevice::SetName(std::string const name) [member function]
     cls.add_method('SetName', 
                    'void', 
@@ -275,11 +301,6 @@
                    'ns3::Ptr< ns3::Channel >', 
                    [], 
                    is_const=True, is_virtual=True)
-    ## csma-net-device.h: ns3::Address ns3::CsmaNetDevice::GetAddress() const [member function]
-    cls.add_method('GetAddress', 
-                   'ns3::Address', 
-                   [], 
-                   is_const=True, is_virtual=True)
     ## csma-net-device.h: bool ns3::CsmaNetDevice::SetMtu(uint16_t const mtu) [member function]
     cls.add_method('SetMtu', 
                    'bool', 
@@ -290,6 +311,11 @@
                    'uint16_t', 
                    [], 
                    is_const=True, is_virtual=True)
+    ## csma-net-device.h: ns3::Address ns3::CsmaNetDevice::GetAddress() const [member function]
+    cls.add_method('GetAddress', 
+                   'ns3::Address', 
+                   [], 
+                   is_const=True, is_virtual=True)
     ## csma-net-device.h: bool ns3::CsmaNetDevice::IsLinkUp() const [member function]
     cls.add_method('IsLinkUp', 
                    'bool', 
--- a/bindings/python/ns3_module_helper.py	Mon Aug 04 17:44:53 2008 -0700
+++ b/bindings/python/ns3_module_helper.py	Tue Aug 05 19:42:53 2008 +0100
@@ -137,6 +137,21 @@
     cls.add_method('InstallAll', 
                    'void', 
                    [])
+    ## mobility-helper.h: static void ns3::MobilityHelper::EnableAscii(std::ostream & os, uint32_t nodeid) [member function]
+    cls.add_method('EnableAscii', 
+                   'void', 
+                   [param('std::ostream&', 'os'), param('uint32_t', 'nodeid')], 
+                   is_static=True)
+    ## mobility-helper.h: static void ns3::MobilityHelper::EnableAscii(std::ostream & os, ns3::NodeContainer n) [member function]
+    cls.add_method('EnableAscii', 
+                   'void', 
+                   [param('std::ostream&', 'os'), param('ns3::NodeContainer', 'n')], 
+                   is_static=True)
+    ## mobility-helper.h: static void ns3::MobilityHelper::EnableAsciiAll(std::ostream & os) [member function]
+    cls.add_method('EnableAsciiAll', 
+                   'void', 
+                   [param('std::ostream&', 'os')], 
+                   is_static=True)
     return
 
 def register_Ns3InternetStackHelper_methods(root_module, cls):
--- a/bindings/python/ns3_module_simulator.py	Mon Aug 04 17:44:53 2008 -0700
+++ b/bindings/python/ns3_module_simulator.py	Tue Aug 05 19:42:53 2008 +0100
@@ -346,7 +346,7 @@
     cls.add_method('EnableLogTo', 
                    'void', 
                    [param('char *', 'filename', transfer_ownership=False, is_const=True)], 
-                   is_static=True)
+                   is_static=True, deprecated=True)
     ## simulator.h: static void ns3::Simulator::Destroy() [member function]
     cls.add_method('Destroy', 
                    'void', 
@@ -366,7 +366,7 @@
     cls.add_method('Run', 
                    'void', 
                    [], 
-                   is_static=True)
+                   is_static=True, unblock_threads=True)
     ## simulator.h: static void ns3::Simulator::Stop() [member function]
     cls.add_method('Stop', 
                    'void', 
--- a/bindings/python/ns3modulescan.py	Mon Aug 04 17:44:53 2008 -0700
+++ b/bindings/python/ns3modulescan.py	Tue Aug 05 19:42:53 2008 +0100
@@ -148,6 +148,13 @@
             and pygccxml_definition.name.startswith('Schedule'):
         global_annotations['ignore'] = None
 
+    # unblock python threads for Simulator::Run
+    if isinstance(pygccxml_definition, member_function_t) \
+            and pygccxml_definition.parent.name == 'Simulator' \
+            and pygccxml_definition.name == 'Run':
+        global_annotations['unblock_threads'] = True
+
+
     ## classes
     if isinstance(pygccxml_definition, class_t):
         # no need for helper classes to allow subclassing in Python, I think...
--- a/bindings/python/wscript	Mon Aug 04 17:44:53 2008 -0700
+++ b/bindings/python/wscript	Tue Aug 05 19:42:53 2008 +0100
@@ -21,7 +21,7 @@
     os.environ['PYTHONPATH'] = LOCAL_PYBINDGEN_PATH
 
 ## https://launchpad.net/pybindgen/
-REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 526)
+REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 530)
 REQUIRED_PYGCCXML_VERSION = (0, 9, 5)