Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: member + designated init and remove redundant cast #14

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ 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(pResource, {}, {}, wl_proxy_get_version(pResource), {}{});{}
}}
)#",
ptrRetType, IFACE_CLASS_NAME_CAMEL, EVENT_NAME, argsC, (ev.newIdType.empty() ? "" : " nullptr"),
Expand Down Expand Up @@ -818,7 +818,7 @@ static const wl_message {}[] = {{
// create type table
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() ? "dummyTypes + 0" : TYPE_TABLE_NAME + " + 0");
}

SOURCE += "};\n";
Expand All @@ -833,7 +833,7 @@ static const wl_message {}[] = {{
// create type table
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() ? "dummyTypes + 0" : TYPE_TABLE_NAME + " + 0");
}

SOURCE += "};\n";
Expand All @@ -842,9 +842,9 @@ static const wl_message {}[] = {{
// iface
SOURCE += std::format(R"#(
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"),
Expand All @@ -854,8 +854,8 @@ const wl_interface {} = {{
// protocol body
if (!clientCode) {
SOURCE += std::format(R"#(
{}::{}(wl_client* client, uint32_t version, uint32_t id) {{
pResource = wl_resource_create(client, &{}, version, id);
{}::{}(wl_client* client, uint32_t version, uint32_t id) :
pResource(wl_resource_create(client, &{}, version, id)) {{

if (!pResource)
return;
Expand Down Expand Up @@ -912,8 +912,7 @@ void {}::onDestroyCalled() {{
DTOR_FUNC = "wl_proxy_destroy(pResource)";

SOURCE += std::format(R"#(
{}::{}(wl_proxy* resource) {{
pResource = resource;
{}::{}(wl_proxy* resource) : pResource(resource) {{

if (!pResource)
return;
Expand Down Expand Up @@ -1059,4 +1058,4 @@ int main(int argc, char** argv, char** envp) {
}

return 0;
}
}