mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
WebIDL: use FLoat32Array (#30990)
* inital * audiobuffer: return float 32 array as channel data * add on heap float 32 array type * fix warnings * add list of webidl interfaces to ignore for float 32 * codegen: remove duplication of builtin return type handling * bindings: derive default for float 32 array wrapper * bindings: allow unsafe code in typedarrays module * bindings: rename float 32 array wrapper * bindings: rename HeapFloat32Array is_set method to is_initialized * bindings: assert float 32 array is initialized before data can be acquired * bindings: use let syntax for error handling in float 32 array wrapper * bindings: use copy_from_slice where possible in float 32 array wrapper * bindings: rename args in typedarray copy methods * codegen: use idl type in builtin names for float 32 array * bindings: add a util to create float 32 arrays, use in dom matrix readonly * codegen: tidy * bindings: box the heap inside heaped float 32 arrays
This commit is contained in:
parent
90f70e3408
commit
e145c51234
6 changed files with 159 additions and 87 deletions
|
@ -25,6 +25,7 @@ use crate::dom::bindings::error::Fallible;
|
|||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::typedarrays::create_float32_array;
|
||||
use crate::dom::dommatrix::DOMMatrix;
|
||||
use crate::dom::dompoint::DOMPoint;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
|
@ -676,8 +677,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
|||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-tofloat32array
|
||||
#[allow(unsafe_code)]
|
||||
fn ToFloat32Array(&self, cx: JSContext) -> NonNull<JSObject> {
|
||||
fn ToFloat32Array(&self, cx: JSContext) -> Float32Array {
|
||||
let vec: Vec<f32> = self
|
||||
.matrix
|
||||
.borrow()
|
||||
|
@ -685,11 +685,9 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
|||
.iter()
|
||||
.map(|&x| x as f32)
|
||||
.collect();
|
||||
unsafe {
|
||||
rooted!(in (*cx) let mut array = ptr::null_mut::<JSObject>());
|
||||
let _ = Float32Array::create(*cx, CreateWith::Slice(&vec), array.handle_mut()).unwrap();
|
||||
NonNull::new_unchecked(array.get())
|
||||
}
|
||||
rooted!(in (*cx) let mut array = ptr::null_mut::<JSObject>());
|
||||
create_float32_array(cx, &vec, array.handle_mut())
|
||||
.expect("Converting matrix to float32 array should never fail")
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-tofloat64array
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue