Skip to content

Use correct numeric types for events #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

eagleflo
Copy link
Contributor

After the recent int / uint debacle and rename to isize and usize, I was wondering why their use is so prevalent in rust-sdl2. As far as I can tell they should not be used as a general purpose integer type in Rust.

This pull request changes the integer types used in events to match the definitions found in SDL_event.h. There is much less casting involved after this change. This will likely break a lot of code, but the recent int -> isize transition also breaks the same code, so I felt this would be a good opportunity for this change.

I also noticed that touch and gesture events use f64 where SDL2 uses f32. This implies greater accuracy than SDL2 provides, so I changed those back to f32, but I'm not sure if this is the right way to go -- those commits can be easily dropped if needed.

I assume you will want to pull jpernst's recent 1.0 alpha fixes, so I based this branch on top of those commits.

@ketsuban
Copy link

I suspect you'll want to deal with the warnings about the deprecated i/u suffixes on integer literals before this can be merged, since that's part of removing unnecessary uses of int/uint.

@jpernst
Copy link
Contributor

jpernst commented Jan 11, 2015

Woops, good catch on the suffixes. I missed those on my initial pass since I forgot to rebuild sdl2-sys and missed the warnings. I've fixed them in my PR, so this should probably be rebased.

Thanks for doing this though. I was meaning to do it but kept putting it off since it's such a slog to go through every use in every API one by one.

@eagleflo eagleflo force-pushed the use-correct-numeric-types-for-events branch from 6363b32 to 34d8fd7 Compare January 12, 2015 01:34
@eagleflo
Copy link
Contributor Author

Rebased.

@AngryLawyer
Copy link
Member

Grand, this is brilliant.

AngryLawyer added a commit that referenced this pull request Jan 12, 2015
…vents

Use correct numeric types for events
@AngryLawyer AngryLawyer merged commit cc3e579 into Rust-SDL2:master Jan 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants