mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Support future uses of traits with associated types in rooting analysis (#34359)
* crown: Support Rc<T::Promise> and callback objects parameterized over a trait.. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * crown: Verify that attributes match between trait associated types and impls. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * crown: Check type aliases as part of associated type checks. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * crown: Add periods to all diagnostic messages. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Tidy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix compile-fail test expectations. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
60dc3b26fb
commit
a014da590a
12 changed files with 296 additions and 33 deletions
|
@ -31,6 +31,7 @@ const MAX_LOG_DEPTH: usize = 10;
|
|||
const MAX_LOG_CHILDREN: usize = 15;
|
||||
|
||||
/// <https://developer.mozilla.org/en-US/docs/Web/API/Console>
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
pub(crate) struct Console;
|
||||
|
||||
impl Console {
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
|
||||
// check-tidy: no specs after this line
|
||||
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
pub(crate) struct TestNS(());
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::JSContext;
|
||||
use js::rust::MutableHandleValue;
|
||||
use webxr_api::{FingerJoint, Hand, Joint};
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::XRHandBinding::{XRHandJoint, XRHandMethods};
|
||||
use crate::dom::bindings::conversions::ToJSValConvertible;
|
||||
use crate::dom::bindings::iterable::Iterable;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
|
@ -163,19 +166,30 @@ impl XRHandMethods<crate::DomTypeHolder> for XRHand {
|
|||
}
|
||||
}
|
||||
|
||||
/// A wrapper to work around a crown error—Root<T> has a crown annotation on it that is not present
|
||||
/// on the Iterable::Value associated type. The absence is harmless in this case.
|
||||
pub(crate) struct ValueWrapper(pub DomRoot<XRJointSpace>);
|
||||
|
||||
impl ToJSValConvertible for ValueWrapper {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
|
||||
self.0.to_jsval(cx, rval)
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterable for XRHand {
|
||||
type Key = XRHandJoint;
|
||||
type Value = DomRoot<XRJointSpace>;
|
||||
type Value = ValueWrapper;
|
||||
|
||||
fn get_iterable_length(&self) -> u32 {
|
||||
JOINT_SPACE_MAP.len() as u32
|
||||
}
|
||||
|
||||
fn get_value_at_index(&self, n: u32) -> DomRoot<XRJointSpace> {
|
||||
fn get_value_at_index(&self, n: u32) -> ValueWrapper {
|
||||
let joint = JOINT_SPACE_MAP[n as usize].1;
|
||||
self.spaces
|
||||
.get(joint)
|
||||
.map(|j| DomRoot::from_ref(&**j))
|
||||
.map(|j| ValueWrapper(DomRoot::from_ref(&**j)))
|
||||
.expect("Failed to get joint pose")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue