Skip to content

Commit

Permalink
Automated fixes to follow Rust development
Browse files Browse the repository at this point in the history
Applied fixes:
	*logging macros need the log crate
	*attribute fix (cf rust-lang/rust#2569)
	*priv attribute removal
	*Rename Chan to Sender (cf rust-lang/rust@7858065)
	*New vec library (cf rust-lang/rust#12771)
	*update the channel constructor (cf rust-lang/rust@7858065)
	*Rename Port to Receiver (cf rust-lang/rust@7858065)
  • Loading branch information
Geal committed Apr 2, 2014
1 parent 974a748 commit 5eb94b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/lib/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn set_monitor_callback<Cb: MonitorCallback + Send>(callback: ~Cb, f: |ffi::
f(monitor_callback);
}

unsafe fn get_chan<'a>(window: &'a *ffi::GLFWwindow) -> &'a Chan<(f64, WindowEvent)> {
unsafe fn get_chan<'a>(window: &'a *ffi::GLFWwindow) -> &'a Sender<(f64, WindowEvent)> {
cast::transmute(ffi::glfwGetWindowUserPointer(*window))
}

Expand Down
31 changes: 17 additions & 14 deletions src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,30 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[crate_type = "lib"];
#[crate_type = "rlib"];
#[crate_type = "dylib"];
#[crate_id = "github.com/bjz/glfw-rs#glfw-rs:0.1"];
#[comment = "Bindings and wrapper functions for glfw3."];
#![crate_type = "lib"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![crate_id = "github.com/bjz/glfw-rs#glfw-rs:0.1"]
#![comment = "Bindings and wrapper functions for glfw3."]

#[feature(globs)];
#[feature(macro_rules)];
#![feature(globs)]
#![feature(macro_rules)]

// TODO: Document differences between GLFW and glfw-rs

#![feature(phase)]
#[phase(syntax, link)]
extern crate log;
extern crate semver;
extern crate sync;

use std::cast;
use std::comm::{Port, Chan, Data};
use std::comm::{Receiver, Sender, Data};
use std::fmt;
use std::libc::*;
use std::ptr;
use std::str;
use std::vec;
use std::vec::Vec;
use semver::Version;

pub mod ffi;
Expand Down Expand Up @@ -712,7 +715,7 @@ pub enum WindowEvent {
}

pub struct WindowEvents<'a> {
priv event_port: &'a Port<(f64, WindowEvent)>,
event_port: &'a Receiver<(f64, WindowEvent)>,
}

impl<'a> Iterator<(f64, WindowEvent)> for WindowEvents<'a> {
Expand All @@ -722,7 +725,7 @@ impl<'a> Iterator<(f64, WindowEvent)> for WindowEvents<'a> {
}

pub struct FlushedWindowEvents<'a> {
priv event_port: &'a Port<(f64, WindowEvent)>,
event_port: &'a Receiver<(f64, WindowEvent)>,
}

impl<'a> Iterator<(f64, WindowEvent)> for FlushedWindowEvents<'a> {
Expand All @@ -737,7 +740,7 @@ impl<'a> Iterator<(f64, WindowEvent)> for FlushedWindowEvents<'a> {
/// A struct that wraps a `*GLFWwindow` handle.
pub struct Window {
ptr: *ffi::GLFWwindow,
event_port: Option<Port<(f64, WindowEvent)>>,
event_port: Option<Receiver<(f64, WindowEvent)>>,
is_shared: bool,
}

Expand Down Expand Up @@ -778,7 +781,7 @@ impl Window {
if ptr.is_null() {
None
} else {
let (port, chan) = Chan::new();
let (port, chan) = comm::channel();
unsafe { ffi::glfwSetWindowUserPointer(ptr, cast::transmute(~chan)); }
Some(Window {
ptr: ptr,
Expand Down Expand Up @@ -1185,7 +1188,7 @@ impl Drop for Window {
}
if !self.ptr.is_null() {
unsafe {
let _: ~Chan<(f64, WindowEvent)> = cast::transmute(ffi::glfwGetWindowUserPointer(self.ptr));
let _: ~Sender<(f64, WindowEvent)> = cast::transmute(ffi::glfwGetWindowUserPointer(self.ptr));
}
}
}
Expand Down

0 comments on commit 5eb94b6

Please sign in to comment.