mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement StructuredCloneData::read.
This commit is contained in:
parent
5978b21abf
commit
14ff55443f
3 changed files with 21 additions and 28 deletions
|
@ -4,10 +4,13 @@
|
|||
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::error::Error::DataClone;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
|
||||
use js::glue::JS_STRUCTURED_CLONE_VERSION;
|
||||
use js::jsapi::JSContext;
|
||||
use js::jsapi::{JS_WriteStructuredClone, JS_ClearPendingException};
|
||||
use js::jsval::JSVal;
|
||||
use js::jsapi::JS_ReadStructuredClone;
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
|
||||
use libc::size_t;
|
||||
use std::ptr;
|
||||
|
@ -37,4 +40,15 @@ impl StructuredCloneData {
|
|||
nbytes: nbytes,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read(self, global: GlobalRef) -> JSVal {
|
||||
let mut message = UndefinedValue();
|
||||
unsafe {
|
||||
assert!(JS_ReadStructuredClone(
|
||||
global.get_cx(), self.data as *const u64, self.nbytes,
|
||||
JS_STRUCTURED_CLONE_VERSION, &mut message,
|
||||
ptr::null(), ptr::null_mut()) != 0);
|
||||
}
|
||||
message
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue