package wayland
Module Wayland.MsgSource
Building and parsing messages.
An ('a, 'rw) t is a message for the 'a interface. 'rw is `R for an incoming message to be read, or `W for an outgoing message to be written.
pp_args types is a formatter for messages with argument types types.
Reading messages
parse ~fds buf returns the first message in buf, if any. When get_fd is called, it will take one from fds. Returns None if buf does not contain a complete message.
length t is the total size of the message (including any space for arguments not yet added).
get_int t returns the next argument (which must be an integer) from t and advances the next-argument pointer.
get_string t returns the next argument (which must be a string) from t and advances the next-argument pointer. The string returned does not include the trailing '\0'.
get_string_opt t returns the next argument (which must be a string or NULL) from t and advances the next-argument pointer. The string returned does not include the trailing '\0'.
get_array t returns the next argument (which must be array) from t and advances the next-argument pointer.
get_fd t takes the next FD from the queue. It raises an exception if the queue is empty. Note that the Wayland protocol does not indicate which FDs below to which messages, so if used incorrectly this will remove FDs intended for other messages. The caller takes ownership of the FD and is responsible for closing it.
get_fixed t returns the next argument (which must be a fixed-point number) from t and advances the next-argument pointer.
Generating messages
val alloc :
obj:int32 ->
op:int ->
ints:int ->
strings:string option list ->
arrays:string list ->
('a, [ `W ]) tSee Proxy.alloc.
add_fd t fd adds a copy of fd (made with Unix.dup) to the message.