android: Use event identifier instead of userdata pointer (#1826)

ndk-glue currently sets both the `ident` field and user-data pointer to
`0` or `1` for the event pipe and input queue respectively, to tell
these sources apart. While it works to reinterpret this `data` pointer
as integer identifier it shouldn't be abused for that, in particular
when one may wish to provide extra information with an event in the
future; then the `data` field is used as pointer (or abused as abstract
value) for that.
This commit is contained in:
Marijn Suijten 2021-01-13 23:02:55 +01:00 committed by GitHub
parent d1a7749df5
commit 05fe983757
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,7 +30,7 @@ enum EventSource {
fn poll(poll: Poll) -> Option<EventSource> { fn poll(poll: Poll) -> Option<EventSource> {
match poll { match poll {
Poll::Event { data, .. } => match data as usize { Poll::Event { ident, .. } => match ident {
0 => Some(EventSource::Callback), 0 => Some(EventSource::Callback),
1 => Some(EventSource::InputQueue), 1 => Some(EventSource::InputQueue),
_ => unreachable!(), _ => unreachable!(),