diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-10-14 14:48:44 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-10-14 14:48:44 -0600 |
commit | b34fd5bd7e55be1d577df5cf70b41af8a6cc716b (patch) | |
tree | da75856d209b23755de169dcbfe798afb0487a4a /components/script/dom/browsercontext.rs | |
parent | f35f809938792fbad61fd517187e46c1e009cd16 (diff) | |
parent | 3129fb2330251a38d0025766c28855eaa197afb8 (diff) | |
download | servo-b34fd5bd7e55be1d577df5cf70b41af8a6cc716b.tar.gz servo-b34fd5bd7e55be1d577df5cf70b41af8a6cc716b.zip |
Auto merge of #7727 - michaelwu:update-bindings, r=jdm
Support the updated spidermonkey bindings
Still need to finish the rust-mozjs update and make cargo use it, but it's close enough that I don't expect much to change on the servo side.
Some changes here
- bools are properly translated now
- char16_t is handled as u16 now
- JS_GlobalObjectTraceHook isn't mangled now
- JSJitInfo has been adjusted
- A const fn is used to generate bitfields in JSJitInfo
- Manually generating handles now requires calling an unsafe function. It's not actually required, but it's too much of a hassle to generate them manually now due to bindgen++ adding base classes now.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7727)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/browsercontext.rs')
-rw-r--r-- | components/script/dom/browsercontext.rs | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/components/script/dom/browsercontext.rs b/components/script/dom/browsercontext.rs index 3209231d196..3df44a5ba9b 100644 --- a/components/script/dom/browsercontext.rs +++ b/components/script/dom/browsercontext.rs @@ -13,14 +13,13 @@ use dom::element::Element; use dom::window::Window; use js::glue::{CreateWrapperProxyHandler, ProxyTraps, WrapperNew}; use js::glue::{GetProxyPrivate}; -use js::jsapi::{Handle, HandleValue, Heap, JS_ForwardSetPropertyTo, ObjectOpResult, RootedObject, RootedValue}; +use js::jsapi::{Handle, Heap, JS_ForwardSetPropertyTo, ObjectOpResult, RootedObject, RootedValue}; use js::jsapi::{HandleId, HandleObject, MutableHandle, MutableHandleValue}; use js::jsapi::{JSAutoCompartment, JSAutoRequest}; use js::jsapi::{JSContext, JSErrNum, JSObject, JSPropertyDescriptor}; use js::jsapi::{JS_AlreadyHasOwnPropertyById, JS_ForwardGetPropertyTo}; use js::jsapi::{JS_DefinePropertyById6, JS_GetPropertyDescriptorById}; use js::jsval::{ObjectValue, UndefinedValue}; -use js::{JSFalse, JSTrue}; use std::default::Default; use std::ptr; @@ -115,20 +114,20 @@ unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: HandleObject, id: HandleI #[allow(unsafe_code)] unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: HandleObject, id: HandleId, - desc: MutableHandle<JSPropertyDescriptor>) -> u8 { + desc: MutableHandle<JSPropertyDescriptor>) -> bool { let window = GetSubframeWindow(cx, proxy, id); if let Some(window) = window { let mut val = RootedValue::new(cx, UndefinedValue()); window.to_jsval(cx, val.handle_mut()); (*desc.ptr).value = val.ptr; fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, true); - return JSTrue; + return true; } let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object()); // XXX This should be JS_GetOwnPropertyDescriptorById - if JS_GetPropertyDescriptorById(cx, target.handle(), id, desc) == 0 { - return JSFalse; + if !JS_GetPropertyDescriptorById(cx, target.handle(), id, desc) { + return false; } if (*desc.ptr).obj != target.ptr { @@ -138,7 +137,7 @@ unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: HandleObjec (*desc.ptr).obj = *proxy.ptr; } - JSTrue + true } #[allow(unsafe_code)] @@ -146,14 +145,14 @@ unsafe extern fn defineProperty(cx: *mut JSContext, proxy: HandleObject, id: HandleId, desc: Handle<JSPropertyDescriptor>, - res: *mut ObjectOpResult) -> u8 { + res: *mut ObjectOpResult) -> bool { if get_array_index_from_id(cx, id).is_some() { // Spec says to Reject whether this is a supported index or not, // since we have no indexed setter or indexed creator. That means // throwing in strict mode (FIXME: Bug 828137), doing nothing in // non-strict mode. - (*res).code_ = JSErrNum::JSMSG_CANT_DEFINE_WINDOW_ELEMENT as u32; - return JSTrue; + (*res).code_ = JSErrNum::JSMSG_CANT_DEFINE_WINDOW_ELEMENT as ::libc::uintptr_t; + return true; } let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object()); @@ -161,21 +160,21 @@ unsafe extern fn defineProperty(cx: *mut JSContext, } #[allow(unsafe_code)] -unsafe extern fn hasOwn(cx: *mut JSContext, proxy: HandleObject, id: HandleId, bp: *mut u8) -> u8 { +unsafe extern fn hasOwn(cx: *mut JSContext, proxy: HandleObject, id: HandleId, bp: *mut bool) -> bool { let window = GetSubframeWindow(cx, proxy, id); if window.is_some() { - *bp = JSTrue; - return JSTrue; + *bp = true; + return true; } let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object()); - let mut found = 0; - if JS_AlreadyHasOwnPropertyById(cx, target.handle(), id, &mut found) == 0 { - return JSFalse; + let mut found = false; + if !JS_AlreadyHasOwnPropertyById(cx, target.handle(), id, &mut found) { + return false; } - *bp = (found != 0) as u8; - JSTrue + *bp = found; + true } #[allow(unsafe_code)] @@ -183,11 +182,11 @@ unsafe extern fn get(cx: *mut JSContext, proxy: HandleObject, receiver: HandleObject, id: HandleId, - vp: MutableHandleValue) -> u8 { + vp: MutableHandleValue) -> bool { let window = GetSubframeWindow(cx, proxy, id); if let Some(window) = window { window.to_jsval(cx, vp); - return JSTrue; + return true; } let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object()); @@ -200,16 +199,16 @@ unsafe extern fn set(cx: *mut JSContext, receiver: HandleObject, id: HandleId, vp: MutableHandleValue, - res: *mut ObjectOpResult) -> u8 { + res: *mut ObjectOpResult) -> bool { if get_array_index_from_id(cx, id).is_some() { // Reject (which means throw if and only if strict) the set. - (*res).code_ = JSErrNum::JSMSG_READ_ONLY as u32; - return JSTrue; + (*res).code_ = JSErrNum::JSMSG_READ_ONLY as ::libc::uintptr_t; + return true; } let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object()); let receiver = RootedValue::new(cx, ObjectValue(&**receiver.ptr)); - JS_ForwardSetPropertyTo(cx, target.handle(), id, HandleValue { ptr: vp.ptr }, receiver.handle(), res) + JS_ForwardSetPropertyTo(cx, target.handle(), id, vp.to_handle(), receiver.handle(), res) } static PROXY_HANDLER: ProxyTraps = ProxyTraps { |