Update for Rustc

This commit is contained in:
Pierre Krieger 2015-01-03 23:11:59 +01:00
parent ebe32bb2d8
commit 4c5e430dd3
12 changed files with 32 additions and 27 deletions

View file

@ -38,9 +38,9 @@ git = "https://github.com/servo/rust-core-graphics"
git = "https://github.com/servo/rust-core-graphics" git = "https://github.com/servo/rust-core-graphics"
[target.i686-pc-windows-gnu.dependencies.winapi] [target.i686-pc-windows-gnu.dependencies.winapi]
version = "^0.0.3" version = "*"
features = ["gdi32", "kernel32", "user32"] features = ["gdi32", "kernel32", "user32"]
[target.x86_64-pc-windows-gnu.dependencies.winapi] [target.x86_64-pc-windows-gnu.dependencies.winapi]
version = "^0.0.3" version = "*"
features = ["gdi32", "kernel32", "user32"] features = ["gdi32", "kernel32", "user32"]

View file

@ -25,7 +25,7 @@ fn main() {
} }
print!("Please write the number of the monitor to use: "); print!("Please write the number of the monitor to use: ");
let num = from_str(stdin().read_line().unwrap().as_slice().trim()) let num = stdin().read_line().unwrap().as_slice().trim().parse()
.expect("Plase enter a number"); .expect("Plase enter a number");
let monitor = glutin::get_available_monitors().nth(num).expect("Please enter a valid ID"); let monitor = glutin::get_available_monitors().nth(num).expect("Please enter a valid ID");

View file

