diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2013-06-25 15:57:15 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-06-28 19:51:12 -0400 |
commit | 0e439039fc3a54ffe70707f8425f3b3a2a77f52f (patch) | |
tree | f4927a79ab4875482969fa1e315079caaf21bcbf | |
parent | 2e075874435e0f2c8a03faeec24a4062b94c47b2 (diff) |
server: Make wl_object and wl_resource opaque structsopaque-resource
With the work to add wl_resource accessors and port weston to use them,
we're ready to make wl_resource and wl_object opaque structs. We keep
wl_buffer in the header for EGL stacks to use, but don't expose it by
default. In time we'll remove it completely, but for now it provides a
transition paths for code that still uses wl_buffer.
-rw-r--r-- | src/scanner.c | 2 | ||||
-rw-r--r-- | src/wayland-client.c | 5 | ||||
-rw-r--r-- | src/wayland-private.h | 6 | ||||
-rw-r--r-- | src/wayland-server.c | 23 | ||||
-rw-r--r-- | src/wayland-server.h | 42 | ||||
-rw-r--r-- | src/wayland-shm.c | 3 | ||||
-rw-r--r-- | src/wayland-util.h | 6 |
7 files changed, 49 insertions, 38 deletions
diff --git a/src/scanner.c b/src/scanner.c index 9c14ad3..c63c908 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -829,7 +829,7 @@ emit_structs(struct wl_list *message_list, struct interface *interface) else if (is_interface && a->type == NEW_ID && a->interface_name == NULL) printf("const char *interface, uint32_t version, uint32_t "); else if (!is_interface && a->type == OBJECT && a->interface_name == NULL) - printf("struct wl_object *"); + printf("void *"); else if (!is_interface && a->type == NEW_ID) printf("struct %s *", a->interface_name); diff --git a/src/wayland-client.c b/src/wayland-client.c index ec01cdd..8a13084 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -41,8 +41,8 @@ #include "wayland-util.h" #include "wayland-os.h" -#include "wayland-client.h" #include "wayland-private.h" +#include "wayland-client.h" /** \cond */ @@ -388,9 +388,10 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) static void display_handle_error(void *data, - struct wl_display *display, struct wl_object *object, + struct wl_display *display, void *_object, uint32_t code, const char *message) { + struct wl_object *object = _object; int err; wl_log("%s@%u: error %d: %s\n", diff --git a/src/wayland-private.h b/src/wayland-private.h index 71066b5..eec7dff 100644 --- a/src/wayland-private.h +++ b/src/wayland-private.h @@ -39,6 +39,12 @@ #define WL_SERVER_ID_START 0xff000000 #define WL_CLOSURE_MAX_ARGS 20 +struct wl_object { + const struct wl_interface *interface; + const void *implementation; + uint32_t id; +}; + extern struct wl_object global_zombie_object; #define WL_ZOMBIE_OBJECT ((void*)&global_zombie_object) diff --git a/src/wayland-server.c b/src/wayland-server.c index 7907283..0c3fbc9 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -102,6 +102,15 @@ struct wl_global { struct wl_list link; }; +struct wl_resource { + struct wl_object object; + wl_resource_destroy_func_t destroy; + struct wl_list link; + struct wl_signal destroy_signal; + struct wl_client *client; + void *data; +}; + static int wl_debug = 0; static void @@ -373,6 +382,10 @@ wl_client_get_credentials(struct wl_client *client, *gid = client->ucred.gid; } +uint32_t +wl_client_add_resource(struct wl_client *client, + struct wl_resource *resource) WL_DEPRECATED; + WL_EXPORT uint32_t wl_client_add_resource(struct wl_client *client, struct wl_resource *resource) @@ -996,9 +1009,15 @@ wl_client_add_object(struct wl_client *client, return NULL; } - wl_resource_init(resource, interface, implementation, id, data); - resource->client = client; + resource->object.id = id; + resource->object.interface = interface; + resource->object.implementation = implementation; + + wl_signal_init(&resource->destroy_signal); + resource->destroy = NULL; + resource->client = client; + resource->data = data; if (wl_map_insert_at(&client->objects, 0, resource->object.id, resource) < 0) { wl_resource_post_error(client->display_resource, diff --git a/src/wayland-server.h b/src/wayland-server.h index 515efe5..7c53cfc 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -181,12 +181,14 @@ wl_signal_emit(struct wl_signal *signal, void *data) typedef void (*wl_resource_destroy_func_t)(struct wl_resource *resource); -/* The wl_resource structure has be deprecated as a transparent structure. - * While wl_resource will still exist, it will, in the future, be an opaque - * pointer. Instead of accessing wl_resource directly, it should be created by - * wl_client_add_object and wl_client_new_object and only accessed by the - * accessor functions provided. - */ +#ifdef WL_USE_LEGACY_WL_BUFFER + +struct wl_object { + const struct wl_interface *interface; + const void *implementation; + uint32_t id; +}; + struct wl_resource { struct wl_object object; wl_resource_destroy_func_t destroy; @@ -196,27 +198,17 @@ 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; uint32_t busy_count; -}; +} WL_DEPRECATED; + +uint32_t +wl_client_add_resource(struct wl_client *client, + struct wl_resource *resource) WL_DEPRECATED; + +#endif /* * Post an event to the client's object referred to by 'resource'. @@ -247,10 +239,6 @@ void wl_resource_post_no_memory(struct wl_resource *resource); #include "wayland-server-protocol.h" -uint32_t -wl_client_add_resource(struct wl_client *client, - struct wl_resource *resource) WL_DEPRECATED; - struct wl_display * wl_client_get_display(struct wl_client *client); diff --git a/src/wayland-shm.c b/src/wayland-shm.c index c2e1df0..8a10253 100644 --- a/src/wayland-shm.c +++ b/src/wayland-shm.c @@ -283,6 +283,9 @@ wl_shm_buffer_create(struct wl_client *client, WL_EXPORT struct wl_shm_buffer * wl_shm_buffer_get(struct wl_resource *resource) { + if (resource == NULL) + return NULL; + if (wl_resource_instance_of(resource, &wl_buffer_interface, &shm_buffer_interface)) return wl_resource_get_user_data(resource); diff --git a/src/wayland-util.h b/src/wayland-util.h index 119fa33..53d3282 100644 --- a/src/wayland-util.h +++ b/src/wayland-util.h @@ -61,12 +61,6 @@ struct wl_interface { const struct wl_message *events; }; -struct wl_object { - const struct wl_interface *interface; - const void *implementation; - uint32_t id; -}; - /** * wl_list - linked list * |