#![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::EventTargetBinding::EventTarget_Binding;
use crate::dom::bindings::import::base::*;
use crate::dom::types::DOMPointReadOnly;
use crate::dom::types::EventTarget;
use crate::dom::types::XRRigidTransform;
use crate::dom::types::XRSpace;
#[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum XRTextureType {
Texture,
Texture_array
}
pub mod XRTextureTypeValues {
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::XRTextureType)] = &[
("texture", super::XRTextureType::Texture),
("texture-array", super::XRTextureType::Texture_array),
];
impl super::XRTextureType {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::XRTextureType {
fn default() -> super::XRTextureType {
pairs[0].1
}
}
impl ToJSValConvertible for super::XRTextureType {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::XRTextureType {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::XRTextureType>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'XRTextureType'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[repr(usize)]
#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum XRLayerLayout {
Default,
Mono,
Stereo,
Stereo_left_right,
Stereo_top_bottom
}
pub mod XRLayerLayoutValues {
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::XRLayerLayout)] = &[
("default", super::XRLayerLayout::Default),
("mono", super::XRLayerLayout::Mono),
("stereo", super::XRLayerLayout::Stereo),
("stereo-left-right", super::XRLayerLayout::Stereo_left_right),
("stereo-top-bottom", super::XRLayerLayout::Stereo_top_bottom),
];
impl super::XRLayerLayout {
pub fn as_str(&self) -> &'static str {
pairs[*self as usize].0
}
}
impl Default for super::XRLayerLayout {
fn default() -> super::XRLayerLayout {
pairs[0].1
}
}
impl ToJSValConvertible for super::XRLayerLayout {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
pairs[*self as usize].0.to_jsval(cx, rval);
}
}
impl FromJSValConvertible for super::XRLayerLayout {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<super::XRLayerLayout>, ()> {
match find_enum_value(cx, value, pairs) {
Err(_) => Err(()),
Ok((None, search)) => {
Ok(ConversionResult::Failure(
format!("'{}' is not a valid enum value for enumeration 'XRLayerLayout'.", search).into()
))
}
Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
}
}
}
} #[derive(JSTraceable)]
pub struct XRProjectionLayerInit {
pub alpha: bool,
pub depth: bool,
pub scaleFactor: Finite<f64>,
pub stencil: bool,
}
impl XRProjectionLayerInit {
pub fn empty() -> Self {
Self {
alpha: true,
depth: true,
scaleFactor: Finite::wrap(1.0),
stencil: false,
}
}
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<XRProjectionLayerInit>, ()> {
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 = XRProjectionLayerInit {
alpha: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "alpha", 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 {
true
}
},
depth: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "depth", 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 {
true
}
},
scaleFactor: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "scaleFactor", 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 {
Finite::wrap(1.0)
}
},
stencil: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "stencil", 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 {
false
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for XRProjectionLayerInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<XRProjectionLayerInit>, ()> {
XRProjectionLayerInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl XRProjectionLayerInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let alpha = &self.alpha;
rooted!(in(cx) let mut alpha_js = UndefinedValue());
alpha.to_jsval(cx, alpha_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "alpha", alpha_js.handle()).unwrap();
let depth = &self.depth;
rooted!(in(cx) let mut depth_js = UndefinedValue());
depth.to_jsval(cx, depth_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "depth", depth_js.handle()).unwrap();
let scaleFactor = &self.scaleFactor;
rooted!(in(cx) let mut scaleFactor_js = UndefinedValue());
scaleFactor.to_jsval(cx, scaleFactor_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "scaleFactor", scaleFactor_js.handle()).unwrap();
let stencil = &self.stencil;
rooted!(in(cx) let mut stencil_js = UndefinedValue());
stencil.to_jsval(cx, stencil_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "stencil", stencil_js.handle()).unwrap();
}
}
impl ToJSValConvertible for XRProjectionLayerInit {
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 XRQuadLayerInit {
pub parent: crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerInit,
pub height: Finite<f32>,
pub isStatic: bool,
pub transform: Option<Option<DomRoot<XRRigidTransform>>>,
pub width: Finite<f32>,
}
impl XRQuadLayerInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<XRQuadLayerInit>, ()> {
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 = XRQuadLayerInit {
parent: {
match crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerInit::new(cx, val)? {
ConversionResult::Success(v) => v,
ConversionResult::Failure(error) => {
throw_type_error(*cx, &error);
return Err(());
}
}
},
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(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
Finite::wrap(1.0)
}
},
isStatic: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "isStatic", 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 {
false
}
},
transform: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "transform", rval.handle_mut())? && !rval.is_undefined() {
Some(if rval.handle().get().is_object() {
Some(match root_from_handlevalue(rval.handle(), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRRigidTransform.");
return Err(());
}
}
)
} else if rval.handle().get().is_null_or_undefined() {
None
} else {
throw_type_error(*cx, "Value is not an object.");
return Err(());
})
} else {
None
}
},
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(), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return Err(());
}
_ => { return Err(());
}
}
} else {
Finite::wrap(1.0)
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for XRQuadLayerInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<XRQuadLayerInit>, ()> {
XRQuadLayerInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl XRQuadLayerInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
self.parent.to_jsobject(cx, obj);
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 isStatic = &self.isStatic;
rooted!(in(cx) let mut isStatic_js = UndefinedValue());
isStatic.to_jsval(cx, isStatic_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "isStatic", isStatic_js.handle()).unwrap();
if let Some(ref transform) = self.transform {
rooted!(in(cx) let mut transform_js = UndefinedValue());
transform.to_jsval(cx, transform_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "transform", transform_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 XRQuadLayerInit {
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 XRCylinderLayerInit {
pub parent: crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerInit,
pub aspectRatio: Finite<f32>,
pub centralAngle: Finite<f32>,
pub isStatic: bool,
pub radius: Finite<f32>,
pub transform: Option<Option<DomRoot<XRRigidTransform>>>,
}
impl XRCylinderLayerInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<XRCylinderLayerInit>, ()> {
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 = XRCylinderLayerInit {
parent: {
match crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerInit::new(cx, val)? {
ConversionResult::Success(v) => v,
ConversionResult::Failure(error) => {
throw_type_error(*cx, &error);
return Err(());
}
}
},
aspectRatio: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "aspectRatio", 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 {
Finite::wrap(2.0)
}
},
centralAngle: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "centralAngle", 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 {
Finite::wrap(0.78539)
}
},
isStatic: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "isStatic", 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 {
false
}
},
radius: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "radius", 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 {
Finite::wrap(2.0)
}
},
transform: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "transform", rval.handle_mut())? && !rval.is_undefined() {
Some(if rval.handle().get().is_object() {
Some(match root_from_handlevalue(rval.handle(), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRRigidTransform.");
return Err(());
}
}
)
} else if rval.handle().get().is_null_or_undefined() {
None
} else {
throw_type_error(*cx, "Value is not an object.");
return Err(());
})
} else {
None
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for XRCylinderLayerInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<XRCylinderLayerInit>, ()> {
XRCylinderLayerInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl XRCylinderLayerInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
self.parent.to_jsobject(cx, obj);
let aspectRatio = &self.aspectRatio;
rooted!(in(cx) let mut aspectRatio_js = UndefinedValue());
aspectRatio.to_jsval(cx, aspectRatio_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "aspectRatio", aspectRatio_js.handle()).unwrap();
let centralAngle = &self.centralAngle;
rooted!(in(cx) let mut centralAngle_js = UndefinedValue());
centralAngle.to_jsval(cx, centralAngle_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "centralAngle", centralAngle_js.handle()).unwrap();
let isStatic = &self.isStatic;
rooted!(in(cx) let mut isStatic_js = UndefinedValue());
isStatic.to_jsval(cx, isStatic_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "isStatic", isStatic_js.handle()).unwrap();
let radius = &self.radius;
rooted!(in(cx) let mut radius_js = UndefinedValue());
radius.to_jsval(cx, radius_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "radius", radius_js.handle()).unwrap();
if let Some(ref transform) = self.transform {
rooted!(in(cx) let mut transform_js = UndefinedValue());
transform.to_jsval(cx, transform_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "transform", transform_js.handle()).unwrap();
}
}
}
impl ToJSValConvertible for XRCylinderLayerInit {
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 XREquirectLayerInit {
pub parent: crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerInit,
pub centralHorizontalAngle: Finite<f32>,
pub isStatic: bool,
pub lowerVerticalAngle: Finite<f32>,
pub radius: Finite<f32>,
pub transform: Option<Option<DomRoot<XRRigidTransform>>>,
pub upperVerticalAngle: Finite<f32>,
}
impl XREquirectLayerInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<XREquirectLayerInit>, ()> {
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 = XREquirectLayerInit {
parent: {
match crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerInit::new(cx, val)? {
ConversionResult::Success(v) => v,
ConversionResult::Failure(error) => {
throw_type_error(*cx, &error);
return Err(());
}
}
},
centralHorizontalAngle: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "centralHorizontalAngle", 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 {
Finite::wrap(6.28318)
}
},
isStatic: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "isStatic", 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 {
false
}
},
lowerVerticalAngle: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "lowerVerticalAngle", 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 {
Finite::wrap(-1.570795)
}
},
radius: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "radius", 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 {
Finite::wrap(0.0)
}
},
transform: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "transform", rval.handle_mut())? && !rval.is_undefined() {
Some(if rval.handle().get().is_object() {
Some(match root_from_handlevalue(rval.handle(), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRRigidTransform.");
return Err(());
}
}
)
} else if rval.handle().get().is_null_or_undefined() {
None
} else {
throw_type_error(*cx, "Value is not an object.");
return Err(());
})
} else {
None
}
},
upperVerticalAngle: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "upperVerticalAngle", 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 {
Finite::wrap(1.570795)
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for XREquirectLayerInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<XREquirectLayerInit>, ()> {
XREquirectLayerInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl XREquirectLayerInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
self.parent.to_jsobject(cx, obj);
let centralHorizontalAngle = &self.centralHorizontalAngle;
rooted!(in(cx) let mut centralHorizontalAngle_js = UndefinedValue());
centralHorizontalAngle.to_jsval(cx, centralHorizontalAngle_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "centralHorizontalAngle", centralHorizontalAngle_js.handle()).unwrap();
let isStatic = &self.isStatic;
rooted!(in(cx) let mut isStatic_js = UndefinedValue());
isStatic.to_jsval(cx, isStatic_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "isStatic", isStatic_js.handle()).unwrap();
let lowerVerticalAngle = &self.lowerVerticalAngle;
rooted!(in(cx) let mut lowerVerticalAngle_js = UndefinedValue());
lowerVerticalAngle.to_jsval(cx, lowerVerticalAngle_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "lowerVerticalAngle", lowerVerticalAngle_js.handle()).unwrap();
let radius = &self.radius;
rooted!(in(cx) let mut radius_js = UndefinedValue());
radius.to_jsval(cx, radius_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "radius", radius_js.handle()).unwrap();
if let Some(ref transform) = self.transform {
rooted!(in(cx) let mut transform_js = UndefinedValue());
transform.to_jsval(cx, transform_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "transform", transform_js.handle()).unwrap();
}
let upperVerticalAngle = &self.upperVerticalAngle;
rooted!(in(cx) let mut upperVerticalAngle_js = UndefinedValue());
upperVerticalAngle.to_jsval(cx, upperVerticalAngle_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "upperVerticalAngle", upperVerticalAngle_js.handle()).unwrap();
}
}
impl ToJSValConvertible for XREquirectLayerInit {
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 XRCubeLayerInit {
pub parent: crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerInit,
pub isStatic: bool,
pub orientation: Option<Option<DomRoot<DOMPointReadOnly>>>,
}
impl XRCubeLayerInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<XRCubeLayerInit>, ()> {
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 = XRCubeLayerInit {
parent: {
match crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerInit::new(cx, val)? {
ConversionResult::Success(v) => v,
ConversionResult::Failure(error) => {
throw_type_error(*cx, &error);
return Err(());
}
}
},
isStatic: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "isStatic", 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 {
false
}
},
orientation: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "orientation", rval.handle_mut())? && !rval.is_undefined() {
Some(if rval.handle().get().is_object() {
Some(match root_from_handlevalue(rval.handle(), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface DOMPointReadOnly.");
return Err(());
}
}
)
} else if rval.handle().get().is_null_or_undefined() {
None
} else {
throw_type_error(*cx, "Value is not an object.");
return Err(());
})
} else {
None
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for XRCubeLayerInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<XRCubeLayerInit>, ()> {
XRCubeLayerInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl XRCubeLayerInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
self.parent.to_jsobject(cx, obj);
let isStatic = &self.isStatic;
rooted!(in(cx) let mut isStatic_js = UndefinedValue());
isStatic.to_jsval(cx, isStatic_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "isStatic", isStatic_js.handle()).unwrap();
if let Some(ref 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();
}
}
}
impl ToJSValConvertible for XRCubeLayerInit {
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 XRLayerInit {
pub alpha: bool,
pub depth: bool,
pub layout: XRLayerLayout,
pub space: DomRoot<XRSpace>,
pub stencil: bool,
pub viewPixelHeight: u32,
pub viewPixelWidth: u32,
}
impl XRLayerInit {
pub fn new(cx: SafeJSContext, val: HandleValue)
-> Result<ConversionResult<XRLayerInit>, ()> {
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 = XRLayerInit {
alpha: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "alpha", 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 {
true
}
},
depth: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "depth", 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 {
false
}
},
layout: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "layout", 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 {
XRLayerLayout::Mono
}
},
space: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "space", rval.handle_mut())? && !rval.is_undefined() {
if rval.handle().get().is_object() {
match root_from_handlevalue(rval.handle(), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRSpace.");
return Err(());
}
}
} else {
throw_type_error(*cx, "Value is not an object.");
return Err(());
}
} else {
throw_type_error(*cx, "Missing required member \"space\".");
return Err(());
}
},
stencil: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "stencil", 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 {
false
}
},
viewPixelHeight: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "viewPixelHeight", 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 \"viewPixelHeight\".");
return Err(());
}
},
viewPixelWidth: {
rooted!(in(*cx) let mut rval = UndefinedValue());
if get_dictionary_property(*cx, object.handle(), "viewPixelWidth", 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 \"viewPixelWidth\".");
return Err(());
}
},
};
Ok(ConversionResult::Success(dictionary))
}
}
}
impl FromJSValConvertible for XRLayerInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext, value: HandleValue, _option: ())
-> Result<ConversionResult<XRLayerInit>, ()> {
XRLayerInit::new(SafeJSContext::from_ptr(cx), value)
}
}
impl XRLayerInit {
pub(crate) unsafe fn to_jsobject(&self, cx: *mut JSContext, mut obj: MutableHandleObject) {
let alpha = &self.alpha;
rooted!(in(cx) let mut alpha_js = UndefinedValue());
alpha.to_jsval(cx, alpha_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "alpha", alpha_js.handle()).unwrap();
let depth = &self.depth;
rooted!(in(cx) let mut depth_js = UndefinedValue());
depth.to_jsval(cx, depth_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "depth", depth_js.handle()).unwrap();
let layout = &self.layout;
rooted!(in(cx) let mut layout_js = UndefinedValue());
layout.to_jsval(cx, layout_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "layout", layout_js.handle()).unwrap();
let space = &self.space;
rooted!(in(cx) let mut space_js = UndefinedValue());
space.to_jsval(cx, space_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "space", space_js.handle()).unwrap();
let stencil = &self.stencil;
rooted!(in(cx) let mut stencil_js = UndefinedValue());
stencil.to_jsval(cx, stencil_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "stencil", stencil_js.handle()).unwrap();
let viewPixelHeight = &self.viewPixelHeight;
rooted!(in(cx) let mut viewPixelHeight_js = UndefinedValue());
viewPixelHeight.to_jsval(cx, viewPixelHeight_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "viewPixelHeight", viewPixelHeight_js.handle()).unwrap();
let viewPixelWidth = &self.viewPixelWidth;
rooted!(in(cx) let mut viewPixelWidth_js = UndefinedValue());
viewPixelWidth.to_jsval(cx, viewPixelWidth_js.handle_mut());
set_dictionary_property(cx, obj.handle(), "viewPixelWidth", viewPixelWidth_js.handle()).unwrap();
}
}
impl ToJSValConvertible for XRLayerInit {
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::XRWebGLBinding_Binding::{Wrap, XRWebGLBindingMethods, GetProtoObject, DefineDOMInterface};
pub mod XRWebGLBinding_Binding {
use crate::dom;
use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTarget_Binding;
use crate::dom::bindings::codegen::Bindings::XRCompositionLayerBinding::XRCompositionLayer_Binding;
use crate::dom::bindings::codegen::Bindings::XRLayerBinding::XRLayer_Binding;
use crate::dom::bindings::codegen::Bindings::XRSubImageBinding::XRSubImage_Binding;
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREyeValues;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCubeLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCylinderLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XREquirectLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerLayout;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRLayerLayoutValues;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRProjectionLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRQuadLayerInit;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRTextureType;
use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRTextureTypeValues;
use crate::dom::bindings::import::module::*;
use crate::dom::types::DOMPointReadOnly;
use crate::dom::types::EventTarget;
use crate::dom::types::WebGL2RenderingContext;
use crate::dom::types::WebGLRenderingContext;
use crate::dom::types::XRCompositionLayer;
use crate::dom::types::XRCubeLayer;
use crate::dom::types::XRCylinderLayer;
use crate::dom::types::XREquirectLayer;
use crate::dom::types::XRFrame;
use crate::dom::types::XRLayer;
use crate::dom::types::XRProjectionLayer;
use crate::dom::types::XRQuadLayer;
use crate::dom::types::XRRigidTransform;
use crate::dom::types::XRSession;
use crate::dom::types::XRSpace;
use crate::dom::types::XRSubImage;
use crate::dom::types::XRView;
use crate::dom::types::XRWebGLBinding;
use crate::dom::types::XRWebGLSubImage;
unsafe extern fn createProjectionLayer(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 XRWebGLBinding);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"XRWebGLBinding.createProjectionLayer\".");
return false;
}
let arg0: XRTextureType = 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 arg1: crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRProjectionLayerInit = if args.get(1).is_undefined() {
crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRProjectionLayerInit::empty()
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
}
};
let result: Result<DomRoot<XRProjectionLayer>, Error> = this.CreateProjectionLayer(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 createProjectionLayer_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(createProjectionLayer)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::XRWebGLBinding 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 createQuadLayer(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 XRWebGLBinding);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"XRWebGLBinding.createQuadLayer\".");
return false;
}
let arg0: XRTextureType = 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 arg1: Option<crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRQuadLayerInit> = if args.get(1).is_undefined() {
None
} else {
Some(match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
})
};
let result: Result<DomRoot<XRQuadLayer>, Error> = this.CreateQuadLayer(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 createQuadLayer_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(createQuadLayer)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::XRWebGLBinding 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 createCylinderLayer(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 XRWebGLBinding);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"XRWebGLBinding.createCylinderLayer\".");
return false;
}
let arg0: XRTextureType = 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 arg1: Option<crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCylinderLayerInit> = if args.get(1).is_undefined() {
None
} else {
Some(match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
})
};
let result: Result<DomRoot<XRCylinderLayer>, Error> = this.CreateCylinderLayer(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 createCylinderLayer_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(createCylinderLayer)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::XRWebGLBinding 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 createEquirectLayer(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 XRWebGLBinding);
let args = &*args;
let argc = args.argc_;
if argc < 1 {
throw_type_error(*cx, "Not enough arguments to \"XRWebGLBinding.createEquirectLayer\".");
return false;
}
let arg0: XRTextureType = 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 arg1: Option<crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XREquirectLayerInit> = if args.get(1).is_undefined() {
None
} else {
Some(match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
})
};
let result: Result<DomRoot<XREquirectLayer>, Error> = this.CreateEquirectLayer(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 createEquirectLayer_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(createEquirectLayer)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::XRWebGLBinding 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 createCubeLayer(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 XRWebGLBinding);
let args = &*args;
let argc = args.argc_;
let arg0: Option<crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCubeLayerInit> = if args.get(0).is_undefined() {
None
} else {
Some(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<XRCubeLayer>, Error> = this.CreateCubeLayer(&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 createCubeLayer_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(createCubeLayer)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::XRWebGLBinding 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 getSubImage(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 XRWebGLBinding);
let args = &*args;
let argc = args.argc_;
if argc < 2 {
throw_type_error(*cx, "Not enough arguments to \"XRWebGLBinding.getSubImage\".");
return false;
}
let arg0: DomRoot<XRCompositionLayer> = if HandleValue::from_raw(args.get(0)).get().is_object() {
match root_from_handlevalue(HandleValue::from_raw(args.get(0)), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRCompositionLayer.");
return false;
}
}
} else {
throw_type_error(*cx, "Value is not an object.");
return false;
};
let arg1: DomRoot<XRFrame> = if HandleValue::from_raw(args.get(1)).get().is_object() {
match root_from_handlevalue(HandleValue::from_raw(args.get(1)), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRFrame.");
return false;
}
}
} else {
throw_type_error(*cx, "Value is not an object.");
return false;
};
let arg2: XREye = if args.get(2).is_undefined() {
XREye::None
} else {
match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(2)), ()) { Err(_) => { return false;
},
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { throw_type_error(*cx, &error); return false;
},
}
};
let result: Result<DomRoot<XRWebGLSubImage>, Error> = this.GetSubImage(&arg0, &arg1, arg2);
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 getSubImage_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(getSubImage)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::XRWebGLBinding 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 getViewSubImage(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 XRWebGLBinding);
let args = &*args;
let argc = args.argc_;
if argc < 2 {
throw_type_error(*cx, "Not enough arguments to \"XRWebGLBinding.getViewSubImage\".");
return false;
}
let arg0: DomRoot<XRProjectionLayer> = if HandleValue::from_raw(args.get(0)).get().is_object() {
match root_from_handlevalue(HandleValue::from_raw(args.get(0)), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRProjectionLayer.");
return false;
}
}
} else {
throw_type_error(*cx, "Value is not an object.");
return false;
};
let arg1: DomRoot<XRView> = if HandleValue::from_raw(args.get(1)).get().is_object() {
match root_from_handlevalue(HandleValue::from_raw(args.get(1)), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRView.");
return false;
}
}
} else {
throw_type_error(*cx, "Value is not an object.");
return false;
};
let result: Result<DomRoot<XRWebGLSubImage>, Error> = this.GetViewSubImage(&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 getViewSubImage_methodinfo: JSJitInfo = JSJitInfo {
__bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
method: Some(getViewSubImage)
},
__bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
protoID: PrototypeList::ID::XRWebGLBinding 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 _finalize(_cx: *mut GCContext, obj: *mut JSObject) {
wrap_panic(&mut || {
let this = native_from_object_static::<XRWebGLBinding>(obj).unwrap();
finalize_common(this);
})
}
unsafe extern fn _trace(trc: *mut JSTracer, obj: *mut JSObject) {
wrap_panic(&mut || {
let this = native_from_object_static::<XRWebGLBinding>(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"XRWebGLBinding\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::XRWebGLBinding, 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::<XRWebGLBinding> as unsafe fn(&mut _, _) -> _,
global: InterfaceObjectMap::Globals::EMPTY,
}
};
impl XRWebGLBinding {
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<XRWebGLBinding>) -> DomRoot<XRWebGLBinding> {
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::xrwebglbinding::XRWebGLBinding {
const WRAP: unsafe fn(
SafeJSContext,
&GlobalScope,
Option<HandleObject>,
Box<Self>,
) -> Root<Dom<Self>> = Wrap;
}
impl IDLInterface for XRWebGLBinding {
#[inline]
fn derives(class: &'static DOMClass) -> bool {
ptr::eq(class, &Class.dom_class)
}
}
impl PartialEq for XRWebGLBinding {
fn eq(&self, other: &XRWebGLBinding) -> bool {
self as *const XRWebGLBinding == other
}
}
pub trait XRWebGLBindingMethods {
fn CreateProjectionLayer(&self, textureType: XRTextureType, init: &crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRProjectionLayerInit) -> Fallible<DomRoot<XRProjectionLayer>>;
fn CreateQuadLayer(&self, textureType: XRTextureType, init: &Option<crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRQuadLayerInit>) -> Fallible<DomRoot<XRQuadLayer>>;
fn CreateCylinderLayer(&self, textureType: XRTextureType, init: &Option<crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCylinderLayerInit>) -> Fallible<DomRoot<XRCylinderLayer>>;
fn CreateEquirectLayer(&self, textureType: XRTextureType, init: &Option<crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XREquirectLayerInit>) -> Fallible<DomRoot<XREquirectLayer>>;
fn CreateCubeLayer(&self, init: &Option<crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRCubeLayerInit>) -> Fallible<DomRoot<XRCubeLayer>>;
fn GetSubImage(&self, layer: &XRCompositionLayer, frame: &XRFrame, eye: XREye) -> Fallible<DomRoot<XRWebGLSubImage>>;
fn GetViewSubImage(&self, layer: &XRProjectionLayer, view: &XRView) -> Fallible<DomRoot<XRWebGLSubImage>>;
}
const sMethods_specs: &[&[JSFunctionSpec]] = &[
&[
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"createProjectionLayer\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &createProjectionLayer_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"createQuadLayer\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &createQuadLayer_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"createCylinderLayer\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &createCylinderLayer_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"createEquirectLayer\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &createEquirectLayer_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"createCubeLayer\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &createCubeLayer_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"getSubImage\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &getSubImage_methodinfo as *const _ as *const JSJitInfo },
nargs: 2,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: JSPropertySpec_Name { string_: b"getViewSubImage\0" as *const u8 as *const libc::c_char },
call: JSNativeWrapper { op: Some(generic_method), info: &getViewSubImage_methodinfo as *const _ as *const JSJitInfo },
nargs: 2,
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::SecureContext(), 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"XRWebGLBinding\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::XRWebGLBinding), CreateInterfaceObjects, rval)
}
static PrototypeClass: JSClass = JSClass {
name: b"XRWebGLBindingPrototype\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(),
};
unsafe extern fn _constructor(cx: *mut JSContext, argc: u32, vp: *mut JSVal) -> bool {
let mut result = false;
wrap_panic(&mut || result = (|| {
let cx = SafeJSContext::from_ptr(cx);
let args = CallArgs::from_vp(vp, argc);
let global = GlobalScope::from_object(JS_CALLEE(*cx, vp).to_object());
let global = DomRoot::downcast::<dom::types::Window>(global).unwrap();
if !callargs_is_constructing(&args) {
throw_constructor_without_new(*cx, "XRWebGLBinding");
return false;
}
rooted!(in(*cx) let mut desired_proto = ptr::null_mut::<JSObject>());
let proto_result = get_desired_proto(
cx,
&args,
PrototypeList::ID::XRWebGLBinding,
CreateInterfaceObjects,
desired_proto.handle_mut(),
);
assert!(proto_result.is_ok());
if proto_result.is_err() {
return false;
}
if argc < 2 {
throw_type_error(*cx, "Not enough arguments to \"XRWebGLBinding.constructor\".");
return false;
}
let arg0: DomRoot<XRSession> = if HandleValue::from_raw(args.get(0)).get().is_object() {
match root_from_handlevalue(HandleValue::from_raw(args.get(0)), *cx) {
Ok(val) => val,
Err(()) => {
throw_type_error(*cx, "value does not implement interface XRSession.");
return false;
}
}
} else {
throw_type_error(*cx, "Value is not an object.");
return false;
};
let arg1: UnionTypes::WebGLRenderingContextOrWebGL2RenderingContext = match FromJSValConvertible::from_jsval(*cx, HandleValue::from_raw(args.get(1)), ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(*cx, &error);
return false;
}
_ => { return false;
},
};
let result: DomRoot<XRWebGLBinding> = XRWebGLBinding::Constructor(&global, Some(desired_proto.handle()), &arg0, arg1);
(result).to_jsval(*cx, MutableHandleValue::from_raw(args.rval()));
return true;
})());
result
}
static INTERFACE_OBJECT_CLASS: NonCallbackInterfaceObjectClass =
NonCallbackInterfaceObjectClass::new(
{
const BEHAVIOR: InterfaceConstructorBehavior = InterfaceConstructorBehavior::call(_constructor);
&BEHAVIOR
},
b"function XRWebGLBinding() {\n [native code]\n}",
PrototypeList::ID::XRWebGLBinding,
0);
pub fn DefineDOMInterface(cx: SafeJSContext, global: HandleObject) {
define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XRWebGLBinding), CreateInterfaceObjects, ConstructorEnabled)
}
fn ConstructorEnabled(aCx: SafeJSContext, aObj: HandleObject) -> bool {
is_exposed_in(aObj, InterfaceObjectMap::Globals::WINDOW) &&
pref!(dom.webxr.layers.enabled)
}
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::XRWebGLBinding as usize].is_null());
(*cache)[PrototypeList::ID::XRWebGLBinding as usize] = prototype.get();
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::XRWebGLBinding 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"XRWebGLBinding\0",
2,
&[],
interface.handle_mut());
assert!(!interface.is_null());
}
}