scanner: add defines for wayland interface versions

Currently, it is cumbersome for clients that want to know what version of an
interface is supported at compile time. This can especially matter in cases
where the compositor and client aren't neccesarily compiled against the same
wayland and wayland protocol versions. Provide more information by adding a
simple int define for all interfaces that give the version that is already
defined in the source xml file.

Signed-off-by: Dudemanguy <random342@airmail.cc>
This commit is contained in:
Dudemanguy 2024-04-25 18:29:43 -05:00
parent 6137c8c213
commit ab4c580480
9 changed files with 262 additions and 0 deletions

View file

@ -1101,6 +1101,16 @@ format_text_to_comment(const char *text, bool standalone_comment)
printf(" */\n\n");
}
static void
emit_max_interface_version(struct interface *interface)
{
printf("/**\n * @ingroup iface_%s\n */\n", interface->name);
printf("#define %s_MAX_VERSION %d\n",
interface->uppercase_name, interface->version);
printf("\n");
}
static void
emit_opcodes(struct wl_list *message_list, struct interface *interface)
{
@ -1776,12 +1786,14 @@ emit_header(struct protocol *protocol, enum side side)
if (side == SERVER) {
emit_structs(&i->request_list, i, side);
emit_max_interface_version(i);
emit_opcodes(&i->event_list, i);
emit_opcode_versions(&i->event_list, i);
emit_opcode_versions(&i->request_list, i);
emit_event_wrappers(&i->event_list, i);
} else {
emit_structs(&i->event_list, i, side);
emit_max_interface_version(i);
emit_opcodes(&i->request_list, i);
emit_opcode_versions(&i->event_list, i);
emit_opcode_versions(&i->request_list, i);