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/bindings/conversions.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/bindings/conversions.rs')
-rw-r--r-- | components/script/dom/bindings/conversions.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 23105fa7810..3805a0e76d3 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -186,7 +186,7 @@ impl ToJSValConvertible for () { impl ToJSValConvertible for JSVal { fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { rval.set(*self); - if unsafe { JS_WrapValue(cx, rval) } == 0 { + if unsafe { !JS_WrapValue(cx, rval) } { panic!("JS_WrapValue failed."); } } @@ -195,7 +195,7 @@ impl ToJSValConvertible for JSVal { impl ToJSValConvertible for HandleValue { fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { rval.set(self.get()); - if unsafe { JS_WrapValue(cx, rval) } == 0 { + if unsafe { !JS_WrapValue(cx, rval) } { panic!("JS_WrapValue failed."); } } @@ -397,7 +397,7 @@ impl ToJSValConvertible for str { let mut string_utf16: Vec<u16> = Vec::with_capacity(self.len()); unsafe { string_utf16.extend(self.utf16_units()); - let jsstr = JS_NewUCStringCopyN(cx, string_utf16.as_ptr() as *const i16, + let jsstr = JS_NewUCStringCopyN(cx, string_utf16.as_ptr(), string_utf16.len() as libc::size_t); if jsstr.is_null() { panic!("JS_NewUCStringCopyN failed"); @@ -426,7 +426,7 @@ pub enum StringificationBehavior { /// contain valid UTF-16. pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString { let mut length = 0; - let latin1 = unsafe { JS_StringHasLatin1Chars(s) != 0 }; + let latin1 = unsafe { JS_StringHasLatin1Chars(s) }; if latin1 { let chars = unsafe { JS_GetLatin1StringCharsAndLength(cx, ptr::null(), s, &mut length) @@ -479,7 +479,7 @@ pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString { /// string, or if the string does not contain valid UTF-16. pub fn jsid_to_str(cx: *mut JSContext, id: HandleId) -> DOMString { unsafe { - assert!(RUST_JSID_IS_STRING(id) != 0); + assert!(RUST_JSID_IS_STRING(id)); jsstring_to_str(cx, RUST_JSID_TO_STRING(id)) } } @@ -519,7 +519,7 @@ impl FromJSValConvertible for USVString { debug!("ToString failed"); return Err(()); } - let latin1 = unsafe { JS_StringHasLatin1Chars(jsstr) != 0 }; + let latin1 = unsafe { JS_StringHasLatin1Chars(jsstr) }; if latin1 { return Ok(USVString(jsstring_to_str(cx, jsstr))); } @@ -555,7 +555,7 @@ impl FromJSValConvertible for ByteString { return Err(()); } - let latin1 = unsafe { JS_StringHasLatin1Chars(string) != 0 }; + let latin1 = unsafe { JS_StringHasLatin1Chars(string) }; if latin1 { let mut length = 0; let chars = unsafe { @@ -577,7 +577,7 @@ impl FromJSValConvertible for ByteString { let char_vec = slice::from_raw_parts(chars, length as usize); if char_vec.iter().any(|&c| c > 0xFF) { - // XXX Throw + throw_type_error(cx, "Invalid ByteString"); Err(()) } else { Ok(ByteString::new(char_vec.iter().map(|&c| c as u8).collect())) @@ -591,7 +591,7 @@ impl ToJSValConvertible for Reflector { let obj = self.get_jsobject().get(); assert!(!obj.is_null()); rval.set(ObjectValue(unsafe { &*obj })); - if unsafe { JS_WrapValue(cx, rval) } == 0 { + if unsafe { !JS_WrapValue(cx, rval) } { panic!("JS_WrapValue failed."); } } @@ -670,14 +670,14 @@ pub unsafe fn private_from_proto_chain(mut obj: *mut JSObject, proto_id: u16, proto_depth: u16) -> Result<*const libc::c_void, ()> { let dom_class = try!(get_dom_class(obj).or_else(|_| { - if IsWrapper(obj) == 1 { + if IsWrapper(obj) { debug!("found wrapper"); obj = UnwrapObject(obj, /* stopAtOuter = */ 0); if obj.is_null() { debug!("unwrapping security wrapper failed"); Err(()) } else { - assert!(IsWrapper(obj) == 0); + assert!(!IsWrapper(obj)); debug!("unwrapped successfully"); get_dom_class(obj) } @@ -774,7 +774,7 @@ impl ToJSValConvertible for *mut JSObject { fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { rval.set(ObjectOrNullValue(*self)); unsafe { - assert!(JS_WrapValue(cx, rval) != 0); + assert!(JS_WrapValue(cx, rval)); } } } |