summaryrefslogtreecommitdiff
path: root/lib/CWayland/CWayland.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CWayland/CWayland.cc')
-rw-r--r--lib/CWayland/CWayland.cc74
1 files changed, 20 insertions, 54 deletions
diff --git a/lib/CWayland/CWayland.cc b/lib/CWayland/CWayland.cc
index 7ff9332..abb9ee5 100644
--- a/lib/CWayland/CWayland.cc
+++ b/lib/CWayland/CWayland.cc
@@ -841,7 +841,7 @@ namespace
{
class argument_buffer
{
- enum class type { uninitialized, i32, u32, fixed, string, object, new_id, array, fd };
+ enum class type { uninitialized, i32, u32, fixed, string, object, array, fd };
struct meta
{
type type{ type::uninitialized };
@@ -917,14 +917,6 @@ namespace
meta[i].ref = std::move(value);
}
- void write_new_id(ref value)
- {
- auto i = next_write();
- args[i].o = static_cast<wl_object*>(lean_get_external_data(value.get()));
- meta[i].type = type::object;
- meta[i].ref = std::move(value);
- }
-
void write_array(ref value)
{
auto i = next_write();
@@ -974,7 +966,7 @@ namespace
meta[i].ref = ref::steal(lean_box(0));
}
}
- else if (signature_type == "o" || signature_type == "?o")
+ else if (signature_type == "o" || signature_type == "?o" || signature_type == "n")
{
meta[i].type = type::object;
if (arg.o)
@@ -990,10 +982,6 @@ namespace
meta[i].ref = ref::steal(lean_box(0));
}
}
- else if (signature_type == "n")
- {
- meta[i].type = type::new_id;
- }
else if (signature_type == "a")
{
meta[i].type = type::array;
@@ -1041,12 +1029,6 @@ namespace
return ref{ std::move(meta[i].ref) };
}
- ref read_new_id()
- {
- auto i = next_read(type::new_id);
- return ref::steal(lean_box_uint32(args[i].n));
- }
-
ref read_array()
{
auto i = next_read(type::array);
@@ -1118,14 +1100,6 @@ lean_obj_res waylean_argument_buffer_write_object(b_lean_obj_arg buffer_obj, b_l
return lean_io_result_mk_ok(lean_box(0));
}
-// ArgumentBuffer.writeNewID : (buffer : @& ArgumentBuffer) → (value : @& Proxy) → IO Unit
-lean_obj_res waylean_argument_buffer_write_new_id(b_lean_obj_arg buffer_obj, b_lean_obj_arg value)
-{
- auto buffer = static_cast<argument_buffer*>(lean_get_external_data(buffer_obj));
- buffer->write_new_id(ref{ value });
- return lean_io_result_mk_ok(lean_box(0));
-}
-
// ArgumentBuffer.writeArray : (buffer : @& ArgumentBuffer) → (value : @& ByteArray) → IO Unit
lean_obj_res waylean_argument_buffer_write_array(b_lean_obj_arg buffer_obj, b_lean_obj_arg value)
{
@@ -1177,13 +1151,6 @@ lean_obj_res waylean_argument_buffer_read_object(b_lean_obj_arg buffer_obj)
return lean_io_result_mk_ok(buffer->read_object().release());
}
-// ArgumentBuffer.readNewID : (buffer : @& ArgumentBuffer) → IO UInt32
-lean_obj_res waylean_argument_buffer_read_new_id(b_lean_obj_arg buffer_obj)
-{
- auto buffer = static_cast<argument_buffer*>(lean_get_external_data(buffer_obj));
- return lean_io_result_mk_ok(buffer->read_new_id().release());
-}
-
// ArgumentBuffer.readArray : (buffer : @& ArgumentBuffer) → IO ByteArray
lean_obj_res waylean_argument_buffer_read_array(b_lean_obj_arg buffer_obj)
{
@@ -1204,7 +1171,6 @@ namespace
{
int dispatcher_func(const void* user_data, void* target, uint32_t opcode, const wl_message* msg, wl_argument* args)
{
- fprintf(stderr, "Dispatcher func!\n");
if (!user_data) { return 0; }
auto handler = ref{ (lean_object*)user_data };
@@ -1269,24 +1235,6 @@ lean_obj_res waylean_proxy_from_display(lean_obj_arg display)
return lean_io_result_mk_ok(display);
}
-// Proxy.new : (factory : @& Proxy) → (typeMap : @& TypeMap) → (ifaceName : @& String) → IO Proxy
-lean_obj_res waylean_proxy_new(b_lean_obj_arg factory_obj, b_lean_obj_arg map_obj, b_lean_obj_arg iface_name)
-{
- auto factory = static_cast<wl_proxy*>(lean_get_external_data(factory_obj));
- auto map = static_cast<type_map*>(lean_get_external_data(map_obj));
- auto iface = map->resolve_iface(lean_string_cstr(iface_name));
-
- assert(iface->initialized && "expected interface to be initialized during construction");
- wl_proxy* res = wl_proxy_create(factory, &iface->desc);
- lean_object* waylean_res = lean_alloc_external(waylean_proxy_class(), res);
- if (!res) { return io_result_mk_from_errno("<unknown>"); }
-
- int stat = wl_proxy_add_dispatcher(res, dispatcher_func, waylean_res, nullptr);
- fprintf(stderr, "add_dispatcher: %d\n", stat);
-
- return lean_io_result_mk_ok(waylean_res);
-}
-
// Proxy.send : (proxy : @& Proxy) → (opcode : UInt32) → (argumentBuffer : @& ArgumentBuffer) → IO Unit
lean_obj_res waylean_proxy_send(b_lean_obj_arg proxy_obj, uint32_t opcode, b_lean_obj_arg buffer_obj)
{
@@ -1298,6 +1246,24 @@ lean_obj_res waylean_proxy_send(b_lean_obj_arg proxy_obj, uint32_t opcode, b_lea
return lean_io_result_mk_ok(lean_box(0));
}
+// Proxy.sendConstructor : (proxy : @& Proxy) → (opcode : UInt32) → (argumentBuffer : @& ArgumentBuffer) → (typeMap : @& TypeMap) → (ifaceName : @& String) → IO Proxy
+lean_obj_res waylean_proxy_send_constructor(b_lean_obj_arg proxy_obj, uint32_t opcode, b_lean_obj_arg buffer_obj, b_lean_obj_arg map_obj, b_lean_obj_arg iface_name)
+{
+ auto proxy = static_cast<wl_proxy*>(lean_get_external_data(proxy_obj));
+ auto buffer = static_cast<argument_buffer*>(lean_get_external_data(buffer_obj));
+ auto map = static_cast<type_map*>(lean_get_external_data(map_obj));
+ auto iface = map->resolve_iface(lean_string_cstr(iface_name));
+ assert(iface->initialized && "expected interface to be initialized during construction");
+
+ wl_proxy* res = wl_proxy_marshal_array_constructor(proxy, opcode, buffer->get_args(), &iface->desc);
+ if (!res) { return io_result_mk_from_errno("<unknown>"); }
+
+ lean_object* waylean_res = lean_alloc_external(waylean_proxy_class(), res);
+ int stat = wl_proxy_add_dispatcher(res, dispatcher_func, waylean_res, nullptr);
+
+ return lean_io_result_mk_ok(waylean_res);
+}
+
// Proxy.listen : (proxy : @& Proxy) → (handler : UInt32 → ArgumentBuffer → EventLoop M × M) → IO Unit
lean_obj_res waylean_proxy_listen(b_lean_obj_arg proxy_obj, lean_obj_arg handler)
{