mark create_type_array as unsafe in vrframedata component

This commit is contained in:
Vladimir Iacob 2019-01-06 19:04:18 +02:00
parent 0196160551
commit 8a615fc880
2 changed files with 13 additions and 10 deletions

View file

@ -58,10 +58,12 @@ impl VRFrameData {
VRFrameDataBinding::Wrap, VRFrameDataBinding::Wrap,
); );
let cx = global.get_cx(); let cx = global.get_cx();
create_typed_array(cx, &matrix, &root.left_proj); unsafe {
create_typed_array(cx, &matrix, &root.left_view); create_typed_array(cx, &matrix, &root.left_proj);
create_typed_array(cx, &matrix, &root.right_proj); create_typed_array(cx, &matrix, &root.left_view);
create_typed_array(cx, &matrix, &root.right_view); create_typed_array(cx, &matrix, &root.right_proj);
create_typed_array(cx, &matrix, &root.right_view);
}
root root
} }
@ -73,11 +75,9 @@ impl VRFrameData {
/// FIXME(#22526) this should be in a better place /// FIXME(#22526) this should be in a better place
#[allow(unsafe_code)] #[allow(unsafe_code)]
pub fn create_typed_array(cx: *mut JSContext, src: &[f32], dst: &Heap<*mut JSObject>) { pub unsafe fn create_typed_array(cx: *mut JSContext, src: &[f32], dst: &Heap<*mut JSObject>) {
rooted!(in (cx) let mut array = ptr::null_mut::<JSObject>()); rooted!(in (cx) let mut array = ptr::null_mut::<JSObject>());
unsafe { let _ = Float32Array::create(cx, CreateWith::Slice(src), array.handle_mut());
let _ = Float32Array::create(cx, CreateWith::Slice(src), array.handle_mut());
}
(*dst).set(array.get()); (*dst).set(array.get());
} }

View file

@ -34,6 +34,7 @@ impl XRView {
} }
} }
#[allow(unsafe_code)]
pub fn new( pub fn new(
global: &GlobalScope, global: &GlobalScope,
session: &XRSession, session: &XRSession,
@ -53,8 +54,10 @@ impl XRView {
}; };
let cx = global.get_cx(); let cx = global.get_cx();
create_typed_array(cx, proj, &ret.proj); unsafe {
create_typed_array(cx, view, &ret.view); create_typed_array(cx, proj, &ret.proj);
create_typed_array(cx, view, &ret.view);
}
ret ret
} }