@ -80,7 +80,7 @@ impl Context {
} }
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
static VERTEX_DATA: [f32, ..15] = [ static VERTEX_DATA: [f32; 15] = [
-0.5, -0.5, 1.0, 0.0, 0.0, -0.5, -0.5, 1.0, 0.0, 0.0,
0.0, 0.5, 0.0, 1.0, 0.0, 0.0, 0.5, 0.0, 1.0, 0.0,
0.5, -0.5, 0.0, 0.0, 1.0 0.5, -0.5, 0.0, 0.0, 1.0

View file

@ -287,7 +287,7 @@ unsafe impl Send for Window {}
unsafe impl Sync for Window {} unsafe impl Sync for Window {}
#[cfg(feature = "window")] #[cfg(feature = "window")]
#[deriving(Clone)] #[derive(Clone)]
pub struct WindowProxy; pub struct WindowProxy;
impl WindowProxy { impl WindowProxy {

View file

@ -1,4 +1,4 @@
#[deriving(Clone, Show, Copy)] #[derive(Clone, Show, Copy)]
pub enum Event { pub enum Event {
/// The size of the window has changed. /// The size of the window has changed.
Resized(uint, uint), Resized(uint, uint),
@ -38,13 +38,13 @@ pub enum Event {
pub type ScanCode = u8; pub type ScanCode = u8;
#[deriving(Show, Hash, PartialEq, Eq, Clone, Copy)] #[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
pub enum ElementState { pub enum ElementState {
Pressed, Pressed,
Released, Released,
} }
#[deriving(Show, Hash, PartialEq, Eq, Clone, Copy)] #[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
pub enum MouseButton { pub enum MouseButton {
LeftMouseButton, LeftMouseButton,
RightMouseButton, RightMouseButton,
@ -52,7 +52,7 @@ pub enum MouseButton {
OtherMouseButton(u8), OtherMouseButton(u8),
} }
#[deriving(Show, Hash, PartialEq, Eq, Clone, Copy)] #[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
pub enum VirtualKeyCode { pub enum VirtualKeyCode {
/// The '1' key over the letters. /// The '1' key over the letters.
Key1, Key1,

View file

@ -68,7 +68,7 @@ mod events;
pub struct MonitorID(winimpl::MonitorID); pub struct MonitorID(winimpl::MonitorID);
/// Error that can happen while creating a window or a headless renderer. /// Error that can happen while creating a window or a headless renderer.
#[deriving(Clone, Show, PartialEq, Eq)] #[derive(Clone, Show, PartialEq, Eq)]
pub enum CreationError { pub enum CreationError {
OsError(String), OsError(String),
NotSupported, NotSupported,
@ -84,7 +84,7 @@ impl std::error::Error for CreationError {
} }
/// All APIs related to OpenGL that you can possibly get while using glutin. /// All APIs related to OpenGL that you can possibly get while using glutin.
#[deriving(Show, Clone, Copy, PartialEq, Eq)] #[derive(Show, Clone, Copy, PartialEq, Eq)]
pub enum Api { pub enum Api {
/// The classical OpenGL. Available on Windows, Linux, OS/X. /// The classical OpenGL. Available on Windows, Linux, OS/X.
OpenGl, OpenGl,
@ -575,7 +575,7 @@ impl gl_common::GlFunctionsSource for Window {
/// threads. /// threads.
/// ///
#[cfg(feature = "window")] #[cfg(feature = "window")]
#[deriving(Clone)] #[derive(Clone)]
pub struct WindowProxy { pub struct WindowProxy {
proxy: winimpl::WindowProxy, proxy: winimpl::WindowProxy,
} }

View file

@ -78,7 +78,7 @@ unsafe impl Send for Window {}
unsafe impl Sync for Window {} unsafe impl Sync for Window {}
#[cfg(feature = "window")] #[cfg(feature = "window")]
#[deriving(Clone)] #[derive(Clone)]
pub struct WindowProxy; pub struct WindowProxy;
impl WindowProxy { impl WindowProxy {

View file

@ -7,6 +7,7 @@ use CreationError::OsError;
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
use std::sync::mpsc::{Sender, Receiver, channel};
use libc; use libc;
use super::gl; use super::gl;
@ -222,11 +223,12 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// loading the extra WGL functions // loading the extra WGL functions
let extra_functions = gl::wgl_extra::Wgl::load_with(|addr| { let extra_functions = gl::wgl_extra::Wgl::load_with(|addr| {
use libc;
use std::c_str::ToCStr;
unsafe { unsafe {
addr.with_c_str(|s| { let addr = addr.to_c_str();
use libc; gl::wgl::GetProcAddress(addr.as_ptr()) as *const libc::c_void
gl::wgl::GetProcAddress(s) as *const libc::c_void
})
} }
}); });
@ -417,7 +419,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
} }
}).detach(); }).detach();
rx.recv() rx.recv().unwrap()
} }
/// Checks that the window is the good one, and if so send the event to it. /// Checks that the window is the good one, and if so send the event to it.
@ -435,7 +437,7 @@ fn send_event(input_window: winapi::HWND, event: Event) {
return; return;
} }
sender.send_opt(event).ok(); // ignoring if closed sender.send(event).ok(); // ignoring if closed
}); });
} }

View file

@ -1,6 +1,7 @@
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::ptr; use std::ptr;
use std::collections::RingBuf; use std::collections::RingBuf;
use std::sync::mpsc::Receiver;
use libc; use libc;
use {CreationError, Event}; use {CreationError, Event};
@ -89,7 +90,7 @@ impl Window {
} }
} }
#[deriving(Clone)] #[derive(Clone)]
pub struct WindowProxy; pub struct WindowProxy;
impl WindowProxy { impl WindowProxy {
@ -222,7 +223,7 @@ impl Window {
/// See the docs in the crate root file. /// See the docs in the crate root file.
// TODO: return iterator // TODO: return iterator
pub fn wait_events(&self) -> RingBuf<Event> { pub fn wait_events(&self) -> RingBuf<Event> {
match self.events_receiver.recv_opt() { match self.events_receiver.recv() {
Ok(ev) => { Ok(ev) => {
// if the received event is `Closed`, setting `is_closed` to true // if the received event is `Closed`, setting `is_closed` to true
match ev { match ev {

View file

@ -5,7 +5,7 @@ use std::collections::RingBuf;
/// Win32 implementation of the main `MonitorID` object. /// Win32 implementation of the main `MonitorID` object.
pub struct MonitorID { pub struct MonitorID {
/// The system name of the monitor. /// The system name of the monitor.
name: [winapi::WCHAR, ..32], name: [winapi::WCHAR; 32],
/// Name to give to the user. /// Name to give to the user.
readable_name: String, readable_name: String,

View file

@ -1241,7 +1241,7 @@ pub struct XSetWindowAttributes {
#[repr(C)] #[repr(C)]
pub struct XEvent { pub struct XEvent {
pub type_: libc::c_int, pub type_: libc::c_int,
pad: [libc::c_long, ..24], pad: [libc::c_long; 24],
} }
#[repr(C)] #[repr(C)]
@ -1253,7 +1253,7 @@ pub struct XClientMessageEvent {
pub window: Window, pub window: Window,
pub message_type: Atom, pub message_type: Atom,
pub format: libc::c_int, pub format: libc::c_int,
pub l: [libc::c_long, ..5], pub l: [libc::c_long; 5],
} }
#[repr(C)] #[repr(C)]
@ -1435,7 +1435,7 @@ extern "C" {
res_class: *mut libc::c_char) -> XIM; res_class: *mut libc::c_char) -> XIM;
// TODO: this is a vararg function // TODO: this is a vararg function
//pub fn XCreateIC(im: XIM, ...) -> XIC; //pub fn XCreateIC(im: XIM; .) -> XIC;
pub fn XCreateIC(im: XIM, a: *const libc::c_char, b: libc::c_long, c: *const libc::c_char, pub fn XCreateIC(im: XIM, a: *const libc::c_char, b: libc::c_long, c: *const libc::c_char,
d: Window, e: *const ()) -> XIC; d: Window, e: *const ()) -> XIC;
pub fn XDestroyIC(ic: XIC); pub fn XDestroyIC(ic: XIC);

View file

@ -57,7 +57,7 @@ impl Drop for XWindow {
} }
} }
#[deriving(Clone)] #[derive(Clone)]
pub struct WindowProxy { pub struct WindowProxy {
x: Arc<XWindow>, x: Arc<XWindow>,
} }
@ -302,6 +302,7 @@ impl Window {
// loading the extra GLX functions // loading the extra GLX functions
let extra_functions = ffi::glx_extra::Glx::load_with(|addr| { let extra_functions = ffi::glx_extra::Glx::load_with(|addr| {
use std::c_str::ToCStr;
addr.with_c_str(|s| { addr.with_c_str(|s| {
use libc; use libc;
ffi::glx::GetProcAddress(s as *const u8) as *const libc::c_void ffi::glx::GetProcAddress(s as *const u8) as *const libc::c_void
@ -355,6 +356,7 @@ impl Window {
} }
pub fn set_title(&self, title: &str) { pub fn set_title(&self, title: &str) {
use std::c_str::ToCStr;
let c_title = title.to_c_str(); let c_title = title.to_c_str();
unsafe { unsafe {
ffi::XStoreName(self.x.display, self.x.window, c_title.as_ptr()); ffi::XStoreName(self.x.display, self.x.window, c_title.as_ptr());
@ -494,7 +496,7 @@ impl Window {
let written = unsafe { let written = unsafe {
use std::str; use std::str;
let mut buffer: [u8, ..16] = [mem::uninitialized(), ..16]; let mut buffer: [u8; 16] = [mem::uninitialized(); 16];
let raw_ev: *mut ffi::XKeyEvent = event; let raw_ev: *mut ffi::XKeyEvent = event;
let count = ffi::Xutf8LookupString(self.x.ic, mem::transmute(raw_ev), let count = ffi::Xutf8LookupString(self.x.ic, mem::transmute(raw_ev),
mem::transmute(buffer.as_mut_ptr()), mem::transmute(buffer.as_mut_ptr()),