From 55c78a56c0f6831a62945f8d3edc62ed827c575c Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 27 Jun 2024 00:24:36 +0200 Subject: [PATCH] client: do not define destroy listener in client mode fixes #9 --- src/main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 153ea3b..0623519 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -299,12 +299,19 @@ void parseHeader() { const auto IFACE_NAME_CAMEL = camelize(iface.name); const auto IFACE_CLASS_NAME_CAMEL = camelize((clientCode ? "CC_" : "C_") + iface.name); - // begin the class - HEADER += std::format(R"#( + if (!clientCode) { + HEADER += std::format(R"#( struct {}DestroyWrapper {{ wl_listener listener; {}* parent = nullptr; }}; + )#", + IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL); + } + + // begin the class + HEADER += + std::format(R"#( class {} {{ public: @@ -312,8 +319,7 @@ class {} {{ ~{}(); )#", - IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, - (clientCode ? "wl_resource*" : "wl_client* client, uint32_t version, uint32_t id"), IFACE_CLASS_NAME_CAMEL); + IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, (clientCode ? "wl_resource*" : "wl_client* client, uint32_t version, uint32_t id"), IFACE_CLASS_NAME_CAMEL); if (!clientCode) { HEADER += std::format(R"#(