mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-02-27 01:41:06 -05:00
Add support for signed 24.8 decimal numbers
'fixed' is a signed decimal type which offers a sign bit, 23 bits of integer precision, and 8 bits of decimal precision. This is exposed as an opaque struct with conversion helpers to and from double and int on the C API side. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
c49f632dae
commit
c5aba11acc
6 changed files with 81 additions and 3 deletions
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
|
@ -428,6 +429,13 @@ wl_closure_vmarshal(struct wl_closure *closure,
|
|||
|
||||
for (i = 2; i < count; i++) {
|
||||
switch (message->signature[i - 2]) {
|
||||
case 'f':
|
||||
closure->types[i] = &ffi_type_sint32;
|
||||
closure->args[i] = p;
|
||||
if (end - p < 1)
|
||||
goto err;
|
||||
*p++ = va_arg(ap, wl_fixed_t);
|
||||
break;
|
||||
case 'u':
|
||||
closure->types[i] = &ffi_type_uint32;
|
||||
closure->args[i] = p;
|
||||
|
|
@ -611,6 +619,10 @@ wl_connection_demarshal(struct wl_connection *connection,
|
|||
closure->types[i] = &ffi_type_sint32;
|
||||
closure->args[i] = p++;
|
||||
break;
|
||||
case 'f':
|
||||
closure->types[i] = &ffi_type_sint32;
|
||||
closure->args[i] = p++;
|
||||
break;
|
||||
case 's':
|
||||
closure->types[i] = &ffi_type_pointer;
|
||||
length = *p++;
|
||||
|
|
@ -812,6 +824,7 @@ void
|
|||
wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
|
||||
{
|
||||
union wl_value *value;
|
||||
int32_t si;
|
||||
int i;
|
||||
struct timespec tp;
|
||||
unsigned int time;
|
||||
|
|
@ -835,7 +848,12 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
|
|||
fprintf(stderr, "%u", value->uint32);
|
||||
break;
|
||||
case 'i':
|
||||
fprintf(stderr, "%d", value->uint32);
|
||||
si = (int32_t) value->uint32;
|
||||
fprintf(stderr, "%d", si);
|
||||
break;
|
||||
case 'f':
|
||||
si = (int32_t) value->uint32;
|
||||
fprintf(stderr, "%f", (double) si / 256.0);
|
||||
break;
|
||||
case 's':
|
||||
fprintf(stderr, "\"%s\"", value->string);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue