Clean up and refactor wl_closure and associated functions

The primary purpose of this patch is to clean up wl_closure and separate
closure storage, libffi, and the wire format.  To that end, a number of changes
have been made:

 - The maximum number of closure arguments has been changed from a magic number
   to a #define WL_CLOSURE_MAX_ARGS

 - A wl_argument union has been added for storing a generalized closure
   argument and wl_closure has been converted to use wl_argument instead of the
   combination of libffi, the wire format, and a dummy extra buffer.  As of
   now, the "extra" field in wl_closure should be treated as bulk storage and
   never direclty referenced outside of wl_connection_demarshal.

 - Everything having to do with libffi has been moved into wl_closure_invoke
   and the convert_arguments_to_ffi helper function.

 - Everything having to do with the wire format has been restricted to
   wl_connection_demarshal and the new static serialize_closure function.  The
   wl_closure_send and wl_closure_queue functions are now light wrappers around
   serialize_closure.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Jason Ekstrand 2013-02-26 11:30:51 -05:00 committed by Kristian Høgsberg
parent a51ed6d50f
commit 2fc248dc2c
4 changed files with 399 additions and 352 deletions

View file

@ -191,23 +191,6 @@ wl_resource_post_error(struct wl_resource *resource,
WL_DISPLAY_ERROR, resource, code, buffer);
}
static void
deref_new_objects(struct wl_closure *closure)
{
const char *signature;
int i;
signature = closure->message->signature;
for (i = 0; signature[i]; i++) {
switch (signature[i]) {
case 'n':
closure->args[i + 2] = *(uint32_t **) closure->args[i + 2];
closure->types[i] = &ffi_type_uint32;
break;
}
}
}
static int
wl_client_connection_data(int fd, uint32_t mask, void *data)
{
@ -294,8 +277,6 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
if (wl_debug)
wl_closure_print(closure, object, false);
deref_new_objects(closure);
wl_closure_invoke(closure, object,
object->implementation[opcode], client);