Upgrade to rustc 0.12.0-pre (4d2af3861 2014-09-17 15:51:11 +0000)

This commit is contained in:
Keegan McAllister 2014-09-16 13:00:18 -07:00
parent 8a7eefefd5
commit a640a7c5c3
74 changed files with 459 additions and 449 deletions

View file

@ -121,7 +121,7 @@ pub fn WrapCallThisObject<T: Reflectable>(cx: *mut JSContext,
unsafe {
if JS_WrapObject(cx, &mut obj) == 0 {
return ptr::mut_null();
return ptr::null_mut();
}
}

View file

@ -1757,6 +1757,7 @@ class CGAbstractMethod(CGThing):
decorators.append('#[inline(always)]')
if self.extern:
decorators.append('unsafe')
decorators.append('extern')
if self.pub:
@ -4538,7 +4539,6 @@ class CGBindingRoot(CGThing):
'dom::bindings::conversions::{Default, Empty}',
'dom::bindings::codegen::*',
'dom::bindings::codegen::Bindings::*',
'dom::bindings::codegen::RegisterBindings',
'dom::bindings::codegen::UnionTypes::*',
'dom::bindings::error::{FailureUnknown, Fallible, Error, ErrorResult}',
'dom::bindings::error::throw_dom_exception',
@ -5477,12 +5477,12 @@ class GlobalGenRoots():
}
#[inline(always)]
fn from_ref<'a, T: ${fromBound}>(derived: JSRef<'a, T>) -> JSRef<'a, Self> {
fn from_ref<'a, T: ${fromBound}+Reflectable>(derived: JSRef<'a, T>) -> JSRef<'a, Self> {
unsafe { derived.transmute() }
}
#[inline(always)]
fn from_borrowed_ref<'a, 'b, T: ${fromBound}>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, Self> {
fn from_borrowed_ref<'a, 'b, T: ${fromBound}+Reflectable>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, Self> {
unsafe { derived.transmute_borrowed() }
}

View file

@ -97,7 +97,7 @@ static ERROR_FORMAT_STRING: JSErrorFormatString = JSErrorFormatString {
};
/// Callback used to throw `TypeError`s.
extern fn get_error_message(_user_ref: *mut libc::c_void,
unsafe extern fn get_error_message(_user_ref: *mut libc::c_void,
_locale: *const libc::c_char,
error_number: libc::c_uint) -> *const JSErrorFormatString
{
@ -109,6 +109,6 @@ extern fn get_error_message(_user_ref: *mut libc::c_void,
pub fn throw_type_error(cx: *mut JSContext, error: &str) {
let error = error.to_c_str();
unsafe {
JS_ReportErrorNumber(cx, Some(get_error_message), ptr::mut_null(), 0, error.as_ptr());
JS_ReportErrorNumber(cx, Some(get_error_message), ptr::null_mut(), 0, error.as_ptr());
}
}

View file

@ -255,7 +255,7 @@ impl<T> Assignable<T> for JS<T> {
}
}
impl<'a, T> Assignable<T> for JSRef<'a, T> {
impl<'a, T: Reflectable> Assignable<T> for JSRef<'a, T> {
unsafe fn get_js(&self) -> JS<T> {
self.unrooted()
}

View file

@ -26,11 +26,10 @@ use std::mem::size_of;
static JSPROXYSLOT_EXPANDO: u32 = 0;
pub extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject,
id: jsid, set: bool,
desc: *mut JSPropertyDescriptor)
-> bool {
unsafe {
pub unsafe extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject,
id: jsid, set: bool,
desc: *mut JSPropertyDescriptor)
-> bool {
let handler = GetProxyHandler(proxy);
if !InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, set, desc) {
return false;
@ -42,55 +41,50 @@ pub extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject,
//let proto = JS_GetPrototype(proxy);
let proto = GetObjectProto(proxy);
if proto.is_null() {
(*desc).obj = ptr::mut_null();
(*desc).obj = ptr::null_mut();
return true;
}
JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, desc) != 0
}
}
pub fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
desc: *mut JSPropertyDescriptor) -> bool {
pub unsafe fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
desc: *mut JSPropertyDescriptor) -> bool {
static JSMSG_GETTER_ONLY: libc::c_uint = 160;
unsafe {
//FIXME: Workaround for https://github.com/mozilla/rust/issues/13385
let setter: *const libc::c_void = mem::transmute((*desc).setter);
let setter_stub: *const libc::c_void = mem::transmute(JS_StrictPropertyStub);
if ((*desc).attrs & JSPROP_GETTER) != 0 && setter == setter_stub {
return JS_ReportErrorFlagsAndNumber(cx,
JSREPORT_WARNING | JSREPORT_STRICT |
JSREPORT_STRICT_MODE_ERROR,
Some(RUST_js_GetErrorMessage), ptr::mut_null(),
JSMSG_GETTER_ONLY) != 0;
}
let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return JS_DefinePropertyById(cx, expando, id, (*desc).value, (*desc).getter,
(*desc).setter, (*desc).attrs) != 0;
//FIXME: Workaround for https://github.com/mozilla/rust/issues/13385
let setter: *const libc::c_void = mem::transmute((*desc).setter);
let setter_stub: *const libc::c_void = mem::transmute(JS_StrictPropertyStub);
if ((*desc).attrs & JSPROP_GETTER) != 0 && setter == setter_stub {
return JS_ReportErrorFlagsAndNumber(cx,
JSREPORT_WARNING | JSREPORT_STRICT |
JSREPORT_STRICT_MODE_ERROR,
Some(RUST_js_GetErrorMessage), ptr::null_mut(),
JSMSG_GETTER_ONLY) != 0;
}
let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return JS_DefinePropertyById(cx, expando, id, (*desc).value, (*desc).getter,
(*desc).setter, (*desc).attrs) != 0;
}
pub extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
desc: *mut JSPropertyDescriptor) -> bool {
pub unsafe extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
desc: *mut JSPropertyDescriptor) -> bool {
defineProperty_(cx, proxy, id, desc)
}
pub extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
bp: *mut bool) -> bool {
unsafe {
let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return delete_property_by_id(cx, expando, id, &mut *bp);
pub unsafe extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
bp: *mut bool) -> bool {
let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return delete_property_by_id(cx, expando, id, &mut *bp);
}
pub fn _obj_toString(cx: *mut JSContext, className: *const libc::c_char) -> *mut JSString {
@ -99,7 +93,7 @@ pub fn _obj_toString(cx: *mut JSContext, className: *const libc::c_char) -> *mut
let nchars = "[object ]".len() + name.len();
let chars: *mut jschar = JS_malloc(cx, (nchars + 1) as libc::size_t * (size_of::<jschar>() as libc::size_t)) as *mut jschar;
if chars.is_null() {
return ptr::mut_null();
return ptr::null_mut();
}
let result = format!("[object {}]", name);
@ -121,7 +115,7 @@ pub fn GetExpandoObject(obj: *mut JSObject) -> *mut JSObject {
assert!(is_dom_proxy(obj));
let val = GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
if val.is_undefined() {
ptr::mut_null()
ptr::null_mut()
} else {
val.to_object()
}
@ -133,11 +127,11 @@ pub fn EnsureExpandoObject(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObj
assert!(is_dom_proxy(obj));
let mut expando = GetExpandoObject(obj);
if expando.is_null() {
expando = JS_NewObjectWithGivenProto(cx, ptr::mut_null(),
ptr::mut_null(),
expando = JS_NewObjectWithGivenProto(cx, ptr::null_mut(),
ptr::null_mut(),
GetObjectParent(obj));
if expando.is_null() {
return ptr::mut_null();
return ptr::null_mut();
}
SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(&*expando));

View file

@ -129,7 +129,7 @@ pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject,
let dom_class = get_dom_class(obj).or_else(|_| {
if IsWrapper(obj) == 1 {
debug!("found wrapper");
obj = UnwrapObject(obj, /* stopAtOuter = */ 0, ptr::mut_null());
obj = UnwrapObject(obj, /* stopAtOuter = */ 0, ptr::null_mut());
if obj.is_null() {
debug!("unwrapping security wrapper failed");
Err(())
@ -421,7 +421,7 @@ fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject,
/// A throwing constructor, for those interfaces that have neither
/// `NoInterfaceObject` nor `Constructor`.
pub extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp: *mut JSVal) -> JSBool {
pub unsafe extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp: *mut JSVal) -> JSBool {
throw_type_error(cx, "Illegal constructor.");
return 0;
}
@ -488,7 +488,7 @@ impl Reflector {
/// Create an uninitialized `Reflector`.
pub fn new() -> Reflector {
Reflector {
object: Cell::new(ptr::mut_null()),
object: Cell::new(ptr::null_mut()),
}
}
}
@ -613,7 +613,7 @@ pub fn get_dictionary_property(cx: *mut JSContext,
pub fn HasPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> bool {
// MOZ_ASSERT(js::IsProxy(proxy) && js::GetProxyHandler(proxy) == handler);
let mut found = false;
return !GetPropertyOnPrototype(cx, proxy, id, &mut found, ptr::mut_null()) || found;
return !GetPropertyOnPrototype(cx, proxy, id, &mut found, ptr::null_mut()) || found;
}
/// Returns whether `obj` can be converted to a callback interface per IDL.
@ -626,9 +626,9 @@ pub fn IsConvertibleToCallbackInterface(cx: *mut JSContext, obj: *mut JSObject)
/// Create a DOM global object with the given class.
pub fn CreateDOMGlobal(cx: *mut JSContext, class: *const JSClass) -> *mut JSObject {
unsafe {
let obj = JS_NewGlobalObject(cx, class, ptr::mut_null());
let obj = JS_NewGlobalObject(cx, class, ptr::null_mut());
if obj.is_null() {
return ptr::mut_null();
return ptr::null_mut();
}
with_compartment(cx, obj, || {
JS_InitStandardClasses(cx, obj);
@ -639,18 +639,14 @@ pub fn CreateDOMGlobal(cx: *mut JSContext, class: *const JSClass) -> *mut JSObje
}
/// Callback to outerize windows when wrapping.
pub extern fn wrap_for_same_compartment(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject {
unsafe {
JS_ObjectToOuterObject(cx, obj)
}
pub unsafe extern fn wrap_for_same_compartment(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject {
JS_ObjectToOuterObject(cx, obj)
}
/// Callback to outerize windows before wrapping.
pub extern fn pre_wrap(cx: *mut JSContext, _scope: *mut JSObject,
pub unsafe extern fn pre_wrap(cx: *mut JSContext, _scope: *mut JSObject,
obj: *mut JSObject, _flags: c_uint) -> *mut JSObject {
unsafe {
JS_ObjectToOuterObject(cx, obj)
}
JS_ObjectToOuterObject(cx, obj)
}
/// Callback to outerize windows.
@ -675,12 +671,12 @@ pub fn global_object_for_js_object(obj: *mut JSObject) -> GlobalField {
let global = GetGlobalForObjectCrossCompartment(obj);
let clasp = JS_GetClass(global);
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
match FromJSValConvertible::from_jsval(ptr::mut_null(), ObjectOrNullValue(global), ()) {
match FromJSValConvertible::from_jsval(ptr::null_mut(), ObjectOrNullValue(global), ()) {
Ok(window) => return WindowField(window),
Err(_) => (),
}
match FromJSValConvertible::from_jsval(ptr::mut_null(), ObjectOrNullValue(global), ()) {
match FromJSValConvertible::from_jsval(ptr::null_mut(), ObjectOrNullValue(global), ()) {
Ok(worker) => return WorkerField(worker),
Err(_) => (),
}