From 4a5c3b307cbbae9a462b8ba40a034f91fdef9dfd Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 15 Nov 2016 14:26:25 -0600 Subject: sdbus++: Prepend all errors with 'Error' namespace Old: Error identifier: com.example.Interface.LogicError Exception class: com::example::Interface::common::LogicError New: Error identifier: com.example.Interface.Error.LogicError Exception class: com::example::Interface::Error::LogicError Change-Id: I866046f4a0514f5bce40bdef46a218060d107765 Signed-off-by: Patrick Williams --- tools/example/net/poettering/Calculator.interface.yaml | 2 +- tools/sdbusplus/templates/error.mako.cpp | 4 ++-- tools/sdbusplus/templates/error.mako.hpp | 4 ++-- tools/sdbusplus/templates/method.mako.prototype.hpp | 6 ++++-- 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/example/net/poettering/Calculator.interface.yaml b/tools/example/net/poettering/Calculator.interface.yaml index 4167c36..3c70cbc 100644 --- a/tools/example/net/poettering/Calculator.interface.yaml +++ b/tools/example/net/poettering/Calculator.interface.yaml @@ -40,7 +40,7 @@ methods: description: > The result of (x/y). errors: - - self.DivisionByZero + - self.Error.DivisionByZero - name: Clear description: > Reset the LastResult property to zero. diff --git a/tools/sdbusplus/templates/error.mako.cpp b/tools/sdbusplus/templates/error.mako.cpp index 933ddcb..62cc541 100644 --- a/tools/sdbusplus/templates/error.mako.cpp +++ b/tools/sdbusplus/templates/error.mako.cpp @@ -6,7 +6,7 @@ namespace sdbusplus namespace ${s} { % endfor -namespace common +namespace Error { % for e in error.errors: const char* ${e.name}::what() const noexcept @@ -15,7 +15,7 @@ const char* ${e.name}::what() const noexcept } % endfor -} // namespace common +} // namespace Error % for s in reversed(namespaces): } // namespace ${s} % endfor diff --git a/tools/sdbusplus/templates/error.mako.hpp b/tools/sdbusplus/templates/error.mako.hpp index 9f4f7f8..51f4860 100644 --- a/tools/sdbusplus/templates/error.mako.hpp +++ b/tools/sdbusplus/templates/error.mako.hpp @@ -8,7 +8,7 @@ namespace sdbusplus namespace ${s} { % endfor -namespace common +namespace Error { % for e in error.errors: @@ -22,7 +22,7 @@ struct ${e.name} : public sdbusplus::exception_t }; % endfor -} // namespace common +} // namespace Error % for s in reversed(namespaces): } // namespace ${s} % endfor diff --git a/tools/sdbusplus/templates/method.mako.prototype.hpp b/tools/sdbusplus/templates/method.mako.prototype.hpp index 20a4373..d9c1ec7 100644 --- a/tools/sdbusplus/templates/method.mako.prototype.hpp +++ b/tools/sdbusplus/templates/method.mako.prototype.hpp @@ -55,7 +55,9 @@ return e.split('.').pop(); def error_include(e): - return '/'.join(error_namespace(e).split('::')) + '/error.hpp'; + l = error_namespace(e).split('::') + l.pop() # Remove "Error" + return '/'.join(l) + '/error.hpp'; %> ### @@ -140,7 +142,7 @@ int ${interface_name()}::_callback_${ method.CamelCase }( return -EINVAL; } % for e in method.errors: - catch(sdbusplus::${error_namespace(e)}::common::${error_name(e)}& e) + catch(sdbusplus::${error_namespace(e)}::${error_name(e)}& e) { auto name = e.what(); sd_bus_error_set_const(error, name, name); -- cgit v1.2.3