1#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::codegen::GenericBindings::DOMExceptionBinding::DOMException_Binding;
6use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
7use crate::import::base::*;
8
9
10#[repr(usize)]
11#[derive(Copy, Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)]
12pub enum RTCErrorDetailType {
13 Data_channel_failure,
14 Dtls_failure,
15 Fingerprint_failure,
16 Sctp_failure,
17 Sdp_syntax_error,
18 Hardware_encoder_not_available,
19 Hardware_encoder_error
20}
21pub mod RTCErrorDetailTypeValues {
22
23 use crate::utils::find_enum_value;
24 use js::conversions::ConversionResult;
25 use js::conversions::FromJSValConvertible;
26 use js::conversions::ToJSValConvertible;
27 use js::context::RawJSContext;
28 use js::rust::HandleValue;
29 use js::rust::MutableHandleValue;
30 use js::jsval::JSVal;
31
32 pub(crate) const pairs: &[(&str, super::RTCErrorDetailType)] = &[
33 ("data-channel-failure", super::RTCErrorDetailType::Data_channel_failure),
34 ("dtls-failure", super::RTCErrorDetailType::Dtls_failure),
35 ("fingerprint-failure", super::RTCErrorDetailType::Fingerprint_failure),
36 ("sctp-failure", super::RTCErrorDetailType::Sctp_failure),
37 ("sdp-syntax-error", super::RTCErrorDetailType::Sdp_syntax_error),
38 ("hardware-encoder-not-available", super::RTCErrorDetailType::Hardware_encoder_not_available),
39 ("hardware-encoder-error", super::RTCErrorDetailType::Hardware_encoder_error),
40 ];
41
42 impl super::RTCErrorDetailType {
43 pub fn as_str(&self) -> &'static str {
44 pairs[*self as usize].0
45 }
46 }
47
48 impl Default for super::RTCErrorDetailType {
49 fn default() -> super::RTCErrorDetailType {
50 pairs[0].1
51 }
52 }
53
54 impl std::str::FromStr for super::RTCErrorDetailType {
55 type Err = ();
56
57 fn from_str(s: &str) -> Result<Self, Self::Err> {
58 pairs
59 .iter()
60 .find(|&&(key, _)| s == key)
61 .map(|&(_, ev)| ev)
62 .ok_or(())
63 }
64 }
65
66 impl ToJSValConvertible for super::RTCErrorDetailType {
67 unsafe fn to_jsval(&self, cx: *mut RawJSContext, rval: MutableHandleValue) {
68 pairs[*self as usize].0.to_jsval(cx, rval);
69 }
70 }
71
72 impl FromJSValConvertible for super::RTCErrorDetailType {
73 type Config = ();
74 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
75 -> Result<ConversionResult<super::RTCErrorDetailType>, ()> {
76 match find_enum_value(cx, value, pairs) {
77 Err(_) => Err(()),
78 Ok((None, search)) => {
79 Ok(ConversionResult::Failure(
80 format!("'{}' is not a valid enum value for enumeration 'RTCErrorDetailType'.", search).into()
81 ))
82 }
83 Ok((Some(&value), _)) => Ok(ConversionResult::Success(value)),
84 }
85 }
86 }
87 } #[derive(JSTraceable)]
90pub struct RTCErrorInit {
91 pub errorDetail: RTCErrorDetailType,
92 pub httpRequestStatusCode: Option<i32>,
93 pub receivedAlert: Option<u32>,
94 pub sctpCauseCode: Option<i32>,
95 pub sdpLineNumber: Option<i32>,
96 pub sentAlert: Option<u32>,
97}
98
99impl RTCErrorInit {
100
101 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
102 -> Result<ConversionResult<RTCErrorInit>, ()> {
103 unsafe {
104 let object = if val.get().is_null_or_undefined() {
105 ptr::null_mut()
106 } else if val.get().is_object() {
107 val.get().to_object()
108 } else {
109 return Ok(ConversionResult::Failure("Value is not an object.".into()));
110 };
111 rooted!(&in(cx) let object = object);
112 let dictionary = RTCErrorInit {
113 errorDetail: {
114 rooted!(&in(cx) let mut rval = UndefinedValue());
115 if get_dictionary_property(cx.raw_cx(), object.handle(), "errorDetail", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
116 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
117 Ok(ConversionResult::Success(value)) => value,
118 Ok(ConversionResult::Failure(error)) => {
119 throw_type_error(cx.raw_cx(), &error); return Err(());
120
121 }
122 _ => {
123 return Err(());
124
125 },
126 }
127
128 } else {
129 throw_type_error(cx.raw_cx(), "Missing required member \"errorDetail\".");
130 return Err(());
131 }
132 },
133 httpRequestStatusCode: {
134 rooted!(&in(cx) let mut rval = UndefinedValue());
135 if get_dictionary_property(cx.raw_cx(), object.handle(), "httpRequestStatusCode", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
136 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
137 Ok(ConversionResult::Success(value)) => value,
138 Ok(ConversionResult::Failure(error)) => {
139 throw_type_error(cx.raw_cx(), &error);
140 return Err(());
141
142 }
143 _ => {
144 return Err(());
145
146 },
147 }
148 )
149 } else {
150 None
151 }
152 },
153 receivedAlert: {
154 rooted!(&in(cx) let mut rval = UndefinedValue());
155 if get_dictionary_property(cx.raw_cx(), object.handle(), "receivedAlert", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
156 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
157 Ok(ConversionResult::Success(value)) => value,
158 Ok(ConversionResult::Failure(error)) => {
159 throw_type_error(cx.raw_cx(), &error);
160 return Err(());
161
162 }
163 _ => {
164 return Err(());
165
166 },
167 }
168 )
169 } else {
170 None
171 }
172 },
173 sctpCauseCode: {
174 rooted!(&in(cx) let mut rval = UndefinedValue());
175 if get_dictionary_property(cx.raw_cx(), object.handle(), "sctpCauseCode", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
176 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
177 Ok(ConversionResult::Success(value)) => value,
178 Ok(ConversionResult::Failure(error)) => {
179 throw_type_error(cx.raw_cx(), &error);
180 return Err(());
181
182 }
183 _ => {
184 return Err(());
185
186 },
187 }
188 )
189 } else {
190 None
191 }
192 },
193 sdpLineNumber: {
194 rooted!(&in(cx) let mut rval = UndefinedValue());
195 if get_dictionary_property(cx.raw_cx(), object.handle(), "sdpLineNumber", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
196 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
197 Ok(ConversionResult::Success(value)) => value,
198 Ok(ConversionResult::Failure(error)) => {
199 throw_type_error(cx.raw_cx(), &error);
200 return Err(());
201
202 }
203 _ => {
204 return Err(());
205
206 },
207 }
208 )
209 } else {
210 None
211 }
212 },
213 sentAlert: {
214 rooted!(&in(cx) let mut rval = UndefinedValue());
215 if get_dictionary_property(cx.raw_cx(), object.handle(), "sentAlert", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
216 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
217 Ok(ConversionResult::Success(value)) => value,
218 Ok(ConversionResult::Failure(error)) => {
219 throw_type_error(cx.raw_cx(), &error);
220 return Err(());
221
222 }
223 _ => {
224 return Err(());
225
226 },
227 }
228 )
229 } else {
230 None
231 }
232 },
233 };
234 Ok(ConversionResult::Success(dictionary))
235 }
236 }
237}
238
239impl FromJSValConvertible for RTCErrorInit {
240 type Config = ();
241 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
242 -> Result<ConversionResult<RTCErrorInit>, ()> {
243 RTCErrorInit::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
244 }
245}
246
247impl RTCErrorInit {
248 #[allow(clippy::wrong_self_convention)]
249 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
250 let errorDetail = &self.errorDetail;
251 rooted!(in(cx) let mut errorDetail_js = UndefinedValue());
252 errorDetail.to_jsval(cx, errorDetail_js.handle_mut());
253 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "errorDetail", errorDetail_js.handle()).unwrap();
254 if let Some(ref httpRequestStatusCode) = self.httpRequestStatusCode {
255 rooted!(in(cx) let mut httpRequestStatusCode_js = UndefinedValue());
256 httpRequestStatusCode.to_jsval(cx, httpRequestStatusCode_js.handle_mut());
257 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "httpRequestStatusCode", httpRequestStatusCode_js.handle()).unwrap();
258 }
259 if let Some(ref receivedAlert) = self.receivedAlert {
260 rooted!(in(cx) let mut receivedAlert_js = UndefinedValue());
261 receivedAlert.to_jsval(cx, receivedAlert_js.handle_mut());
262 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "receivedAlert", receivedAlert_js.handle()).unwrap();
263 }
264 if let Some(ref sctpCauseCode) = self.sctpCauseCode {
265 rooted!(in(cx) let mut sctpCauseCode_js = UndefinedValue());
266 sctpCauseCode.to_jsval(cx, sctpCauseCode_js.handle_mut());
267 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "sctpCauseCode", sctpCauseCode_js.handle()).unwrap();
268 }
269 if let Some(ref sdpLineNumber) = self.sdpLineNumber {
270 rooted!(in(cx) let mut sdpLineNumber_js = UndefinedValue());
271 sdpLineNumber.to_jsval(cx, sdpLineNumber_js.handle_mut());
272 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "sdpLineNumber", sdpLineNumber_js.handle()).unwrap();
273 }
274 if let Some(ref sentAlert) = self.sentAlert {
275 rooted!(in(cx) let mut sentAlert_js = UndefinedValue());
276 sentAlert.to_jsval(cx, sentAlert_js.handle_mut());
277 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "sentAlert", sentAlert_js.handle()).unwrap();
278 }
279 }
280}
281
282impl ToJSValConvertible for RTCErrorInit {
283 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
284 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
285 self.to_jsobject(cx, obj.handle_mut());
286 rval.set(ObjectOrNullValue(obj.get()))
287 }
288}
289
290
291pub use self::RTCError_Binding::{Wrap, RTCErrorMethods, GetProtoObject, DefineDOMInterface};
292pub mod RTCError_Binding {
293use crate::codegen::GenericBindings::DOMExceptionBinding::DOMException_Binding;
294use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
295use crate::codegen::GenericBindings::RTCErrorBinding::RTCErrorDetailType;
296use crate::codegen::GenericBindings::RTCErrorBinding::RTCErrorDetailTypeValues;
297use crate::codegen::GenericBindings::RTCErrorBinding::RTCErrorInit;
298use crate::import::module::*;
299
300unsafe extern "C" fn get_errorDetail<D: DomTypes>
301(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
302 let mut result = false;
303 wrap_panic(&mut || result = (|| {
304 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
305 let this = &*(this as *const D::RTCError);
306 let result: RTCErrorDetailType = this.ErrorDetail();
307
308 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
309 return true;
310 })());
311 result
312}
313
314
315static errorDetail_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
316
317pub(crate) fn init_errorDetail_getterinfo<D: DomTypes>() {
318 errorDetail_getterinfo.set(JSJitInfo {
319 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
320 getter: Some(get_errorDetail::<D>)
321 },
322 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
323 protoID: PrototypeList::ID::RTCError as u16,
324 },
325 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
326 _bitfield_align_1: [],
327 _bitfield_1: __BindgenBitfieldUnit::new(
328 new_jsjitinfo_bitfield_1!(
329 JSJitInfo_OpType::Getter as u8,
330 JSJitInfo_AliasSet::AliasEverything as u8,
331 JSValueType::JSVAL_TYPE_STRING as u8,
332 true,
333 false,
334 false,
335 false,
336 false,
337 false,
338 0,
339 ).to_ne_bytes()
340 ),
341});
342}
343unsafe extern "C" fn get_sdpLineNumber<D: DomTypes>
344(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
345 let mut result = false;
346 wrap_panic(&mut || result = (|| {
347 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
348 let this = &*(this as *const D::RTCError);
349 let result: Option<i32> = this.GetSdpLineNumber();
350
351 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
352 return true;
353 })());
354 result
355}
356
357
358static sdpLineNumber_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
359
360pub(crate) fn init_sdpLineNumber_getterinfo<D: DomTypes>() {
361 sdpLineNumber_getterinfo.set(JSJitInfo {
362 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
363 getter: Some(get_sdpLineNumber::<D>)
364 },
365 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
366 protoID: PrototypeList::ID::RTCError as u16,
367 },
368 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
369 _bitfield_align_1: [],
370 _bitfield_1: __BindgenBitfieldUnit::new(
371 new_jsjitinfo_bitfield_1!(
372 JSJitInfo_OpType::Getter as u8,
373 JSJitInfo_AliasSet::AliasEverything as u8,
374 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
375 true,
376 false,
377 false,
378 false,
379 false,
380 false,
381 0,
382 ).to_ne_bytes()
383 ),
384});
385}
386unsafe extern "C" fn get_httpRequestStatusCode<D: DomTypes>
387(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
388 let mut result = false;
389 wrap_panic(&mut || result = (|| {
390 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
391 let this = &*(this as *const D::RTCError);
392 let result: Option<i32> = this.GetHttpRequestStatusCode();
393
394 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
395 return true;
396 })());
397 result
398}
399
400
401static httpRequestStatusCode_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
402
403pub(crate) fn init_httpRequestStatusCode_getterinfo<D: DomTypes>() {
404 httpRequestStatusCode_getterinfo.set(JSJitInfo {
405 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
406 getter: Some(get_httpRequestStatusCode::<D>)
407 },
408 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
409 protoID: PrototypeList::ID::RTCError as u16,
410 },
411 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
412 _bitfield_align_1: [],
413 _bitfield_1: __BindgenBitfieldUnit::new(
414 new_jsjitinfo_bitfield_1!(
415 JSJitInfo_OpType::Getter as u8,
416 JSJitInfo_AliasSet::AliasEverything as u8,
417 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
418 true,
419 false,
420 false,
421 false,
422 false,
423 false,
424 0,
425 ).to_ne_bytes()
426 ),
427});
428}
429unsafe extern "C" fn get_sctpCauseCode<D: DomTypes>
430(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
431 let mut result = false;
432 wrap_panic(&mut || result = (|| {
433 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
434 let this = &*(this as *const D::RTCError);
435 let result: Option<i32> = this.GetSctpCauseCode();
436
437 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
438 return true;
439 })());
440 result
441}
442
443
444static sctpCauseCode_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
445
446pub(crate) fn init_sctpCauseCode_getterinfo<D: DomTypes>() {
447 sctpCauseCode_getterinfo.set(JSJitInfo {
448 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
449 getter: Some(get_sctpCauseCode::<D>)
450 },
451 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
452 protoID: PrototypeList::ID::RTCError as u16,
453 },
454 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
455 _bitfield_align_1: [],
456 _bitfield_1: __BindgenBitfieldUnit::new(
457 new_jsjitinfo_bitfield_1!(
458 JSJitInfo_OpType::Getter as u8,
459 JSJitInfo_AliasSet::AliasEverything as u8,
460 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
461 true,
462 false,
463 false,
464 false,
465 false,
466 false,
467 0,
468 ).to_ne_bytes()
469 ),
470});
471}
472unsafe extern "C" fn get_receivedAlert<D: DomTypes>
473(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
474 let mut result = false;
475 wrap_panic(&mut || result = (|| {
476 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
477 let this = &*(this as *const D::RTCError);
478 let result: Option<u32> = this.GetReceivedAlert();
479
480 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
481 return true;
482 })());
483 result
484}
485
486
487static receivedAlert_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
488
489pub(crate) fn init_receivedAlert_getterinfo<D: DomTypes>() {
490 receivedAlert_getterinfo.set(JSJitInfo {
491 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
492 getter: Some(get_receivedAlert::<D>)
493 },
494 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
495 protoID: PrototypeList::ID::RTCError as u16,
496 },
497 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
498 _bitfield_align_1: [],
499 _bitfield_1: __BindgenBitfieldUnit::new(
500 new_jsjitinfo_bitfield_1!(
501 JSJitInfo_OpType::Getter as u8,
502 JSJitInfo_AliasSet::AliasEverything as u8,
503 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
504 true,
505 false,
506 false,
507 false,
508 false,
509 false,
510 0,
511 ).to_ne_bytes()
512 ),
513});
514}
515unsafe extern "C" fn get_sentAlert<D: DomTypes>
516(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
517 let mut result = false;
518 wrap_panic(&mut || result = (|| {
519 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
520 let this = &*(this as *const D::RTCError);
521 let result: Option<u32> = this.GetSentAlert();
522
523 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
524 return true;
525 })());
526 result
527}
528
529
530static sentAlert_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
531
532pub(crate) fn init_sentAlert_getterinfo<D: DomTypes>() {
533 sentAlert_getterinfo.set(JSJitInfo {
534 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
535 getter: Some(get_sentAlert::<D>)
536 },
537 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
538 protoID: PrototypeList::ID::RTCError as u16,
539 },
540 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 1 },
541 _bitfield_align_1: [],
542 _bitfield_1: __BindgenBitfieldUnit::new(
543 new_jsjitinfo_bitfield_1!(
544 JSJitInfo_OpType::Getter as u8,
545 JSJitInfo_AliasSet::AliasEverything as u8,
546 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
547 true,
548 false,
549 false,
550 false,
551 false,
552 false,
553 0,
554 ).to_ne_bytes()
555 ),
556});
557}
558unsafe extern "C" fn _finalize<D: DomTypes>
559(_cx: *mut GCContext, obj: *mut JSObject){
560 wrap_panic(&mut || {
561
562 let this = native_from_object_static::<D::RTCError>(obj).unwrap();
563 finalize_common(this);
564 })
565}
566
567unsafe extern "C" fn _trace<D: DomTypes>
568(trc: *mut JSTracer, obj: *mut JSObject){
569 wrap_panic(&mut || {
570
571 let this = native_from_object_static::<D::RTCError>(obj).unwrap();
572 if this.is_null() { return; } (*this).trace(trc);
574 })
575}
576
577
578static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
579
580pub(crate) fn init_class_ops<D: DomTypes>() {
581 CLASS_OPS.set(JSClassOps {
582 addProperty: None,
583 delProperty: None,
584 enumerate: None,
585 newEnumerate: None,
586 resolve: None,
587 mayResolve: None,
588 finalize: Some(_finalize::<D>),
589 call: None,
590 construct: None,
591 trace: Some(_trace::<D>),
592 });
593}
594
595pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
596
597pub(crate) fn init_domjs_class<D: DomTypes>() {
598 init_class_ops::<D>();
599 Class.set(DOMJSClass {
600 base: JSClass {
601 name: c"RTCError".as_ptr(),
602 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
603 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
604 ,
605 cOps: unsafe { CLASS_OPS.get() },
606 spec: ptr::null(),
607 ext: ptr::null(),
608 oOps: ptr::null(),
609 },
610 dom_class:
611DOMClass {
612 interface_chain: [ PrototypeList::ID::DOMException, PrototypeList::ID::RTCError, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
613 depth: 1,
614 type_id: crate::codegen::InheritTypes::TopTypeId { domexception: (crate::codegen::InheritTypes::DOMExceptionTypeId::RTCError) },
615 malloc_size_of: malloc_size_of_including_raw_self::<D::RTCError> as unsafe fn(&mut _, _) -> _,
616 global: Globals::EMPTY,
617},
618 });
619}
620
621#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
622(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::RTCError>, _can_gc: CanGc) -> DomRoot<D::RTCError>{
623
624 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
625
626 let scope = scope.reflector().get_jsobject();
627 assert!(!scope.get().is_null());
628 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
629 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
630
631 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
632 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
633 assert!(!canonical_proto.is_null());
634
635
636 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
637 if let Some(given) = given_proto {
638 proto.set(*given);
639 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
640 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
641 }
642 } else {
643 proto.set(*canonical_proto);
644 }
645 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
646 cx.raw_cx(),
647 &Class.get().base,
648 proto.handle(),
649 ));
650 assert!(!obj.is_null());
651 JS_SetReservedSlot(
652 obj.get(),
653 DOM_OBJECT_SLOT,
654 &PrivateValue(raw.as_ptr() as *const libc::c_void),
655 );
656
657 let root = raw.reflect_with(obj.get());
658
659
660
661 DomRoot::from_ref(&*root)
662}
663
664pub trait RTCErrorMethods<D: DomTypes> {
665 fn ErrorDetail(&self, ) -> RTCErrorDetailType;
666 fn GetSdpLineNumber(&self, ) -> Option<i32>;
667 fn GetHttpRequestStatusCode(&self, ) -> Option<i32>;
668 fn GetSctpCauseCode(&self, ) -> Option<i32>;
669 fn GetReceivedAlert(&self, ) -> Option<u32>;
670 fn GetSentAlert(&self, ) -> Option<u32>;
671 fn Constructor(r#global: &D::Window, r#proto: Option<HandleObject>, r#can_gc: CanGc, r#init: &crate::codegen::GenericBindings::RTCErrorBinding::RTCErrorInit, r#message: DOMString) -> DomRoot<D::RTCError>;
672}
673static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
674
675pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
676 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
677 JSPropertySpec {
678 name: JSPropertySpec_Name { string_: c"errorDetail".as_ptr() },
679 attributes_: (JSPROP_ENUMERATE),
680 kind_: (JSPropertySpec_Kind::NativeAccessor),
681 u: JSPropertySpec_AccessorsOrValue {
682 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
683 getter: JSPropertySpec_Accessor {
684 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { errorDetail_getterinfo.get() } },
685 },
686 setter: JSPropertySpec_Accessor {
687 native: JSNativeWrapper { op: None, info: ptr::null() },
688 }
689 }
690 }
691 }
692,
693 JSPropertySpec {
694 name: JSPropertySpec_Name { string_: c"sdpLineNumber".as_ptr() },
695 attributes_: (JSPROP_ENUMERATE),
696 kind_: (JSPropertySpec_Kind::NativeAccessor),
697 u: JSPropertySpec_AccessorsOrValue {
698 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
699 getter: JSPropertySpec_Accessor {
700 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { sdpLineNumber_getterinfo.get() } },
701 },
702 setter: JSPropertySpec_Accessor {
703 native: JSNativeWrapper { op: None, info: ptr::null() },
704 }
705 }
706 }
707 }
708,
709 JSPropertySpec {
710 name: JSPropertySpec_Name { string_: c"httpRequestStatusCode".as_ptr() },
711 attributes_: (JSPROP_ENUMERATE),
712 kind_: (JSPropertySpec_Kind::NativeAccessor),
713 u: JSPropertySpec_AccessorsOrValue {
714 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
715 getter: JSPropertySpec_Accessor {
716 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { httpRequestStatusCode_getterinfo.get() } },
717 },
718 setter: JSPropertySpec_Accessor {
719 native: JSNativeWrapper { op: None, info: ptr::null() },
720 }
721 }
722 }
723 }
724,
725 JSPropertySpec {
726 name: JSPropertySpec_Name { string_: c"sctpCauseCode".as_ptr() },
727 attributes_: (JSPROP_ENUMERATE),
728 kind_: (JSPropertySpec_Kind::NativeAccessor),
729 u: JSPropertySpec_AccessorsOrValue {
730 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
731 getter: JSPropertySpec_Accessor {
732 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { sctpCauseCode_getterinfo.get() } },
733 },
734 setter: JSPropertySpec_Accessor {
735 native: JSNativeWrapper { op: None, info: ptr::null() },
736 }
737 }
738 }
739 }
740,
741 JSPropertySpec {
742 name: JSPropertySpec_Name { string_: c"receivedAlert".as_ptr() },
743 attributes_: (JSPROP_ENUMERATE),
744 kind_: (JSPropertySpec_Kind::NativeAccessor),
745 u: JSPropertySpec_AccessorsOrValue {
746 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
747 getter: JSPropertySpec_Accessor {
748 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { receivedAlert_getterinfo.get() } },
749 },
750 setter: JSPropertySpec_Accessor {
751 native: JSNativeWrapper { op: None, info: ptr::null() },
752 }
753 }
754 }
755 }
756,
757 JSPropertySpec {
758 name: JSPropertySpec_Name { string_: c"sentAlert".as_ptr() },
759 attributes_: (JSPROP_ENUMERATE),
760 kind_: (JSPropertySpec_Kind::NativeAccessor),
761 u: JSPropertySpec_AccessorsOrValue {
762 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
763 getter: JSPropertySpec_Accessor {
764 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { sentAlert_getterinfo.get() } },
765 },
766 setter: JSPropertySpec_Accessor {
767 native: JSNativeWrapper { op: None, info: ptr::null() },
768 }
769 }
770 }
771 }
772,
773 JSPropertySpec::ZERO]))[..]
774,
775&Box::leak(Box::new([
776 JSPropertySpec {
777 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
778 attributes_: (JSPROP_READONLY),
779 kind_: (JSPropertySpec_Kind::Value),
780 u: JSPropertySpec_AccessorsOrValue {
781 value: JSPropertySpec_ValueWrapper {
782 type_: JSPropertySpec_ValueWrapper_Type::String,
783 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
784 string: c"RTCError".as_ptr(),
785 }
786 }
787 }
788 }
789,
790 JSPropertySpec::ZERO]))[..]
791])));
792}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
793
794pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
795 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
796 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
797}
798pub fn GetProtoObject<D: DomTypes>
799(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
800 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::RTCError), CreateInterfaceObjects::<D>, rval)
802}
803
804
805static PrototypeClass: JSClass = JSClass {
806 name: c"RTCErrorPrototype".as_ptr(),
807 flags:
808 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
810 cOps: ptr::null(),
811 spec: ptr::null(),
812 ext: ptr::null(),
813 oOps: ptr::null(),
814};
815
816unsafe extern "C" fn _constructor<D: DomTypes>
817(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
818 let mut result = false;
819 wrap_panic(&mut || result = {
820 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
821 let args = CallArgs::from_vp(vp, argc);
822 let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
823
824 call_default_constructor::<D>(
825 SafeJSContext::from_ptr(cx.raw_cx()),
826 &args,
827 &global,
828 PrototypeList::ID::RTCError,
829 "RTCError",
830 CreateInterfaceObjects::<D>,
831 |cx: SafeJSContext, args: &CallArgs, global: &D::GlobalScope, desired_proto: HandleObject| {
832
833 if argc < 1 {
834 throw_type_error(cx.raw_cx(), "Not enough arguments to \"RTCError.constructor\".");
835 return false;
836 }
837 let arg0: crate::codegen::GenericBindings::RTCErrorBinding::RTCErrorInit = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ()) {
838 Ok(ConversionResult::Success(value)) => value,
839 Ok(ConversionResult::Failure(error)) => {
840 throw_type_error(cx.raw_cx(), &error);
841 return false;
842
843 }
844 _ => {
845 return false;
846
847 },
848 }
849 ;
850 let arg1: DOMString = if args.get(1).is_undefined() {
851 DOMString::from("")
852 } else {
853 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), StringificationBehavior::Default) {
854 Ok(ConversionResult::Success(value)) => value,
855 Ok(ConversionResult::Failure(error)) => {
856 throw_type_error(cx.raw_cx(), &error);
857 return false;
858
859 }
860 _ => {
861 return false;
862
863 },
864 }
865
866 };
867 let result: DomRoot<D::RTCError> = <D::RTCError>::Constructor(global.downcast::<D::Window>().unwrap(), Some(desired_proto), CanGc::note(), &arg0, arg1);
868
869 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
870 return true;
871 }
872 )
873
874 });
875 result
876}
877
878
879static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
880
881pub(crate) fn init_interface_object<D: DomTypes>() {
882 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
883 Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
884 b"function RTCError() {\n [native code]\n}",
885 PrototypeList::ID::RTCError,
886 1,
887 ));
888}
889
890pub fn DefineDOMInterface<D: DomTypes>
891(cx: SafeJSContext, global: HandleObject){
892 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::RTCError),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
893}
894
895pub fn ConstructorEnabled<D: DomTypes>
896(aCx: SafeJSContext, aObj: HandleObject) -> bool{
897 is_exposed_in(aObj, Globals::WINDOW) &&
898 pref!(dom_webrtc_enabled)
899}
900
901unsafe fn CreateInterfaceObjects<D: DomTypes>
902(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
903
904 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
905 DOMException_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
906 assert!(!prototype_proto.is_null());
907
908 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
909 create_interface_prototype_object::<D>(cx,
910 global,
911 prototype_proto.handle(),
912 &PrototypeClass,
913 &[],
914 sAttributes.get(),
915 &[],
916 &[],
917 prototype.handle_mut());
918 assert!(!prototype.is_null());
919 assert!((*cache)[PrototypeList::ID::RTCError as usize].is_null());
920 (*cache)[PrototypeList::ID::RTCError as usize] = prototype.get();
921 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::RTCError as isize),
922 ptr::null_mut(),
923 prototype.get());
924
925 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
926
927 DOMException_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
928
929 assert!(!interface_proto.is_null());
930
931 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
932 create_noncallback_interface_object::<D>(cx,
933 global,
934 interface_proto.handle(),
935 INTERFACE_OBJECT_CLASS.get(),
936 &[],
937 &[],
938 &[],
939 prototype.handle(),
940 c"RTCError",
941 1,
942 &[],
943 interface.handle_mut());
944 assert!(!interface.is_null());
945}
946
947
948 pub(crate) fn init_statics<D: DomTypes>() {
949 init_interface_object::<D>();
950 init_domjs_class::<D>();
951
952 init_errorDetail_getterinfo::<D>();
953init_sdpLineNumber_getterinfo::<D>();
954init_httpRequestStatusCode_getterinfo::<D>();
955init_sctpCauseCode_getterinfo::<D>();
956init_receivedAlert_getterinfo::<D>();
957init_sentAlert_getterinfo::<D>();
958
959
960 init_sAttributes_specs::<D>();
961init_sAttributes_prefs::<D>();
962 }
963 }