mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Use out parameter for generated methods returning JSVal (#34087)
* Make generated bindings that return a WebIDL `any` value use out parameters. Returning raw JSVal values makes it easier to create GC hazards in code that calls these methods. Accepting a MutableHandle argument instead ensures that the values are rooted by the caller. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Update mozjs. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
537958a3cc
commit
25a0764a37
38 changed files with 763 additions and 515 deletions
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::MutableHandleValue;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::XRBoundedReferenceSpaceBinding::XRBoundedReferenceSpaceMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::XRReferenceSpaceType;
|
||||
|
@ -67,7 +67,7 @@ impl XRBoundedReferenceSpace {
|
|||
|
||||
impl XRBoundedReferenceSpaceMethods for XRBoundedReferenceSpace {
|
||||
/// <https://www.w3.org/TR/webxr/#dom-xrboundedreferencespace-boundsgeometry>
|
||||
fn BoundsGeometry(&self, cx: JSContext, can_gc: CanGc) -> JSVal {
|
||||
fn BoundsGeometry(&self, cx: JSContext, can_gc: CanGc, retval: MutableHandleValue) {
|
||||
if let Some(bounds) = self.reference_space.get_bounds() {
|
||||
let points: Vec<DomRoot<DOMPointReadOnly>> = bounds
|
||||
.into_iter()
|
||||
|
@ -83,9 +83,9 @@ impl XRBoundedReferenceSpaceMethods for XRBoundedReferenceSpace {
|
|||
})
|
||||
.collect();
|
||||
|
||||
to_frozen_array(&points, cx)
|
||||
to_frozen_array(&points, cx, retval)
|
||||
} else {
|
||||
to_frozen_array::<DomRoot<DOMPointReadOnly>>(&[], cx)
|
||||
to_frozen_array::<DomRoot<DOMPointReadOnly>>(&[], cx, retval)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue