Update upstream source from tag 'upstream/0.4.4'

Update to upstream version '0.4.4'
with Debian dir f4a9f057d8
This commit is contained in:
alan (NyxTrail) 2025-03-02 10:20:27 +00:00
commit 95d26cd408
5 changed files with 31 additions and 19 deletions

View File

@ -1,6 +1,9 @@
# hyprwayland-scanner # hyprwayland-scanner
A Hyprland implementation of wayland-scanner, in and for C++. 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 ## Usage
```sh ```sh

View File

@ -1 +1 @@
0.4.2 0.4.4

View File

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1721138476, "lastModified": 1734119587,
"narHash": "sha256-+W5eZOhhemLQxelojLxETfbFbc19NWawsXBlapYpqIA=", "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "ad0b5eed1b6031efaed382844806550c3dcb4206", "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -36,7 +36,7 @@
default = self.overlays.hyprwayland-scanner; default = self.overlays.hyprwayland-scanner;
hyprwayland-scanner = final: prev: { hyprwayland-scanner = final: prev: {
hyprwayland-scanner = final.callPackage ./nix/default.nix { 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"); version = version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
}; };
}; };

View File

@ -47,6 +47,10 @@ struct {
std::vector<SEnum> enums; std::vector<SEnum> enums;
} XMLDATA; } XMLDATA;
const char* resourceName() {
return clientCode ? "wl_proxy" : "wl_resource";
}
std::string sanitize(const std::string& in) { std::string sanitize(const std::string& in) {
if (in == "namespace") if (in == "namespace")
return "namespace_"; return "namespace_";
@ -124,7 +128,7 @@ std::string WPTypeToCType(const SRequestArgument& arg, bool event /* events pass
if (i.name == arg.interface) if (i.name == arg.interface)
return camelize((clientCode ? "CC_" : "C_") + arg.interface + "*"); return camelize((clientCode ? "CC_" : "C_") + arg.interface + "*");
} }
return "wl_resource*"; return std::string{resourceName()} + "*";
} }
return "uint32_t"; 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 camelize((clientCode ? "CC_" : "C_") + arg.interface + "*");
} }
} }
return "wl_resource*"; return std::string{resourceName()} + "*";
} }
if (arg.wlType == "int" || arg.wlType == "fd") if (arg.wlType == "int" || arg.wlType == "fd")
return "int32_t"; return "int32_t";
@ -241,7 +245,8 @@ void parseXML(pugi::xml_document& doc) {
void parseHeader() { void parseHeader() {
// add some boilerplate // add some boilerplate
HEADER += std::format(R"#(#pragma once HEADER +=
std::format(R"#(#pragma once
#include <functional> #include <functional>
#include <cstdint> #include <cstdint>
@ -253,8 +258,7 @@ void parseHeader() {
{} {}
)#", )#",
(clientCode ? "#include <wayland-client.h>" : "#include <wayland-server.h>"), (clientCode ? "#include <wayland-client.h>" : "#include <wayland-server.h>"), (clientCode ? "struct wl_proxy;" : "struct wl_client;\nstruct wl_resource;"));
(clientCode ? "struct wl_proxy;\ntypedef wl_proxy wl_resource;" : "struct wl_client;\nstruct wl_resource;"));
// parse all enums // parse all enums
if (!waylandEnums) { 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) { if (!clientCode) {
HEADER += std::format(R"#( HEADER += std::format(R"#(
@ -382,7 +386,12 @@ class {} {{
}} }}
// get the raw wl_resource (wl_proxy) ptr // 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; return pResource;
}} }}
@ -493,7 +502,7 @@ class {} {{
IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL); IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL);
} else { } else {
HEADER += R"#( HEADER += R"#(
wl_resource* pResource = nullptr; wl_proxy* pResource = nullptr;
bool destroyed = false; bool destroyed = false;
@ -675,8 +684,8 @@ static const void* {}[] = {{
std::string argsN = ", "; std::string argsN = ", ";
for (auto& arg : ev.args) { for (auto& arg : ev.args) {
if (arg.newType) if (arg.newType)
continue; argsN += "nullptr, ";
if (!WPTypeToCType(arg, true).starts_with("C")) else if (!WPTypeToCType(arg, true).starts_with("C"))
argsN += arg.name + ", "; argsN += arg.name + ", ";
else else
argsN += (arg.name + " ? " + arg.name + "->pResource : nullptr, "); argsN += (arg.name + " ? " + arg.name + "->pResource : nullptr, ");
@ -703,12 +712,12 @@ void {}::{}({}) {{
if (!pResource) if (!pResource)
return{};{} 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"), 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.destructor ? "\n destroyed = true;" : ""), evid, (ev.newIdType.empty() ? "nullptr" : "&" + ev.newIdType + "_interface"), flags, argsN,
(!ev.newIdType.empty() ? ", nullptr" : ""), argsN, (ev.newIdType.empty() ? "\n proxy;" : "\n\n return proxy;")); (ev.newIdType.empty() ? "\n proxy;" : "\n\n return proxy;"));
} }
evid++; evid++;
@ -903,7 +912,7 @@ void {}::onDestroyCalled() {{
DTOR_FUNC = "wl_proxy_destroy(pResource)"; DTOR_FUNC = "wl_proxy_destroy(pResource)";
SOURCE += std::format(R"#( SOURCE += std::format(R"#(
{}::{}(wl_resource* resource) {{ {}::{}(wl_proxy* resource) {{
pResource = resource; pResource = resource;
if (!pResource) if (!pResource)