async: server: avoid ambiguous base-class error
Fix the same ambigous base-class error in the async::server
classes as was fixed for the async::client with Change
I047f00ca8df071eef13e8fdd71a56910cc7b3e26.
When the async::server is used with multiple interfaces, there was
an ambiguous base-class error in the helper class used to derive the
async::context from `this`. Turn it into a static function with
a `self` parameter instead of relying on `this`.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If985dbb5197feaec0f4b874a16994400ab88a9e6
diff --git a/include/sdbusplus/async/server.hpp b/include/sdbusplus/async/server.hpp
index 43d023b..2a3a960 100644
--- a/include/sdbusplus/async/server.hpp
+++ b/include/sdbusplus/async/server.hpp
@@ -44,10 +44,10 @@
*/
struct server_context_friend
{
- template <typename T>
- sdbusplus::async::context& context()
+ template <typename Client, typename Self>
+ static sdbusplus::async::context& context(Self* self)
{
- return static_cast<T*>(this)->ctx;
+ return static_cast<Client*>(self)->ctx;
}
};
diff --git a/tools/sdbusplus/templates/interface.aserver.hpp.mako b/tools/sdbusplus/templates/interface.aserver.hpp.mako
index 0c10273..7592c82 100644
--- a/tools/sdbusplus/templates/interface.aserver.hpp.mako
+++ b/tools/sdbusplus/templates/interface.aserver.hpp.mako
@@ -94,7 +94,8 @@
/** @return the async context */
sdbusplus::async::context& _context()
{
- return server_details::server_context_friend::context<Server>();
+ return server_details::server_context_friend::
+ context<Server, ${interface.classname}>(this);
}
sdbusplus::server::interface_t