From ce0dabd90034851c7682cf7218688e9e4fe16fba Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Thu, 6 May 2010 14:21:20 +0100 Subject: [PATCH] Fix Python bindings ns3.Object subclassing bug --- bindings/python/ns3modulegen_core_customizations.py | 4 ++++ bindings/python/wscript | 2 +- utils/python-unit-tests.py | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bindings/python/ns3modulegen_core_customizations.py b/bindings/python/ns3modulegen_core_customizations.py index 242ee3383..2b2aa6c23 100644 --- a/bindings/python/ns3modulegen_core_customizations.py +++ b/bindings/python/ns3modulegen_core_customizations.py @@ -362,9 +362,13 @@ static ns3::TypeId GetTypeId (void) % cpp_class.full_name) code_block.write_code("%s = new %s(%s);" % (lvalue, construct_type_name, parameters)) code_block.write_code("%s->Ref ();" % (lvalue)) + + def ns3_object_post_instance_creation_function(cpp_class, code_block, lvalue, + parameters, construct_type_name): code_block.write_code("ns3::CompleteConstruct(%s);" % (lvalue, )) Object.set_instance_creation_function(ns3_object_instance_creation_function) + Object.set_post_instance_creation_function(ns3_object_post_instance_creation_function) def Attribute_customizations(module): diff --git a/bindings/python/wscript b/bindings/python/wscript index 712cc017d..6aa044384 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -15,7 +15,7 @@ import Build import Utils ## https://launchpad.net/pybindgen/ -REQUIRED_PYBINDGEN_VERSION = (0, 14, 1) +REQUIRED_PYBINDGEN_VERSION = (0, 14, 1, 764) REQUIRED_PYGCCXML_VERSION = (0, 9, 5) diff --git a/utils/python-unit-tests.py b/utils/python-unit-tests.py index 0d99c6a17..fcd011952 100644 --- a/utils/python-unit-tests.py +++ b/utils/python-unit-tests.py @@ -145,5 +145,13 @@ class TestSimulator(unittest.TestCase): self.assertEqual(cmd.test_xxx, "123") self.assertEqual(foo.test_foo, "xpto") + def testSubclass(self): + class MyNode(ns3.Node): + def __init__(self): + super(MyNode, self).__init__() + + node = MyNode() + + if __name__ == '__main__': unittest.main()