Add wl_resource_init and use it in libwayland implementations of data sharing and SHM

This commit adds a wl_resource_init function for initializing wl_resource
structures similar to wl_client_add_object.

From this commit forward, wl_resource structures should not be initialized
manually, but should use wl_resource_init.  In the event of a change to the
wl_resource structure, this allows us to protect against regressions by filling
in added fields with reasonable defaults.  In this way, while changing
wl_object or wl_resource still constitutes an ABI break, compositors following
this rule will only need to be recompiled in order to properly link against the
new version.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Jason Ekstrand 2013-03-08 22:26:13 -06:00 committed by Kristian Høgsberg
parent ca5b1946cb
commit bedc3432ff
4 changed files with 27 additions and 35 deletions

View file

@ -1396,13 +1396,9 @@ wl_client_add_object(struct wl_client *client,
return NULL;
}
resource->object.interface = interface;
resource->object.implementation = implementation;
resource->object.id = id;
wl_resource_init(resource, interface, implementation, id, data);
resource->client = client;
resource->data = data;
resource->destroy = (void *) free;
wl_signal_init(&resource->destroy_signal);
if (wl_map_insert_at(&client->objects, resource->object.id, resource) < 0) {
wl_resource_post_error(client->display_resource,