mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Update rustc to 00b112c45a604fa6f4b59af2a40c9deeadfdb7c6/rustc-1.0.0-dev.
This commit is contained in:
parent
ff8cbff810
commit
95fc29fa0d
255 changed files with 3550 additions and 3362 deletions
|
@ -18,10 +18,11 @@ use js::glue::{ReportError};
|
|||
use js::rust::with_compartment;
|
||||
|
||||
use libc;
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
|
||||
/// DOM exceptions that can be thrown by a native DOM method.
|
||||
#[deriving(Show, Clone)]
|
||||
#[derive(Show, Clone)]
|
||||
pub enum Error {
|
||||
/// IndexSizeError
|
||||
IndexSize,
|
||||
|
@ -95,14 +96,13 @@ 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);
|
||||
message.with_c_str(|string| {
|
||||
unsafe { ReportError(cx, string) };
|
||||
});
|
||||
let string = CString::from_slice(message.as_bytes());
|
||||
unsafe { ReportError(cx, string.as_ptr()) };
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Format string used to throw `TypeError`s.
|
||||
static ERROR_FORMAT_STRING_STRING: [libc::c_char, ..4] = [
|
||||
const ERROR_FORMAT_STRING_STRING: [libc::c_char; 4] = [
|
||||
'{' as libc::c_char,
|
||||
'0' as libc::c_char,
|
||||
'}' as libc::c_char,
|
||||
|
@ -110,7 +110,7 @@ static ERROR_FORMAT_STRING_STRING: [libc::c_char, ..4] = [
|
|||
];
|
||||
|
||||
/// Format string struct used to throw `TypeError`s.
|
||||
static ERROR_FORMAT_STRING: JSErrorFormatString = JSErrorFormatString {
|
||||
const ERROR_FORMAT_STRING: JSErrorFormatString = JSErrorFormatString {
|
||||
format: &ERROR_FORMAT_STRING_STRING as *const libc::c_char,
|
||||
argCount: 1,
|
||||
exnType: JSEXN_TYPEERR as i16,
|
||||
|
@ -127,8 +127,12 @@ 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 = error.to_c_str();
|
||||
let error = CString::from_slice(error.as_bytes());
|
||||
unsafe {
|
||||
JS_ReportErrorNumber(cx, Some(get_error_message), ptr::null_mut(), 0, error.as_ptr());
|
||||
JS_ReportErrorNumber(cx,
|
||||
Some(get_error_message as
|
||||
unsafe extern "C" fn(*mut libc::c_void, *const libc::c_char,
|
||||
libc::c_uint) -> *const JSErrorFormatString),
|
||||
ptr::null_mut(), 0, error.as_ptr());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue