sdbus++: error: move cpp functions inline
All of the functions generated in the error.cpp files are trivial
accessors that likely emit smaller code by making them inline (since
a trivial member access should be cheaper than a function call).
Move them inline, which eliminates all content in the error.cpp and
would allow it to be removed from the generator.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If1de781e315b19334e025b47a2b26ca5e8ffbe04
diff --git a/tools/sdbusplus/templates/error.cpp.mako b/tools/sdbusplus/templates/error.cpp.mako
index 5859970..e69de29 100644
--- a/tools/sdbusplus/templates/error.cpp.mako
+++ b/tools/sdbusplus/templates/error.cpp.mako
@@ -1,36 +0,0 @@
-#include <${ '/'.join(error.name.split('.')) }/error.hpp>
-<% namespaces = error.name.split('.') %>
-namespace sdbusplus
-{
- % for s in namespaces:
-namespace ${s}
-{
- % endfor
-namespace Error
-{
- % for e in error.errors:
-const char* ${e.name}::name() const noexcept
-{
- return errName;
-}
-const char* ${e.name}::description() const noexcept
-{
- return errDesc;
-}
-const char* ${e.name}::what() const noexcept
-{
- return errWhat;
-}
- % if e.errno:
-int ${e.name}::get_errno() const noexcept
-{
- return errErrno;
-}
- % endif
- % endfor
-
-} // namespace Error
- % for s in reversed(namespaces):
-} // namespace ${s}
- % endfor
-} // namespace sdbusplus
diff --git a/tools/sdbusplus/templates/error.hpp.mako b/tools/sdbusplus/templates/error.hpp.mako
index 52e8fae..9200fc7 100644
--- a/tools/sdbusplus/templates/error.hpp.mako
+++ b/tools/sdbusplus/templates/error.hpp.mako
@@ -20,11 +20,23 @@
static constexpr auto errErrno = ${e.errno};
% endif
- const char* name() const noexcept override;
- const char* description() const noexcept override;
- const char* what() const noexcept override;
+ const char* name() const noexcept override
+ {
+ return errName;
+ }
+ const char* description() const noexcept override
+ {
+ return errDesc;
+ }
+ const char* what() const noexcept override
+ {
+ return errWhat;
+ }
% if e.errno:
- int get_errno() const noexcept override;
+ int get_errno() const noexcept override
+ {
+ return errErrno;
+ }
% endif
};
% endfor