summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2013-06-28 01:09:18 (GMT)
committerKristian Høgsberg <krh@bitplanet.net>2013-07-02 19:52:47 (GMT)
commitd94a8722cb29d8b897672be66ff3c9ff79eab6fe (patch)
tree4314f9c98913c36a12525062680440a336a88092
parent2e075874435e0f2c8a03faeec24a4062b94c47b2 (diff)
downloadwayland-d94a8722cb29d8b897672be66ff3c9ff79eab6fe.tar.gz
wayland-d94a8722cb29d8b897672be66ff3c9ff79eab6fe.tar.xz
server: Make wl_object and wl_resource opaque structs
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. Reviewed-by: Jason Ekstrand<jason@jlekstrand.net>
-rw-r--r--src/event-loop.c2
-rw-r--r--src/scanner.c2
-rw-r--r--src/wayland-client.c5
-rw-r--r--src/wayland-private.h9
-rw-r--r--src/wayland-server.c23
-rw-r--r--src/wayland-server.h42
-rw-r--r--src/wayland-shm.c3
-rw-r--r--src/wayland-util.h6
-rw-r--r--tests/client-test.c2
-rw-r--r--tests/display-test.c2
-rw-r--r--tests/event-loop-test.c3
11 files changed, 57 insertions, 42 deletions
diff --git a/src/event-loop.c b/src/event-loop.c
index e556cc7..d323601 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -34,8 +34,8 @@
#include <sys/timerfd.h>
#include <unistd.h>
#include <assert.h>
-#include "wayland-server.h"
#include "wayland-private.h"
+#include "wayland-server.h"
#include "wayland-os.h"
struct wl_event_loop {
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..cb091ab 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -388,13 +388,14 @@ 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_proxy *proxy = object;
int err;
wl_log("%s@%u: error %d: %s\n",
- object->interface->name, object->id, code, message);
+ proxy->object.interface->name, proxy->object.id, code, message);
switch (code) {
case WL_DISPLAY_ERROR_INVALID_OBJECT:
diff --git a/src/wayland-private.h b/src/wayland-private.h
index 71066b5..b53cc40 100644
--- a/src/wayland-private.h
+++ b/src/wayland-private.h
@@ -26,6 +26,9 @@
#define WAYLAND_PRIVATE_H
#include <stdarg.h>
+
+#define WL_HIDE_DEPRECATED 1
+
#include "wayland-util.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
@@ -39,6 +42,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..df771e9 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.
- */
+#ifndef WL_HIDE_DEPRECATED
+
+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
*
diff --git a/tests/client-test.c b/tests/client-test.c
index 5cf374d..fde3877 100644
--- a/tests/client-test.c
+++ b/tests/client-test.c
@@ -31,8 +31,8 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include "wayland-server.h"
#include "wayland-private.h"
+#include "wayland-server.h"
#include "test-runner.h"
struct client_destroy_listener {
diff --git a/tests/display-test.c b/tests/display-test.c
index 95b939e..844a649 100644
--- a/tests/display-test.c
+++ b/tests/display-test.c
@@ -32,8 +32,8 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include "wayland-server.h"
#include "wayland-private.h"
+#include "wayland-server.h"
#include "test-runner.h"
struct display_destroy_listener {
diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
index c46d3b0..cba46d4 100644
--- a/tests/event-loop-test.c
+++ b/tests/event-loop-test.c
@@ -25,8 +25,9 @@
#include <assert.h>
#include <unistd.h>
#include <signal.h>
-#include "wayland-server.h"
+
#include "wayland-private.h"
+#include "wayland-server.h"
#include "test-runner.h"
static int