diff --git a/glut.rc b/glut.rc index fe3e2c9..b2b027f 100644 --- a/glut.rc +++ b/glut.rc @@ -7,13 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[crate_id = "github.com/mozilla-servo/rust-glut#glut:0.1"]; -#[crate_type = "lib"]; -#[crate_type = "dylib"]; -#[crate_type = "rlib"]; +#![crate_id = "github.com/mozilla-servo/rust-glut#glut:0.1"] +#![crate_type = "lib"] +#![crate_type = "dylib"] +#![crate_type = "rlib"] -#[feature(macro_rules)]; +#![feature(macro_rules)] +extern crate libc; extern crate std; pub mod glut; diff --git a/glut.rs b/glut.rs index 359fda2..7cf93d9 100644 --- a/glut.rs +++ b/glut.rs @@ -9,8 +9,8 @@ /* automatically generated by rust-bindgen */ +use libc::{c_int, c_uint, c_uchar, c_char}; use std::cast; -use std::libc::{c_int, c_uint, c_uchar, c_char}; use std::local_data; use std::ptr::null; @@ -37,7 +37,7 @@ pub type GLint = i32; pub type GLfloat = f32; pub type GLdouble = f64; -pub struct Window(c_int); +pub struct Window(pub c_int); pub static DOUBLE: c_uint = 2 as c_uint; @@ -73,21 +73,15 @@ pub trait ReshapeCallback { fn call(&self, x: c_int, y: c_int); } pub trait IdleCallback { fn call(&self); } pub trait MouseWheelCallback { fn call(&self, wheel: c_int, direction: c_int, x: c_int, y: c_int); } -macro_rules! local_data_key( - ($name:ident, $func:ty) => ( - static $name: local_data::Key<$func> = &local_data::Key; - ); -) - -local_data_key!(display_tls_key, ~DisplayCallback) -local_data_key!(keyboard_tls_key, ~KeyboardCallback) -local_data_key!(mouse_tls_key, ~MouseCallback) -local_data_key!(motion_tls_key, ~MotionCallback) -local_data_key!(passive_motion_tls_key, ~PassiveMotionCallback) -local_data_key!(timer_tls_key, ~TimerCallback) -local_data_key!(reshape_tls_key, ~ReshapeCallback) -local_data_key!(idle_tls_key, ~IdleCallback) -local_data_key!(mouse_wheel_tls_key, ~MouseWheelCallback) +local_data_key!(display_tls_key: ~DisplayCallback:'static) +local_data_key!(keyboard_tls_key: ~KeyboardCallback:'static) +local_data_key!(mouse_tls_key: ~MouseCallback:'static) +local_data_key!(motion_tls_key: ~MotionCallback:'static) +local_data_key!(passive_motion_tls_key: ~PassiveMotionCallback:'static) +local_data_key!(timer_tls_key: ~TimerCallback:'static) +local_data_key!(reshape_tls_key: ~ReshapeCallback:'static) +local_data_key!(idle_tls_key: ~IdleCallback:'static) +local_data_key!(mouse_wheel_tls_key: ~MouseWheelCallback:'static) pub enum State { WindowWidth, @@ -155,7 +149,7 @@ pub extern "C" fn display_callback() { }); } -pub fn display_func(callback: ~DisplayCallback) { +pub fn display_func(callback: ~DisplayCallback:'static) { local_data::set(display_tls_key, callback); unsafe { glutDisplayFunc(display_callback); @@ -170,7 +164,7 @@ pub extern "C" fn keyboard_callback(key: c_uchar, x: c_int, y: c_int) { }); } -pub fn keyboard_func(callback: ~KeyboardCallback) { +pub fn keyboard_func(callback: ~KeyboardCallback:'static) { local_data::set(keyboard_tls_key, callback); unsafe { glutKeyboardFunc(keyboard_callback); @@ -185,7 +179,7 @@ pub extern "C" fn mouse_callback(button: c_int, state: c_int, x: c_int, y: c_int }); } -pub fn mouse_func(callback: ~MouseCallback) { +pub fn mouse_func(callback: ~MouseCallback:'static) { local_data::set(mouse_tls_key, callback); unsafe { glutMouseFunc(mouse_callback); @@ -200,7 +194,7 @@ pub extern "C" fn motion_callback(x: c_int, y: c_int) { }); } -pub fn motion_func(callback: ~MotionCallback) { +pub fn motion_func(callback: ~MotionCallback:'static) { local_data::set(motion_tls_key, callback); unsafe { glutMotionFunc(motion_callback); @@ -215,7 +209,7 @@ pub extern "C" fn passive_motion_callback(x: c_int, y: c_int) { }); } -pub fn passive_motion_func(callback: ~PassiveMotionCallback) { +pub fn passive_motion_func(callback: ~PassiveMotionCallback:'static) { local_data::set(passive_motion_tls_key, callback); unsafe { glutPassiveMotionFunc(passive_motion_callback); @@ -230,7 +224,7 @@ pub extern "C" fn timer_callback(_index: int) { }); } -pub fn timer_func(msecs: u32, callback: ~TimerCallback) { +pub fn timer_func(msecs: u32, callback: ~TimerCallback:'static) { local_data::set(timer_tls_key, callback); unsafe { glutTimerFunc(msecs, timer_callback, 0); @@ -245,7 +239,7 @@ pub extern "C" fn reshape_callback(width: c_int, height: c_int) { }); } -pub fn reshape_func(_window: Window, callback: ~ReshapeCallback) { +pub fn reshape_func(_window: Window, callback: ~ReshapeCallback:'static) { local_data::set(reshape_tls_key, callback); unsafe { glutReshapeFunc(reshape_callback); @@ -260,7 +254,7 @@ pub extern "C" fn idle_callback() { }); } -pub fn idle_func(callback: ~IdleCallback) { +pub fn idle_func(callback: ~IdleCallback:'static) { local_data::set(idle_tls_key, callback); unsafe { glutIdleFunc(idle_callback); @@ -282,7 +276,7 @@ pub extern "C" fn mouse_wheel_callback(wheel: c_int, direction: c_int, x: c_int, #[cfg(target_os="linux")] #[cfg(target_os="android")] -pub fn mouse_wheel_func(callback: ~MouseWheelCallback) { +pub fn mouse_wheel_func(callback: ~MouseWheelCallback:'static) { local_data::set(mouse_wheel_tls_key, callback); unsafe { glutMouseWheelFunc(mouse_wheel_callback); @@ -290,7 +284,7 @@ pub fn mouse_wheel_func(callback: ~MouseWheelCallback) { } #[cfg(target_os="macos")] -pub fn mouse_wheel_func(callback: ~MouseWheelCallback) { +pub fn mouse_wheel_func(callback: ~MouseWheelCallback:'static) { local_data::set(mouse_wheel_tls_key, callback); } diff --git a/machack.rs b/machack.rs index c8dd9b5..5a3079c 100644 --- a/machack.rs +++ b/machack.rs @@ -1,11 +1,11 @@ -#[allow(non_uppercase_statics)]; +#![allow(non_uppercase_statics)] extern crate cocoa; use glut::{mouse_callback_tls_key, mouse_wheel_callback_tls_key}; +use libc::{c_int, c_void}; use std::cast::transmute; -use std::libc::{c_int, c_void}; use std::local_data::local_data_get; use std::ptr::null; use machack::cocoa::base::{SEL, class_addMethod, id, msg_send_double, msg_send_id, objc_getClass}; diff --git a/test.rs b/test.rs index b5eb01f..4f0cca4 100644 --- a/test.rs +++ b/test.rs @@ -21,8 +21,8 @@ use self::opengles::gl2::{get_shader_info_log, get_shader_iv}; use self::opengles::gl2::{link_program, shader_source}; use self::opengles::gl2::{use_program, vertex_attrib_pointer_f32}; +use libc::c_int; use std::comm; -use std::libc::c_int; use std::io::println; use std::task;