use crate::dom;
use crate::dom::bindings::codegen::Bindings::AudioContextBinding::AudioContextLatencyCategory;
use crate::dom::bindings::codegen::Bindings::AudioContextBinding::AudioContextLatencyCategoryValues;
use crate::dom::bindings::codegen::Bindings::DocumentBinding::ElementCreationOptions;
use crate::dom::bindings::codegen::Bindings::EventTargetBinding::AddEventListenerOptions;
use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventListenerOptions;
use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::ConstrainDoubleRange;
use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::ConstrainULongRange;
use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::MediaTrackConstraints;
use crate::dom::bindings::codegen::Bindings::TestBindingBinding::TestDictionary;
use crate::dom::bindings::codegen::Bindings::VTTCueBinding::AutoKeyword;
use crate::dom::bindings::codegen::Bindings::VTTCueBinding::AutoKeywordValues;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUAutoLayoutMode;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUAutoLayoutModeValues;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBufferBinding;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUColorDict;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUExtent3DDict;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUOrigin2DDict;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUOrigin3DDict;
use crate::dom::bindings::conversions::windowproxy_from_handlevalue;
use crate::dom::bindings::import::base::*;
use crate::dom::bindings::record::Record;
use crate::dom::types::*;
use crate::dom::windowproxy::WindowProxy;
use js::typedarray;
#[derive(JSTraceable)]
pub enum AddEventListenerOptionsOrBoolean {
AddEventListenerOptions(AddEventListenerOptions),
Boolean(bool),
}
impl ToJSValConvertible for AddEventListenerOptionsOrBoolean {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
AddEventListenerOptionsOrBoolean::AddEventListenerOptions(ref inner) => inner.to_jsval(cx, rval),
AddEventListenerOptionsOrBoolean::Boolean(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for AddEventListenerOptionsOrBoolean {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<AddEventListenerOptionsOrBoolean>, ()> {
match AddEventListenerOptionsOrBoolean::TryConvertToAddEventListenerOptions(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(AddEventListenerOptionsOrBoolean::AddEventListenerOptions(value))),
Ok(None) => (),
}
match AddEventListenerOptionsOrBoolean::TryConvertToBoolean(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(AddEventListenerOptionsOrBoolean::Boolean(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: AddEventListenerOptions".into()))
}
}
impl AddEventListenerOptionsOrBoolean {
unsafe fn TryConvertToAddEventListenerOptions(cx: SafeJSContext, value: HandleValue) -> Result<Option<AddEventListenerOptions>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToBoolean(cx: SafeJSContext, value: HandleValue) -> Result<Option<bool>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum ArrayBufferOrArrayBufferView {
ArrayBuffer(RootedTraceableBox<typedarray::HeapArrayBuffer>),
ArrayBufferView(RootedTraceableBox<typedarray::HeapArrayBufferView>),
}
impl ToJSValConvertible for ArrayBufferOrArrayBufferView {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ArrayBufferOrArrayBufferView::ArrayBuffer(ref inner) => inner.to_jsval(cx, rval),
ArrayBufferOrArrayBufferView::ArrayBufferView(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ArrayBufferOrArrayBufferView {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ArrayBufferOrArrayBufferView>, ()> {
if value.get().is_object() {
match ArrayBufferOrArrayBufferView::TryConvertToArrayBuffer(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ArrayBufferOrArrayBufferView::ArrayBuffer(value))),
Ok(None) => (),
}
match ArrayBufferOrArrayBufferView::TryConvertToArrayBufferView(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ArrayBufferOrArrayBufferView::ArrayBufferView(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ArrayBuffer, ArrayBufferView".into()))
}
}
impl ArrayBufferOrArrayBufferView {
unsafe fn TryConvertToArrayBuffer(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBuffer>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBuffer::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToArrayBufferView(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBufferView>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBufferView::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
}
#[derive(JSTraceable)]
pub enum ArrayBufferOrArrayBufferViewOrBlobOrString {
ArrayBuffer(RootedTraceableBox<typedarray::HeapArrayBuffer>),
ArrayBufferView(RootedTraceableBox<typedarray::HeapArrayBufferView>),
Blob(DomRoot<Blob>),
String(DOMString),
}
impl ToJSValConvertible for ArrayBufferOrArrayBufferViewOrBlobOrString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ArrayBufferOrArrayBufferViewOrBlobOrString::ArrayBuffer(ref inner) => inner.to_jsval(cx, rval),
ArrayBufferOrArrayBufferViewOrBlobOrString::ArrayBufferView(ref inner) => inner.to_jsval(cx, rval),
ArrayBufferOrArrayBufferViewOrBlobOrString::Blob(ref inner) => inner.to_jsval(cx, rval),
ArrayBufferOrArrayBufferViewOrBlobOrString::String(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ArrayBufferOrArrayBufferViewOrBlobOrString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ArrayBufferOrArrayBufferViewOrBlobOrString>, ()> {
if value.get().is_object() {
match ArrayBufferOrArrayBufferViewOrBlobOrString::TryConvertToArrayBuffer(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ArrayBufferOrArrayBufferViewOrBlobOrString::ArrayBuffer(value))),
Ok(None) => (),
}
match ArrayBufferOrArrayBufferViewOrBlobOrString::TryConvertToArrayBufferView(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ArrayBufferOrArrayBufferViewOrBlobOrString::ArrayBufferView(value))),
Ok(None) => (),
}
match ArrayBufferOrArrayBufferViewOrBlobOrString::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ArrayBufferOrArrayBufferViewOrBlobOrString::Blob(value))),
Ok(None) => (),
}
}
match ArrayBufferOrArrayBufferViewOrBlobOrString::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ArrayBufferOrArrayBufferViewOrBlobOrString::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ArrayBuffer, ArrayBufferView, Blob".into()))
}
}
impl ArrayBufferOrArrayBufferViewOrBlobOrString {
unsafe fn TryConvertToArrayBuffer(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBuffer>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBuffer::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToArrayBufferView(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBufferView>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBufferView::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum ArrayBufferViewOrArrayBuffer {
ArrayBufferView(RootedTraceableBox<typedarray::HeapArrayBufferView>),
ArrayBuffer(RootedTraceableBox<typedarray::HeapArrayBuffer>),
}
impl ToJSValConvertible for ArrayBufferViewOrArrayBuffer {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref inner) => inner.to_jsval(cx, rval),
ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ArrayBufferViewOrArrayBuffer {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ArrayBufferViewOrArrayBuffer>, ()> {
if value.get().is_object() {
match ArrayBufferViewOrArrayBuffer::TryConvertToArrayBufferView(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ArrayBufferViewOrArrayBuffer::ArrayBufferView(value))),
Ok(None) => (),
}
match ArrayBufferViewOrArrayBuffer::TryConvertToArrayBuffer(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ArrayBufferViewOrArrayBuffer::ArrayBuffer(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ArrayBufferView, ArrayBuffer".into()))
}
}
impl ArrayBufferViewOrArrayBuffer {
unsafe fn TryConvertToArrayBufferView(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBufferView>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBufferView::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToArrayBuffer(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBuffer>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBuffer::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
}
#[derive(JSTraceable)]
pub enum AudioContextLatencyCategoryOrDouble {
AudioContextLatencyCategory(AudioContextLatencyCategory),
Double(Finite<f64>),
}
impl ToJSValConvertible for AudioContextLatencyCategoryOrDouble {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
AudioContextLatencyCategoryOrDouble::AudioContextLatencyCategory(ref inner) => inner.to_jsval(cx, rval),
AudioContextLatencyCategoryOrDouble::Double(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for AudioContextLatencyCategoryOrDouble {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<AudioContextLatencyCategoryOrDouble>, ()> {
if value.get().is_number() {
match AudioContextLatencyCategoryOrDouble::TryConvertToDouble(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(AudioContextLatencyCategoryOrDouble::Double(value))),
Ok(None) => (),
}
}
match AudioContextLatencyCategoryOrDouble::TryConvertToAudioContextLatencyCategory(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(AudioContextLatencyCategoryOrDouble::AudioContextLatencyCategory(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ".into()))
}
}
impl AudioContextLatencyCategoryOrDouble {
unsafe fn TryConvertToAudioContextLatencyCategory(cx: SafeJSContext, value: HandleValue) -> Result<Option<AudioContextLatencyCategory>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) { Err(_) => { return Err(()); },
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { return Ok(None); },
}))
}
unsafe fn TryConvertToDouble(cx: SafeJSContext, value: HandleValue) -> Result<Option<Finite<f64>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum BlobOrBlobSequence {
Blob(DomRoot<Blob>),
BlobSequence(Vec<DomRoot<Blob>>),
}
impl ToJSValConvertible for BlobOrBlobSequence {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
BlobOrBlobSequence::Blob(ref inner) => inner.to_jsval(cx, rval),
BlobOrBlobSequence::BlobSequence(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for BlobOrBlobSequence {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<BlobOrBlobSequence>, ()> {
if value.get().is_object() {
match BlobOrBlobSequence::TryConvertToBlobSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBlobSequence::BlobSequence(value))),
Ok(None) => (),
}
match BlobOrBlobSequence::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBlobSequence::Blob(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Blob, BlobSequence".into()))
}
}
impl BlobOrBlobSequence {
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToBlobSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<DomRoot<Blob>>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum BlobOrBoolean {
Blob(DomRoot<Blob>),
Boolean(bool),
}
impl ToJSValConvertible for BlobOrBoolean {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
BlobOrBoolean::Blob(ref inner) => inner.to_jsval(cx, rval),
BlobOrBoolean::Boolean(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for BlobOrBoolean {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<BlobOrBoolean>, ()> {
if value.get().is_object() {
match BlobOrBoolean::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBoolean::Blob(value))),
Ok(None) => (),
}
}
match BlobOrBoolean::TryConvertToBoolean(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBoolean::Boolean(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Blob".into()))
}
}
impl BlobOrBoolean {
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToBoolean(cx: SafeJSContext, value: HandleValue) -> Result<Option<bool>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams {
Blob(DomRoot<Blob>),
ArrayBufferView(RootedTraceableBox<typedarray::HeapArrayBufferView>),
ArrayBuffer(RootedTraceableBox<typedarray::HeapArrayBuffer>),
FormData(DomRoot<FormData>),
String(DOMString),
URLSearchParams(DomRoot<URLSearchParams>),
}
impl ToJSValConvertible for BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::Blob(ref inner) => inner.to_jsval(cx, rval),
BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::ArrayBufferView(ref inner) => inner.to_jsval(cx, rval),
BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::ArrayBuffer(ref inner) => inner.to_jsval(cx, rval),
BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::FormData(ref inner) => inner.to_jsval(cx, rval),
BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::String(ref inner) => inner.to_jsval(cx, rval),
BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::URLSearchParams(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams>, ()> {
if value.get().is_object() {
match BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::Blob(value))),
Ok(None) => (),
}
match BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::TryConvertToArrayBufferView(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::ArrayBufferView(value))),
Ok(None) => (),
}
match BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::TryConvertToArrayBuffer(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::ArrayBuffer(value))),
Ok(None) => (),
}
match BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::TryConvertToFormData(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::FormData(value))),
Ok(None) => (),
}
match BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::TryConvertToURLSearchParams(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::URLSearchParams(value))),
Ok(None) => (),
}
}
match BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Blob, ArrayBufferView, ArrayBuffer, FormData, URLSearchParams".into()))
}
}
impl BlobOrBufferSourceOrFormDataOrStringOrURLSearchParams {
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToArrayBufferView(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBufferView>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBufferView::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToArrayBuffer(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBuffer>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBuffer::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToFormData(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<FormData>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToURLSearchParams(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<URLSearchParams>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum BlobOrString {
Blob(DomRoot<Blob>),
String(DOMString),
}
impl ToJSValConvertible for BlobOrString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
BlobOrString::Blob(ref inner) => inner.to_jsval(cx, rval),
BlobOrString::String(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for BlobOrString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<BlobOrString>, ()> {
if value.get().is_object() {
match BlobOrString::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrString::Blob(value))),
Ok(None) => (),
}
}
match BlobOrString::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrString::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Blob".into()))
}
}
impl BlobOrString {
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum BlobOrUnsignedLong {
Blob(DomRoot<Blob>),
UnsignedLong(u32),
}
impl ToJSValConvertible for BlobOrUnsignedLong {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
BlobOrUnsignedLong::Blob(ref inner) => inner.to_jsval(cx, rval),
BlobOrUnsignedLong::UnsignedLong(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for BlobOrUnsignedLong {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<BlobOrUnsignedLong>, ()> {
if value.get().is_object() {
match BlobOrUnsignedLong::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrUnsignedLong::Blob(value))),
Ok(None) => (),
}
}
match BlobOrUnsignedLong::TryConvertToUnsignedLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BlobOrUnsignedLong::UnsignedLong(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Blob".into()))
}
}
impl BlobOrUnsignedLong {
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToUnsignedLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<u32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum BooleanOrMediaTrackConstraints {
Boolean(bool),
MediaTrackConstraints(MediaTrackConstraints),
}
impl ToJSValConvertible for BooleanOrMediaTrackConstraints {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
BooleanOrMediaTrackConstraints::Boolean(ref inner) => inner.to_jsval(cx, rval),
BooleanOrMediaTrackConstraints::MediaTrackConstraints(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for BooleanOrMediaTrackConstraints {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<BooleanOrMediaTrackConstraints>, ()> {
match BooleanOrMediaTrackConstraints::TryConvertToMediaTrackConstraints(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BooleanOrMediaTrackConstraints::MediaTrackConstraints(value))),
Ok(None) => (),
}
match BooleanOrMediaTrackConstraints::TryConvertToBoolean(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(BooleanOrMediaTrackConstraints::Boolean(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: MediaTrackConstraints".into()))
}
}
impl BooleanOrMediaTrackConstraints {
unsafe fn TryConvertToBoolean(cx: SafeJSContext, value: HandleValue) -> Result<Option<bool>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToMediaTrackConstraints(cx: SafeJSContext, value: HandleValue) -> Result<Option<MediaTrackConstraints>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum ByteStringOrLong {
ByteString(ByteString),
Long(i32),
}
impl ToJSValConvertible for ByteStringOrLong {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ByteStringOrLong::ByteString(ref inner) => inner.to_jsval(cx, rval),
ByteStringOrLong::Long(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ByteStringOrLong {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ByteStringOrLong>, ()> {
if value.get().is_number() {
match ByteStringOrLong::TryConvertToLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringOrLong::Long(value))),
Ok(None) => (),
}
}
match ByteStringOrLong::TryConvertToByteString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringOrLong::ByteString(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ".into()))
}
}
impl ByteStringOrLong {
unsafe fn TryConvertToByteString(cx: SafeJSContext, value: HandleValue) -> Result<Option<ByteString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<i32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum ByteStringSequenceOrLong {
ByteStringSequence(Vec<ByteString>),
Long(i32),
}
impl ToJSValConvertible for ByteStringSequenceOrLong {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ByteStringSequenceOrLong::ByteStringSequence(ref inner) => inner.to_jsval(cx, rval),
ByteStringSequenceOrLong::Long(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ByteStringSequenceOrLong {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ByteStringSequenceOrLong>, ()> {
if value.get().is_object() {
match ByteStringSequenceOrLong::TryConvertToByteStringSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringSequenceOrLong::ByteStringSequence(value))),
Ok(None) => (),
}
}
match ByteStringSequenceOrLong::TryConvertToLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringSequenceOrLong::Long(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ByteStringSequence".into()))
}
}
impl ByteStringSequenceOrLong {
unsafe fn TryConvertToByteStringSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<ByteString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<i32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum ByteStringSequenceOrLongOrString {
ByteStringSequence(Vec<ByteString>),
Long(i32),
String(DOMString),
}
impl ToJSValConvertible for ByteStringSequenceOrLongOrString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ByteStringSequenceOrLongOrString::ByteStringSequence(ref inner) => inner.to_jsval(cx, rval),
ByteStringSequenceOrLongOrString::Long(ref inner) => inner.to_jsval(cx, rval),
ByteStringSequenceOrLongOrString::String(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ByteStringSequenceOrLongOrString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ByteStringSequenceOrLongOrString>, ()> {
if value.get().is_object() {
match ByteStringSequenceOrLongOrString::TryConvertToByteStringSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringSequenceOrLongOrString::ByteStringSequence(value))),
Ok(None) => (),
}
}
if value.get().is_number() {
match ByteStringSequenceOrLongOrString::TryConvertToLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringSequenceOrLongOrString::Long(value))),
Ok(None) => (),
}
}
match ByteStringSequenceOrLongOrString::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringSequenceOrLongOrString::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ByteStringSequence".into()))
}
}
impl ByteStringSequenceOrLongOrString {
unsafe fn TryConvertToByteStringSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<ByteString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<i32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum ByteStringSequenceSequenceOrByteStringByteStringRecord {
ByteStringSequenceSequence(Vec<Vec<ByteString>>),
ByteStringByteStringRecord(Record<ByteString, ByteString>),
}
impl ToJSValConvertible for ByteStringSequenceSequenceOrByteStringByteStringRecord {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ByteStringSequenceSequenceOrByteStringByteStringRecord::ByteStringSequenceSequence(ref inner) => inner.to_jsval(cx, rval),
ByteStringSequenceSequenceOrByteStringByteStringRecord::ByteStringByteStringRecord(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ByteStringSequenceSequenceOrByteStringByteStringRecord {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ByteStringSequenceSequenceOrByteStringByteStringRecord>, ()> {
if value.get().is_object() {
match ByteStringSequenceSequenceOrByteStringByteStringRecord::TryConvertToByteStringSequenceSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringSequenceSequenceOrByteStringByteStringRecord::ByteStringSequenceSequence(value))),
Ok(None) => (),
}
match ByteStringSequenceSequenceOrByteStringByteStringRecord::TryConvertToByteStringByteStringRecord(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ByteStringSequenceSequenceOrByteStringByteStringRecord::ByteStringByteStringRecord(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ByteStringSequenceSequence, ByteStringByteStringRecord".into()))
}
}
impl ByteStringSequenceSequenceOrByteStringByteStringRecord {
unsafe fn TryConvertToByteStringSequenceSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<Vec<ByteString>>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToByteStringByteStringRecord(cx: SafeJSContext, value: HandleValue) -> Result<Option<Record<ByteString, ByteString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext {
CanvasRenderingContext2D(DomRoot<CanvasRenderingContext2D>),
WebGLRenderingContext(DomRoot<WebGLRenderingContext>),
WebGL2RenderingContext(DomRoot<WebGL2RenderingContext>),
GPUCanvasContext(DomRoot<GPUCanvasContext>),
}
impl ToJSValConvertible for CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::CanvasRenderingContext2D(ref inner) => inner.to_jsval(cx, rval),
CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::WebGLRenderingContext(ref inner) => inner.to_jsval(cx, rval),
CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::WebGL2RenderingContext(ref inner) => inner.to_jsval(cx, rval),
CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::GPUCanvasContext(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext>, ()> {
if value.get().is_object() {
match CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::TryConvertToCanvasRenderingContext2D(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::CanvasRenderingContext2D(value))),
Ok(None) => (),
}
match CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::TryConvertToWebGLRenderingContext(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::WebGLRenderingContext(value))),
Ok(None) => (),
}
match CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::TryConvertToWebGL2RenderingContext(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::WebGL2RenderingContext(value))),
Ok(None) => (),
}
match CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::TryConvertToGPUCanvasContext(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext::GPUCanvasContext(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: CanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext, GPUCanvasContext".into()))
}
}
impl CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrGPUCanvasContext {
unsafe fn TryConvertToCanvasRenderingContext2D(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<CanvasRenderingContext2D>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToWebGLRenderingContext(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<WebGLRenderingContext>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToWebGL2RenderingContext(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<WebGL2RenderingContext>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToGPUCanvasContext(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<GPUCanvasContext>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum ClampedUnsignedLongOrConstrainULongRange {
ClampedUnsignedLong(u32),
ConstrainULongRange(ConstrainULongRange),
}
impl ToJSValConvertible for ClampedUnsignedLongOrConstrainULongRange {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ClampedUnsignedLongOrConstrainULongRange::ClampedUnsignedLong(ref inner) => inner.to_jsval(cx, rval),
ClampedUnsignedLongOrConstrainULongRange::ConstrainULongRange(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ClampedUnsignedLongOrConstrainULongRange {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ClampedUnsignedLongOrConstrainULongRange>, ()> {
match ClampedUnsignedLongOrConstrainULongRange::TryConvertToConstrainULongRange(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ClampedUnsignedLongOrConstrainULongRange::ConstrainULongRange(value))),
Ok(None) => (),
}
match ClampedUnsignedLongOrConstrainULongRange::TryConvertToClampedUnsignedLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ClampedUnsignedLongOrConstrainULongRange::ClampedUnsignedLong(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ConstrainULongRange".into()))
}
}
impl ClampedUnsignedLongOrConstrainULongRange {
unsafe fn TryConvertToClampedUnsignedLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<u32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Clamp) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToConstrainULongRange(cx: SafeJSContext, value: HandleValue) -> Result<Option<ConstrainULongRange>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum DocumentOrTestTypedef {
Document(DomRoot<Document>),
String(DOMString),
URL(DomRoot<URL>),
Blob(DomRoot<Blob>),
}
impl ToJSValConvertible for DocumentOrTestTypedef {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
DocumentOrTestTypedef::Document(ref inner) => inner.to_jsval(cx, rval),
DocumentOrTestTypedef::String(ref inner) => inner.to_jsval(cx, rval),
DocumentOrTestTypedef::URL(ref inner) => inner.to_jsval(cx, rval),
DocumentOrTestTypedef::Blob(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for DocumentOrTestTypedef {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<DocumentOrTestTypedef>, ()> {
if value.get().is_object() {
match DocumentOrTestTypedef::TryConvertToDocument(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrTestTypedef::Document(value))),
Ok(None) => (),
}
match DocumentOrTestTypedef::TryConvertToURL(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrTestTypedef::URL(value))),
Ok(None) => (),
}
match DocumentOrTestTypedef::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrTestTypedef::Blob(value))),
Ok(None) => (),
}
}
match DocumentOrTestTypedef::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrTestTypedef::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Document, URL, Blob".into()))
}
}
impl DocumentOrTestTypedef {
unsafe fn TryConvertToDocument(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Document>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToURL(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<URL>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum DocumentOrXMLHttpRequestBodyInit {
Document(DomRoot<Document>),
Blob(DomRoot<Blob>),
ArrayBufferView(RootedTraceableBox<typedarray::HeapArrayBufferView>),
ArrayBuffer(RootedTraceableBox<typedarray::HeapArrayBuffer>),
FormData(DomRoot<FormData>),
String(DOMString),
URLSearchParams(DomRoot<URLSearchParams>),
}
impl ToJSValConvertible for DocumentOrXMLHttpRequestBodyInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
DocumentOrXMLHttpRequestBodyInit::Document(ref inner) => inner.to_jsval(cx, rval),
DocumentOrXMLHttpRequestBodyInit::Blob(ref inner) => inner.to_jsval(cx, rval),
DocumentOrXMLHttpRequestBodyInit::ArrayBufferView(ref inner) => inner.to_jsval(cx, rval),
DocumentOrXMLHttpRequestBodyInit::ArrayBuffer(ref inner) => inner.to_jsval(cx, rval),
DocumentOrXMLHttpRequestBodyInit::FormData(ref inner) => inner.to_jsval(cx, rval),
DocumentOrXMLHttpRequestBodyInit::String(ref inner) => inner.to_jsval(cx, rval),
DocumentOrXMLHttpRequestBodyInit::URLSearchParams(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for DocumentOrXMLHttpRequestBodyInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<DocumentOrXMLHttpRequestBodyInit>, ()> {
if value.get().is_object() {
match DocumentOrXMLHttpRequestBodyInit::TryConvertToDocument(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrXMLHttpRequestBodyInit::Document(value))),
Ok(None) => (),
}
match DocumentOrXMLHttpRequestBodyInit::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrXMLHttpRequestBodyInit::Blob(value))),
Ok(None) => (),
}
match DocumentOrXMLHttpRequestBodyInit::TryConvertToArrayBufferView(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrXMLHttpRequestBodyInit::ArrayBufferView(value))),
Ok(None) => (),
}
match DocumentOrXMLHttpRequestBodyInit::TryConvertToArrayBuffer(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrXMLHttpRequestBodyInit::ArrayBuffer(value))),
Ok(None) => (),
}
match DocumentOrXMLHttpRequestBodyInit::TryConvertToFormData(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrXMLHttpRequestBodyInit::FormData(value))),
Ok(None) => (),
}
match DocumentOrXMLHttpRequestBodyInit::TryConvertToURLSearchParams(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrXMLHttpRequestBodyInit::URLSearchParams(value))),
Ok(None) => (),
}
}
match DocumentOrXMLHttpRequestBodyInit::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DocumentOrXMLHttpRequestBodyInit::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Document, Blob, ArrayBufferView, ArrayBuffer, FormData, URLSearchParams".into()))
}
}
impl DocumentOrXMLHttpRequestBodyInit {
unsafe fn TryConvertToDocument(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Document>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToArrayBufferView(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBufferView>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBufferView::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToArrayBuffer(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBuffer>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBuffer::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToFormData(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<FormData>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToURLSearchParams(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<URLSearchParams>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum DoubleOrAutoKeyword {
Double(Finite<f64>),
AutoKeyword(AutoKeyword),
}
impl ToJSValConvertible for DoubleOrAutoKeyword {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
DoubleOrAutoKeyword::Double(ref inner) => inner.to_jsval(cx, rval),
DoubleOrAutoKeyword::AutoKeyword(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for DoubleOrAutoKeyword {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<DoubleOrAutoKeyword>, ()> {
if value.get().is_number() {
match DoubleOrAutoKeyword::TryConvertToDouble(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DoubleOrAutoKeyword::Double(value))),
Ok(None) => (),
}
}
match DoubleOrAutoKeyword::TryConvertToAutoKeyword(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DoubleOrAutoKeyword::AutoKeyword(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ".into()))
}
}
impl DoubleOrAutoKeyword {
unsafe fn TryConvertToDouble(cx: SafeJSContext, value: HandleValue) -> Result<Option<Finite<f64>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToAutoKeyword(cx: SafeJSContext, value: HandleValue) -> Result<Option<AutoKeyword>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) { Err(_) => { return Err(()); },
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { return Ok(None); },
}))
}
}
#[derive(JSTraceable)]
pub enum DoubleOrConstrainDoubleRange {
Double(Finite<f64>),
ConstrainDoubleRange(ConstrainDoubleRange),
}
impl ToJSValConvertible for DoubleOrConstrainDoubleRange {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
DoubleOrConstrainDoubleRange::Double(ref inner) => inner.to_jsval(cx, rval),
DoubleOrConstrainDoubleRange::ConstrainDoubleRange(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for DoubleOrConstrainDoubleRange {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<DoubleOrConstrainDoubleRange>, ()> {
match DoubleOrConstrainDoubleRange::TryConvertToConstrainDoubleRange(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DoubleOrConstrainDoubleRange::ConstrainDoubleRange(value))),
Ok(None) => (),
}
match DoubleOrConstrainDoubleRange::TryConvertToDouble(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DoubleOrConstrainDoubleRange::Double(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ConstrainDoubleRange".into()))
}
}
impl DoubleOrConstrainDoubleRange {
unsafe fn TryConvertToDouble(cx: SafeJSContext, value: HandleValue) -> Result<Option<Finite<f64>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToConstrainDoubleRange(cx: SafeJSContext, value: HandleValue) -> Result<Option<ConstrainDoubleRange>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum DoubleSequenceOrGPUColorDict {
DoubleSequence(Vec<Finite<f64>>),
GPUColorDict(GPUColorDict),
}
impl ToJSValConvertible for DoubleSequenceOrGPUColorDict {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
DoubleSequenceOrGPUColorDict::DoubleSequence(ref inner) => inner.to_jsval(cx, rval),
DoubleSequenceOrGPUColorDict::GPUColorDict(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for DoubleSequenceOrGPUColorDict {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<DoubleSequenceOrGPUColorDict>, ()> {
if value.get().is_object() {
match DoubleSequenceOrGPUColorDict::TryConvertToDoubleSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DoubleSequenceOrGPUColorDict::DoubleSequence(value))),
Ok(None) => (),
}
}
match DoubleSequenceOrGPUColorDict::TryConvertToGPUColorDict(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(DoubleSequenceOrGPUColorDict::GPUColorDict(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: DoubleSequence, GPUColorDict".into()))
}
}
impl DoubleSequenceOrGPUColorDict {
unsafe fn TryConvertToDoubleSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<Finite<f64>>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToGPUColorDict(cx: SafeJSContext, value: HandleValue) -> Result<Option<GPUColorDict>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum EventListenerOptionsOrBoolean {
EventListenerOptions(EventListenerOptions),
Boolean(bool),
}
impl ToJSValConvertible for EventListenerOptionsOrBoolean {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
EventListenerOptionsOrBoolean::EventListenerOptions(ref inner) => inner.to_jsval(cx, rval),
EventListenerOptionsOrBoolean::Boolean(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for EventListenerOptionsOrBoolean {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<EventListenerOptionsOrBoolean>, ()> {
match EventListenerOptionsOrBoolean::TryConvertToEventListenerOptions(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(EventListenerOptionsOrBoolean::EventListenerOptions(value))),
Ok(None) => (),
}
match EventListenerOptionsOrBoolean::TryConvertToBoolean(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(EventListenerOptionsOrBoolean::Boolean(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: EventListenerOptions".into()))
}
}
impl EventListenerOptionsOrBoolean {
unsafe fn TryConvertToEventListenerOptions(cx: SafeJSContext, value: HandleValue) -> Result<Option<EventListenerOptions>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToBoolean(cx: SafeJSContext, value: HandleValue) -> Result<Option<bool>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum EventOrString {
Event(DomRoot<Event>),
String(DOMString),
}
impl ToJSValConvertible for EventOrString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
EventOrString::Event(ref inner) => inner.to_jsval(cx, rval),
EventOrString::String(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for EventOrString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<EventOrString>, ()> {
if value.get().is_object() {
match EventOrString::TryConvertToEvent(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(EventOrString::Event(value))),
Ok(None) => (),
}
}
match EventOrString::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(EventOrString::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Event".into()))
}
}
impl EventOrString {
unsafe fn TryConvertToEvent(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Event>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum EventOrUSVString {
Event(DomRoot<Event>),
USVString(USVString),
}
impl ToJSValConvertible for EventOrUSVString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
EventOrUSVString::Event(ref inner) => inner.to_jsval(cx, rval),
EventOrUSVString::USVString(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for EventOrUSVString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<EventOrUSVString>, ()> {
if value.get().is_object() {
match EventOrUSVString::TryConvertToEvent(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(EventOrUSVString::Event(value))),
Ok(None) => (),
}
}
match EventOrUSVString::TryConvertToUSVString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(EventOrUSVString::USVString(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Event".into()))
}
}
impl EventOrUSVString {
unsafe fn TryConvertToEvent(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Event>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToUSVString(cx: SafeJSContext, value: HandleValue) -> Result<Option<USVString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum FileOrUSVString {
File(DomRoot<File>),
USVString(USVString),
}
impl ToJSValConvertible for FileOrUSVString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
FileOrUSVString::File(ref inner) => inner.to_jsval(cx, rval),
FileOrUSVString::USVString(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for FileOrUSVString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<FileOrUSVString>, ()> {
if value.get().is_object() {
match FileOrUSVString::TryConvertToFile(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(FileOrUSVString::File(value))),
Ok(None) => (),
}
}
match FileOrUSVString::TryConvertToUSVString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(FileOrUSVString::USVString(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: File".into()))
}
}
impl FileOrUSVString {
unsafe fn TryConvertToFile(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<File>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToUSVString(cx: SafeJSContext, value: HandleValue) -> Result<Option<USVString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum FileOrUSVStringOrFormData {
File(DomRoot<File>),
USVString(USVString),
FormData(DomRoot<FormData>),
}
impl ToJSValConvertible for FileOrUSVStringOrFormData {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
FileOrUSVStringOrFormData::File(ref inner) => inner.to_jsval(cx, rval),
FileOrUSVStringOrFormData::USVString(ref inner) => inner.to_jsval(cx, rval),
FileOrUSVStringOrFormData::FormData(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for FileOrUSVStringOrFormData {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<FileOrUSVStringOrFormData>, ()> {
if value.get().is_object() {
match FileOrUSVStringOrFormData::TryConvertToFile(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(FileOrUSVStringOrFormData::File(value))),
Ok(None) => (),
}
match FileOrUSVStringOrFormData::TryConvertToFormData(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(FileOrUSVStringOrFormData::FormData(value))),
Ok(None) => (),
}
}
match FileOrUSVStringOrFormData::TryConvertToUSVString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(FileOrUSVStringOrFormData::USVString(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: File, FormData".into()))
}
}
impl FileOrUSVStringOrFormData {
unsafe fn TryConvertToFile(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<File>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToUSVString(cx: SafeJSContext, value: HandleValue) -> Result<Option<USVString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToFormData(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<FormData>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum Float32ArrayOrUnrestrictedFloatSequence {
Float32Array(RootedTraceableBox<typedarray::HeapFloat32Array>),
UnrestrictedFloatSequence(Vec<f32>),
}
impl ToJSValConvertible for Float32ArrayOrUnrestrictedFloatSequence {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
Float32ArrayOrUnrestrictedFloatSequence::Float32Array(ref inner) => inner.to_jsval(cx, rval),
Float32ArrayOrUnrestrictedFloatSequence::UnrestrictedFloatSequence(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for Float32ArrayOrUnrestrictedFloatSequence {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<Float32ArrayOrUnrestrictedFloatSequence>, ()> {
if value.get().is_object() {
match Float32ArrayOrUnrestrictedFloatSequence::TryConvertToUnrestrictedFloatSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(Float32ArrayOrUnrestrictedFloatSequence::UnrestrictedFloatSequence(value))),
Ok(None) => (),
}
match Float32ArrayOrUnrestrictedFloatSequence::TryConvertToFloat32Array(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(Float32ArrayOrUnrestrictedFloatSequence::Float32Array(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Float32Array, UnrestrictedFloatSequence".into()))
}
}
impl Float32ArrayOrUnrestrictedFloatSequence {
unsafe fn TryConvertToFloat32Array(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapFloat32Array>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapFloat32Array::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToUnrestrictedFloatSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<f32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum GPUOutOfMemoryErrorOrGPUValidationError {
GPUOutOfMemoryError(DomRoot<GPUOutOfMemoryError>),
GPUValidationError(DomRoot<GPUValidationError>),
}
impl ToJSValConvertible for GPUOutOfMemoryErrorOrGPUValidationError {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
GPUOutOfMemoryErrorOrGPUValidationError::GPUOutOfMemoryError(ref inner) => inner.to_jsval(cx, rval),
GPUOutOfMemoryErrorOrGPUValidationError::GPUValidationError(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for GPUOutOfMemoryErrorOrGPUValidationError {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<GPUOutOfMemoryErrorOrGPUValidationError>, ()> {
if value.get().is_object() {
match GPUOutOfMemoryErrorOrGPUValidationError::TryConvertToGPUOutOfMemoryError(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(GPUOutOfMemoryErrorOrGPUValidationError::GPUOutOfMemoryError(value))),
Ok(None) => (),
}
match GPUOutOfMemoryErrorOrGPUValidationError::TryConvertToGPUValidationError(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(GPUOutOfMemoryErrorOrGPUValidationError::GPUValidationError(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: GPUOutOfMemoryError, GPUValidationError".into()))
}
}
impl GPUOutOfMemoryErrorOrGPUValidationError {
unsafe fn TryConvertToGPUOutOfMemoryError(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<GPUOutOfMemoryError>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToGPUValidationError(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<GPUValidationError>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum GPUPipelineLayoutOrGPUAutoLayoutMode {
GPUPipelineLayout(DomRoot<GPUPipelineLayout>),
GPUAutoLayoutMode(GPUAutoLayoutMode),
}
impl ToJSValConvertible for GPUPipelineLayoutOrGPUAutoLayoutMode {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
GPUPipelineLayoutOrGPUAutoLayoutMode::GPUPipelineLayout(ref inner) => inner.to_jsval(cx, rval),
GPUPipelineLayoutOrGPUAutoLayoutMode::GPUAutoLayoutMode(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for GPUPipelineLayoutOrGPUAutoLayoutMode {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<GPUPipelineLayoutOrGPUAutoLayoutMode>, ()> {
if value.get().is_object() {
match GPUPipelineLayoutOrGPUAutoLayoutMode::TryConvertToGPUPipelineLayout(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(GPUPipelineLayoutOrGPUAutoLayoutMode::GPUPipelineLayout(value))),
Ok(None) => (),
}
}
match GPUPipelineLayoutOrGPUAutoLayoutMode::TryConvertToGPUAutoLayoutMode(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(GPUPipelineLayoutOrGPUAutoLayoutMode::GPUAutoLayoutMode(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: GPUPipelineLayout".into()))
}
}
impl GPUPipelineLayoutOrGPUAutoLayoutMode {
unsafe fn TryConvertToGPUPipelineLayout(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<GPUPipelineLayout>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToGPUAutoLayoutMode(cx: SafeJSContext, value: HandleValue) -> Result<Option<GPUAutoLayoutMode>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) { Err(_) => { return Err(()); },
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => { return Ok(None); },
}))
}
}
#[derive(JSTraceable)]
pub enum GPUSamplerOrGPUTextureViewOrGPUBufferBinding {
GPUSampler(DomRoot<GPUSampler>),
GPUTextureView(DomRoot<GPUTextureView>),
GPUBufferBinding(GPUBufferBinding),
}
impl ToJSValConvertible for GPUSamplerOrGPUTextureViewOrGPUBufferBinding {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
GPUSamplerOrGPUTextureViewOrGPUBufferBinding::GPUSampler(ref inner) => inner.to_jsval(cx, rval),
GPUSamplerOrGPUTextureViewOrGPUBufferBinding::GPUTextureView(ref inner) => inner.to_jsval(cx, rval),
GPUSamplerOrGPUTextureViewOrGPUBufferBinding::GPUBufferBinding(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for GPUSamplerOrGPUTextureViewOrGPUBufferBinding {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<GPUSamplerOrGPUTextureViewOrGPUBufferBinding>, ()> {
if value.get().is_object() {
match GPUSamplerOrGPUTextureViewOrGPUBufferBinding::TryConvertToGPUSampler(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(GPUSamplerOrGPUTextureViewOrGPUBufferBinding::GPUSampler(value))),
Ok(None) => (),
}
match GPUSamplerOrGPUTextureViewOrGPUBufferBinding::TryConvertToGPUTextureView(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(GPUSamplerOrGPUTextureViewOrGPUBufferBinding::GPUTextureView(value))),
Ok(None) => (),
}
}
match GPUSamplerOrGPUTextureViewOrGPUBufferBinding::TryConvertToGPUBufferBinding(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(GPUSamplerOrGPUTextureViewOrGPUBufferBinding::GPUBufferBinding(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: GPUSampler, GPUTextureView, GPUBufferBinding".into()))
}
}
impl GPUSamplerOrGPUTextureViewOrGPUBufferBinding {
unsafe fn TryConvertToGPUSampler(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<GPUSampler>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToGPUTextureView(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<GPUTextureView>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToGPUBufferBinding(cx: SafeJSContext, value: HandleValue) -> Result<Option<GPUBufferBinding>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum HTMLCanvasElementOrOffscreenCanvas {
HTMLCanvasElement(DomRoot<HTMLCanvasElement>),
OffscreenCanvas(DomRoot<OffscreenCanvas>),
}
impl ToJSValConvertible for HTMLCanvasElementOrOffscreenCanvas {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(ref inner) => inner.to_jsval(cx, rval),
HTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for HTMLCanvasElementOrOffscreenCanvas {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<HTMLCanvasElementOrOffscreenCanvas>, ()> {
if value.get().is_object() {
match HTMLCanvasElementOrOffscreenCanvas::TryConvertToHTMLCanvasElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(value))),
Ok(None) => (),
}
match HTMLCanvasElementOrOffscreenCanvas::TryConvertToOffscreenCanvas(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: HTMLCanvasElement, OffscreenCanvas".into()))
}
}
impl HTMLCanvasElementOrOffscreenCanvas {
unsafe fn TryConvertToHTMLCanvasElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLCanvasElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToOffscreenCanvas(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<OffscreenCanvas>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum HTMLElementOrLong {
HTMLElement(DomRoot<HTMLElement>),
Long(i32),
}
impl ToJSValConvertible for HTMLElementOrLong {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
HTMLElementOrLong::HTMLElement(ref inner) => inner.to_jsval(cx, rval),
HTMLElementOrLong::Long(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for HTMLElementOrLong {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<HTMLElementOrLong>, ()> {
if value.get().is_object() {
match HTMLElementOrLong::TryConvertToHTMLElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLElementOrLong::HTMLElement(value))),
Ok(None) => (),
}
}
match HTMLElementOrLong::TryConvertToLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLElementOrLong::Long(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: HTMLElement".into()))
}
}
impl HTMLElementOrLong {
unsafe fn TryConvertToHTMLElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<i32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum HTMLElementOrUnsignedLongOrStringOrBoolean {
HTMLElement(DomRoot<HTMLElement>),
UnsignedLong(u32),
String(DOMString),
Boolean(bool),
}
impl ToJSValConvertible for HTMLElementOrUnsignedLongOrStringOrBoolean {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
HTMLElementOrUnsignedLongOrStringOrBoolean::HTMLElement(ref inner) => inner.to_jsval(cx, rval),
HTMLElementOrUnsignedLongOrStringOrBoolean::UnsignedLong(ref inner) => inner.to_jsval(cx, rval),
HTMLElementOrUnsignedLongOrStringOrBoolean::String(ref inner) => inner.to_jsval(cx, rval),
HTMLElementOrUnsignedLongOrStringOrBoolean::Boolean(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for HTMLElementOrUnsignedLongOrStringOrBoolean {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<HTMLElementOrUnsignedLongOrStringOrBoolean>, ()> {
if value.get().is_object() {
match HTMLElementOrUnsignedLongOrStringOrBoolean::TryConvertToHTMLElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLElementOrUnsignedLongOrStringOrBoolean::HTMLElement(value))),
Ok(None) => (),
}
}
if value.get().is_boolean() {
match HTMLElementOrUnsignedLongOrStringOrBoolean::TryConvertToBoolean(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLElementOrUnsignedLongOrStringOrBoolean::Boolean(value))),
Ok(None) => (),
}
}
if value.get().is_number() {
match HTMLElementOrUnsignedLongOrStringOrBoolean::TryConvertToUnsignedLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLElementOrUnsignedLongOrStringOrBoolean::UnsignedLong(value))),
Ok(None) => (),
}
}
match HTMLElementOrUnsignedLongOrStringOrBoolean::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLElementOrUnsignedLongOrStringOrBoolean::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: HTMLElement".into()))
}
}
impl HTMLElementOrUnsignedLongOrStringOrBoolean {
unsafe fn TryConvertToHTMLElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToUnsignedLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<u32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToBoolean(cx: SafeJSContext, value: HandleValue) -> Result<Option<bool>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum HTMLOptionElementOrHTMLOptGroupElement {
HTMLOptionElement(DomRoot<HTMLOptionElement>),
HTMLOptGroupElement(DomRoot<HTMLOptGroupElement>),
}
impl ToJSValConvertible for HTMLOptionElementOrHTMLOptGroupElement {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
HTMLOptionElementOrHTMLOptGroupElement::HTMLOptionElement(ref inner) => inner.to_jsval(cx, rval),
HTMLOptionElementOrHTMLOptGroupElement::HTMLOptGroupElement(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for HTMLOptionElementOrHTMLOptGroupElement {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<HTMLOptionElementOrHTMLOptGroupElement>, ()> {
if value.get().is_object() {
match HTMLOptionElementOrHTMLOptGroupElement::TryConvertToHTMLOptionElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOptionElementOrHTMLOptGroupElement::HTMLOptionElement(value))),
Ok(None) => (),
}
match HTMLOptionElementOrHTMLOptGroupElement::TryConvertToHTMLOptGroupElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOptionElementOrHTMLOptGroupElement::HTMLOptGroupElement(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: HTMLOptionElement, HTMLOptGroupElement".into()))
}
}
impl HTMLOptionElementOrHTMLOptGroupElement {
unsafe fn TryConvertToHTMLOptionElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLOptionElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToHTMLOptGroupElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLOptGroupElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue {
HTMLImageElement(DomRoot<HTMLImageElement>),
HTMLCanvasElement(DomRoot<HTMLCanvasElement>),
OffscreenCanvas(DomRoot<OffscreenCanvas>),
CSSStyleValue(DomRoot<CSSStyleValue>),
}
impl ToJSValConvertible for HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::HTMLImageElement(ref inner) => inner.to_jsval(cx, rval),
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::HTMLCanvasElement(ref inner) => inner.to_jsval(cx, rval),
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::OffscreenCanvas(ref inner) => inner.to_jsval(cx, rval),
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::CSSStyleValue(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue>, ()> {
if value.get().is_object() {
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::TryConvertToHTMLImageElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::HTMLImageElement(value))),
Ok(None) => (),
}
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::TryConvertToHTMLCanvasElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::HTMLCanvasElement(value))),
Ok(None) => (),
}
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::TryConvertToOffscreenCanvas(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::OffscreenCanvas(value))),
Ok(None) => (),
}
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::TryConvertToCSSStyleValue(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue::CSSStyleValue(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: HTMLImageElement, HTMLCanvasElement, OffscreenCanvas, CSSStyleValue".into()))
}
}
impl HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValue {
unsafe fn TryConvertToHTMLImageElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLImageElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToHTMLCanvasElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLCanvasElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToOffscreenCanvas(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<OffscreenCanvas>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToCSSStyleValue(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<CSSStyleValue>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData {
HTMLImageElement(DomRoot<HTMLImageElement>),
HTMLCanvasElement(DomRoot<HTMLCanvasElement>),
OffscreenCanvas(DomRoot<OffscreenCanvas>),
CSSStyleValue(DomRoot<CSSStyleValue>),
Blob(DomRoot<Blob>),
ImageData(DomRoot<ImageData>),
}
impl ToJSValConvertible for HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::HTMLImageElement(ref inner) => inner.to_jsval(cx, rval),
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::HTMLCanvasElement(ref inner) => inner.to_jsval(cx, rval),
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::OffscreenCanvas(ref inner) => inner.to_jsval(cx, rval),
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::CSSStyleValue(ref inner) => inner.to_jsval(cx, rval),
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::Blob(ref inner) => inner.to_jsval(cx, rval),
HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::ImageData(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData>, ()> {
if value.get().is_object() {
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::TryConvertToHTMLImageElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::HTMLImageElement(value))),
Ok(None) => (),
}
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::TryConvertToHTMLCanvasElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::HTMLCanvasElement(value))),
Ok(None) => (),
}
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::TryConvertToOffscreenCanvas(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::OffscreenCanvas(value))),
Ok(None) => (),
}
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::TryConvertToCSSStyleValue(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::CSSStyleValue(value))),
Ok(None) => (),
}
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::Blob(value))),
Ok(None) => (),
}
match HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::TryConvertToImageData(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData::ImageData(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: HTMLImageElement, HTMLCanvasElement, OffscreenCanvas, CSSStyleValue, Blob, ImageData".into()))
}
}
impl HTMLOrSVGImageElementOrHTMLCanvasElementOrOffscreenCanvasOrCSSStyleValueOrBlobOrImageData {
unsafe fn TryConvertToHTMLImageElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLImageElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToHTMLCanvasElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLCanvasElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToOffscreenCanvas(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<OffscreenCanvas>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToCSSStyleValue(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<CSSStyleValue>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToImageData(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<ImageData>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas {
ImageBitmap(DomRoot<ImageBitmap>),
HTMLCanvasElement(DomRoot<HTMLCanvasElement>),
OffscreenCanvas(DomRoot<OffscreenCanvas>),
}
impl ToJSValConvertible for ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::ImageBitmap(ref inner) => inner.to_jsval(cx, rval),
ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(ref inner) => inner.to_jsval(cx, rval),
ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas>, ()> {
if value.get().is_object() {
match ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::TryConvertToImageBitmap(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::ImageBitmap(value))),
Ok(None) => (),
}
match ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::TryConvertToHTMLCanvasElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(value))),
Ok(None) => (),
}
match ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::TryConvertToOffscreenCanvas(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ImageBitmap, HTMLCanvasElement, OffscreenCanvas".into()))
}
}
impl ImageBitmapOrHTMLCanvasElementOrOffscreenCanvas {
unsafe fn TryConvertToImageBitmap(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<ImageBitmap>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToHTMLCanvasElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLCanvasElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToOffscreenCanvas(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<OffscreenCanvas>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement {
ImageData(DomRoot<ImageData>),
HTMLImageElement(DomRoot<HTMLImageElement>),
HTMLCanvasElement(DomRoot<HTMLCanvasElement>),
HTMLVideoElement(DomRoot<HTMLVideoElement>),
}
impl ToJSValConvertible for ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::ImageData(ref inner) => inner.to_jsval(cx, rval),
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLImageElement(ref inner) => inner.to_jsval(cx, rval),
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLCanvasElement(ref inner) => inner.to_jsval(cx, rval),
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLVideoElement(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement>, ()> {
if value.get().is_object() {
match ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::TryConvertToImageData(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::ImageData(value))),
Ok(None) => (),
}
match ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::TryConvertToHTMLImageElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLImageElement(value))),
Ok(None) => (),
}
match ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::TryConvertToHTMLCanvasElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLCanvasElement(value))),
Ok(None) => (),
}
match ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::TryConvertToHTMLVideoElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLVideoElement(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ImageData, HTMLImageElement, HTMLCanvasElement, HTMLVideoElement".into()))
}
}
impl ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement {
unsafe fn TryConvertToImageData(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<ImageData>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToHTMLImageElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLImageElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToHTMLCanvasElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLCanvasElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToHTMLVideoElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLVideoElement>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum Int32ArrayOrLongSequence {
Int32Array(RootedTraceableBox<typedarray::HeapInt32Array>),
LongSequence(Vec<i32>),
}
impl ToJSValConvertible for Int32ArrayOrLongSequence {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
Int32ArrayOrLongSequence::Int32Array(ref inner) => inner.to_jsval(cx, rval),
Int32ArrayOrLongSequence::LongSequence(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for Int32ArrayOrLongSequence {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<Int32ArrayOrLongSequence>, ()> {
if value.get().is_object() {
match Int32ArrayOrLongSequence::TryConvertToLongSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(Int32ArrayOrLongSequence::LongSequence(value))),
Ok(None) => (),
}
match Int32ArrayOrLongSequence::TryConvertToInt32Array(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(Int32ArrayOrLongSequence::Int32Array(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Int32Array, LongSequence".into()))
}
}
impl Int32ArrayOrLongSequence {
unsafe fn TryConvertToInt32Array(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapInt32Array>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapInt32Array::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToLongSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<i32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum LongOrLongSequenceSequence {
Long(i32),
LongSequenceSequence(Vec<Vec<i32>>),
}
impl ToJSValConvertible for LongOrLongSequenceSequence {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
LongOrLongSequenceSequence::Long(ref inner) => inner.to_jsval(cx, rval),
LongOrLongSequenceSequence::LongSequenceSequence(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for LongOrLongSequenceSequence {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<LongOrLongSequenceSequence>, ()> {
if value.get().is_object() {
match LongOrLongSequenceSequence::TryConvertToLongSequenceSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongOrLongSequenceSequence::LongSequenceSequence(value))),
Ok(None) => (),
}
}
match LongOrLongSequenceSequence::TryConvertToLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongOrLongSequenceSequence::Long(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: LongSequenceSequence".into()))
}
}
impl LongOrLongSequenceSequence {
unsafe fn TryConvertToLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<i32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToLongSequenceSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<Vec<i32>>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum LongOrStringByteStringRecord {
Long(i32),
StringByteStringRecord(Record<DOMString, ByteString>),
}
impl ToJSValConvertible for LongOrStringByteStringRecord {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
LongOrStringByteStringRecord::Long(ref inner) => inner.to_jsval(cx, rval),
LongOrStringByteStringRecord::StringByteStringRecord(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for LongOrStringByteStringRecord {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<LongOrStringByteStringRecord>, ()> {
if value.get().is_object() {
match LongOrStringByteStringRecord::TryConvertToStringByteStringRecord(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongOrStringByteStringRecord::StringByteStringRecord(value))),
Ok(None) => (),
}
}
match LongOrStringByteStringRecord::TryConvertToLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongOrStringByteStringRecord::Long(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: StringByteStringRecord".into()))
}
}
impl LongOrStringByteStringRecord {
unsafe fn TryConvertToLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<i32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToStringByteStringRecord(cx: SafeJSContext, value: HandleValue) -> Result<Option<Record<DOMString, ByteString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum LongSequenceOrBoolean {
LongSequence(Vec<i32>),
Boolean(bool),
}
impl ToJSValConvertible for LongSequenceOrBoolean {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
LongSequenceOrBoolean::LongSequence(ref inner) => inner.to_jsval(cx, rval),
LongSequenceOrBoolean::Boolean(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for LongSequenceOrBoolean {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<LongSequenceOrBoolean>, ()> {
if value.get().is_object() {
match LongSequenceOrBoolean::TryConvertToLongSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongSequenceOrBoolean::LongSequence(value))),
Ok(None) => (),
}
}
match LongSequenceOrBoolean::TryConvertToBoolean(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongSequenceOrBoolean::Boolean(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: LongSequence".into()))
}
}
impl LongSequenceOrBoolean {
unsafe fn TryConvertToLongSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<i32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToBoolean(cx: SafeJSContext, value: HandleValue) -> Result<Option<bool>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum LongSequenceOrTestTypedef {
LongSequence(Vec<i32>),
String(DOMString),
URL(DomRoot<URL>),
Blob(DomRoot<Blob>),
}
impl ToJSValConvertible for LongSequenceOrTestTypedef {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
LongSequenceOrTestTypedef::LongSequence(ref inner) => inner.to_jsval(cx, rval),
LongSequenceOrTestTypedef::String(ref inner) => inner.to_jsval(cx, rval),
LongSequenceOrTestTypedef::URL(ref inner) => inner.to_jsval(cx, rval),
LongSequenceOrTestTypedef::Blob(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for LongSequenceOrTestTypedef {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<LongSequenceOrTestTypedef>, ()> {
if value.get().is_object() {
match LongSequenceOrTestTypedef::TryConvertToLongSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongSequenceOrTestTypedef::LongSequence(value))),
Ok(None) => (),
}
match LongSequenceOrTestTypedef::TryConvertToURL(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongSequenceOrTestTypedef::URL(value))),
Ok(None) => (),
}
match LongSequenceOrTestTypedef::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongSequenceOrTestTypedef::Blob(value))),
Ok(None) => (),
}
}
match LongSequenceOrTestTypedef::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(LongSequenceOrTestTypedef::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: URL, Blob, LongSequence".into()))
}
}
impl LongSequenceOrTestTypedef {
unsafe fn TryConvertToLongSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<i32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToURL(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<URL>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum MediaStreamOrBlob {
MediaStream(DomRoot<MediaStream>),
Blob(DomRoot<Blob>),
}
impl ToJSValConvertible for MediaStreamOrBlob {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
MediaStreamOrBlob::MediaStream(ref inner) => inner.to_jsval(cx, rval),
MediaStreamOrBlob::Blob(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for MediaStreamOrBlob {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<MediaStreamOrBlob>, ()> {
if value.get().is_object() {
match MediaStreamOrBlob::TryConvertToMediaStream(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(MediaStreamOrBlob::MediaStream(value))),
Ok(None) => (),
}
match MediaStreamOrBlob::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(MediaStreamOrBlob::Blob(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: MediaStream, Blob".into()))
}
}
impl MediaStreamOrBlob {
unsafe fn TryConvertToMediaStream(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<MediaStream>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum MediaStreamTrackOrString {
MediaStreamTrack(DomRoot<MediaStreamTrack>),
String(DOMString),
}
impl ToJSValConvertible for MediaStreamTrackOrString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
MediaStreamTrackOrString::MediaStreamTrack(ref inner) => inner.to_jsval(cx, rval),
MediaStreamTrackOrString::String(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for MediaStreamTrackOrString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<MediaStreamTrackOrString>, ()> {
if value.get().is_object() {
match MediaStreamTrackOrString::TryConvertToMediaStreamTrack(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(MediaStreamTrackOrString::MediaStreamTrack(value))),
Ok(None) => (),
}
}
match MediaStreamTrackOrString::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(MediaStreamTrackOrString::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: MediaStreamTrack".into()))
}
}
impl MediaStreamTrackOrString {
unsafe fn TryConvertToMediaStreamTrack(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<MediaStreamTrack>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum NodeOrString {
Node(DomRoot<Node>),
String(DOMString),
}
impl ToJSValConvertible for NodeOrString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
NodeOrString::Node(ref inner) => inner.to_jsval(cx, rval),
NodeOrString::String(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for NodeOrString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<NodeOrString>, ()> {
if value.get().is_object() {
match NodeOrString::TryConvertToNode(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(NodeOrString::Node(value))),
Ok(None) => (),
}
}
match NodeOrString::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(NodeOrString::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Node".into()))
}
}
impl NodeOrString {
unsafe fn TryConvertToNode(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Node>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext {
OffscreenCanvasRenderingContext2D(DomRoot<OffscreenCanvasRenderingContext2D>),
WebGLRenderingContext(DomRoot<WebGLRenderingContext>),
WebGL2RenderingContext(DomRoot<WebGL2RenderingContext>),
}
impl ToJSValConvertible for OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::OffscreenCanvasRenderingContext2D(ref inner) => inner.to_jsval(cx, rval),
OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::WebGLRenderingContext(ref inner) => inner.to_jsval(cx, rval),
OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::WebGL2RenderingContext(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext>, ()> {
if value.get().is_object() {
match OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::TryConvertToOffscreenCanvasRenderingContext2D(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::OffscreenCanvasRenderingContext2D(value))),
Ok(None) => (),
}
match OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::TryConvertToWebGLRenderingContext(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::WebGLRenderingContext(value))),
Ok(None) => (),
}
match OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::TryConvertToWebGL2RenderingContext(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext::WebGL2RenderingContext(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: OffscreenCanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext".into()))
}
}
impl OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext {
unsafe fn TryConvertToOffscreenCanvasRenderingContext2D(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<OffscreenCanvasRenderingContext2D>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToWebGLRenderingContext(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<WebGLRenderingContext>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToWebGL2RenderingContext(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<WebGL2RenderingContext>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum RadioNodeListOrElement {
RadioNodeList(DomRoot<RadioNodeList>),
Element(DomRoot<Element>),
}
impl ToJSValConvertible for RadioNodeListOrElement {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
RadioNodeListOrElement::RadioNodeList(ref inner) => inner.to_jsval(cx, rval),
RadioNodeListOrElement::Element(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for RadioNodeListOrElement {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<RadioNodeListOrElement>, ()> {
if value.get().is_object() {
match RadioNodeListOrElement::TryConvertToRadioNodeList(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RadioNodeListOrElement::RadioNodeList(value))),
Ok(None) => (),
}
match RadioNodeListOrElement::TryConvertToElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RadioNodeListOrElement::Element(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: RadioNodeList, Element".into()))
}
}
impl RadioNodeListOrElement {
unsafe fn TryConvertToRadioNodeList(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<RadioNodeList>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Element>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict {
RangeEnforcedUnsignedLongSequence(Vec<u32>),
GPUExtent3DDict(GPUExtent3DDict),
}
impl ToJSValConvertible for RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict::RangeEnforcedUnsignedLongSequence(ref inner) => inner.to_jsval(cx, rval),
RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict::GPUExtent3DDict(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict>, ()> {
if value.get().is_object() {
match RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict::TryConvertToRangeEnforcedUnsignedLongSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict::RangeEnforcedUnsignedLongSequence(value))),
Ok(None) => (),
}
}
match RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict::TryConvertToGPUExtent3DDict(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict::GPUExtent3DDict(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: RangeEnforcedUnsignedLongSequence, GPUExtent3DDict".into()))
}
}
impl RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict {
unsafe fn TryConvertToRangeEnforcedUnsignedLongSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<u32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToGPUExtent3DDict(cx: SafeJSContext, value: HandleValue) -> Result<Option<GPUExtent3DDict>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict {
RangeEnforcedUnsignedLongSequence(Vec<u32>),
GPUOrigin2DDict(GPUOrigin2DDict),
}
impl ToJSValConvertible for RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict::RangeEnforcedUnsignedLongSequence(ref inner) => inner.to_jsval(cx, rval),
RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict::GPUOrigin2DDict(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict>, ()> {
if value.get().is_object() {
match RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict::TryConvertToRangeEnforcedUnsignedLongSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict::RangeEnforcedUnsignedLongSequence(value))),
Ok(None) => (),
}
}
match RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict::TryConvertToGPUOrigin2DDict(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict::GPUOrigin2DDict(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: RangeEnforcedUnsignedLongSequence, GPUOrigin2DDict".into()))
}
}
impl RangeEnforcedUnsignedLongSequenceOrGPUOrigin2DDict {
unsafe fn TryConvertToRangeEnforcedUnsignedLongSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<u32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToGPUOrigin2DDict(cx: SafeJSContext, value: HandleValue) -> Result<Option<GPUOrigin2DDict>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict {
RangeEnforcedUnsignedLongSequence(Vec<u32>),
GPUOrigin3DDict(GPUOrigin3DDict),
}
impl ToJSValConvertible for RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict::RangeEnforcedUnsignedLongSequence(ref inner) => inner.to_jsval(cx, rval),
RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict::GPUOrigin3DDict(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict>, ()> {
if value.get().is_object() {
match RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict::TryConvertToRangeEnforcedUnsignedLongSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict::RangeEnforcedUnsignedLongSequence(value))),
Ok(None) => (),
}
}
match RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict::TryConvertToGPUOrigin3DDict(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict::GPUOrigin3DDict(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: RangeEnforcedUnsignedLongSequence, GPUOrigin3DDict".into()))
}
}
impl RangeEnforcedUnsignedLongSequenceOrGPUOrigin3DDict {
unsafe fn TryConvertToRangeEnforcedUnsignedLongSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<u32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToGPUOrigin3DDict(cx: SafeJSContext, value: HandleValue) -> Result<Option<GPUOrigin3DDict>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum ReadableStreamOrXMLHttpRequestBodyInit {
ReadableStream(DomRoot<ReadableStream>),
Blob(DomRoot<Blob>),
ArrayBufferView(RootedTraceableBox<typedarray::HeapArrayBufferView>),
ArrayBuffer(RootedTraceableBox<typedarray::HeapArrayBuffer>),
FormData(DomRoot<FormData>),
String(DOMString),
URLSearchParams(DomRoot<URLSearchParams>),
}
impl ToJSValConvertible for ReadableStreamOrXMLHttpRequestBodyInit {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
ReadableStreamOrXMLHttpRequestBodyInit::ReadableStream(ref inner) => inner.to_jsval(cx, rval),
ReadableStreamOrXMLHttpRequestBodyInit::Blob(ref inner) => inner.to_jsval(cx, rval),
ReadableStreamOrXMLHttpRequestBodyInit::ArrayBufferView(ref inner) => inner.to_jsval(cx, rval),
ReadableStreamOrXMLHttpRequestBodyInit::ArrayBuffer(ref inner) => inner.to_jsval(cx, rval),
ReadableStreamOrXMLHttpRequestBodyInit::FormData(ref inner) => inner.to_jsval(cx, rval),
ReadableStreamOrXMLHttpRequestBodyInit::String(ref inner) => inner.to_jsval(cx, rval),
ReadableStreamOrXMLHttpRequestBodyInit::URLSearchParams(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for ReadableStreamOrXMLHttpRequestBodyInit {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<ReadableStreamOrXMLHttpRequestBodyInit>, ()> {
if value.get().is_object() {
match ReadableStreamOrXMLHttpRequestBodyInit::TryConvertToReadableStream(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ReadableStreamOrXMLHttpRequestBodyInit::ReadableStream(value))),
Ok(None) => (),
}
match ReadableStreamOrXMLHttpRequestBodyInit::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ReadableStreamOrXMLHttpRequestBodyInit::Blob(value))),
Ok(None) => (),
}
match ReadableStreamOrXMLHttpRequestBodyInit::TryConvertToArrayBufferView(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ReadableStreamOrXMLHttpRequestBodyInit::ArrayBufferView(value))),
Ok(None) => (),
}
match ReadableStreamOrXMLHttpRequestBodyInit::TryConvertToArrayBuffer(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ReadableStreamOrXMLHttpRequestBodyInit::ArrayBuffer(value))),
Ok(None) => (),
}
match ReadableStreamOrXMLHttpRequestBodyInit::TryConvertToFormData(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ReadableStreamOrXMLHttpRequestBodyInit::FormData(value))),
Ok(None) => (),
}
match ReadableStreamOrXMLHttpRequestBodyInit::TryConvertToURLSearchParams(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ReadableStreamOrXMLHttpRequestBodyInit::URLSearchParams(value))),
Ok(None) => (),
}
}
match ReadableStreamOrXMLHttpRequestBodyInit::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(ReadableStreamOrXMLHttpRequestBodyInit::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ReadableStream, Blob, ArrayBufferView, ArrayBuffer, FormData, URLSearchParams".into()))
}
}
impl ReadableStreamOrXMLHttpRequestBodyInit {
unsafe fn TryConvertToReadableStream(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<ReadableStream>>, ()> {
Ok(Some({
use crate::realms::{AlreadyInRealm, InRealm};
let in_realm_proof = AlreadyInRealm::assert_for_cx(cx);
match ReadableStream::from_js(cx, value.get().to_object(), InRealm::Already(&in_realm_proof)) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
}
))
}
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToArrayBufferView(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBufferView>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBufferView::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToArrayBuffer(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapArrayBuffer>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapArrayBuffer::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToFormData(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<FormData>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToURLSearchParams(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<URLSearchParams>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum RequestOrUSVString {
Request(DomRoot<Request>),
USVString(USVString),
}
impl ToJSValConvertible for RequestOrUSVString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
RequestOrUSVString::Request(ref inner) => inner.to_jsval(cx, rval),
RequestOrUSVString::USVString(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for RequestOrUSVString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<RequestOrUSVString>, ()> {
if value.get().is_object() {
match RequestOrUSVString::TryConvertToRequest(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RequestOrUSVString::Request(value))),
Ok(None) => (),
}
}
match RequestOrUSVString::TryConvertToUSVString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(RequestOrUSVString::USVString(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Request".into()))
}
}
impl RequestOrUSVString {
unsafe fn TryConvertToRequest(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Request>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToUSVString(cx: SafeJSContext, value: HandleValue) -> Result<Option<USVString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum StringOrBoolean {
String(DOMString),
Boolean(bool),
}
impl ToJSValConvertible for StringOrBoolean {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrBoolean::String(ref inner) => inner.to_jsval(cx, rval),
StringOrBoolean::Boolean(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrBoolean {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrBoolean>, ()> {
if value.get().is_boolean() {
match StringOrBoolean::TryConvertToBoolean(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrBoolean::Boolean(value))),
Ok(None) => (),
}
}
match StringOrBoolean::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrBoolean::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ".into()))
}
}
impl StringOrBoolean {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToBoolean(cx: SafeJSContext, value: HandleValue) -> Result<Option<bool>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum StringOrCanvasGradientOrCanvasPattern {
String(DOMString),
CanvasGradient(DomRoot<CanvasGradient>),
CanvasPattern(DomRoot<CanvasPattern>),
}
impl ToJSValConvertible for StringOrCanvasGradientOrCanvasPattern {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrCanvasGradientOrCanvasPattern::String(ref inner) => inner.to_jsval(cx, rval),
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(ref inner) => inner.to_jsval(cx, rval),
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrCanvasGradientOrCanvasPattern {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrCanvasGradientOrCanvasPattern>, ()> {
if value.get().is_object() {
match StringOrCanvasGradientOrCanvasPattern::TryConvertToCanvasGradient(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrCanvasGradientOrCanvasPattern::CanvasGradient(value))),
Ok(None) => (),
}
match StringOrCanvasGradientOrCanvasPattern::TryConvertToCanvasPattern(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrCanvasGradientOrCanvasPattern::CanvasPattern(value))),
Ok(None) => (),
}
}
match StringOrCanvasGradientOrCanvasPattern::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrCanvasGradientOrCanvasPattern::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: CanvasGradient, CanvasPattern".into()))
}
}
impl StringOrCanvasGradientOrCanvasPattern {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToCanvasGradient(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<CanvasGradient>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToCanvasPattern(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<CanvasPattern>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum StringOrElementCreationOptions {
String(DOMString),
ElementCreationOptions(ElementCreationOptions),
}
impl ToJSValConvertible for StringOrElementCreationOptions {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrElementCreationOptions::String(ref inner) => inner.to_jsval(cx, rval),
StringOrElementCreationOptions::ElementCreationOptions(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrElementCreationOptions {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrElementCreationOptions>, ()> {
match StringOrElementCreationOptions::TryConvertToElementCreationOptions(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrElementCreationOptions::ElementCreationOptions(value))),
Ok(None) => (),
}
match StringOrElementCreationOptions::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrElementCreationOptions::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ElementCreationOptions".into()))
}
}
impl StringOrElementCreationOptions {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToElementCreationOptions(cx: SafeJSContext, value: HandleValue) -> Result<Option<ElementCreationOptions>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum StringOrFunction {
String(DOMString),
Function(Rc<Function>),
}
impl ToJSValConvertible for StringOrFunction {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrFunction::String(ref inner) => inner.to_jsval(cx, rval),
StringOrFunction::Function(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrFunction {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrFunction>, ()> {
if value.get().is_object() {
match StringOrFunction::TryConvertToFunction(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrFunction::Function(value))),
Ok(None) => (),
}
}
match StringOrFunction::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrFunction::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ".into()))
}
}
impl StringOrFunction {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToFunction(cx: SafeJSContext, value: HandleValue) -> Result<Option<Rc<Function>>, ()> {
Ok(Some(if IsCallable(value.get().to_object()) {
Function::new(cx, value.get().to_object())
} else {
return Ok(None);
}))
}
}
#[derive(JSTraceable)]
pub enum StringOrLongSequence {
String(DOMString),
LongSequence(Vec<i32>),
}
impl ToJSValConvertible for StringOrLongSequence {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrLongSequence::String(ref inner) => inner.to_jsval(cx, rval),
StringOrLongSequence::LongSequence(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrLongSequence {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrLongSequence>, ()> {
if value.get().is_object() {
match StringOrLongSequence::TryConvertToLongSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrLongSequence::LongSequence(value))),
Ok(None) => (),
}
}
match StringOrLongSequence::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrLongSequence::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: LongSequence".into()))
}
}
impl StringOrLongSequence {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToLongSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<i32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum StringOrObject {
String(DOMString),
Object(RootedTraceableBox<Heap<*mut JSObject>>),
}
impl ToJSValConvertible for StringOrObject {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrObject::String(ref inner) => inner.to_jsval(cx, rval),
StringOrObject::Object(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrObject {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrObject>, ()> {
if value.get().is_object() {
match StringOrObject::TryConvertToObject(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrObject::Object(value))),
Ok(None) => (),
}
}
match StringOrObject::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrObject::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Object".into()))
}
}
impl StringOrObject {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToObject(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<Heap<*mut JSObject>>>, ()> {
Ok(Some(RootedTraceableBox::from_box(Heap::boxed(value.get().to_object()))))
}
}
#[derive(JSTraceable)]
pub enum StringOrStringSequence {
String(DOMString),
StringSequence(Vec<DOMString>),
}
impl ToJSValConvertible for StringOrStringSequence {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrStringSequence::String(ref inner) => inner.to_jsval(cx, rval),
StringOrStringSequence::StringSequence(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrStringSequence {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrStringSequence>, ()> {
if value.get().is_object() {
match StringOrStringSequence::TryConvertToStringSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrStringSequence::StringSequence(value))),
Ok(None) => (),
}
}
match StringOrStringSequence::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrStringSequence::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: StringSequence".into()))
}
}
impl StringOrStringSequence {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToStringSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<DOMString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum StringOrURLOrBlob {
String(DOMString),
URL(DomRoot<URL>),
Blob(DomRoot<Blob>),
}
impl ToJSValConvertible for StringOrURLOrBlob {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrURLOrBlob::String(ref inner) => inner.to_jsval(cx, rval),
StringOrURLOrBlob::URL(ref inner) => inner.to_jsval(cx, rval),
StringOrURLOrBlob::Blob(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrURLOrBlob {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrURLOrBlob>, ()> {
if value.get().is_object() {
match StringOrURLOrBlob::TryConvertToURL(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrURLOrBlob::URL(value))),
Ok(None) => (),
}
match StringOrURLOrBlob::TryConvertToBlob(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrURLOrBlob::Blob(value))),
Ok(None) => (),
}
}
match StringOrURLOrBlob::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrURLOrBlob::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: URL, Blob".into()))
}
}
impl StringOrURLOrBlob {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToURL(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<URL>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToBlob(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Blob>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum StringOrUnrestrictedDoubleSequence {
String(DOMString),
UnrestrictedDoubleSequence(Vec<f64>),
}
impl ToJSValConvertible for StringOrUnrestrictedDoubleSequence {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrUnrestrictedDoubleSequence::String(ref inner) => inner.to_jsval(cx, rval),
StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrUnrestrictedDoubleSequence {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrUnrestrictedDoubleSequence>, ()> {
if value.get().is_object() {
match StringOrUnrestrictedDoubleSequence::TryConvertToUnrestrictedDoubleSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(value))),
Ok(None) => (),
}
}
match StringOrUnrestrictedDoubleSequence::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrUnrestrictedDoubleSequence::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: UnrestrictedDoubleSequence".into()))
}
}
impl StringOrUnrestrictedDoubleSequence {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToUnrestrictedDoubleSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<f64>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum StringOrUnsignedLong {
String(DOMString),
UnsignedLong(u32),
}
impl ToJSValConvertible for StringOrUnsignedLong {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringOrUnsignedLong::String(ref inner) => inner.to_jsval(cx, rval),
StringOrUnsignedLong::UnsignedLong(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringOrUnsignedLong {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringOrUnsignedLong>, ()> {
if value.get().is_number() {
match StringOrUnsignedLong::TryConvertToUnsignedLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrUnsignedLong::UnsignedLong(value))),
Ok(None) => (),
}
}
match StringOrUnsignedLong::TryConvertToString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringOrUnsignedLong::String(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ".into()))
}
}
impl StringOrUnsignedLong {
unsafe fn TryConvertToString(cx: SafeJSContext, value: HandleValue) -> Result<Option<DOMString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToUnsignedLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<u32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum StringSequenceOrUnsignedLong {
StringSequence(Vec<DOMString>),
UnsignedLong(u32),
}
impl ToJSValConvertible for StringSequenceOrUnsignedLong {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
StringSequenceOrUnsignedLong::StringSequence(ref inner) => inner.to_jsval(cx, rval),
StringSequenceOrUnsignedLong::UnsignedLong(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for StringSequenceOrUnsignedLong {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<StringSequenceOrUnsignedLong>, ()> {
if value.get().is_object() {
match StringSequenceOrUnsignedLong::TryConvertToStringSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringSequenceOrUnsignedLong::StringSequence(value))),
Ok(None) => (),
}
}
match StringSequenceOrUnsignedLong::TryConvertToUnsignedLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(StringSequenceOrUnsignedLong::UnsignedLong(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: StringSequence".into()))
}
}
impl StringSequenceOrUnsignedLong {
unsafe fn TryConvertToStringSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<DOMString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, StringificationBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToUnsignedLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<u32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord {
TestBinding(DomRoot<TestBinding>),
ByteStringSequenceSequence(Vec<Vec<ByteString>>),
StringByteStringRecord(Record<DOMString, ByteString>),
}
impl ToJSValConvertible for TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::TestBinding(ref inner) => inner.to_jsval(cx, rval),
TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::ByteStringSequenceSequence(ref inner) => inner.to_jsval(cx, rval),
TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::StringByteStringRecord(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord>, ()> {
if value.get().is_object() {
match TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::TryConvertToByteStringSequenceSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::ByteStringSequenceSequence(value))),
Ok(None) => (),
}
match TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::TryConvertToTestBinding(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::TestBinding(value))),
Ok(None) => (),
}
match TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::TryConvertToStringByteStringRecord(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord::StringByteStringRecord(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: TestBinding, ByteStringSequenceSequence, StringByteStringRecord".into()))
}
}
impl TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord {
unsafe fn TryConvertToTestBinding(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<TestBinding>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToByteStringSequenceSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<Vec<ByteString>>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToStringByteStringRecord(cx: SafeJSContext, value: HandleValue) -> Result<Option<Record<DOMString, ByteString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum TestBindingOrStringByteStringRecord {
TestBinding(DomRoot<TestBinding>),
StringByteStringRecord(Record<DOMString, ByteString>),
}
impl ToJSValConvertible for TestBindingOrStringByteStringRecord {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
TestBindingOrStringByteStringRecord::TestBinding(ref inner) => inner.to_jsval(cx, rval),
TestBindingOrStringByteStringRecord::StringByteStringRecord(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for TestBindingOrStringByteStringRecord {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<TestBindingOrStringByteStringRecord>, ()> {
if value.get().is_object() {
match TestBindingOrStringByteStringRecord::TryConvertToTestBinding(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(TestBindingOrStringByteStringRecord::TestBinding(value))),
Ok(None) => (),
}
match TestBindingOrStringByteStringRecord::TryConvertToStringByteStringRecord(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(TestBindingOrStringByteStringRecord::StringByteStringRecord(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: TestBinding, StringByteStringRecord".into()))
}
}
impl TestBindingOrStringByteStringRecord {
unsafe fn TryConvertToTestBinding(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<TestBinding>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToStringByteStringRecord(cx: SafeJSContext, value: HandleValue) -> Result<Option<Record<DOMString, ByteString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum TestDictionaryOrLong {
TestDictionary(RootedTraceableBox<TestDictionary>),
Long(i32),
}
impl ToJSValConvertible for TestDictionaryOrLong {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
TestDictionaryOrLong::TestDictionary(ref inner) => inner.to_jsval(cx, rval),
TestDictionaryOrLong::Long(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for TestDictionaryOrLong {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<TestDictionaryOrLong>, ()> {
match TestDictionaryOrLong::TryConvertToTestDictionary(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(TestDictionaryOrLong::TestDictionary(value))),
Ok(None) => (),
}
match TestDictionaryOrLong::TryConvertToLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(TestDictionaryOrLong::Long(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: TestDictionary".into()))
}
}
impl TestDictionaryOrLong {
unsafe fn TryConvertToTestDictionary(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<TestDictionary>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(dictionary)) => dictionary,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<i32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString {
USVStringSequenceSequence(Vec<Vec<USVString>>),
USVStringUSVStringRecord(Record<USVString, USVString>),
USVString(USVString),
}
impl ToJSValConvertible for USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringSequenceSequence(ref inner) => inner.to_jsval(cx, rval),
USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringUSVStringRecord(ref inner) => inner.to_jsval(cx, rval),
USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVString(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString>, ()> {
if value.get().is_object() {
match USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::TryConvertToUSVStringSequenceSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringSequenceSequence(value))),
Ok(None) => (),
}
match USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::TryConvertToUSVStringUSVStringRecord(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringUSVStringRecord(value))),
Ok(None) => (),
}
}
match USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::TryConvertToUSVString(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVString(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: USVStringSequenceSequence, USVStringUSVStringRecord".into()))
}
}
impl USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString {
unsafe fn TryConvertToUSVStringSequenceSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<Vec<USVString>>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToUSVStringUSVStringRecord(cx: SafeJSContext, value: HandleValue) -> Result<Option<Record<USVString, USVString>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
unsafe fn TryConvertToUSVString(cx: SafeJSContext, value: HandleValue) -> Result<Option<USVString>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum Uint32ArrayOrUnsignedLongSequence {
Uint32Array(RootedTraceableBox<typedarray::HeapUint32Array>),
UnsignedLongSequence(Vec<u32>),
}
impl ToJSValConvertible for Uint32ArrayOrUnsignedLongSequence {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
Uint32ArrayOrUnsignedLongSequence::Uint32Array(ref inner) => inner.to_jsval(cx, rval),
Uint32ArrayOrUnsignedLongSequence::UnsignedLongSequence(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for Uint32ArrayOrUnsignedLongSequence {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<Uint32ArrayOrUnsignedLongSequence>, ()> {
if value.get().is_object() {
match Uint32ArrayOrUnsignedLongSequence::TryConvertToUnsignedLongSequence(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(Uint32ArrayOrUnsignedLongSequence::UnsignedLongSequence(value))),
Ok(None) => (),
}
match Uint32ArrayOrUnsignedLongSequence::TryConvertToUint32Array(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(Uint32ArrayOrUnsignedLongSequence::Uint32Array(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: Uint32Array, UnsignedLongSequence".into()))
}
}
impl Uint32ArrayOrUnsignedLongSequence {
unsafe fn TryConvertToUint32Array(cx: SafeJSContext, value: HandleValue) -> Result<Option<RootedTraceableBox<typedarray::HeapUint32Array>>, ()> {
Ok(Some(RootedTraceableBox::new(match typedarray::HeapUint32Array::from(value.get().to_object()) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
)))
}
unsafe fn TryConvertToUnsignedLongSequence(cx: SafeJSContext, value: HandleValue) -> Result<Option<Vec<u32>>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(value)) => value,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); },
}))
}
}
#[derive(JSTraceable)]
pub enum UnsignedLongOrBoolean {
UnsignedLong(u32),
Boolean(bool),
}
impl ToJSValConvertible for UnsignedLongOrBoolean {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
UnsignedLongOrBoolean::UnsignedLong(ref inner) => inner.to_jsval(cx, rval),
UnsignedLongOrBoolean::Boolean(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for UnsignedLongOrBoolean {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<UnsignedLongOrBoolean>, ()> {
if value.get().is_boolean() {
match UnsignedLongOrBoolean::TryConvertToBoolean(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(UnsignedLongOrBoolean::Boolean(value))),
Ok(None) => (),
}
}
match UnsignedLongOrBoolean::TryConvertToUnsignedLong(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(UnsignedLongOrBoolean::UnsignedLong(value))),
Ok(None) => (),
}
Ok(ConversionResult::Failure("argument could not be converted to any of: ".into()))
}
}
impl UnsignedLongOrBoolean {
unsafe fn TryConvertToUnsignedLong(cx: SafeJSContext, value: HandleValue) -> Result<Option<u32>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ConversionBehavior::Default) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
unsafe fn TryConvertToBoolean(cx: SafeJSContext, value: HandleValue) -> Result<Option<bool>, ()> {
Ok(Some(match FromJSValConvertible::from_jsval(*cx, value, ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
return Ok(None);
}
_ => { return Err(()); }
}))
}
}
#[derive(JSTraceable)]
pub enum VideoTrackOrAudioTrackOrTextTrack {
VideoTrack(DomRoot<VideoTrack>),
AudioTrack(DomRoot<AudioTrack>),
TextTrack(DomRoot<TextTrack>),
}
impl ToJSValConvertible for VideoTrackOrAudioTrackOrTextTrack {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
VideoTrackOrAudioTrackOrTextTrack::VideoTrack(ref inner) => inner.to_jsval(cx, rval),
VideoTrackOrAudioTrackOrTextTrack::AudioTrack(ref inner) => inner.to_jsval(cx, rval),
VideoTrackOrAudioTrackOrTextTrack::TextTrack(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for VideoTrackOrAudioTrackOrTextTrack {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<VideoTrackOrAudioTrackOrTextTrack>, ()> {
if value.get().is_object() {
match VideoTrackOrAudioTrackOrTextTrack::TryConvertToVideoTrack(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(VideoTrackOrAudioTrackOrTextTrack::VideoTrack(value))),
Ok(None) => (),
}
match VideoTrackOrAudioTrackOrTextTrack::TryConvertToAudioTrack(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(VideoTrackOrAudioTrackOrTextTrack::AudioTrack(value))),
Ok(None) => (),
}
match VideoTrackOrAudioTrackOrTextTrack::TryConvertToTextTrack(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(VideoTrackOrAudioTrackOrTextTrack::TextTrack(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: VideoTrack, AudioTrack, TextTrack".into()))
}
}
impl VideoTrackOrAudioTrackOrTextTrack {
unsafe fn TryConvertToVideoTrack(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<VideoTrack>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToAudioTrack(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<AudioTrack>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToTextTrack(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<TextTrack>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum WebGLRenderingContextOrWebGL2RenderingContext {
WebGLRenderingContext(DomRoot<WebGLRenderingContext>),
WebGL2RenderingContext(DomRoot<WebGL2RenderingContext>),
}
impl ToJSValConvertible for WebGLRenderingContextOrWebGL2RenderingContext {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
WebGLRenderingContextOrWebGL2RenderingContext::WebGLRenderingContext(ref inner) => inner.to_jsval(cx, rval),
WebGLRenderingContextOrWebGL2RenderingContext::WebGL2RenderingContext(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for WebGLRenderingContextOrWebGL2RenderingContext {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<WebGLRenderingContextOrWebGL2RenderingContext>, ()> {
if value.get().is_object() {
match WebGLRenderingContextOrWebGL2RenderingContext::TryConvertToWebGLRenderingContext(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(WebGLRenderingContextOrWebGL2RenderingContext::WebGLRenderingContext(value))),
Ok(None) => (),
}
match WebGLRenderingContextOrWebGL2RenderingContext::TryConvertToWebGL2RenderingContext(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(WebGLRenderingContextOrWebGL2RenderingContext::WebGL2RenderingContext(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: WebGLRenderingContext, WebGL2RenderingContext".into()))
}
}
impl WebGLRenderingContextOrWebGL2RenderingContext {
unsafe fn TryConvertToWebGLRenderingContext(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<WebGLRenderingContext>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToWebGL2RenderingContext(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<WebGL2RenderingContext>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum WindowProxyOrElementOrHTMLCollection {
WindowProxy(DomRoot<WindowProxy>),
Element(DomRoot<Element>),
HTMLCollection(DomRoot<HTMLCollection>),
}
impl ToJSValConvertible for WindowProxyOrElementOrHTMLCollection {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
WindowProxyOrElementOrHTMLCollection::WindowProxy(ref inner) => inner.to_jsval(cx, rval),
WindowProxyOrElementOrHTMLCollection::Element(ref inner) => inner.to_jsval(cx, rval),
WindowProxyOrElementOrHTMLCollection::HTMLCollection(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for WindowProxyOrElementOrHTMLCollection {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<WindowProxyOrElementOrHTMLCollection>, ()> {
if value.get().is_object() {
match WindowProxyOrElementOrHTMLCollection::TryConvertToWindowProxy(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(WindowProxyOrElementOrHTMLCollection::WindowProxy(value))),
Ok(None) => (),
}
match WindowProxyOrElementOrHTMLCollection::TryConvertToElement(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(WindowProxyOrElementOrHTMLCollection::Element(value))),
Ok(None) => (),
}
match WindowProxyOrElementOrHTMLCollection::TryConvertToHTMLCollection(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(WindowProxyOrElementOrHTMLCollection::HTMLCollection(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: WindowProxy, Element, HTMLCollection".into()))
}
}
impl WindowProxyOrElementOrHTMLCollection {
unsafe fn TryConvertToWindowProxy(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<WindowProxy>>, ()> {
Ok(Some(match windowproxy_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToElement(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<Element>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToHTMLCollection(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<HTMLCollection>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}
#[derive(JSTraceable)]
pub enum WindowProxyOrMessagePortOrServiceWorker {
WindowProxy(DomRoot<WindowProxy>),
MessagePort(DomRoot<MessagePort>),
ServiceWorker(DomRoot<ServiceWorker>),
}
impl ToJSValConvertible for WindowProxyOrMessagePortOrServiceWorker {
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
match *self {
WindowProxyOrMessagePortOrServiceWorker::WindowProxy(ref inner) => inner.to_jsval(cx, rval),
WindowProxyOrMessagePortOrServiceWorker::MessagePort(ref inner) => inner.to_jsval(cx, rval),
WindowProxyOrMessagePortOrServiceWorker::ServiceWorker(ref inner) => inner.to_jsval(cx, rval),
}
}
}
impl FromJSValConvertible for WindowProxyOrMessagePortOrServiceWorker {
type Config = ();
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<WindowProxyOrMessagePortOrServiceWorker>, ()> {
if value.get().is_object() {
match WindowProxyOrMessagePortOrServiceWorker::TryConvertToWindowProxy(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(WindowProxyOrMessagePortOrServiceWorker::WindowProxy(value))),
Ok(None) => (),
}
match WindowProxyOrMessagePortOrServiceWorker::TryConvertToMessagePort(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(WindowProxyOrMessagePortOrServiceWorker::MessagePort(value))),
Ok(None) => (),
}
match WindowProxyOrMessagePortOrServiceWorker::TryConvertToServiceWorker(SafeJSContext::from_ptr(cx), value) {
Err(_) => return Err(()),
Ok(Some(value)) => return Ok(ConversionResult::Success(WindowProxyOrMessagePortOrServiceWorker::ServiceWorker(value))),
Ok(None) => (),
}
}
Ok(ConversionResult::Failure("argument could not be converted to any of: WindowProxy, MessagePort, ServiceWorker".into()))
}
}
impl WindowProxyOrMessagePortOrServiceWorker {
unsafe fn TryConvertToWindowProxy(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<WindowProxy>>, ()> {
Ok(Some(match windowproxy_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToMessagePort(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<MessagePort>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
unsafe fn TryConvertToServiceWorker(cx: SafeJSContext, value: HandleValue) -> Result<Option<DomRoot<ServiceWorker>>, ()> {
Ok(Some(match root_from_handlevalue(value, *cx) {
Ok(val) => val,
Err(()) => {
return Ok(None);
}
}
))
}
}