mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 11:18:10 +02:00
scanner: drop the Argument.argtype in favour of DBus-type bindings
This was a brei-specifc implementation detail that is not really needed, we can use the single-character dbus-style bindings.
This commit is contained in:
parent
f500a1cd43
commit
e07d4638d5
4 changed files with 18 additions and 29 deletions
|
|
@ -69,18 +69,6 @@ class Argument:
|
|||
"n": "new_id_t",
|
||||
}[self.signature]
|
||||
|
||||
@property
|
||||
def argtype(self) -> str:
|
||||
return {
|
||||
"u": "u32",
|
||||
"i": "i32",
|
||||
"s": "str",
|
||||
"h": "fd",
|
||||
"f": "f32",
|
||||
"o": "obj",
|
||||
"n": "obj",
|
||||
}[self.signature]
|
||||
|
||||
@signature.validator # type: ignore
|
||||
def _validate_signature(self, attribute, value):
|
||||
assert (
|
||||
|
|
|
|||
|
|
@ -132,15 +132,15 @@ brei_demarshal(struct brei_context *brei, struct iobuf *buf, const char *signatu
|
|||
case 'f':
|
||||
case 'o':
|
||||
case 'n':
|
||||
arg->u32 = *p++;
|
||||
arg->u = *p++;
|
||||
break;
|
||||
case 'h':
|
||||
arg->fd = iobuf_take_fd(buf);
|
||||
arg->h = iobuf_take_fd(buf);
|
||||
break;
|
||||
case 's': {
|
||||
size_t slen = *p++; /* string length includes \0 */
|
||||
if (slen == 0) {
|
||||
arg->str = NULL;
|
||||
arg->s = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ brei_demarshal(struct brei_context *brei, struct iobuf *buf, const char *signatu
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
arg->str = str;
|
||||
arg->s = str;
|
||||
p += slen32;
|
||||
break;
|
||||
}
|
||||
|
|
@ -379,12 +379,12 @@ MUNIT_TEST(test_brei_marshal)
|
|||
rc = brei_demarshal(brei, buf, "noiusf", &args);
|
||||
munit_assert_int(rc, ==, 6);
|
||||
|
||||
munit_assert_int(args[0].obj, ==, 0xab);
|
||||
munit_assert_int(args[1].obj, ==, 0xcd);
|
||||
munit_assert_int(args[2].i32, ==, -13);
|
||||
munit_assert_int(args[3].u32, ==, 0xfffd);
|
||||
munit_assert_string_equal(args[4].str, str);
|
||||
munit_assert_double_equal(args[5].f32, 1.45, 3 /* precision */);
|
||||
munit_assert_int(args[0].o, ==, 0xab);
|
||||
munit_assert_int(args[1].o, ==, 0xcd);
|
||||
munit_assert_int(args[2].i, ==, -13);
|
||||
munit_assert_int(args[3].u, ==, 0xfffd);
|
||||
munit_assert_string_equal(args[4].s, str);
|
||||
munit_assert_double_equal(args[5].f, 1.45, 3 /* precision */);
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,12 +58,13 @@ OBJECT_DECLARE_REF(brei_context);
|
|||
OBJECT_DECLARE_UNREF(brei_context);
|
||||
|
||||
union brei_arg {
|
||||
uint32_t u32;
|
||||
int32_t i32;
|
||||
float f32;
|
||||
int fd;
|
||||
const char *str;
|
||||
uint32_t obj;
|
||||
uint32_t u;
|
||||
int32_t i;
|
||||
float f;
|
||||
int h;
|
||||
const char *s;
|
||||
uint32_t o;
|
||||
uint32_t n;
|
||||
};
|
||||
|
||||
struct brei_message {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static int
|
|||
if (obj->version < {{incoming.fqdn.upper()}}_SINCE_VERSION)
|
||||
return -ENOTSUP;
|
||||
assert(interface->{{incoming.name}} != NULL);
|
||||
return interface->{{incoming.name}}({{interface.name}}{% for arg in incoming.arguments %}, (args + {{loop.index - 1}})->{{arg.argtype}}{% endfor %});
|
||||
return interface->{{incoming.name}}({{interface.name}}{% for arg in incoming.arguments %}, (args + {{loop.index - 1}})->{{arg.signature}}{% endfor %});
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue