diff options
-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' |