aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-02-22 08:40:42 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-02-22 08:40:42 +0100
commit07a584fd28e129be9b20bdcb7f3cbba5cd211d15 (patch)
treef20dbcf83b0f9e39f0a9549bb8a5b52d1dd00410 /src
parentd6ecbe6bfe745b8865a9fcc9ab2a70585d327b8e (diff)
parent5ff649e5db99cd2ad4c8b22f5894b4283c35b6ea (diff)
downloadglutin-07a584fd28e129be9b20bdcb7f3cbba5cd211d15.tar.gz
glutin-07a584fd28e129be9b20bdcb7f3cbba5cd211d15.zip
Merge pull request #290 from frewsxcv/cleanup
Various cleanup commits
Diffstat (limited to 'src')
-rw-r--r--src/cocoa/mod.rs12
-rw-r--r--src/lib.rs9
2 files changed, 10 insertions, 11 deletions
diff --git a/src/cocoa/mod.rs b/src/cocoa/mod.rs
index 877a876..877c9b7 100644
--- a/src/cocoa/mod.rs
+++ b/src/cocoa/mod.rs
@@ -21,7 +21,7 @@ use core_foundation::string::CFString;
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
use std::cell::Cell;
-use std::ffi::{CString, c_str_to_bytes};
+use std::ffi::{CString, CStr};
use std::mem;
use std::ptr;
use std::collections::VecDeque;
@@ -115,15 +115,15 @@ impl WindowDelegate {
class_addMethod(delegate_class,
selector("windowShouldClose:"),
window_should_close,
- CString::from_slice("B@:@".as_bytes()).as_ptr());
+ CString::new("B@:@").unwrap().as_ptr());
class_addMethod(delegate_class,
selector("windowDidResize:"),
window_did_resize,
- CString::from_slice("V@:@".as_bytes()).as_ptr());
+ CString::new("V@:@").unwrap().as_ptr());
// Store internal state as user data
class_addIvar(delegate_class, WindowDelegate::state_ivar_name().as_ptr() as *const i8,
ptr_size as u64, 3,
- CString::from_slice("?".as_bytes()).as_ptr());
+ CString::new("?").unwrap().as_ptr());
objc_registerClassPair(delegate_class);
// Free class at exit
rt::at_exit(|| {
@@ -257,8 +257,8 @@ impl<'a> Iterator for PollEventsIterator<'a> {
NSKeyDown => {
let mut events = VecDeque::new();
let received_c_str = event.characters().UTF8String();
- let received_str = CString::from_slice(c_str_to_bytes(&received_c_str));
- for received_char in from_utf8(received_str.as_bytes()).unwrap().chars() {
+ let received_str = CStr::from_ptr(received_c_str);
+ for received_char in from_utf8(received_str.to_bytes()).unwrap().chars() {
if received_char.is_ascii() {
events.push_back(ReceivedCharacter(received_char));
}
diff --git a/src/lib.rs b/src/lib.rs
index 3798ffd..4ab577a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,5 @@
-#![feature(unsafe_destructor)]
+#![feature(unsafe_destructor,core,std_misc)]
#![unstable]
-#![allow(unstable)]
//! The purpose of this library is to provide an OpenGL context on as many
//! platforms as possible.
@@ -84,9 +83,9 @@ pub enum CreationError {
impl CreationError {
fn to_string(&self) -> &str {
- match self {
- &CreationError::OsError(ref text) => text.as_slice(),
- &CreationError::NotSupported => "Some of the requested attributes are not supported",
+ match *self {
+ CreationError::OsError(ref text) => text.as_slice(),
+ CreationError::NotSupported => "Some of the requested attributes are not supported",
}
}
}