scanner: prepend protocol name to types symbol

When doing unity builds via meson (example project:
https://github.com/swaywm/sway) multiple source files are glued together
via #include directives. Having every wayland-scanner generated source
file have an identifier named '*types[]' will lead to errors in these
unity builds if two or more of these are joined.

Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
This commit is contained in:
Marty E. Plummer 2019-05-11 09:53:01 -05:00
parent a89a5349af
commit 9f004d8b0f
No known key found for this signature in database
GPG Key ID: 47BC0C716C0747F2
5 changed files with 140 additions and 140 deletions

View File

@ -1722,7 +1722,7 @@ emit_types(struct protocol *protocol, struct wl_list *message_list)
}
static void
emit_messages(struct wl_list *message_list,
emit_messages(const char *name, struct wl_list *message_list,
struct interface *interface, const char *suffix)
{
struct message *m;
@ -1775,7 +1775,7 @@ emit_messages(struct wl_list *message_list,
break;
}
}
printf("\", types + %d },\n", m->type_index);
printf("\", %s_types + %d },\n", name, m->type_index);
}
printf("};\n\n");
@ -1832,7 +1832,7 @@ emit_code(struct protocol *protocol, enum visibility vis)
wl_array_release(&types);
printf("\n");
printf("static const struct wl_interface *types[] = {\n");
printf("static const struct wl_interface *%s_types[] = {\n", protocol->name);
emit_null_run(protocol);
wl_list_for_each(i, &protocol->interface_list, link) {
emit_types(protocol, &i->request_list);
@ -1842,8 +1842,8 @@ emit_code(struct protocol *protocol, enum visibility vis)
wl_list_for_each_safe(i, next, &protocol->interface_list, link) {
emit_messages(&i->request_list, i, "requests");
emit_messages(&i->event_list, i, "events");
emit_messages(protocol->name, &i->request_list, i, "requests");
emit_messages(protocol->name, &i->event_list, i, "events");
printf("%s const struct wl_interface "
"%s_interface = {\n"

View File

@ -48,7 +48,7 @@ extern const struct wl_interface wl_subsurface_interface;
extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface wl_touch_interface;
static const struct wl_interface *types[] = {
static const struct wl_interface *wayland_types[] = {
NULL,
NULL,
NULL,
@ -147,13 +147,13 @@ static const struct wl_interface *types[] = {
};
static const struct wl_message wl_display_requests[] = {
{ "sync", "n", types + 8 },
{ "get_registry", "n", types + 9 },
{ "sync", "n", wayland_types + 8 },
{ "get_registry", "n", wayland_types + 9 },
};
static const struct wl_message wl_display_events[] = {
{ "error", "ous", types + 0 },
{ "delete_id", "u", types + 0 },
{ "error", "ous", wayland_types + 0 },
{ "delete_id", "u", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_display_interface = {
@ -163,12 +163,12 @@ WL_EXPORT const struct wl_interface wl_display_interface = {
};
static const struct wl_message wl_registry_requests[] = {
{ "bind", "usun", types + 0 },
{ "bind", "usun", wayland_types + 0 },
};
static const struct wl_message wl_registry_events[] = {
{ "global", "usu", types + 0 },
{ "global_remove", "u", types + 0 },
{ "global", "usu", wayland_types + 0 },
{ "global_remove", "u", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_registry_interface = {
@ -178,7 +178,7 @@ WL_EXPORT const struct wl_interface wl_registry_interface = {
};
static const struct wl_message wl_callback_events[] = {
{ "done", "u", types + 0 },
{ "done", "u", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_callback_interface = {
@ -188,8 +188,8 @@ WL_EXPORT const struct wl_interface wl_callback_interface = {
};
static const struct wl_message wl_compositor_requests[] = {
{ "create_surface", "n", types + 10 },
{ "create_region", "n", types + 11 },
{ "create_surface", "n", wayland_types + 10 },
{ "create_region", "n", wayland_types + 11 },
};
WL_EXPORT const struct wl_interface wl_compositor_interface = {
@ -199,9 +199,9 @@ WL_EXPORT const struct wl_interface wl_compositor_interface = {
};
static const struct wl_message wl_shm_pool_requests[] = {
{ "create_buffer", "niiiiu", types + 12 },
{ "destroy", "", types + 0 },
{ "resize", "i", types + 0 },
{ "create_buffer", "niiiiu", wayland_types + 12 },
{ "destroy", "", wayland_types + 0 },
{ "resize", "i", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_shm_pool_interface = {
@ -211,11 +211,11 @@ WL_EXPORT const struct wl_interface wl_shm_pool_interface = {
};
static const struct wl_message wl_shm_requests[] = {
{ "create_pool", "nhi", types + 18 },
{ "create_pool", "nhi", wayland_types + 18 },
};
static const struct wl_message wl_shm_events[] = {
{ "format", "u", types + 0 },
{ "format", "u", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_shm_interface = {
@ -225,11 +225,11 @@ WL_EXPORT const struct wl_interface wl_shm_interface = {
};
static const struct wl_message wl_buffer_requests[] = {
{ "destroy", "", types + 0 },
{ "destroy", "", wayland_types + 0 },
};
static const struct wl_message wl_buffer_events[] = {
{ "release", "", types + 0 },
{ "release", "", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_buffer_interface = {
@ -239,17 +239,17 @@ WL_EXPORT const struct wl_interface wl_buffer_interface = {
};
static const struct wl_message wl_data_offer_requests[] = {
{ "accept", "u?s", types + 0 },
{ "receive", "sh", types + 0 },
{ "destroy", "", types + 0 },
{ "finish", "3", types + 0 },
{ "set_actions", "3uu", types + 0 },
{ "accept", "u?s", wayland_types + 0 },
{ "receive", "sh", wayland_types + 0 },
{ "destroy", "", wayland_types + 0 },
{ "finish", "3", wayland_types + 0 },
{ "set_actions", "3uu", wayland_types + 0 },
};
static const struct wl_message wl_data_offer_events[] = {
{ "offer", "s", types + 0 },
{ "source_actions", "3u", types + 0 },
{ "action", "3u", types + 0 },
{ "offer", "s", wayland_types + 0 },
{ "source_actions", "3u", wayland_types + 0 },
{ "action", "3u", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_data_offer_interface = {
@ -259,18 +259,18 @@ WL_EXPORT const struct wl_interface wl_data_offer_interface = {
};
static const struct wl_message wl_data_source_requests[] = {
{ "offer", "s", types + 0 },
{ "destroy", "", types + 0 },
{ "set_actions", "3u", types + 0 },
{ "offer", "s", wayland_types + 0 },
{ "destroy", "", wayland_types + 0 },
{ "set_actions", "3u", wayland_types + 0 },
};
static const struct wl_message wl_data_source_events[] = {
{ "target", "?s", types + 0 },
{ "send", "sh", types + 0 },
{ "cancelled", "", types + 0 },
{ "dnd_drop_performed", "3", types + 0 },
{ "dnd_finished", "3", types + 0 },
{ "action", "3u", types + 0 },
{ "target", "?s", wayland_types + 0 },
{ "send", "sh", wayland_types + 0 },
{ "cancelled", "", wayland_types + 0 },
{ "dnd_drop_performed", "3", wayland_types + 0 },
{ "dnd_finished", "3", wayland_types + 0 },
{ "action", "3u", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_data_source_interface = {
@ -280,18 +280,18 @@ WL_EXPORT const struct wl_interface wl_data_source_interface = {
};
static const struct wl_message wl_data_device_requests[] = {
{ "start_drag", "?oo?ou", types + 21 },
{ "set_selection", "?ou", types + 25 },
{ "release", "2", types + 0 },
{ "start_drag", "?oo?ou", wayland_types + 21 },
{ "set_selection", "?ou", wayland_types + 25 },
{ "release", "2", wayland_types + 0 },
};
static const struct wl_message wl_data_device_events[] = {
{ "data_offer", "n", types + 27 },
{ "enter", "uoff?o", types + 28 },
{ "leave", "", types + 0 },
{ "motion", "uff", types + 0 },
{ "drop", "", types + 0 },
{ "selection", "?o", types + 33 },
{ "data_offer", "n", wayland_types + 27 },
{ "enter", "uoff?o", wayland_types + 28 },
{ "leave", "", wayland_types + 0 },
{ "motion", "uff", wayland_types + 0 },
{ "drop", "", wayland_types + 0 },
{ "selection", "?o", wayland_types + 33 },
};
WL_EXPORT const struct wl_interface wl_data_device_interface = {
@ -301,8 +301,8 @@ WL_EXPORT const struct wl_interface wl_data_device_interface = {
};
static const struct wl_message wl_data_device_manager_requests[] = {
{ "create_data_source", "n", types + 34 },
{ "get_data_device", "no", types + 35 },
{ "create_data_source", "n", wayland_types + 34 },
{ "get_data_device", "no", wayland_types + 35 },
};
WL_EXPORT const struct wl_interface wl_data_device_manager_interface = {
@ -312,7 +312,7 @@ WL_EXPORT const struct wl_interface wl_data_device_manager_interface = {
};
static const struct wl_message wl_shell_requests[] = {
{ "get_shell_surface", "no", types + 37 },
{ "get_shell_surface", "no", wayland_types + 37 },
};
WL_EXPORT const struct wl_interface wl_shell_interface = {
@ -322,22 +322,22 @@ WL_EXPORT const struct wl_interface wl_shell_interface = {
};
static const struct wl_message wl_shell_surface_requests[] = {
{ "pong", "u", types + 0 },
{ "move", "ou", types + 39 },
{ "resize", "ouu", types + 41 },
{ "set_toplevel", "", types + 0 },
{ "set_transient", "oiiu", types + 44 },
{ "set_fullscreen", "uu?o", types + 48 },
{ "set_popup", "ouoiiu", types + 51 },
{ "set_maximized", "?o", types + 57 },
{ "set_title", "s", types + 0 },
{ "set_class", "s", types + 0 },
{ "pong", "u", wayland_types + 0 },
{ "move", "ou", wayland_types + 39 },
{ "resize", "ouu", wayland_types + 41 },
{ "set_toplevel", "", wayland_types + 0 },
{ "set_transient", "oiiu", wayland_types + 44 },
{ "set_fullscreen", "uu?o", wayland_types + 48 },
{ "set_popup", "ouoiiu", wayland_types + 51 },
{ "set_maximized", "?o", wayland_types + 57 },
{ "set_title", "s", wayland_types + 0 },
{ "set_class", "s", wayland_types + 0 },
};
static const struct wl_message wl_shell_surface_events[] = {
{ "ping", "u", types + 0 },
{ "configure", "uii", types + 0 },
{ "popup_done", "", types + 0 },
{ "ping", "u", wayland_types + 0 },
{ "configure", "uii", wayland_types + 0 },
{ "popup_done", "", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_shell_surface_interface = {
@ -347,21 +347,21 @@ WL_EXPORT const struct wl_interface wl_shell_surface_interface = {
};
static const struct wl_message wl_surface_requests[] = {
{ "destroy", "", types + 0 },
{ "attach", "?oii", types + 58 },
{ "damage", "iiii", types + 0 },
{ "frame", "n", types + 61 },
{ "set_opaque_region", "?o", types + 62 },
{ "set_input_region", "?o", types + 63 },
{ "commit", "", types + 0 },
{ "set_buffer_transform", "2i", types + 0 },
{ "set_buffer_scale", "3i", types + 0 },
{ "damage_buffer", "4iiii", types + 0 },
{ "destroy", "", wayland_types + 0 },
{ "attach", "?oii", wayland_types + 58 },
{ "damage", "iiii", wayland_types + 0 },
{ "frame", "n", wayland_types + 61 },
{ "set_opaque_region", "?o", wayland_types + 62 },
{ "set_input_region", "?o", wayland_types + 63 },
{ "commit", "", wayland_types + 0 },
{ "set_buffer_transform", "2i", wayland_types + 0 },
{ "set_buffer_scale", "3i", wayland_types + 0 },
{ "damage_buffer", "4iiii", wayland_types + 0 },
};
static const struct wl_message wl_surface_events[] = {
{ "enter", "o", types + 64 },
{ "leave", "o", types + 65 },
{ "enter", "o", wayland_types + 64 },
{ "leave", "o", wayland_types + 65 },
};
WL_EXPORT const struct wl_interface wl_surface_interface = {
@ -371,15 +371,15 @@ WL_EXPORT const struct wl_interface wl_surface_interface = {
};
static const struct wl_message wl_seat_requests[] = {
{ "get_pointer", "n", types + 66 },
{ "get_keyboard", "n", types + 67 },
{ "get_touch", "n", types + 68 },
{ "release", "5", types + 0 },
{ "get_pointer", "n", wayland_types + 66 },
{ "get_keyboard", "n", wayland_types + 67 },
{ "get_touch", "n", wayland_types + 68 },
{ "release", "5", wayland_types + 0 },
};
static const struct wl_message wl_seat_events[] = {
{ "capabilities", "u", types + 0 },
{ "name", "2s", types + 0 },
{ "capabilities", "u", wayland_types + 0 },
{ "name", "2s", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_seat_interface = {
@ -389,20 +389,20 @@ WL_EXPORT const struct wl_interface wl_seat_interface = {
};
static const struct wl_message wl_pointer_requests[] = {
{ "set_cursor", "u?oii", types + 69 },
{ "release", "3", types + 0 },
{ "set_cursor", "u?oii", wayland_types + 69 },
{ "release", "3", wayland_types + 0 },
};
static const struct wl_message wl_pointer_events[] = {
{ "enter", "uoff", types + 73 },
{ "leave", "uo", types + 77 },
{ "motion", "uff", types + 0 },
{ "button", "uuuu", types + 0 },
{ "axis", "uuf", types + 0 },
{ "frame", "5", types + 0 },
{ "axis_source", "5u", types + 0 },
{ "axis_stop", "5uu", types + 0 },
{ "axis_discrete", "5ui", types + 0 },
{ "enter", "uoff", wayland_types + 73 },
{ "leave", "uo", wayland_types + 77 },
{ "motion", "uff", wayland_types + 0 },
{ "button", "uuuu", wayland_types + 0 },
{ "axis", "uuf", wayland_types + 0 },
{ "frame", "5", wayland_types + 0 },
{ "axis_source", "5u", wayland_types + 0 },
{ "axis_stop", "5uu", wayland_types + 0 },
{ "axis_discrete", "5ui", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_pointer_interface = {
@ -412,16 +412,16 @@ WL_EXPORT const struct wl_interface wl_pointer_interface = {
};
static const struct wl_message wl_keyboard_requests[] = {
{ "release", "3", types + 0 },
{ "release", "3", wayland_types + 0 },
};
static const struct wl_message wl_keyboard_events[] = {
{ "keymap", "uhu", types + 0 },
{ "enter", "uoa", types + 79 },
{ "leave", "uo", types + 82 },
{ "key", "uuuu", types + 0 },
{ "modifiers", "uuuuu", types + 0 },
{ "repeat_info", "4ii", types + 0 },
{ "keymap", "uhu", wayland_types + 0 },
{ "enter", "uoa", wayland_types + 79 },
{ "leave", "uo", wayland_types + 82 },
{ "key", "uuuu", wayland_types + 0 },
{ "modifiers", "uuuuu", wayland_types + 0 },
{ "repeat_info", "4ii", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_keyboard_interface = {
@ -431,17 +431,17 @@ WL_EXPORT const struct wl_interface wl_keyboard_interface = {
};
static const struct wl_message wl_touch_requests[] = {
{ "release", "3", types + 0 },
{ "release", "3", wayland_types + 0 },
};
static const struct wl_message wl_touch_events[] = {
{ "down", "uuoiff", types + 84 },
{ "up", "uui", types + 0 },
{ "motion", "uiff", types + 0 },
{ "frame", "", types + 0 },
{ "cancel", "", types + 0 },
{ "shape", "6iff", types + 0 },
{ "orientation", "6if", types + 0 },
{ "down", "uuoiff", wayland_types + 84 },
{ "up", "uui", wayland_types + 0 },
{ "motion", "uiff", wayland_types + 0 },
{ "frame", "", wayland_types + 0 },
{ "cancel", "", wayland_types + 0 },
{ "shape", "6iff", wayland_types + 0 },
{ "orientation", "6if", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_touch_interface = {
@ -451,14 +451,14 @@ WL_EXPORT const struct wl_interface wl_touch_interface = {
};
static const struct wl_message wl_output_requests[] = {
{ "release", "3", types + 0 },
{ "release", "3", wayland_types + 0 },
};
static const struct wl_message wl_output_events[] = {
{ "geometry", "iiiiissi", types + 0 },
{ "mode", "uiii", types + 0 },
{ "done", "2", types + 0 },
{ "scale", "2i", types + 0 },
{ "geometry", "iiiiissi", wayland_types + 0 },
{ "mode", "uiii", wayland_types + 0 },
{ "done", "2", wayland_types + 0 },
{ "scale", "2i", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_output_interface = {
@ -468,9 +468,9 @@ WL_EXPORT const struct wl_interface wl_output_interface = {
};
static const struct wl_message wl_region_requests[] = {
{ "destroy", "", types + 0 },
{ "add", "iiii", types + 0 },
{ "subtract", "iiii", types + 0 },
{ "destroy", "", wayland_types + 0 },
{ "add", "iiii", wayland_types + 0 },
{ "subtract", "iiii", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_region_interface = {
@ -480,8 +480,8 @@ WL_EXPORT const struct wl_interface wl_region_interface = {
};
static const struct wl_message wl_subcompositor_requests[] = {
{ "destroy", "", types + 0 },
{ "get_subsurface", "noo", types + 90 },
{ "destroy", "", wayland_types + 0 },
{ "get_subsurface", "noo", wayland_types + 90 },
};
WL_EXPORT const struct wl_interface wl_subcompositor_interface = {
@ -491,12 +491,12 @@ WL_EXPORT const struct wl_interface wl_subcompositor_interface = {
};
static const struct wl_message wl_subsurface_requests[] = {
{ "destroy", "", types + 0 },
{ "set_position", "ii", types + 0 },
{ "place_above", "o", types + 93 },
{ "place_below", "o", types + 94 },
{ "set_sync", "", types + 0 },
{ "set_desync", "", types + 0 },
{ "destroy", "", wayland_types + 0 },
{ "set_position", "ii", wayland_types + 0 },
{ "place_above", "o", wayland_types + 93 },
{ "place_below", "o", wayland_types + 94 },
{ "set_sync", "", wayland_types + 0 },
{ "set_desync", "", wayland_types + 0 },
};
WL_EXPORT const struct wl_interface wl_subsurface_interface = {

View File

@ -32,7 +32,7 @@
extern const struct wl_interface another_intf_interface;
extern const struct wl_interface intf_not_here_interface;
static const struct wl_interface *types[] = {
static const struct wl_interface *small_test_types[] = {
NULL,
&intf_not_here_interface,
NULL,
@ -44,13 +44,13 @@ static const struct wl_interface *types[] = {
};
static const struct wl_message intf_A_requests[] = {
{ "rq1", "sun", types + 0 },
{ "rq2", "nsiufho", types + 1 },
{ "destroy", "", types + 0 },
{ "rq1", "sun", small_test_types + 0 },
{ "rq2", "nsiufho", small_test_types + 1 },
{ "destroy", "", small_test_types + 0 },
};
static const struct wl_message intf_A_events[] = {
{ "hey", "", types + 0 },
{ "hey", "", small_test_types + 0 },
};
WL_EXPORT const struct wl_interface intf_A_interface = {

View File

@ -32,7 +32,7 @@
extern const struct wl_interface another_intf_interface;
extern const struct wl_interface intf_not_here_interface;
static const struct wl_interface *types[] = {
static const struct wl_interface *small_test_types[] = {
NULL,
&intf_not_here_interface,
NULL,
@ -44,13 +44,13 @@ static const struct wl_interface *types[] = {
};
static const struct wl_message intf_A_requests[] = {
{ "rq1", "sun", types + 0 },
{ "rq2", "nsiufho", types + 1 },
{ "destroy", "", types + 0 },
{ "rq1", "sun", small_test_types + 0 },
{ "rq2", "nsiufho", small_test_types + 1 },
{ "destroy", "", small_test_types + 0 },
};
static const struct wl_message intf_A_events[] = {
{ "hey", "", types + 0 },
{ "hey", "", small_test_types + 0 },
};
WL_EXPORT const struct wl_interface intf_A_interface = {

View File

@ -42,7 +42,7 @@
extern const struct wl_interface another_intf_interface;
extern const struct wl_interface intf_not_here_interface;
static const struct wl_interface *types[] = {
static const struct wl_interface *small_test_types[] = {
NULL,
&intf_not_here_interface,
NULL,
@ -54,13 +54,13 @@ static const struct wl_interface *types[] = {
};
static const struct wl_message intf_A_requests[] = {
{ "rq1", "sun", types + 0 },
{ "rq2", "nsiufho", types + 1 },
{ "destroy", "", types + 0 },
{ "rq1", "sun", small_test_types + 0 },
{ "rq2", "nsiufho", small_test_types + 1 },
{ "destroy", "", small_test_types + 0 },
};
static const struct wl_message intf_A_events[] = {
{ "hey", "", types + 0 },
{ "hey", "", small_test_types + 0 },
};
WL_PRIVATE const struct wl_interface intf_A_interface = {