And provide a function to write it to a connection.
ffi_cif cif;
void *args[20];
uint32_t buffer[64];
+ uint32_t *start;
};
struct wl_connection {
return extra;
}
-void
+struct wl_closure *
wl_connection_vmarshal(struct wl_connection *connection,
struct wl_object *sender,
uint32_t opcode, va_list ap,
size = (p - start) * sizeof *p;
start[0] = sender->id;
start[1] = opcode | (size << 16);
- wl_connection_write(connection, start, size);
+ closure->start = start;
+
+ return closure;
}
struct wl_closure *
}
void
+wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
+{
+ uint32_t size;
+
+ size = closure->start[1] >> 16;
+ wl_connection_write(connection, closure->start, size);
+}
+
+void
wl_closure_print(struct wl_closure *closure, struct wl_object *target)
{
union wl_value *value;
int wl_connection_data(struct wl_connection *connection, uint32_t mask);
void wl_connection_write(struct wl_connection *connection, const void *data, size_t count);
-void wl_connection_vmarshal(struct wl_connection *connection,
- struct wl_object *sender,
- uint32_t opcode, va_list ap,
- const struct wl_message *message);
+struct wl_closure *
+wl_connection_vmarshal(struct wl_connection *connection,
+ struct wl_object *sender,
+ uint32_t opcode, va_list ap,
+ const struct wl_message *message);
struct wl_closure *
wl_connection_demarshal(struct wl_connection *connection,
wl_closure_invoke(struct wl_closure *closure,
struct wl_object *target, void (*func)(void), void *data);
void
+wl_closure_send(struct wl_closure *closure, struct wl_connection *connection);
+void
wl_closure_print(struct wl_closure *closure, struct wl_object *target);
void
wl_closure_destroy(struct wl_closure *closure);
WL_EXPORT void
wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
{
+ struct wl_closure *closure;
va_list ap;
va_start(ap, opcode);
- wl_connection_vmarshal(proxy->display->connection,
- &proxy->base, opcode, ap,
- &proxy->base.interface->methods[opcode]);
+ closure = wl_connection_vmarshal(proxy->display->connection,
+ &proxy->base, opcode, ap,
+ &proxy->base.interface->methods[opcode]);
va_end(ap);
+
+ wl_closure_send(closure, proxy->display->connection);
+ wl_closure_destroy(closure);
}
static void
wl_client_post_event(struct wl_client *client, struct wl_object *sender,
uint32_t opcode, ...)
{
+ struct wl_closure *closure;
va_list ap;
if (client == NULL)
return;
va_start(ap, opcode);
- wl_connection_vmarshal(client->connection,
- sender, opcode, ap,
- &sender->interface->events[opcode]);
+ closure = wl_connection_vmarshal(client->connection,
+ sender, opcode, ap,
+ &sender->interface->events[opcode]);
va_end(ap);
+
+ wl_closure_send(closure, client->connection);
+ wl_closure_destroy(closure);
}
static void
object->implementation[opcode], client);
wl_closure_destroy(closure);
-
}
}