mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Use FLoat32Array in GamepadPose (#31106)
* Use FLoat32Array in GamepadPose Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Remove unused create_typed_array Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> --------- Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
9a698b7bfb
commit
9d2c102fa0
4 changed files with 38 additions and 84 deletions
|
@ -1460,10 +1460,6 @@ def getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs):
|
|||
return "()"
|
||||
|
||||
|
||||
def todo_switch_float_32(des):
|
||||
return des.interface.identifier.name in ['GamepadPose']
|
||||
|
||||
|
||||
def builtin_return_type(returnType):
|
||||
result = CGGeneric(builtinNames[returnType.tag()])
|
||||
if returnType.nullable():
|
||||
|
@ -1478,7 +1474,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider):
|
|||
return CGGeneric("()")
|
||||
if returnType.isPrimitive() and returnType.tag() in builtinNames:
|
||||
return builtin_return_type(returnType)
|
||||
if returnType.isTypedArray() and returnType.tag() in builtinNames and not todo_switch_float_32(descriptorProvider):
|
||||
if returnType.isTypedArray() and returnType.tag() in builtinNames:
|
||||
return builtin_return_type(returnType)
|
||||
if returnType.isDOMString():
|
||||
result = CGGeneric("DOMString")
|
||||
|
|
|
@ -102,4 +102,13 @@ impl HeapFloat32Array {
|
|||
pub fn get_internal(&self) -> Result<Float32Array, ()> {
|
||||
Float32Array::from(self.internal.get())
|
||||
}
|
||||
|
||||
pub fn internal_to_option(&self) -> Option<Float32Array> {
|
||||
if self.is_initialized() {
|
||||
Some(self.get_internal().expect("Failed to get internal."))
|
||||
} else {
|
||||
warn!("Internal not initialized.");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ use js::rust::{
|
|||
get_object_class, is_dom_class, GCMethods, Handle, HandleId, HandleObject, HandleValue,
|
||||
MutableHandleValue, ToString,
|
||||
};
|
||||
use js::typedarray::{CreateWith, Float32Array};
|
||||
use js::JS_CALLEE;
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
|
||||
|
@ -133,15 +132,6 @@ pub fn to_frozen_array<T: ToJSValConvertible>(convertibles: &[T], cx: SafeJSCont
|
|||
*ports
|
||||
}
|
||||
|
||||
/// Creates a Float32 array
|
||||
pub fn create_typed_array(cx: SafeJSContext, 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());
|
||||
}
|
||||
(*dst).set(array.get());
|
||||
}
|
||||
|
||||
/// Returns the ProtoOrIfaceArray for the given global object.
|
||||
/// Fails if `global` is not a DOM global object.
|
||||
pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut ProtoOrIfaceArray {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue