From 91ae3bb10b64ce9cf68142c257f1fe1209cf48f1 Mon Sep 17 00:00:00 2001 From: Gustavo Carneiro Date: Fri, 26 Feb 2016 06:55:11 -0800 Subject: [PATCH] bindings: Improve custom support for callback forward declarations --- bindings/python/ns3modulegen_core_customizations.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bindings/python/ns3modulegen_core_customizations.py b/bindings/python/ns3modulegen_core_customizations.py index c237d473b..fa79960f2 100644 --- a/bindings/python/ns3modulegen_core_customizations.py +++ b/bindings/python/ns3modulegen_core_customizations.py @@ -240,7 +240,17 @@ public: else: kwargs = {} try: - arguments.append(Parameter.new(str(param_ctype), arg_name, **kwargs)) + param = Parameter.new(str(param_ctype), arg_name, **kwargs) + cpp_class = getattr(param, "cpp_class", None) + if isinstance(cpp_class, cppclass.CppClass): + # check if the "helper class" can be constructed + if cpp_class.helper_class is not None: + cpp_class.helper_class.generate_forward_declarations( + MemoryCodeSink()) + if cpp_class.helper_class.cannot_be_constructed: + cpp_class.helper_class = None + cpp_class.helper_class_disabled = True + arguments.append(param) except (typehandlers.TypeLookupError, typehandlers.TypeConfigurationError) as ex: warnings.warn("***** Unable to register callback; parameter '%s %s' error (used in %s): %r" % (arg_type, arg_name, cls_name, ex),