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

@ -190,6 +190,22 @@ struct wl_resource {
void *data;
};
static inline void
wl_resource_init(struct wl_resource *resource,
const struct wl_interface *interface,
const void *implementation, uint32_t id, void *data)
{
resource->object.id = id;
resource->object.interface = interface;
resource->object.implementation = implementation;
wl_signal_init(&resource->destroy_signal);
resource->destroy = NULL;
resource->client = NULL;
resource->data = data;
}
struct wl_buffer {
struct wl_resource resource;
int32_t width, height;