mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Upgrade to rustc 0.12.0-pre (4d2af3861 2014-09-17 15:51:11 +0000)
This commit is contained in:
parent
8a7eefefd5
commit
a640a7c5c3
74 changed files with 459 additions and 449 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue