Merge pull request #290 from frewsxcv/cleanup

Various cleanup commits
This commit is contained in:
tomaka 2015-02-22 08:40:42 +01:00
commit 07a584fd28
3 changed files with 11 additions and 12 deletions

View file

@ -1,4 +1,4 @@
#![allow(unstable)] #![feature(old_io,old_path,os)]
extern crate gl_generator; extern crate gl_generator;
extern crate khronos_api; extern crate khronos_api;

View file

@ -21,7 +21,7 @@ use core_foundation::string::CFString;
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName}; use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
use std::cell::Cell; use std::cell::Cell;
use std::ffi::{CString, c_str_to_bytes}; use std::ffi::{CString, CStr};
use std::mem; use std::mem;
use std::ptr; use std::ptr;
use std::collections::VecDeque; use std::collections::VecDeque;
@ -115,15 +115,15 @@ impl WindowDelegate {
class_addMethod(delegate_class, class_addMethod(delegate_class,
selector("windowShouldClose:"), selector("windowShouldClose:"),
window_should_close, window_should_close,
CString::from_slice("B@:@".as_bytes()).as_ptr()); CString::new("B@:@").unwrap().as_ptr());
class_addMethod(delegate_class, class_addMethod(delegate_class,
selector("windowDidResize:"), selector("windowDidResize:"),
window_did_resize, window_did_resize,
CString::from_slice("V@:@".as_bytes()).as_ptr()); CString::new("V@:@").unwrap().as_ptr());
// Store internal state as user data // Store internal state as user data
class_addIvar(delegate_class, WindowDelegate::state_ivar_name().as_ptr() as *const i8, class_addIvar(delegate_class, WindowDelegate::state_ivar_name().as_ptr() as *const i8,
ptr_size as u64, 3, ptr_size as u64, 3,
CString::from_slice("?".as_bytes()).as_ptr()); CString::new("?").unwrap().as_ptr());
objc_registerClassPair(delegate_class); objc_registerClassPair(delegate_class);
// Free class at exit // Free class at exit
rt::at_exit(|| { rt::at_exit(|| {
@ -257,8 +257,8 @@ impl<'a> Iterator for PollEventsIterator<'a> {
NSKeyDown => { NSKeyDown => {
let mut events = VecDeque::new(); let mut events = VecDeque::new();
let received_c_str = event.characters().UTF8String(); let received_c_str = event.characters().UTF8String();
let received_str = CString::from_slice(c_str_to_bytes(&received_c_str)); let received_str = CStr::from_ptr(received_c_str);
for received_char in from_utf8(received_str.as_bytes()).unwrap().chars() { for received_char in from_utf8(received_str.to_bytes()).unwrap().chars() {
if received_char.is_ascii() { if received_char.is_ascii() {
events.push_back(ReceivedCharacter(received_char)); events.push_back(ReceivedCharacter(received_char));
} }

View file

@ -1,6 +1,5 @@
#![feature(unsafe_destructor)] #![feature(unsafe_destructor,core,std_misc)]
#![unstable] #![unstable]
#![allow(unstable)]
//! The purpose of this library is to provide an OpenGL context on as many //! The purpose of this library is to provide an OpenGL context on as many
//! platforms as possible. //! platforms as possible.
@ -84,9 +83,9 @@ pub enum CreationError {
impl CreationError { impl CreationError {
fn to_string(&self) -> &str { fn to_string(&self) -> &str {
match self { match *self {
&CreationError::OsError(ref text) => text.as_slice(), CreationError::OsError(ref text) => text.as_slice(),
&CreationError::NotSupported => "Some of the requested attributes are not supported", CreationError::NotSupported => "Some of the requested attributes are not supported",
} }
} }
} }