From d71e1b0f64f2dc39b477f146ae5fb18c0cc70651 Mon Sep 17 00:00:00 2001 From: Andelf Date: Tue, 1 Apr 2014 12:14:52 +0800 Subject: [PATCH] SOURCE: fix compile error under newest Rust; README: update compile commands. --- README.md | 8 +++++--- src/demo/main.rs | 8 ++++---- src/sdl2_image/ffi.rs | 3 +-- src/sdl2_image/lib.rs | 21 +++++++++++---------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d2c58b18..25484bc0 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,15 @@ Installation ``` git clone https://github.com/xsleonard/rust-sdl2_image cd rust-sdl2_image -rustpkg install sdl2_image +rustc src/sdl2_image/lib.rs +# OR if you are using the mac framework version +rustc --cfg mac_framework src/sdl2_image/lib.rs ``` Demo ---- ``` -rustpkg install demo -./bin/demo image.[png|jpg] +rustc -L. src/demo/main.rs -o demo +./demo image.[png|jpg] ``` diff --git a/src/demo/main.rs b/src/demo/main.rs index dcfb9646..21b5490c 100644 --- a/src/demo/main.rs +++ b/src/demo/main.rs @@ -1,8 +1,8 @@ -#[crate_type = "bin"]; +#![crate_type = "bin"] -extern mod sdl2; -extern mod sdl2_image; -extern mod native; +extern crate sdl2; +extern crate sdl2_image; +extern crate native; use std::os; diff --git a/src/sdl2_image/ffi.rs b/src/sdl2_image/ffi.rs index d6cf38e8..e3e7bb11 100644 --- a/src/sdl2_image/ffi.rs +++ b/src/sdl2_image/ffi.rs @@ -1,4 +1,4 @@ -extern mod sdl2; +extern crate sdl2; use std::libc::{c_int, c_char}; use sdl2::surface::ll::SDL_Surface; @@ -93,4 +93,3 @@ pub fn IMG_SavePNG_RW(surface: *SDL_Surface, dst: *SDL_RWops, freedst: c_int) -> c_int; } // extern "C" - diff --git a/src/sdl2_image/lib.rs b/src/sdl2_image/lib.rs index b9a61499..aa445bb4 100644 --- a/src/sdl2_image/lib.rs +++ b/src/sdl2_image/lib.rs @@ -1,11 +1,11 @@ -#[crate_id="sdl2_image#sdl2_image:0.1"]; -#[crate_type = "lib"]; -#[desc = "SDL2_image bindings and wrappers"]; -#[comment = "SDL2_image bindings and wrappers"]; -#[license = "MIT"]; +#![crate_id="sdl2_image#sdl2_image:0.1"] +#![crate_type = "lib"] +#![desc = "SDL2_image bindings and wrappers"] +#![comment = "SDL2_image bindings and wrappers"] +#![license = "MIT"] -extern mod sdl2; +extern crate sdl2; use std::libc::{c_int, c_char}; use std::ptr; @@ -34,6 +34,7 @@ mod others { extern {} } +#[allow(non_camel_case_types, dead_code)] mod ffi; /// InitFlags are passed to init() to control which subsystem @@ -41,7 +42,7 @@ mod ffi; // repr(C) "makes the size of the enum's discriminant the default // size of enums that the C ABI for the platform uses." #[repr(C)] -#[deriving(Clone, Eq, IterBytes, ToStr)] +#[deriving(Clone, Eq, Hash, Show)] pub enum InitFlag { InitJpg = ffi::IMG_INIT_JPG as int, InitPng = ffi::IMG_INIT_PNG as int, @@ -57,9 +58,9 @@ pub struct SDLImageVersion { patch: int, } -impl ToStr for SDLImageVersion { - fn to_str(&self) -> ~str { - format!("{}.{}.{}", self.major, self.minor, self.patch) +impl ::std::fmt::Show for SDLImageVersion { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(f.buf, "{}.{}.{}", self.major, self.minor, self.patch) } }