mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Fix various build warnings.
This commit is contained in:
parent
717805a593
commit
1604515fd9
16 changed files with 32 additions and 35 deletions
|
@ -99,7 +99,7 @@ impl CallbackInterface {
|
|||
-> Result<JSVal, ()> {
|
||||
let mut callable = UndefinedValue();
|
||||
unsafe {
|
||||
let name = CString::from_slice(name.as_bytes());
|
||||
let name = CString::new(name).unwrap();
|
||||
if JS_GetProperty(cx, self.callback(), name.as_ptr(), &mut callable) == 0 {
|
||||
return Err(());
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ pub fn report_pending_exception(cx: *mut JSContext, obj: *mut JSObject) {
|
|||
pub fn throw_not_in_union(cx: *mut JSContext, names: &'static str) -> JSBool {
|
||||
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
||||
let message = format!("argument could not be converted to any of: {}", names);
|
||||
let string = CString::from_slice(message.as_bytes());
|
||||
let string = CString::new(message).unwrap();
|
||||
unsafe { ReportError(cx, string.as_ptr()) };
|
||||
return 0;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ unsafe extern fn get_error_message(_user_ref: *mut libc::c_void,
|
|||
|
||||
/// Throw a `TypeError` with the given message.
|
||||
pub fn throw_type_error(cx: *mut JSContext, error: &str) {
|
||||
let error = CString::from_slice(error.as_bytes());
|
||||
let error = CString::new(error).unwrap();
|
||||
unsafe {
|
||||
JS_ReportErrorNumber(cx,
|
||||
Some(get_error_message as
|
||||
|
|
|
@ -92,7 +92,7 @@ pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: JSVal) {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let name = CString::from_slice(description.as_bytes());
|
||||
let name = CString::new(description).unwrap();
|
||||
(*tracer).debugPrinter = None;
|
||||
(*tracer).debugPrintIndex = -1;
|
||||
(*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void;
|
||||
|
@ -110,7 +110,7 @@ pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Ref
|
|||
/// Trace a `JSObject`.
|
||||
pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: *mut JSObject) {
|
||||
unsafe {
|
||||
let name = CString::from_slice(description.as_bytes());
|
||||
let name = CString::new(description).unwrap();
|
||||
(*tracer).debugPrinter = None;
|
||||
(*tracer).debugPrintIndex = -1;
|
||||
(*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void;
|
||||
|
|
|
@ -197,7 +197,7 @@ pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject,
|
|||
|
||||
match constructor {
|
||||
Some((native, name, nargs)) => {
|
||||
let s = CString::from_slice(name.as_bytes());
|
||||
let s = CString::new(name).unwrap();
|
||||
create_interface_object(cx, global, receiver,
|
||||
native, nargs, proto,
|
||||
members, s.as_ptr())
|
||||
|
@ -516,7 +516,7 @@ pub fn get_dictionary_property(cx: *mut JSContext,
|
|||
}
|
||||
}
|
||||
|
||||
let property = CString::from_slice(property.as_bytes());
|
||||
let property = CString::new(property).unwrap();
|
||||
if object.is_null() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
|
|
@ -126,8 +126,8 @@ impl<'a> BlobMethods for JSRef<'a, Blob> {
|
|||
match self.bytes {
|
||||
None => Blob::new(global.r(), None, relativeContentType.as_slice()),
|
||||
Some(ref vec) => {
|
||||
let start = relativeStart.to_uint().unwrap();
|
||||
let end = (relativeStart + span).to_uint().unwrap();
|
||||
let start = relativeStart.to_usize().unwrap();
|
||||
let end = (relativeStart + span).to_usize().unwrap();
|
||||
let mut bytes: Vec<u8> = Vec::new();
|
||||
bytes.push_all(&vec[start..end]);
|
||||
Blob::new(global.r(), Some(bytes), relativeContentType.as_slice())
|
||||
|
|
|
@ -198,8 +198,8 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
|||
scope: *mut JSObject,
|
||||
ty: &str,
|
||||
source: DOMString) {
|
||||
let url = CString::from_slice(url.serialize().as_bytes());
|
||||
let name = CString::from_slice(ty.as_bytes());
|
||||
let url = CString::new(url.serialize()).unwrap();
|
||||
let name = CString::new(ty).unwrap();
|
||||
let lineno = 0; //XXXjdm need to get a real number here
|
||||
|
||||
let nargs = 1; //XXXjdm not true for onerror
|
||||
|
|
|
@ -32,7 +32,6 @@ use util::str::DOMString;
|
|||
|
||||
use string_cache::Atom;
|
||||
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::default::Default;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ impl ImageData {
|
|||
|
||||
if let Some(vec) = data {
|
||||
let js_object_data: *mut uint8_t = JS_GetUint8ClampedArrayData(js_object, cx);
|
||||
ptr::copy_nonoverlapping_memory(js_object_data, vec.as_ptr(), vec.len())
|
||||
ptr::copy_nonoverlapping(js_object_data, vec.as_ptr(), vec.len())
|
||||
}
|
||||
|
||||
ImageData {
|
||||
|
|
|
@ -470,7 +470,7 @@ impl<'a, T: Reflectable> ScriptHelpers for JSRef<'a, T> {
|
|||
let global = global_object_for_js_object(this).root().r().reflector().get_jsobject();
|
||||
let code: Vec<u16> = code.as_slice().utf16_units().collect();
|
||||
let mut rval = UndefinedValue();
|
||||
let filename = CString::from_slice(filename.as_bytes());
|
||||
let filename = CString::new(filename).unwrap();
|
||||
|
||||
with_compartment(cx, global, || {
|
||||
unsafe {
|
||||
|
|
|
@ -30,8 +30,8 @@ use net::resource_task::{ProgressMsg, LoadResponse};
|
|||
use util::task_state;
|
||||
use util::task_state::IN_HTML_PARSER;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::Cow;
|
||||
use std::old_io::{Writer, IoResult};
|
||||
use std::string::CowString;
|
||||
use url::Url;
|
||||
use html5ever::Attribute;
|
||||
use html5ever::serialize::{Serializable, Serializer, AttrRef};
|
||||
|
@ -120,7 +120,7 @@ impl<'a> TreeSink for servohtmlparser::Sink {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_error(&mut self, msg: CowString<'static>) {
|
||||
fn parse_error(&mut self, msg: Cow<'static, str>) {
|
||||
debug!("Parse error: {}", msg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue