Skip to content
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

Update to work with latest rust master #74

Merged
merged 1 commit into from
Jul 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*.dummy
demos
build
Makefile
4 changes: 2 additions & 2 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub enum AudioFormat {
S16MsbAudioFormat = AUDIO_S16MSB as int
}

pub static U16AudioFormat: AudioFormat = U16LsbAudioFormat;
pub static S16AudioFormat: AudioFormat = S16LsbAudioFormat;
pub static U16_AUDIO_FORMAT: AudioFormat = U16LsbAudioFormat;
pub static S16_AUDIO_FORMAT: AudioFormat = S16LsbAudioFormat;

impl AudioFormat {
pub fn to_ll_format(self) -> uint16_t {
Expand Down
37 changes: 23 additions & 14 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,14 @@ pub enum AppState {
}

fn wrap_app_state(bitflags: u8) -> ~[AppState] {
do [AppMouseFocusState,
let flags = [AppMouseFocusState,
AppInputFocusState,
AppActiveState].filter_mapped |&flag| {
AppActiveState];

do flags.iter().filter_map |&flag| {
if bitflags & (flag as u8) != 0 { Some(flag) }
else { None }
}
}.collect()
}

#[deriving(Eq)]
Expand Down Expand Up @@ -485,7 +487,7 @@ pub enum Mod {
}

fn wrap_mod_state(bitflags: ll::SDLMod) -> ~[Mod] {
do [NoMod,
let flags = [NoMod,
LShiftMod,
RShiftMod,
LCtrlMod,
Expand All @@ -497,10 +499,12 @@ fn wrap_mod_state(bitflags: ll::SDLMod) -> ~[Mod] {
NumMod,
CapsMod,
ModeMod,
ReservedMod].filter_mapped |&flag| {
ReservedMod];

do flags.iter().filter_map |&flag| {
if bitflags & (flag as ll::SDLMod) != 0 { Some(flag) }
else { None }
}
}.collect()
}

#[deriving(Eq)]
Expand All @@ -513,14 +517,16 @@ pub enum HatState {
}

fn wrap_hat_state(bitflags: u8) -> ~[HatState] {
do [CenteredHatState,
let flags = [CenteredHatState,
UpHatState,
RightHatState,
DownHatState,
LeftHatState].filter_mapped |&flag| {
LeftHatState];

do flags.iter().filter_map |&flag| {
if bitflags & (flag as u8) != 0 { Some(flag) }
else { None }
}
}.collect()
}

#[deriving(Eq)]
Expand Down Expand Up @@ -555,16 +561,18 @@ pub enum MouseState {
}

fn wrap_mouse_state(bitflags: u8) -> ~[MouseState] {
do [LeftMouseState,
let flags = [LeftMouseState,
MiddleMouseState,
RightMouseState,
WheelUpMouseState,
WheelDownMouseState,
X1MouseState,
X2MouseState].filter_mapped |&flag| {
X2MouseState];

do flags.iter().filter_map |&flag| {
if bitflags & (flag as u8) != 0 { Some(flag) }
else { None }
}
}.collect()
}

#[deriving(Eq)]
Expand Down Expand Up @@ -759,14 +767,15 @@ pub fn get_key_state() -> ~[(Key, bool)] {
let mut i = -1;

unsafe {
do vec::raw::from_buf_raw(data, num as uint).filter_mapped |&state| {
let buf = vec::raw::from_buf_raw(data, num as uint);
do buf.iter().filter_map |&state| {
i += 1;

match wrap_key(i as ll::SDLKey) {
Some(key) => Some((key, state == 1)),
None => None
}
}
}.collect()
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ pub fn init(flags: &[InitFlag]) -> ~[InitFlag] {
})
};

do [InitJPG,
let flags = [InitJPG,
InitPNG,
InitTIF].filter_mapped |&flag| {
InitTIF];

do flags.iter().filter_map |&flag| {
if bitflags & (flag as c_int) != 0 { Some(flag) }
else { None }
}
}.collect()
}

pub fn load(file: &Path) -> Result<~Surface, ~str> {
Expand Down
8 changes: 5 additions & 3 deletions src/sdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,19 @@ pub fn was_inited(flags: &[InitFlag]) -> ~[InitFlag] {
};
let bitflags = unsafe { ll::SDL_WasInit(flags) };

do [InitTimer,
let flags = [InitTimer,
InitAudio,
InitVideo,
InitCDRom,
InitJoystick,
InitNoParachute,
InitEventThread,
InitEverything].filter_mapped |&flag| {
InitEverything];

do flags.iter().filter_map |&flag| {
if bitflags & (flag as ll::SDL_InitFlag) != 0 { Some(flag) }
else { None }
}
}.collect()
}

pub fn get_error() -> ~str {
Expand Down
8 changes: 5 additions & 3 deletions src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,20 @@ pub struct VideoInfo {
}

fn wrap_video_info_flags(bitflags: u32) -> ~[VideoInfoFlag] {
do [HWAvailable,
let flags = [HWAvailable,
WMAvailable,
BlitHW,
BlitHWColorkey,
BlitHWAlpha,
BlitSW,
BlitSWColorkey,
BlitSWAlpha,
BlitFill].filter_mapped |&flag| {
BlitFill];

do flags.iter().filter_map |&flag| {
if bitflags & (flag as u32) != 0 { Some(flag) }
else { None }
}
}.collect()
}

pub fn get_video_info() -> ~VideoInfo {
Expand Down