diff options
Diffstat (limited to 'tests/GenerateSipBindings/rules_SipTest.py')
-rw-r--r-- | tests/GenerateSipBindings/rules_SipTest.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/GenerateSipBindings/rules_SipTest.py b/tests/GenerateSipBindings/rules_SipTest.py index e0cd2b9e..1331da41 100644 --- a/tests/GenerateSipBindings/rules_SipTest.py +++ b/tests/GenerateSipBindings/rules_SipTest.py @@ -11,7 +11,44 @@ def local_function_rules(): ["MyObject", "fwdDeclRef", ".*", ".*", ".*", rules_engine.function_discard], ] +def methodGenerator(function, sip, entry): + sip["code"] = """ + %MethodCode + sipRes = {} + myAcumulate(a0); + %End + """.format(entry["param"]) + + class RuleSet(Qt5Ruleset.RuleSet): def __init__(self): Qt5Ruleset.RuleSet.__init__(self) self._fn_db = rules_engine.FunctionRuleDb(lambda: local_function_rules() + Qt5Ruleset.function_rules()) + self._modulecode = rules_engine.ModuleCodeDb({ + "cpplib.h": { + "code": """ +%ModuleCode +int myAcumulate(const QList<int> *list) { + return std::accumulate(list->begin(), list->end(), 0); +} +%End\n + """ + } + }) + + self._methodcode = rules_engine.MethodCodeDb({ + "SomeNS": { + "customMethod": { + "code": """ + %MethodCode + sipRes = myAcumulate(a0); + %End + """ + } + }, + "cpplib.h": { + "anotherCustomMethod": { + "code": methodGenerator, + "param": 42 + } + } + }) |