From f6dbe63aff2e8989d41db41da5ba28ae723e0d37 Mon Sep 17 00:00:00 2001 From: "alan (NyxTrail)" Date: Sun, 2 Mar 2025 10:20:27 +0000 Subject: [PATCH] New upstream version 0.4.4 --- README.md | 3 +++ VERSION | 2 +- flake.lock | 6 +++--- flake.nix | 2 +- src/main.cpp | 37 +++++++++++++++++++++++-------------- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 0992594..1b71f2a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # hyprwayland-scanner A Hyprland implementation of wayland-scanner, in and for C++. +hw-s automatically generates properly RAII-ready, modern C++ bindings for Wayland protocols, for +either servers or clients. + ## Usage ```sh diff --git a/VERSION b/VERSION index 2b7c5ae..6f2743d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.2 +0.4.4 diff --git a/flake.lock b/flake.lock index aeb7fc2..184825a 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1721138476, - "narHash": "sha256-+W5eZOhhemLQxelojLxETfbFbc19NWawsXBlapYpqIA=", + "lastModified": 1734119587, + "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ad0b5eed1b6031efaed382844806550c3dcb4206", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6d4473b..4fcf4a7 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,7 @@ default = self.overlays.hyprwayland-scanner; hyprwayland-scanner = final: prev: { hyprwayland-scanner = final.callPackage ./nix/default.nix { - stdenv = final.gcc13Stdenv; + stdenv = final.gcc14Stdenv; version = version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); }; }; diff --git a/src/main.cpp b/src/main.cpp index 8cb6429..0bce456 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,6 +47,10 @@ struct { std::vector enums; } XMLDATA; +const char* resourceName() { + return clientCode ? "wl_proxy" : "wl_resource"; +} + std::string sanitize(const std::string& in) { if (in == "namespace") return "namespace_"; @@ -124,7 +128,7 @@ std::string WPTypeToCType(const SRequestArgument& arg, bool event /* events pass if (i.name == arg.interface) return camelize((clientCode ? "CC_" : "C_") + arg.interface + "*"); } - return "wl_resource*"; + return std::string{resourceName()} + "*"; } return "uint32_t"; @@ -136,7 +140,7 @@ std::string WPTypeToCType(const SRequestArgument& arg, bool event /* events pass return camelize((clientCode ? "CC_" : "C_") + arg.interface + "*"); } } - return "wl_resource*"; + return std::string{resourceName()} + "*"; } if (arg.wlType == "int" || arg.wlType == "fd") return "int32_t"; @@ -241,7 +245,8 @@ void parseXML(pugi::xml_document& doc) { void parseHeader() { // add some boilerplate - HEADER += std::format(R"#(#pragma once + HEADER += + std::format(R"#(#pragma once #include #include @@ -253,8 +258,7 @@ void parseHeader() { {} )#", - (clientCode ? "#include " : "#include "), - (clientCode ? "struct wl_proxy;\ntypedef wl_proxy wl_resource;" : "struct wl_client;\nstruct wl_resource;")); + (clientCode ? "#include " : "#include "), (clientCode ? "struct wl_proxy;" : "struct wl_client;\nstruct wl_resource;")); // parse all enums if (!waylandEnums) { @@ -324,7 +328,7 @@ class {} {{ ~{}(); )#", - 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_proxy*" : "wl_client* client, uint32_t version, uint32_t id"), IFACE_CLASS_NAME_CAMEL); if (!clientCode) { HEADER += std::format(R"#( @@ -382,7 +386,12 @@ class {} {{ }} // get the raw wl_resource (wl_proxy) ptr - wl_resource* resource() {{ + wl_proxy* resource() {{ + return pResource; + }} + + // get the raw wl_proxy ptr + wl_proxy* proxy() {{ return pResource; }} @@ -493,7 +502,7 @@ class {} {{ IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL); } else { HEADER += R"#( - wl_resource* pResource = nullptr; + wl_proxy* pResource = nullptr; bool destroyed = false; @@ -675,8 +684,8 @@ static const void* {}[] = {{ std::string argsN = ", "; for (auto& arg : ev.args) { if (arg.newType) - continue; - if (!WPTypeToCType(arg, true).starts_with("C")) + argsN += "nullptr, "; + else if (!WPTypeToCType(arg, true).starts_with("C")) argsN += arg.name + ", "; else argsN += (arg.name + " ? " + arg.name + "->pResource : nullptr, "); @@ -703,12 +712,12 @@ void {}::{}({}) {{ if (!pResource) return{};{} - auto proxy = wl_proxy_marshal_flags((wl_proxy*)pResource, {}, {}, wl_proxy_get_version((wl_proxy*)pResource), {}{}{});{} + auto proxy = wl_proxy_marshal_flags((wl_proxy*)pResource, {}, {}, wl_proxy_get_version((wl_proxy*)pResource), {}{});{} }} )#", ptrRetType, IFACE_CLASS_NAME_CAMEL, EVENT_NAME, argsC, (ev.newIdType.empty() ? "" : " nullptr"), - (ev.destructor ? "\n destroyed = true;" : ""), evid, (ev.newIdType.empty() ? "nullptr" : "&" + ev.newIdType + "_interface"), flags, - (!ev.newIdType.empty() ? ", nullptr" : ""), argsN, (ev.newIdType.empty() ? "\n proxy;" : "\n\n return proxy;")); + (ev.destructor ? "\n destroyed = true;" : ""), evid, (ev.newIdType.empty() ? "nullptr" : "&" + ev.newIdType + "_interface"), flags, argsN, + (ev.newIdType.empty() ? "\n proxy;" : "\n\n return proxy;")); } evid++; @@ -903,7 +912,7 @@ void {}::onDestroyCalled() {{ DTOR_FUNC = "wl_proxy_destroy(pResource)"; SOURCE += std::format(R"#( -{}::{}(wl_resource* resource) {{ +{}::{}(wl_proxy* resource) {{ pResource = resource; if (!pResource)