Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make create_typed_array an unsafe function #22640

Merged
merged 1 commit into from Jan 8, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

mark create_type_array as unsafe in vrframedata component

  • Loading branch information
heh9 committed Jan 6, 2019
commit 8a615fc8802bd25e449dc69d37df15fbb1807fb0
@@ -58,10 +58,12 @@ impl VRFrameData {
VRFrameDataBinding::Wrap,
);
let cx = global.get_cx();
create_typed_array(cx, &matrix, &root.left_proj);
create_typed_array(cx, &matrix, &root.left_view);
create_typed_array(cx, &matrix, &root.right_proj);
create_typed_array(cx, &matrix, &root.right_view);
unsafe {
create_typed_array(cx, &matrix, &root.left_proj);
create_typed_array(cx, &matrix, &root.left_view);
create_typed_array(cx, &matrix, &root.right_proj);
create_typed_array(cx, &matrix, &root.right_view);
}

root
}
@@ -73,11 +75,9 @@ impl VRFrameData {

/// FIXME(#22526) this should be in a better place
#[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>());
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());
}

@@ -34,6 +34,7 @@ impl XRView {
}
}

#[allow(unsafe_code)]
pub fn new(
global: &GlobalScope,
session: &XRSession,
@@ -53,8 +54,10 @@ impl XRView {
};

let cx = global.get_cx();
create_typed_array(cx, proj, &ret.proj);
create_typed_array(cx, view, &ret.view);
unsafe {
create_typed_array(cx, proj, &ret.proj);
create_typed_array(cx, view, &ret.view);
}
ret
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.