mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Upgrade to SM 39
This commit is contained in:
parent
a256f39796
commit
675267b782
205 changed files with 6546 additions and 5340 deletions
|
@ -13,7 +13,7 @@ use js::glue::JS_STRUCTURED_CLONE_VERSION;
|
|||
use js::jsapi::JSContext;
|
||||
use js::jsapi::{JS_WriteStructuredClone, JS_ClearPendingException};
|
||||
use js::jsapi::JS_ReadStructuredClone;
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use js::jsapi::{HandleValue, MutableHandleValue};
|
||||
|
||||
use libc::size_t;
|
||||
use std::ptr;
|
||||
|
@ -26,13 +26,14 @@ pub struct StructuredCloneData {
|
|||
|
||||
impl StructuredCloneData {
|
||||
/// Writes a structured clone. Returns a `DataClone` error if that fails.
|
||||
pub fn write(cx: *mut JSContext, message: JSVal)
|
||||
pub fn write(cx: *mut JSContext, message: HandleValue)
|
||||
-> Fallible<StructuredCloneData> {
|
||||
let mut data = ptr::null_mut();
|
||||
let mut nbytes = 0;
|
||||
let result = unsafe {
|
||||
JS_WriteStructuredClone(cx, message, &mut data, &mut nbytes,
|
||||
ptr::null(), ptr::null_mut())
|
||||
ptr::null(), ptr::null_mut(),
|
||||
HandleValue::undefined())
|
||||
};
|
||||
if result == 0 {
|
||||
unsafe { JS_ClearPendingException(cx); }
|
||||
|
@ -47,15 +48,13 @@ impl StructuredCloneData {
|
|||
/// Reads a structured clone.
|
||||
///
|
||||
/// Panics if `JS_ReadStructuredClone` fails.
|
||||
pub fn read(self, global: GlobalRef) -> JSVal {
|
||||
let mut message = UndefinedValue();
|
||||
pub fn read(self, global: GlobalRef, rval: MutableHandleValue) {
|
||||
unsafe {
|
||||
assert!(JS_ReadStructuredClone(
|
||||
global.get_cx(), self.data as *const u64, self.nbytes,
|
||||
JS_STRUCTURED_CLONE_VERSION, &mut message,
|
||||
global.get_cx(), self.data, self.nbytes,
|
||||
JS_STRUCTURED_CLONE_VERSION, rval,
|
||||
ptr::null(), ptr::null_mut()) != 0);
|
||||
}
|
||||
message
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue