diff options
author | Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com> | 2017-04-04 12:34:00 +0200 |
---|---|---|
committer | Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com> | 2017-04-04 12:34:00 +0200 |
commit | 1496c73920d2749b191fcd9eb79a1de11364c1d2 (patch) | |
tree | ac4458dfb8c020261f18c885c3ac1f9928c38a1c | |
parent | 8db91c520e2c18144edc2af28cb25d5c4259f542 (diff) | |
download | qtivi-qface-1496c73920d2749b191fcd9eb79a1de11364c1d2.tar.gz |
updated namespace filters to support also using a namespace
-rw-r--r-- | qface/helper/qtcpp.py | 10 | ||||
-rw-r--r-- | tests/test_qtcpp_helper.py | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/qface/helper/qtcpp.py b/qface/helper/qtcpp.py index 213abfe..7e8f3ca 100644 --- a/qface/helper/qtcpp.py +++ b/qface/helper/qtcpp.py @@ -107,12 +107,18 @@ class Filters(object): @staticmethod def open_ns(symbol): - # 'namespace x { y {' + ''' generates a open namespace from symbol namespace x { y { z {''' blocks = ['{0} {{'.format(x) for x in symbol.module.name_parts] return 'namespace {0}'.format(str.join(' ', blocks)) @staticmethod def close_ns(symbol): - # '} }' + '''generates a closing names statement from a symbol''' return ' '.join(['}' for x in symbol.module.name_parts]) + @staticmethod + def using_ns(symbol): + '''generates a using namespace x::y::z statement from a symbol''' + id = '::'.join(symbol.module.name_parts) + return 'using namespace {0}'.format(id) + diff --git a/tests/test_qtcpp_helper.py b/tests/test_qtcpp_helper.py index 2c2e20e..535905a 100644 --- a/tests/test_qtcpp_helper.py +++ b/tests/test_qtcpp_helper.py @@ -209,3 +209,6 @@ def test_namespace(): ns = qtcpp.Filters.close_ns(module) assert ns == '} }' + + ns = qtcpp.Filters.using_ns(module) + assert ns == 'using namespace org::example' |