mirror of
https://github.com/hyprwm/hyprwayland-scanner.git
synced 2025-12-20 09:10:02 +01:00
Compare commits
26 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6cf414ca0 | ||
|
|
b3b0f1f40a | ||
| fcca0c61f9 | |||
| 8fb426b3e5 | |||
| aa38edd6e3 | |||
|
|
817918315e | ||
|
|
e511882b9c | ||
|
|
206367a08d | ||
| 04146df74a | |||
| de913476b5 | |||
| 4a53f1acc7 | |||
| 3d6681fd35 | |||
| c0c13f07a0 | |||
| 4d7367b6ee | |||
|
|
90e87f7fcf | ||
| 500c81a9e1 | |||
| b68dab23fc | |||
| 96d33362e6 | |||
| eebf1cb749 | |||
| 9df631193a | |||
| 4d3d80fcb1 | |||
| f68f159255 | |||
| a048a6cb01 | |||
| 8907e8a64e | |||
| 4a1f262f37 | |||
| 117b6d93ed |
7 changed files with 124 additions and 61 deletions
31
.github/workflows/nix.yml
vendored
31
.github/workflows/nix.yml
vendored
|
|
@ -7,8 +7,35 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: cachix/install-nix-action@v25
|
- name: Install Nix
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
uses: nixbuild/nix-quick-install-action@v31
|
||||||
|
with:
|
||||||
|
nix_conf: |
|
||||||
|
keep-env-derivations = true
|
||||||
|
keep-outputs = true
|
||||||
|
|
||||||
|
- name: Restore and save Nix store
|
||||||
|
uses: nix-community/cache-nix-action@v6
|
||||||
|
with:
|
||||||
|
# restore and save a cache using this key
|
||||||
|
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
|
||||||
|
# if there's no cache hit, restore a cache by this prefix
|
||||||
|
restore-prefixes-first-match: nix-${{ runner.os }}-
|
||||||
|
# collect garbage until the Nix store size (in bytes) is at most this number
|
||||||
|
# before trying to save a new cache
|
||||||
|
# 1G = 1073741824
|
||||||
|
gc-max-store-size-linux: 1G
|
||||||
|
# do purge caches
|
||||||
|
purge: true
|
||||||
|
# purge all versions of the cache
|
||||||
|
purge-prefixes: nix-${{ runner.os }}-
|
||||||
|
# created more than this number of seconds ago
|
||||||
|
purge-created: 0
|
||||||
|
# or, last accessed more than this number of seconds ago
|
||||||
|
# relative to the start of the `Post Restore and save Nix store` phase
|
||||||
|
purge-last-accessed: 0
|
||||||
|
# except any version with the key that is the same as the `primary-key`
|
||||||
|
purge-primary-key: never
|
||||||
|
|
||||||
# not needed (yet)
|
# not needed (yet)
|
||||||
# - uses: cachix/cachix-action@v12
|
# - uses: cachix/cachix-action@v12
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
cmake_minimum_required(VERSION 3.19)
|
cmake_minimum_required(VERSION 3.19)
|
||||||
|
|
||||||
set(VERSION 0.4.0)
|
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
|
||||||
|
string(STRIP ${VER_RAW} VERSION)
|
||||||
|
|
||||||
project(hyprwayland-scanner
|
project(
|
||||||
DESCRIPTION "A hyprland version of wayland-scanner in and for C++"
|
hyprwayland-scanner
|
||||||
VERSION ${VERSION}
|
DESCRIPTION "A hyprland version of wayland-scanner in and for C++"
|
||||||
)
|
VERSION ${VERSION})
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
@ -15,18 +16,17 @@ set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||||
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
message(STATUS "Configuring hyprwayland-scanner in Debug with CMake")
|
message(STATUS "Configuring hyprwayland-scanner in Debug with CMake")
|
||||||
add_compile_definitions(HYPRLAND_DEBUG)
|
add_compile_definitions(HYPRLAND_DEBUG)
|
||||||
else()
|
else()
|
||||||
add_compile_options(-O3)
|
add_compile_options(-O3)
|
||||||
message(STATUS "Configuring hyprwayland-scanner in Release with CMake")
|
message(STATUS "Configuring hyprwayland-scanner in Release with CMake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# configure
|
# configure
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
||||||
-Wno-missing-field-initializers -Wno-narrowing)
|
-Wno-missing-field-initializers -Wno-narrowing)
|
||||||
|
|
||||||
add_compile_definitions(SCANNER_VERSION="${VERSION}")
|
add_compile_definitions(SCANNER_VERSION="${VERSION}")
|
||||||
|
|
||||||
|
|
@ -41,25 +41,29 @@ pkg_check_modules(deps REQUIRED IMPORTED_TARGET pugixml)
|
||||||
|
|
||||||
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
||||||
add_executable(hyprwayland-scanner ${SRCFILES})
|
add_executable(hyprwayland-scanner ${SRCFILES})
|
||||||
target_link_libraries(hyprwayland-scanner PRIVATE rt Threads::Threads PkgConfig::deps)
|
find_library(librt rt)
|
||||||
|
if("${librt}" MATCHES "librt-NOTFOUND")
|
||||||
|
unset(LIBRT)
|
||||||
|
else()
|
||||||
|
set(LIBRT rt)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(hyprwayland-scanner PRIVATE ${LIBRT} Threads::Threads
|
||||||
|
PkgConfig::deps)
|
||||||
|
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
hyprwayland-scanner-config.cmake.in
|
hyprwayland-scanner-config.cmake.in hyprwayland-scanner-config.cmake
|
||||||
hyprwayland-scanner-config.cmake
|
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hyprwayland-scanner"
|
||||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hyprwayland-scanner"
|
PATH_VARS CMAKE_INSTALL_BINDIR)
|
||||||
PATH_VARS CMAKE_INSTALL_BINDIR
|
|
||||||
)
|
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
"hyprwayland-scanner-config-version.cmake"
|
"hyprwayland-scanner-config-version.cmake"
|
||||||
VERSION "${VERSION}"
|
VERSION "${VERSION}"
|
||||||
COMPATIBILITY AnyNewerVersion
|
ARCH_INDEPENDENT
|
||||||
)
|
COMPATIBILITY AnyNewerVersion)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
install(TARGETS hyprwayland-scanner)
|
install(TARGETS hyprwayland-scanner)
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/hyprwayland-scanner.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
install(FILES ${CMAKE_BINARY_DIR}/hyprwayland-scanner.pc
|
||||||
install(FILES
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
${CMAKE_BINARY_DIR}/hyprwayland-scanner-config.cmake
|
install(FILES ${CMAKE_BINARY_DIR}/hyprwayland-scanner-config.cmake
|
||||||
${CMAKE_BINARY_DIR}/hyprwayland-scanner-config-version.cmake
|
${CMAKE_BINARY_DIR}/hyprwayland-scanner-config-version.cmake
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hyprwayland-scanner
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hyprwayland-scanner)
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,20 @@
|
||||||
# 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
|
||||||
hyprwayland-scanner '/path/to/proto' '/path/to/output/directory'
|
hyprwayland-scanner '/path/to/proto' '/path/to/output/directory'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
- `--client` -> generate client code
|
||||||
|
- `--wayland-enums` -> use wayland enum naming (snake instead of camel)
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
Requires a compiler with C++23 support.
|
Requires a compiler with C++23 support.
|
||||||
|
|
|
||||||
1
VERSION
Normal file
1
VERSION
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
0.4.5
|
||||||
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1717974879,
|
"lastModified": 1748929857,
|
||||||
"narHash": "sha256-GTO3C88+5DX171F/gVS3Qga/hOs/eRMxPFpiHq2t+D8=",
|
"narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "c7b821ba2e1e635ba5a76d299af62821cbcb09f3",
|
"rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,15 @@
|
||||||
(builtins.substring 4 2 longDate)
|
(builtins.substring 4 2 longDate)
|
||||||
(builtins.substring 6 2 longDate)
|
(builtins.substring 6 2 longDate)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
version = lib.removeSuffix "\n" (builtins.readFile ./VERSION);
|
||||||
in {
|
in {
|
||||||
overlays = {
|
overlays = {
|
||||||
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.gcc15Stdenv;
|
||||||
version = "0.1.0" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
version = version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
75
src/main.cpp
75
src/main.cpp
|
|
@ -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_";
|
||||||
|
|
@ -107,11 +111,16 @@ std::string WPTypeToCType(const SRequestArgument& arg, bool event /* events pass
|
||||||
return "uint32_t";
|
return "uint32_t";
|
||||||
|
|
||||||
// enum
|
// enum
|
||||||
if (!arg.enumName.empty())
|
if (!arg.enumName.empty()) {
|
||||||
for (auto& e : XMLDATA.enums) {
|
for (auto& e : XMLDATA.enums) {
|
||||||
if (e.nameOriginal == arg.enumName)
|
if (e.nameOriginal == arg.enumName)
|
||||||
return e.name;
|
return e.name;
|
||||||
}
|
}
|
||||||
|
return "uint32_t";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event && clientCode && arg.wlType == "new_id")
|
||||||
|
return "wl_proxy*";
|
||||||
|
|
||||||
// iface
|
// iface
|
||||||
if (!arg.interface.empty() && event) {
|
if (!arg.interface.empty() && event) {
|
||||||
|
|
@ -119,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";
|
||||||
|
|
@ -131,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";
|
||||||
|
|
@ -236,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>
|
||||||
|
|
@ -248,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) {
|
||||||
|
|
@ -319,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"#(
|
||||||
|
|
@ -377,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;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
@ -488,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;
|
||||||
|
|
||||||
|
|
@ -502,6 +516,8 @@ class {} {{
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseSource() {
|
void parseSource() {
|
||||||
|
std::string DUMMY_TYPE_TABLE_NAME = PROTO_DATA.name + "_dummyTypes";
|
||||||
|
|
||||||
SOURCE += std::format(R"#(#define private public
|
SOURCE += std::format(R"#(#define private public
|
||||||
#define HYPRWAYLAND_SCANNER_NO_INTERFACES
|
#define HYPRWAYLAND_SCANNER_NO_INTERFACES
|
||||||
#include "{}.hpp"
|
#include "{}.hpp"
|
||||||
|
|
@ -513,9 +529,9 @@ void parseSource() {
|
||||||
// reference interfaces
|
// reference interfaces
|
||||||
|
|
||||||
// dummy
|
// dummy
|
||||||
SOURCE += R"#(
|
SOURCE += std::format(R"#(
|
||||||
static const wl_interface* dummyTypes[] = { nullptr };
|
static const wl_interface* {}[] = {{ nullptr }};
|
||||||
)#";
|
)#", DUMMY_TYPE_TABLE_NAME);
|
||||||
|
|
||||||
SOURCE += R"#(
|
SOURCE += R"#(
|
||||||
// Reference all other interfaces.
|
// Reference all other interfaces.
|
||||||
|
|
@ -647,6 +663,10 @@ static const void* {}[] = {{
|
||||||
SOURCE += std::format(" (void*){},\n", REQUEST_NAME);
|
SOURCE += std::format(" (void*){},\n", REQUEST_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((clientCode ? iface.events : iface.requests).empty()) {
|
||||||
|
SOURCE += " nullptr,\n";
|
||||||
|
}
|
||||||
|
|
||||||
SOURCE += "};\n";
|
SOURCE += "};\n";
|
||||||
|
|
||||||
// create events
|
// create events
|
||||||
|
|
@ -670,8 +690,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, ");
|
||||||
|
|
@ -698,12 +718,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(pResource, {}, {}, wl_proxy_get_version(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++;
|
||||||
|
|
@ -804,7 +824,8 @@ static const wl_message {}[] = {{
|
||||||
// create type table
|
// create type table
|
||||||
const auto TYPE_TABLE_NAME = camelize(std::string{"_"} + "C_" + IFACE_NAME + "_" + rq.name + "_types");
|
const auto TYPE_TABLE_NAME = camelize(std::string{"_"} + "C_" + IFACE_NAME + "_" + rq.name + "_types");
|
||||||
|
|
||||||
SOURCE += std::format(" {{ \"{}\", \"{}\", {}}},\n", rq.name, argsToShort(rq.args, rq.since), rq.args.empty() ? "dummyTypes + 0" : TYPE_TABLE_NAME + " + 0");
|
SOURCE += std::format(" {{ .name = \"{}\", .signature = \"{}\", .types = {}}},\n", rq.name, argsToShort(rq.args, rq.since),
|
||||||
|
rq.args.empty() ? std::format("{} + 0", DUMMY_TYPE_TABLE_NAME) : TYPE_TABLE_NAME + " + 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
SOURCE += "};\n";
|
SOURCE += "};\n";
|
||||||
|
|
@ -819,7 +840,8 @@ static const wl_message {}[] = {{
|
||||||
// create type table
|
// create type table
|
||||||
const auto TYPE_TABLE_NAME = camelize(std::string{"_"} + "C_" + IFACE_NAME + "_" + ev.name + "_types");
|
const auto TYPE_TABLE_NAME = camelize(std::string{"_"} + "C_" + IFACE_NAME + "_" + ev.name + "_types");
|
||||||
|
|
||||||
SOURCE += std::format(" {{ \"{}\", \"{}\", {}}},\n", ev.name, argsToShort(ev.args, ev.since), ev.args.empty() ? "dummyTypes + 0" : TYPE_TABLE_NAME + " + 0");
|
SOURCE += std::format(" {{ .name = \"{}\", .signature = \"{}\", .types = {}}},\n", ev.name, argsToShort(ev.args, ev.since),
|
||||||
|
ev.args.empty() ? std::format("{} + 0", DUMMY_TYPE_TABLE_NAME) : TYPE_TABLE_NAME + " + 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
SOURCE += "};\n";
|
SOURCE += "};\n";
|
||||||
|
|
@ -828,9 +850,9 @@ static const wl_message {}[] = {{
|
||||||
// iface
|
// iface
|
||||||
SOURCE += std::format(R"#(
|
SOURCE += std::format(R"#(
|
||||||
const wl_interface {} = {{
|
const wl_interface {} = {{
|
||||||
"{}", {},
|
.name = "{}", .version = {},
|
||||||
{}, {},
|
.method_count = {}, .methods = {},
|
||||||
{}, {},
|
.event_count = {}, .events = {},
|
||||||
}};
|
}};
|
||||||
)#",
|
)#",
|
||||||
IFACE_WL_NAME, iface.name, iface.version, iface.requests.size(), (iface.requests.size() > 0 ? MESSAGE_NAME_REQUESTS : "nullptr"),
|
IFACE_WL_NAME, iface.name, iface.version, iface.requests.size(), (iface.requests.size() > 0 ? MESSAGE_NAME_REQUESTS : "nullptr"),
|
||||||
|
|
@ -840,8 +862,8 @@ const wl_interface {} = {{
|
||||||
// protocol body
|
// protocol body
|
||||||
if (!clientCode) {
|
if (!clientCode) {
|
||||||
SOURCE += std::format(R"#(
|
SOURCE += std::format(R"#(
|
||||||
{}::{}(wl_client* client, uint32_t version, uint32_t id) {{
|
{}::{}(wl_client* client, uint32_t version, uint32_t id) :
|
||||||
pResource = wl_resource_create(client, &{}, version, id);
|
pResource(wl_resource_create(client, &{}, version, id)) {{
|
||||||
|
|
||||||
if (!pResource)
|
if (!pResource)
|
||||||
return;
|
return;
|
||||||
|
|
@ -898,8 +920,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)
|
||||||
return;
|
return;
|
||||||
|
|
@ -1045,4 +1066,4 @@ int main(int argc, char** argv, char** envp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue