Make HeapFloat32Array generic (#31167)

* Make HeapFloat32Array generic

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Define all the methods defaults on the HeapTypedArray trait

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Use generic type instead of trait

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

---------

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
Taym Haddadi 2024-01-29 12:57:50 +01:00 committed by GitHub
parent 7d1b19c865
commit 742d3ed97f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 78 additions and 56 deletions

View file

@ -3,9 +3,9 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use dom_struct::dom_struct;
use js::typedarray::Float32Array;
use js::typedarray::{Float32, Float32Array};
use super::bindings::typedarrays::HeapFloat32Array;
use super::bindings::typedarrays::HeapTypedArray;
use crate::dom::bindings::codegen::Bindings::GamepadPoseBinding::GamepadPoseMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
@ -16,17 +16,17 @@ use crate::script_runtime::JSContext;
pub struct GamepadPose {
reflector_: Reflector,
#[ignore_malloc_size_of = "mozjs"]
position: HeapFloat32Array,
position: HeapTypedArray<Float32>,
#[ignore_malloc_size_of = "mozjs"]
orientation: HeapFloat32Array,
orientation: HeapTypedArray<Float32>,
#[ignore_malloc_size_of = "mozjs"]
linear_vel: HeapFloat32Array,
linear_vel: HeapTypedArray<Float32>,
#[ignore_malloc_size_of = "mozjs"]
angular_vel: HeapFloat32Array,
angular_vel: HeapTypedArray<Float32>,
#[ignore_malloc_size_of = "mozjs"]
linear_acc: HeapFloat32Array,
linear_acc: HeapTypedArray<Float32>,
#[ignore_malloc_size_of = "mozjs"]
angular_acc: HeapFloat32Array,
angular_acc: HeapTypedArray<Float32>,
}
// TODO: support gamepad discovery
@ -35,12 +35,12 @@ impl GamepadPose {
fn new_inherited() -> GamepadPose {
GamepadPose {
reflector_: Reflector::new(),
position: HeapFloat32Array::default(),
orientation: HeapFloat32Array::default(),
linear_vel: HeapFloat32Array::default(),
angular_vel: HeapFloat32Array::default(),
linear_acc: HeapFloat32Array::default(),
angular_acc: HeapFloat32Array::default(),
position: HeapTypedArray::default(),
orientation: HeapTypedArray::default(),
linear_vel: HeapTypedArray::default(),
angular_vel: HeapTypedArray::default(),
linear_acc: HeapTypedArray::default(),
angular_acc: HeapTypedArray::default(),
}
}