New upstream version 0.4.4

This commit is contained in:
alan (NyxTrail) 2025-03-02 10:20:27 +00:00
parent da27435de4
commit f6dbe63aff
5 changed files with 31 additions and 19 deletions

View File

@ -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

View File

@ -1 +1 @@
0.4.2
0.4.4

View File

@ -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": {

View File

@ -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");
};
};

View File

@ -47,6 +47,10 @@ struct {
std::vector<SEnum> 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 <functional>
#include <cstdint>
@ -253,8 +258,7 @@ void parseHeader() {
{}
)#",
(clientCode ? "#include <wayland-client.h>" : "#include <wayland-server.h>"),
(clientCode ? "struct wl_proxy;\ntypedef wl_proxy wl_resource;" : "struct wl_client;\nstruct wl_resource;"));
(clientCode ? "#include <wayland-client.h>" : "#include <wayland-server.h>"), (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)