add no iface

This commit is contained in:
Vaxry 2024-06-18 15:57:26 +02:00
parent 85f1334c51
commit b860f59da9
1 changed files with 34 additions and 26 deletions

View File

@ -10,6 +10,7 @@
bool waylandEnums = false; bool waylandEnums = false;
bool clientCode = false; bool clientCode = false;
bool noInterfaces = false;
struct SRequestArgument { struct SRequestArgument {
std::string wlType; std::string wlType;
@ -661,7 +662,7 @@ void {}::{}({}) {{
)#", )#",
IFACE_CLASS_NAME_CAMEL, EVENT_NAME, argsC, evid, argsN); IFACE_CLASS_NAME_CAMEL, EVENT_NAME, argsC, evid, argsN);
} else { } else {
std::string retType = ev.newIdType.empty() ? "void" : camelize("C_" + ev.newIdType); std::string retType = ev.newIdType.empty() ? "void" : camelize("C_" + ev.newIdType);
std::string ptrRetType = ev.newIdType.empty() ? "void" : camelize("C_" + ev.newIdType) + "*"; std::string ptrRetType = ev.newIdType.empty() ? "void" : camelize("C_" + ev.newIdType) + "*";
std::string flags = ev.destructor ? "1" : "0"; std::string flags = ev.destructor ? "1" : "0";
SOURCE += std::format(R"#( SOURCE += std::format(R"#(
@ -761,46 +762,48 @@ void {}::{}({}) {{
const auto MESSAGE_NAME_EVENTS = camelize(std::string{"_"} + "C_" + IFACE_NAME + "_events"); const auto MESSAGE_NAME_EVENTS = camelize(std::string{"_"} + "C_" + IFACE_NAME + "_events");
// message // message
if (iface.requests.size() > 0) { if (!noInterfaces) {
SOURCE += std::format(R"#( if (iface.requests.size() > 0) {
SOURCE += std::format(R"#(
static const wl_message {}[] = {{ static const wl_message {}[] = {{
)#", )#",
MESSAGE_NAME_REQUESTS); MESSAGE_NAME_REQUESTS);
for (auto& rq : iface.requests) { for (auto& rq : iface.requests) {
// 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(" {{ \"{}\", \"{}\", {}}},\n", rq.name, argsToShort(rq.args, rq.since), rq.args.empty() ? "dummyTypes + 0" : TYPE_TABLE_NAME + " + 0");
}
SOURCE += "};\n";
} }
SOURCE += "};\n"; if (iface.events.size() > 0) {
} SOURCE += std::format(R"#(
if (iface.events.size() > 0) {
SOURCE += std::format(R"#(
static const wl_message {}[] = {{ static const wl_message {}[] = {{
)#", )#",
MESSAGE_NAME_EVENTS); MESSAGE_NAME_EVENTS);
for (auto& ev : iface.events) { for (auto& ev : iface.events) {
// 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(" {{ \"{}\", \"{}\", {}}},\n", ev.name, argsToShort(ev.args, ev.since), ev.args.empty() ? "dummyTypes + 0" : TYPE_TABLE_NAME + " + 0");
}
SOURCE += "};\n";
} }
SOURCE += "};\n"; // iface
} SOURCE += std::format(R"#(
const wl_interface {} = {{false
// iface
SOURCE += std::format(R"#(
const wl_interface {} = {{
"{}", {}, "{}", {},
{}, {}, {}, {},
{}, {}, {}, {},
}}; }};
)#", )#",
IFACE_WL_NAME, iface.name, iface.version, iface.requests.size(), (iface.requests.size() > 0 ? MESSAGE_NAME_REQUESTS : "nullptr"), iface.events.size(), IFACE_WL_NAME, iface.name, iface.version, iface.requests.size(), (iface.requests.size() > 0 ? MESSAGE_NAME_REQUESTS : "nullptr"),
(iface.events.size() > 0 ? MESSAGE_NAME_EVENTS : "nullptr")); iface.events.size(), (iface.events.size() > 0 ? MESSAGE_NAME_EVENTS : "nullptr"));
}
// protocol body // protocol body
if (!clientCode) { if (!clientCode) {
@ -906,6 +909,11 @@ int main(int argc, char** argv, char** envp) {
continue; continue;
} }
if (curarg == "--no-interfaces") {
noInterfaces = true;
continue;
}
if (curarg == "--wayland-enums") { if (curarg == "--wayland-enums") {
waylandEnums = true; waylandEnums = true;
continue; continue;