#![allow(non_camel_case_types,non_upper_case_globals,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREyeValues;
use crate::dom::bindings::import::base::*;
#[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum FakeXRRegionType {
Point,
Plane,
Mesh
}
pub mod FakeXRRegionTypeValues {
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::conversions::FromJSValConvertible;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::utils::find_enum_value;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use js::rust::MutableHandleValue;
use js::jsval::JSVal;
pub const pairs: &[(&str, super::FakeXRRegionType)] = &[
("point", super::FakeXRRegionType::Point),
("plane", super::FakeXRRegionType::Plane),
("mesh", super::FakeXRRegionType::Mesh),
];
impl super::FakeXRRegionType {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::FakeXRRegionType {
fn default() -> super::FakeXRRegionType {
pairs[0].1
}
}
impl ToJSValConvertible for super::FakeXRRegionType {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::FakeXRRegionType {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::FakeXRRegionType>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'FakeXRRegionType'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[derive(JSTraceable)]
pub struct FakeXRViewInit {
pub eye: XREye,
pub fieldOfView: Option<crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRFieldOfViewInit>,
pub projectionMatrix: Vec<Finite<f32>>,
pub resolution: crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRDeviceResolution,
pub viewOffset: crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit,
}
impl FakeXRViewInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<FakeXRViewInit>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = FakeXRViewInit {
eye: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "eye", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) { Err(_) => { return Err(());
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"eye\".");
return Err(());
}
},
fieldOfView: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "fieldOfView", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
})
} else {
None
}
},
projectionMatrix: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "projectionMatrix", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"projectionMatrix\".");
return Err(());
}
},
resolution: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "resolution", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"resolution\".");
return Err(());
}
},
viewOffset: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "viewOffset", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"viewOffset\".");
return Err(());
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for FakeXRViewInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<FakeXRViewInit>, ()> {
FakeXRViewInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl FakeXRViewInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let eye = &self.eye;
rooted!(in(cx) let mut eye_js = UndefinedValue());
eye.to_jsval(cx, eye_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "eye", eye_js.handle()).unwrap();
if let Some(ref fieldOfView) = self.fieldOfView {
rooted!(in(cx) let mut fieldOfView_js = UndefinedValue());
fieldOfView.to_jsval(cx, fieldOfView_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "fieldOfView", fieldOfView_js.handle()).unwrap();
}
let projectionMatrix = &self.projectionMatrix;
rooted!(in(cx) let mut projectionMatrix_js = UndefinedValue());
projectionMatrix.to_jsval(cx, projectionMatrix_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "projectionMatrix", projectionMatrix_js.handle()).unwrap();
let resolution = &self.resolution;
rooted!(in(cx) let mut resolution_js = UndefinedValue());
resolution.to_jsval(cx, resolution_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "resolution", resolution_js.handle()).unwrap();
let viewOffset = &self.viewOffset;
rooted!(in(cx) let mut viewOffset_js = UndefinedValue());
viewOffset.to_jsval(cx, viewOffset_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "viewOffset", viewOffset_js.handle()).unwrap();
}
}
impl ToJSValConvertible for FakeXRViewInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct FakeXRDeviceResolution {
pub height: i32,
pub width: i32,
}
impl FakeXRDeviceResolution {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<FakeXRDeviceResolution>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = FakeXRDeviceResolution {
height: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "height", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
throw_type_error(*cx, "Missing required member \"height\".");
return Err(());
}
},
width: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "width", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
throw_type_error(*cx, "Missing required member \"width\".");
return Err(());
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for FakeXRDeviceResolution {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<FakeXRDeviceResolution>, ()> {
FakeXRDeviceResolution::new(SafeJSContext::from_ptr(cx), value)
}
}
impl FakeXRDeviceResolution {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let height = &self.height;
rooted!(in(cx) let mut height_js = UndefinedValue());
height.to_jsval(cx, height_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "height", height_js.handle()).unwrap();
let width = &self.width;
rooted!(in(cx) let mut width_js = UndefinedValue());
width.to_jsval(cx, width_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "width", width_js.handle()).unwrap();
}
}
impl ToJSValConvertible for FakeXRDeviceResolution {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct FakeXRBoundsPoint {
pub x: Option<Finite<f64>>,
pub z: Option<Finite<f64>>,
}
impl FakeXRBoundsPoint {
pub fn empty() -> Self {
Self {
x: None,
z: None,
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<FakeXRBoundsPoint>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = FakeXRBoundsPoint {
x: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "x", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
})
} else {
None
}
},
z: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "z", rval.handle_mut())? && !rval.is_undefined() {
Some(match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
})
} else {
None
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for FakeXRBoundsPoint {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<FakeXRBoundsPoint>, ()> {
FakeXRBoundsPoint::new(SafeJSContext::from_ptr(cx), value)
}
}
impl FakeXRBoundsPoint {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
if let Some(ref x) = self.x {
rooted!(in(cx) let mut x_js = UndefinedValue());
x.to_jsval(cx, x_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "x", x_js.handle()).unwrap();
}
if let Some(ref z) = self.z {
rooted!(in(cx) let mut z_js = UndefinedValue());
z.to_jsval(cx, z_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "z", z_js.handle()).unwrap();
}
}
}
impl ToJSValConvertible for FakeXRBoundsPoint {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct FakeXRRigidTransformInit {
pub orientation: Vec<Finite<f32>>,
pub position: Vec<Finite<f32>>,
}
impl FakeXRRigidTransformInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<FakeXRRigidTransformInit>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = FakeXRRigidTransformInit {
orientation: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "orientation", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"orientation\".");
return Err(());
}
},
position: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "position", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"position\".");
return Err(());
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for FakeXRRigidTransformInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<FakeXRRigidTransformInit>, ()> {
FakeXRRigidTransformInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl FakeXRRigidTransformInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let orientation = &self.orientation;
rooted!(in(cx) let mut orientation_js = UndefinedValue());
orientation.to_jsval(cx, orientation_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "orientation", orientation_js.handle()).unwrap();
let position = &self.position;
rooted!(in(cx) let mut position_js = UndefinedValue());
position.to_jsval(cx, position_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "position", position_js.handle()).unwrap();
}
}
impl ToJSValConvertible for FakeXRRigidTransformInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct FakeXRFieldOfViewInit {
pub downDegrees: Finite<f32>,
pub leftDegrees: Finite<f32>,
pub rightDegrees: Finite<f32>,
pub upDegrees: Finite<f32>,
}
impl FakeXRFieldOfViewInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<FakeXRFieldOfViewInit>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = FakeXRFieldOfViewInit {
downDegrees: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "downDegrees", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
throw_type_error(*cx, "Missing required member \"downDegrees\".");
return Err(());
}
},
leftDegrees: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "leftDegrees", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
throw_type_error(*cx, "Missing required member \"leftDegrees\".");
return Err(());
}
},
rightDegrees: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "rightDegrees", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
throw_type_error(*cx, "Missing required member \"rightDegrees\".");
return Err(());
}
},
upDegrees: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "upDegrees", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
throw_type_error(*cx, "Missing required member \"upDegrees\".");
return Err(());
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for FakeXRFieldOfViewInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<FakeXRFieldOfViewInit>, ()> {
FakeXRFieldOfViewInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl FakeXRFieldOfViewInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let downDegrees = &self.downDegrees;
rooted!(in(cx) let mut downDegrees_js = UndefinedValue());
downDegrees.to_jsval(cx, downDegrees_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "downDegrees", downDegrees_js.handle()).unwrap();
let leftDegrees = &self.leftDegrees;
rooted!(in(cx) let mut leftDegrees_js = UndefinedValue());
leftDegrees.to_jsval(cx, leftDegrees_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "leftDegrees", leftDegrees_js.handle()).unwrap();
let rightDegrees = &self.rightDegrees;
rooted!(in(cx) let mut rightDegrees_js = UndefinedValue());
rightDegrees.to_jsval(cx, rightDegrees_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "rightDegrees", rightDegrees_js.handle()).unwrap();
let upDegrees = &self.upDegrees;
rooted!(in(cx) let mut upDegrees_js = UndefinedValue());
upDegrees.to_jsval(cx, upDegrees_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "upDegrees", upDegrees_js.handle()).unwrap();
}
}
impl ToJSValConvertible for FakeXRFieldOfViewInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct FakeXRWorldInit {
pub hitTestRegions: Vec<crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRegionInit>,
}
impl FakeXRWorldInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<FakeXRWorldInit>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = FakeXRWorldInit {
hitTestRegions: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "hitTestRegions", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"hitTestRegions\".");
return Err(());
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for FakeXRWorldInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<FakeXRWorldInit>, ()> {
FakeXRWorldInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl FakeXRWorldInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let hitTestRegions = &self.hitTestRegions;
rooted!(in(cx) let mut hitTestRegions_js = UndefinedValue());
hitTestRegions.to_jsval(cx, hitTestRegions_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "hitTestRegions", hitTestRegions_js.handle()).unwrap();
}
}
impl ToJSValConvertible for FakeXRWorldInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct FakeXRRegionInit {
pub faces: Vec<crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRTriangleInit>,
pub type_: FakeXRRegionType,
}
impl FakeXRRegionInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<FakeXRRegionInit>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = FakeXRRegionInit {
faces: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "faces", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"faces\".");
return Err(());
}
},
type_: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "type", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) { Err(_) => { return Err(());
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"type\".");
return Err(());
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for FakeXRRegionInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<FakeXRRegionInit>, ()> {
FakeXRRegionInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl FakeXRRegionInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let faces = &self.faces;
rooted!(in(cx) let mut faces_js = UndefinedValue());
faces.to_jsval(cx, faces_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "faces", faces_js.handle()).unwrap();
let type_ = &self.type_;
rooted!(in(cx) let mut type__js = UndefinedValue());
type_.to_jsval(cx, type__js.handle_mut());
set_dictionary_property(cx, obj.handle(), "type", type__js.handle()).unwrap();
}
}
impl ToJSValConvertible for FakeXRRegionInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
#[derive(JSTraceable)]
pub struct FakeXRTriangleInit {
pub vertices: Vec<crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit>,
}
impl FakeXRTriangleInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<FakeXRTriangleInit>, ()> {
unsafe {
let object = if val.get().is_null_or_undefined() {
ptr::null_mut()
} else if val.get().is_object() {
val.get().to_object()
} else {
return Ok(ConversionResult::Failure("Value is not an object.".into()));
};
rooted!(in(*cx) let object = object);
let dictionary = FakeXRTriangleInit {
vertices: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "vertices", rval.handle_mut())? && !rval.is_undefined() {
match FromJSValConvertible::from_jsval(*cx, rval.handle(), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
},
}
} else {
throw_type_error(*cx, "Missing required member \"vertices\".");
return Err(());
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for FakeXRTriangleInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<FakeXRTriangleInit>, ()> {
FakeXRTriangleInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl FakeXRTriangleInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let vertices = &self.vertices;
rooted!(in(cx) let mut vertices_js = UndefinedValue());
vertices.to_jsval(cx, vertices_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "vertices", vertices_js.handle()).unwrap();
}
}
impl ToJSValConvertible for FakeXRTriangleInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) {
rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
self.to_jsobject(cx, obj.handle_mut());
rval.set(ObjectOrNullValue(obj.get()))
}
}
pub use self::FakeXRDevice_Binding::{Wrap, FakeXRDeviceMethods, GetProtoObject, DefineDOMInterface};
pub mod FakeXRDevice_Binding {
use crate::dom;
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRDeviceResolution;
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRFieldOfViewInit;
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRegionInit;
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit;
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRViewInit;
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRWorldInit;
use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRButtonStateInit;
use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputSourceInit;
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::XRHandedness;
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::XRHandednessValues;
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::XRTargetRayMode;
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::XRTargetRayModeValues;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRVisibilityState;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRVisibilityStateValues;
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREyeValues;
use crate::dom::bindings::import::module::*;
use crate::dom::promise::Promise;
use crate::dom::types::FakeXRDevice;
use crate::dom::types::FakeXRInputController;
unsafe extern fn setViews(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"FakeXRDevice.setViews\".");
return false;
}
let arg0: Vec<crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRViewInit> = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let result: Result<(), Error> = this.SetViews(arg0);
let result = match result {
Ok(result) => result,
Err(e) => {
throw_dom_exception(cx, &this.global(), e);
return false;
},
};
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const setViews_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(setViews)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn setViewerOrigin(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"FakeXRDevice.setViewerOrigin\".");
return false;
}
let arg0: crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let arg1: bool = if args.get(1).is_undefined() {
false
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
}
}
};
let result: Result<(), Error> = this.SetViewerOrigin(&arg0, arg1);
let result = match result {
Ok(result) => result,
Err(e) => {
throw_dom_exception(cx, &this.global(), e);
return false;
},
};
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const setViewerOrigin_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(setViewerOrigin)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn clearViewerOrigin(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
let result: () = this.ClearViewerOrigin();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const clearViewerOrigin_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(clearViewerOrigin)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn setFloorOrigin(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"FakeXRDevice.setFloorOrigin\".");
return false;
}
let arg0: crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let result: Result<(), Error> = this.SetFloorOrigin(&arg0);
let result = match result {
Ok(result) => result,
Err(e) => {
throw_dom_exception(cx, &this.global(), e);
return false;
},
};
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const setFloorOrigin_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(setFloorOrigin)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn clearFloorOrigin(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
let result: () = this.ClearFloorOrigin();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const clearFloorOrigin_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(clearFloorOrigin)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn simulateVisibilityChange(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"FakeXRDevice.simulateVisibilityChange\".");
return false;
}
let arg0: XRVisibilityState = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) { Err(_) => { return false;
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return false;
},
};
let result: () = this.SimulateVisibilityChange(arg0);
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const simulateVisibilityChange_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(simulateVisibilityChange)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn simulateInputSourceConnection(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"FakeXRDevice.simulateInputSourceConnection\".");
return false;
}
let arg0: crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputSourceInit = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let result: Result<DomRoot<FakeXRInputController>, Error> = this.SimulateInputSourceConnection(&arg0);
let result = match result {
Ok(result) => result,
Err(e) => {
throw_dom_exception(cx, &this.global(), e);
return false;
},
};
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const simulateInputSourceConnection_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(simulateInputSourceConnection)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn disconnect(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
let result: Rc<Promise> = this.Disconnect();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const disconnect_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(disconnect)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_OBJECT as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn setWorld(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"FakeXRDevice.setWorld\".");
return false;
}
let arg0: crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRWorldInit = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(0)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let result: Result<(), Error> = this.SetWorld(&arg0);
let result = match result {
Ok(result) => result,
Err(e) => {
throw_dom_exception(cx, &this.global(), e);
return false;
},
};
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const setWorld_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(setWorld)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn clearWorld(cx: *mut JSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let this = &*(this as *const FakeXRDevice);
let args = &*args;
let argc = args.argc_;
let result: () = this.ClearWorld();
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
const clearWorld_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(clearWorld)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::FakeXRDevice as u16,
},
__bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
_bitfield_align_1: [],
_bitfield_1: __BindgenBitfieldUnit::new(
new_jsjitinfo_bitfield_1!(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
true,
false,
false,
false,
false,
false,
0,
).to_ne_bytes()
),
};
unsafe extern fn _finalize(_cx: *mut GCContext, obj: *mut JSObject) {
wrap_panic(&mut || {
let this = native_from_object_static::<FakeXRDevice>(obj).unwrap();
finalize_common(this);
})
}
unsafe extern fn _trace(trc: *mut JSTracer, obj: *mut JSObject) {
wrap_panic(&mut || {
let this = native_from_object_static::<FakeXRDevice>(obj).unwrap();
if this.is_null() { return; } (*this).trace(trc);
})
}
static CLASS_OPS: JSClassOps = JSClassOps {
addProperty: None,
delProperty: None,
enumerate: None,
newEnumerate: None,
resolve: None,
mayResolve: None,
finalize: Some(_finalize),
call: None,
construct: None,
trace: Some(_trace),
};
static Class: DOMJSClass = DOMJSClass {
base: JSClass {
name: b"FakeXRDevice\0" as *const u8 as *const libc::c_char,
flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
(((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
,
cOps: &CLASS_OPS,
spec: ptr::null(),
ext: ptr::null(),
oOps: ptr::null(),
},
dom_class: DOMClass {
interface_chain: [ PrototypeList::ID::FakeXRDevice, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
depth: 0,
type_id: crate::dom::bindings::codegen::InheritTypes::TopTypeId { alone: () },
malloc_size_of: malloc_size_of_including_raw_self::<FakeXRDevice> as unsafe fn(&mut _, _) -> _,
global: InterfaceObjectMap::Globals::EMPTY,
}
};
impl FakeXRDevice {
fn __assert_parent_type(&self) {
use crate::dom::bindings::inheritance::HasParent;
let _: &Reflector = self.as_parent();
}
}
pub unsafe fn Wrap(cx: SafeJSContext, scope: &GlobalScope, given_proto: Option<HandleObject>, object: Box<FakeXRDevice>) -> DomRoot<FakeXRDevice> {
let raw = Root::new(MaybeUnreflectedDom::from_box(object));
let scope = scope.reflector().get_jsobject();
assert!(!scope.get().is_null());
assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
let _ac = JSAutoRealm::new(*cx, scope.get());
rooted!(in(*cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
GetProtoObject(cx, scope, canonical_proto.handle_mut());
assert!(!canonical_proto.is_null());
rooted!(in(*cx) let mut proto = ptr::null_mut::<JSObject>());
if let Some(given) = given_proto {
*proto = *given;
if get_context_realm(*cx) != get_object_realm(*given) {
assert!(JS_WrapObject(*cx, proto.handle_mut()));
}
} else {
*proto = *canonical_proto;
}
rooted!(in(*cx) let obj = JS_NewObjectWithGivenProto(
*cx,
&Class.base,
proto.handle(),
));
assert!(!obj.is_null());
JS_SetReservedSlot(
obj.get(),
DOM_OBJECT_SLOT,
&PrivateValue(raw.as_ptr() as *const libc::c_void),
);
let root = raw.reflect_with(obj.get());
DomRoot::from_ref(&*root)
}
impl DomObjectWrap for dom::fakexrdevice::FakeXRDevice {
const WRAP: unsafe fn(
SafeJSContext,
&GlobalScope,
Option<HandleObject>,
Box<Self>,
) -> Root<Dom<Self>> = Wrap;
}
impl IDLInterface for FakeXRDevice {
#[inline]
fn derives(class: &'static DOMClass) -> bool {
ptr::eq(class, &Class.dom_class)
}
}
impl PartialEq for FakeXRDevice {
fn eq(&self, other: &FakeXRDevice) -> bool {
self as *const FakeXRDevice == other
}
}
pub trait FakeXRDeviceMethods {
fn SetViews(&self, views: Vec<crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRViewInit>) -> Fallible<()>;
fn SetViewerOrigin(&self, origin: &crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit, emulatedPosition: bool) -> Fallible<()>;
fn ClearViewerOrigin(&self);
fn SetFloorOrigin(&self, origin: &crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit) -> Fallible<()>;
fn ClearFloorOrigin(&self);
fn SimulateVisibilityChange(&self, state: XRVisibilityState);
fn SimulateInputSourceConnection(&self, init: &crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputSourceInit) -> Fallible<DomRoot<FakeXRInputController>>;
fn Disconnect(&self) -> Rc<Promise>;
fn SetWorld(&self, world: &crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRWorldInit) -> Fallible<()>;
fn ClearWorld(&self);
}
const sMethods_specs: &[&[JSFunctionSpec]] = &[
&[
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"setViews\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &setViews_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"setViewerOrigin\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &setViewerOrigin_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"clearViewerOrigin\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &clearViewerOrigin_methodinfo as *const _ as *const JSJitInfo },
nargs: 0,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"setFloorOrigin\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &setFloorOrigin_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"clearFloorOrigin\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &clearFloorOrigin_methodinfo as *const _ as *const JSJitInfo },
nargs: 0,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"simulateVisibilityChange\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &simulateVisibilityChange_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"simulateInputSourceConnection\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &simulateInputSourceConnection_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"disconnect\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &disconnect_methodinfo as *const _ as *const JSJitInfo },
nargs: 0,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"setWorld\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &setWorld_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"clearWorld\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &clearWorld_methodinfo as *const _ as *const JSJitInfo },
nargs: 0,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: ptr::null() },
call: JSNativeWrapper { op: None, info: ptr::null() },
nargs: 0,
flags: 0,
selfHostedName: ptr::null()
}]
];
const sMethods: &[Guard<&[JSFunctionSpec]>] = &[
Guard::new(Condition::Exposed(InterfaceObjectMap::Globals::WINDOW), sMethods_specs[0])
];
const sAttributes_specs: &[&[JSPropertySpec]] = &[
&[
JSPropertySpec {
name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
attributes_: (JSPROP_READONLY),
kind_: (JSPropertySpec_Kind::Value),
u: JSPropertySpec_AccessorsOrValue {
value: JSPropertySpec_ValueWrapper {
type_: JSPropertySpec_ValueWrapper_Type::String,
__bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
string: b"FakeXRDevice\0" as *const u8 as *const libc::c_char,
}
}
}
}
,
JSPropertySpec::ZERO]
];
const sAttributes: &[Guard<&[JSPropertySpec]>] = &[
Guard::new(Condition::Satisfied, sAttributes_specs[0])
];
pub fn GetProtoObject(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject) {
get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::FakeXRDevice), CreateInterfaceObjects, rval)
}
static PrototypeClass: JSClass = JSClass {
name: b"FakeXRDevicePrototype\0" as *const u8 as *const libc::c_char,
flags:
(0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
cOps: 0 as *const _,
spec: ptr::null(),
ext: ptr::null(),
oOps: ptr::null(),
};
static INTERFACE_OBJECT_CLASS: NonCallbackInterfaceObjectClass =
NonCallbackInterfaceObjectClass::new(
{
const BEHAVIOR: InterfaceConstructorBehavior = InterfaceConstructorBehavior::throw();
&BEHAVIOR
},
b"function FakeXRDevice() {\n [native code]\n}",
PrototypeList::ID::FakeXRDevice,
0);
pub fn DefineDOMInterface(cx: SafeJSContext, global: HandleObject) {
define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::FakeXRDevice), CreateInterfaceObjects, ConstructorEnabled)
}
fn ConstructorEnabled(aCx: SafeJSContext, aObj: HandleObject) -> bool {
is_exposed_in(aObj, InterfaceObjectMap::Globals::WINDOW) &&
pref!(dom.webxr.test)
}
unsafe fn CreateInterfaceObjects(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray) {
rooted!(in(*cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
prototype_proto.set(GetRealmObjectPrototype(*cx));
assert!(!prototype_proto.is_null());
rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>());
create_interface_prototype_object(cx,
global,
prototype_proto.handle(),
&PrototypeClass,
sMethods,
sAttributes,
&[],
&[],
prototype.handle_mut());
assert!(!prototype.is_null());
assert!((*cache)[PrototypeList::ID::FakeXRDevice as usize].is_null());
(*cache)[PrototypeList::ID::FakeXRDevice as usize] = prototype.get();
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::FakeXRDevice as isize),
ptr::null_mut(),
prototype.get());
rooted!(in(*cx) let mut interface_proto = ptr::null_mut::<JSObject>());
interface_proto.set(GetRealmFunctionPrototype(*cx));
assert!(!interface_proto.is_null());
rooted!(in(*cx) let mut interface = ptr::null_mut::<JSObject>());
create_noncallback_interface_object(cx,
global,
interface_proto.handle(),
&INTERFACE_OBJECT_CLASS,
&[],
&[],
&[],
prototype.handle(),
b"FakeXRDevice\0",
0,
&[],
interface.handle_mut());
assert!(!interface.is_null());
}
}