From 636d6acc7adf8bf7169d38833340161dc42d3484 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 14 Jan 2017 22:13:49 +0000 Subject: Bindings: Fix handling of forward declarations It is not appropriate to decorate each forward declaration with the SIP attribute /External/. That is only needed for forward declarations of types which are defined in a different module. Local forward declarations can be omitted from the sip code. In sip code, a forward declaration followed later by a full class definition is an error. Omit forward declarations unless they are decorated with the external attribute. Introduce a rules database for consumers to decorate them with the attribute as required. --- tests/GenerateSipBindings/rules_SipTest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/GenerateSipBindings/rules_SipTest.py') diff --git a/tests/GenerateSipBindings/rules_SipTest.py b/tests/GenerateSipBindings/rules_SipTest.py index ad3fcb64..c570a039 100644 --- a/tests/GenerateSipBindings/rules_SipTest.py +++ b/tests/GenerateSipBindings/rules_SipTest.py @@ -10,10 +10,13 @@ def local_container_rules(): [".*", "Shared", ".*", ".*", ".*", rules_engine.discard_QSharedData_base] ] +def local_forward_declaration_rules(): + return [ + [".*", "ExternalFwdDecl", ".*", rules_engine.mark_forward_declaration_external] + ] + def local_function_rules(): return [ - ["MyObject", "fwdDecl", ".*", ".*", ".*", rules_engine.function_discard], - ["MyObject", "fwdDeclRef", ".*", ".*", ".*", rules_engine.function_discard], ["TypedefUser", "setTagPattern", ".*", ".*", ".*", rules_engine.function_discard], ] @@ -34,6 +37,7 @@ class RuleSet(Qt5Ruleset.RuleSet): def __init__(self): Qt5Ruleset.RuleSet.__init__(self) self._container_db = rules_engine.ContainerRuleDb(lambda: local_container_rules() + Qt5Ruleset.container_rules()) + self._forward_declaration_db = rules_engine.ForwardDeclarationRuleDb(lambda: local_forward_declaration_rules() + Qt5Ruleset.forward_declaration_rules()) self._fn_db = rules_engine.FunctionRuleDb(lambda: local_function_rules() + Qt5Ruleset.function_rules()) self._typedef_db = rules_engine.TypedefRuleDb(lambda: local_typedef_rules() + Qt5Ruleset.typedef_rules()) self._modulecode = rules_engine.ModuleCodeDb({ -- cgit v1.2.1