From 7f47b8b8e21bb9273ae5324109a432f17a7a774e Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 13 Feb 2015 14:57:11 +0100 Subject: [PATCH] Fix warnings in cef. --- ports/cef/browser.rs | 20 ++++++++++---------- ports/cef/command_line.rs | 6 +++--- ports/cef/eutil.rs | 2 +- ports/cef/lib.rs | 14 ++++++++++++-- ports/cef/string.rs | 21 ++++++++++++--------- ports/cef/window.rs | 5 +---- 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs index 76f2c42f31b..f572ebe86c0 100644 --- a/ports/cef/browser.rs +++ b/ports/cef/browser.rs @@ -17,7 +17,7 @@ use glutin_app; use libc::c_int; use util::opts; use std::borrow::ToOwned; -use std::cell::{Cell, RefCell}; +use std::cell::{Cell, RefCell, BorrowState}; use std::sync::atomic::{AtomicInt, Ordering}; thread_local!(pub static ID_COUNTER: AtomicInt = AtomicInt::new(0)); @@ -144,19 +144,19 @@ impl ServoCefBrowserExtensions for CefBrowser { self.downcast().message_queue.borrow_mut().push(event); loop { - match self.downcast().servo_browser.try_borrow_mut() { - None => { - // We're trying to send an event while processing another one. This will - // cause general badness, so queue up that event instead of immediately - // processing it. - break - } - Some(ref mut browser) => { + match self.downcast().servo_browser.borrow_state() { + BorrowState::Unused => { let event = match self.downcast().message_queue.borrow_mut().pop() { None => return, Some(event) => event, }; - browser.handle_event(event); + self.downcast().servo_browser.borrow_mut().handle_event(event); + } + _ => { + // We're trying to send an event while processing another one. This will + // cause general badness, so queue up that event instead of immediately + // processing it. + break } } } diff --git a/ports/cef/command_line.rs b/ports/cef/command_line.rs index 393b3d62004..6b0d91d4130 100644 --- a/ports/cef/command_line.rs +++ b/ports/cef/command_line.rs @@ -33,7 +33,7 @@ fn command_line_new() -> *mut command_line_t { pub fn command_line_init(argc: c_int, argv: *const *const u8) { unsafe { let mut a: Vec = vec!(); - for i in range(0u, argc as uint) { + for i in 0u..(argc as uint) { let offset = *argv.offset(i as int) as *const c_char; let slice = ffi::c_str_to_bytes(&offset); let s = str::from_utf8(slice).unwrap(); @@ -58,7 +58,7 @@ pub extern "C" fn command_line_get_switch_value(cmd: *mut cef_command_line_t, na let cl: *mut command_line_t = mem::transmute(cmd); let cs: *const cef_string_utf16_t = mem::transmute(name); let buf = (*cs).str as *const _; - let slice = slice::from_raw_buf(&buf, (*cs).length as usize); + let slice = slice::from_raw_parts(buf, (*cs).length as usize); let opt = String::from_utf16(slice).unwrap(); //debug!("opt: {}", opt); for s in (*cl).argv.iter() { @@ -66,7 +66,7 @@ pub extern "C" fn command_line_get_switch_value(cmd: *mut cef_command_line_t, na //debug!("arg: {}", o); if o.as_slice().starts_with(opt.as_slice()) { let mut string = mem::uninitialized(); - let arg = o.slice_from(opt.len() + 1).as_bytes(); + let arg = o[opt.len() + 1..].as_bytes(); let c_str = ffi::CString::from_slice(arg); cef_string_utf16_set(c_str.as_bytes().as_ptr() as *const _, arg.len() as size_t, diff --git a/ports/cef/eutil.rs b/ports/cef/eutil.rs index 9ba9852e051..d6bf20b780f 100644 --- a/ports/cef/eutil.rs +++ b/ports/cef/eutil.rs @@ -21,7 +21,7 @@ pub trait Downcast { pub fn slice_to_str(s: *const u8, l: uint, f: F) -> c_int where F: FnOnce(&str) -> c_int { unsafe { - let s = slice::from_raw_buf(&s, l); + let s = slice::from_raw_parts(s, l); str::from_utf8(s).map(f).unwrap_or(0) } } diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index afd3289b1ee..0f1a930ec05 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -2,9 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#![feature(thread_local, link_args, plugin, box_syntax, int_uint)] +#![feature(int_uint)] +#![feature(box_syntax)] +#![feature(plugin)] +#![feature(link_args)] +#![feature(thread_local)] +#![feature(libc)] +#![feature(unicode)] +#![feature(core)] +#![feature(std_misc)] +#![feature(rustc_private)] +#![feature(collections)] -#![allow(experimental, non_camel_case_types, unstable)] +#![allow(non_camel_case_types)] #[macro_use] extern crate log; diff --git a/ports/cef/string.rs b/ports/cef/string.rs index efc35744434..4ad1d00a92a 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -18,6 +18,7 @@ use types::{cef_string_userfree_utf16_t, cef_string_userfree_utf8_t, cef_string_ //cef_string #[no_mangle] +#[allow(private_no_mangle_fns)] extern "C" fn string_wide_dtor(str: *mut wchar_t) { unsafe { libc::free(str as *mut c_void) @@ -25,6 +26,7 @@ extern "C" fn string_wide_dtor(str: *mut wchar_t) { } #[no_mangle] +#[allow(private_no_mangle_fns)] extern "C" fn string_utf8_dtor(str: *mut u8) { unsafe { libc::free(str as *mut c_void) @@ -32,6 +34,7 @@ extern "C" fn string_utf8_dtor(str: *mut u8) { } #[no_mangle] +#[allow(private_no_mangle_fns)] extern "C" fn string_utf16_dtor(str: *mut c_ushort) { unsafe { libc::free(str as *mut c_void) @@ -109,8 +112,8 @@ pub extern "C" fn cef_string_utf8_cmp(a: *const cef_string_utf8_t, b: *const cef unsafe { let astr = (*a).str as *const u8; let bstr = (*b).str as *const u8; - let astr = slice::from_raw_buf(&astr, (*a).length as uint); - let bstr = slice::from_raw_buf(&bstr, (*b).length as uint); + let astr = slice::from_raw_parts(astr, (*a).length as uint); + let bstr = slice::from_raw_parts(bstr, (*b).length as uint); match astr.cmp(bstr) { Ordering::Less => -1, Ordering::Equal => 0, @@ -131,7 +134,7 @@ pub extern "C" fn cef_string_utf8_to_utf16(src: *const u8, src_len: size_t, outp #[no_mangle] pub extern "C" fn cef_string_utf16_to_utf8(src: *const u16, src_len: size_t, output: *mut cef_string_utf8_t) -> c_int { unsafe { - let ustr = slice::from_raw_buf(&src, src_len as uint); + let ustr = slice::from_raw_parts(src, src_len as uint); match string::String::from_utf16(ustr) { Ok(str) => { cef_string_utf8_set(str.as_bytes().as_ptr(), str.len() as size_t, output, 1); @@ -190,8 +193,8 @@ pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const c unsafe { let astr = (*a).str as *const _; let bstr = (*b).str as *const _; - let astr: &[u16] = slice::from_raw_buf(&astr, (*a).length as uint); - let bstr: &[u16] = slice::from_raw_buf(&bstr, (*b).length as uint); + let astr: &[u16] = slice::from_raw_parts(astr, (*a).length as uint); + let bstr: &[u16] = slice::from_raw_parts(bstr, (*b).length as uint); match astr.cmp(bstr) { Ordering::Less => -1, Ordering::Equal => 0, @@ -248,8 +251,8 @@ pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef unsafe { let astr = (*a).str as *const wchar_t; let bstr = (*b).str as *const wchar_t; - let astr = slice::from_raw_buf(&astr, (*a).length as uint); - let bstr = slice::from_raw_buf(&bstr, (*b).length as uint); + let astr = slice::from_raw_parts(astr, (*a).length as uint); + let bstr = slice::from_raw_parts(bstr, (*b).length as uint); match astr.cmp(bstr) { Ordering::Less => -1, Ordering::Equal => 0, @@ -275,7 +278,7 @@ pub extern "C" fn cef_string_wide_to_utf8(src: *const wchar_t, src_len: size_t, return cef_string_utf16_to_utf8(src as *const u16, src_len, output); } unsafe { - let ustr = slice::from_raw_buf(&src, src_len as uint); + let ustr = slice::from_raw_parts(src, src_len as uint); let conv = ustr.iter().map(|&c| char::from_u32(c as u32).unwrap_or('\u{FFFD}')).collect::(); cef_string_utf8_set(conv.as_bytes().as_ptr(), conv.len() as size_t, output, 1) } @@ -292,7 +295,7 @@ pub extern "C" fn cef_string_ascii_to_utf16(src: *const u8, src_len: size_t, out #[no_mangle] pub extern "C" fn cef_string_ascii_to_wide(src: *const u8, src_len: size_t, output: *mut cef_string_wide_t) -> c_int { unsafe { - let ustr = slice::from_raw_buf(&src, src_len as uint); + let ustr = slice::from_raw_parts(src, src_len as uint); let conv = ustr.iter().map(|&c| c as u8).collect::>(); cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) } diff --git a/ports/cef/window.rs b/ports/cef/window.rs index b4185695dce..a2e0dd8576c 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -31,9 +31,6 @@ use std::ffi::CString; use std::rc::Rc; use std::sync::mpsc::{Sender, channel}; -#[cfg(target_os="macos")] -use std::ptr; - /// The type of an off-screen window. #[derive(Clone)] pub struct Window { @@ -355,7 +352,7 @@ impl CompositorProxy for CefCompositorProxy { #[cfg(target_os="linux")] fn send(&mut self, msg: compositor_task::Msg) { // FIXME(pcwalton): Kick the GTK event loop awake? - self.sender.send(msg); + self.sender.send(msg).unwrap(); } fn clone_compositor_proxy(&self) -> Box {