script_bindings/home/runner/work/servo/servo/target/debug/build/script_bindings-d55f55d5af1efaee/out/Bindings/
WritableStreamDefaultWriterBinding.rs

1/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
2
3#![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::EventTargetBinding::EventTarget_Binding;
6use crate::codegen::GenericBindings::WorkerGlobalScopeBinding::WorkerGlobalScope_Binding;
7use crate::codegen::GenericBindings::WorkletGlobalScopeBinding::WorkletGlobalScope_Binding;
8use crate::import::base::*;
9
10pub use self::WritableStreamDefaultWriter_Binding::{Wrap, WritableStreamDefaultWriterMethods, GetProtoObject, DefineDOMInterface};
11pub mod WritableStreamDefaultWriter_Binding {
12use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
13use crate::codegen::GenericBindings::WorkerGlobalScopeBinding::WorkerGlobalScope_Binding;
14use crate::codegen::GenericBindings::WorkletGlobalScopeBinding::WorkletGlobalScope_Binding;
15use crate::import::module::*;
16
17unsafe extern "C" fn get_closed<D: DomTypes>
18(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
19    let mut result = false;
20    wrap_panic(&mut || result = (|| {
21        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
22        let this = &*(this as *const D::WritableStreamDefaultWriter);
23        let result: Rc<D::Promise> = this.Closed();
24
25        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
26        return true;
27    })());
28    result
29}
30
31unsafe extern "C" fn get_closed_promise_wrapper<D: DomTypes>
32(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
33    let mut result = false;
34    wrap_panic(&mut || result = (|| {
35        let ok = get_closed::<D>(cx, _obj, this, args);
36        if ok {
37          return true;
38        }
39        return exception_to_promise(cx, args.rval(), CanGc::note());
40
41    })());
42    result
43}
44
45
46static closed_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
47
48pub(crate) fn init_closed_getterinfo<D: DomTypes>() {
49    closed_getterinfo.set(JSJitInfo {
50    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
51        getter: Some(get_closed_promise_wrapper::<D>)
52    },
53    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
54        protoID: PrototypeList::ID::WritableStreamDefaultWriter as u16,
55    },
56    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
57    _bitfield_align_1: [],
58    _bitfield_1: __BindgenBitfieldUnit::new(
59        new_jsjitinfo_bitfield_1!(
60            JSJitInfo_OpType::Getter as u8,
61            JSJitInfo_AliasSet::AliasEverything as u8,
62            JSValueType::JSVAL_TYPE_OBJECT as u8,
63            true,
64            false,
65            false,
66            false,
67            false,
68            false,
69            0,
70        ).to_ne_bytes()
71    ),
72});
73}
74unsafe extern "C" fn get_desiredSize<D: DomTypes>
75(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
76    let mut result = false;
77    wrap_panic(&mut || result = (|| {
78        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
79        let this = &*(this as *const D::WritableStreamDefaultWriter);
80        let result: Result<Option<f64>, Error> = this.GetDesiredSize();
81        let result = match result {
82            Ok(result) => result,
83            Err(e) => {
84                <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), &this.global_(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx())))), e, CanGc::note());
85                return false;
86            },
87        };
88
89        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
90        return true;
91    })());
92    result
93}
94
95
96static desiredSize_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
97
98pub(crate) fn init_desiredSize_getterinfo<D: DomTypes>() {
99    desiredSize_getterinfo.set(JSJitInfo {
100    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
101        getter: Some(get_desiredSize::<D>)
102    },
103    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
104        protoID: PrototypeList::ID::WritableStreamDefaultWriter as u16,
105    },
106    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
107    _bitfield_align_1: [],
108    _bitfield_1: __BindgenBitfieldUnit::new(
109        new_jsjitinfo_bitfield_1!(
110            JSJitInfo_OpType::Getter as u8,
111            JSJitInfo_AliasSet::AliasEverything as u8,
112            JSValueType::JSVAL_TYPE_UNKNOWN as u8,
113            false,
114            false,
115            false,
116            false,
117            false,
118            false,
119            0,
120        ).to_ne_bytes()
121    ),
122});
123}
124unsafe extern "C" fn get_ready<D: DomTypes>
125(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
126    let mut result = false;
127    wrap_panic(&mut || result = (|| {
128        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
129        let this = &*(this as *const D::WritableStreamDefaultWriter);
130        let result: Rc<D::Promise> = this.Ready();
131
132        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
133        return true;
134    })());
135    result
136}
137
138unsafe extern "C" fn get_ready_promise_wrapper<D: DomTypes>
139(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
140    let mut result = false;
141    wrap_panic(&mut || result = (|| {
142        let ok = get_ready::<D>(cx, _obj, this, args);
143        if ok {
144          return true;
145        }
146        return exception_to_promise(cx, args.rval(), CanGc::note());
147
148    })());
149    result
150}
151
152
153static ready_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
154
155pub(crate) fn init_ready_getterinfo<D: DomTypes>() {
156    ready_getterinfo.set(JSJitInfo {
157    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
158        getter: Some(get_ready_promise_wrapper::<D>)
159    },
160    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
161        protoID: PrototypeList::ID::WritableStreamDefaultWriter as u16,
162    },
163    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
164    _bitfield_align_1: [],
165    _bitfield_1: __BindgenBitfieldUnit::new(
166        new_jsjitinfo_bitfield_1!(
167            JSJitInfo_OpType::Getter as u8,
168            JSJitInfo_AliasSet::AliasEverything as u8,
169            JSValueType::JSVAL_TYPE_OBJECT as u8,
170            true,
171            false,
172            false,
173            false,
174            false,
175            false,
176            0,
177        ).to_ne_bytes()
178    ),
179});
180}
181unsafe extern "C" fn abort<D: DomTypes>
182(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
183    let mut result = false;
184    wrap_panic(&mut || result = (|| {
185        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
186        let this = &*(this as *const D::WritableStreamDefaultWriter);
187        let args = &*args;
188        let argc = args.argc_;
189        let arg0: HandleValue = if args.get(0).is_undefined() {
190            HandleValue::undefined()
191        } else {
192            HandleValue::from_raw(args.get(0))
193        };
194        let result: Rc<D::Promise> = this.Abort(SafeJSContext::from_ptr(cx.raw_cx()), arg0, InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()))), CanGc::note());
195
196        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
197        return true;
198    })());
199    result
200}
201
202unsafe extern "C" fn abort_promise_wrapper<D: DomTypes>
203(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
204    let mut result = false;
205    wrap_panic(&mut || result = (|| {
206        let ok = abort::<D>(cx, _obj, this, args);
207        if ok {
208          return true;
209        }
210        return exception_to_promise(cx, (*args).rval(), CanGc::note());
211
212    })());
213    result
214}
215
216
217static abort_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
218
219pub(crate) fn init_abort_methodinfo<D: DomTypes>() {
220    abort_methodinfo.set(JSJitInfo {
221    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
222        method: Some(abort_promise_wrapper::<D>)
223    },
224    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
225        protoID: PrototypeList::ID::WritableStreamDefaultWriter as u16,
226    },
227    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
228    _bitfield_align_1: [],
229    _bitfield_1: __BindgenBitfieldUnit::new(
230        new_jsjitinfo_bitfield_1!(
231            JSJitInfo_OpType::Method as u8,
232            JSJitInfo_AliasSet::AliasEverything as u8,
233            JSValueType::JSVAL_TYPE_OBJECT as u8,
234            false,
235            false,
236            false,
237            false,
238            false,
239            false,
240            0,
241        ).to_ne_bytes()
242    ),
243});
244}
245unsafe extern "C" fn close<D: DomTypes>
246(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
247    let mut result = false;
248    wrap_panic(&mut || result = (|| {
249        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
250        let this = &*(this as *const D::WritableStreamDefaultWriter);
251        let args = &*args;
252        let argc = args.argc_;
253        let result: Rc<D::Promise> = this.Close(InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()))), CanGc::note());
254
255        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
256        return true;
257    })());
258    result
259}
260
261unsafe extern "C" fn close_promise_wrapper<D: DomTypes>
262(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
263    let mut result = false;
264    wrap_panic(&mut || result = (|| {
265        let ok = close::<D>(cx, _obj, this, args);
266        if ok {
267          return true;
268        }
269        return exception_to_promise(cx, (*args).rval(), CanGc::note());
270
271    })());
272    result
273}
274
275
276static close_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
277
278pub(crate) fn init_close_methodinfo<D: DomTypes>() {
279    close_methodinfo.set(JSJitInfo {
280    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
281        method: Some(close_promise_wrapper::<D>)
282    },
283    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
284        protoID: PrototypeList::ID::WritableStreamDefaultWriter as u16,
285    },
286    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
287    _bitfield_align_1: [],
288    _bitfield_1: __BindgenBitfieldUnit::new(
289        new_jsjitinfo_bitfield_1!(
290            JSJitInfo_OpType::Method as u8,
291            JSJitInfo_AliasSet::AliasEverything as u8,
292            JSValueType::JSVAL_TYPE_OBJECT as u8,
293            true,
294            false,
295            false,
296            false,
297            false,
298            false,
299            0,
300        ).to_ne_bytes()
301    ),
302});
303}
304unsafe extern "C" fn releaseLock<D: DomTypes>
305(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
306    let mut result = false;
307    wrap_panic(&mut || result = (|| {
308        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
309        let this = &*(this as *const D::WritableStreamDefaultWriter);
310        let args = &*args;
311        let argc = args.argc_;
312        let result: () = this.ReleaseLock(CanGc::note());
313
314        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
315        return true;
316    })());
317    result
318}
319
320
321static releaseLock_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
322
323pub(crate) fn init_releaseLock_methodinfo<D: DomTypes>() {
324    releaseLock_methodinfo.set(JSJitInfo {
325    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
326        method: Some(releaseLock::<D>)
327    },
328    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
329        protoID: PrototypeList::ID::WritableStreamDefaultWriter as u16,
330    },
331    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
332    _bitfield_align_1: [],
333    _bitfield_1: __BindgenBitfieldUnit::new(
334        new_jsjitinfo_bitfield_1!(
335            JSJitInfo_OpType::Method as u8,
336            JSJitInfo_AliasSet::AliasEverything as u8,
337            JSValueType::JSVAL_TYPE_UNDEFINED as u8,
338            true,
339            false,
340            false,
341            false,
342            false,
343            false,
344            0,
345        ).to_ne_bytes()
346    ),
347});
348}
349unsafe extern "C" fn write<D: DomTypes>
350(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
351    let mut result = false;
352    wrap_panic(&mut || result = (|| {
353        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
354        let this = &*(this as *const D::WritableStreamDefaultWriter);
355        let args = &*args;
356        let argc = args.argc_;
357        let arg0: HandleValue = if args.get(0).is_undefined() {
358            HandleValue::undefined()
359        } else {
360            HandleValue::from_raw(args.get(0))
361        };
362        let result: Rc<D::Promise> = this.Write(SafeJSContext::from_ptr(cx.raw_cx()), arg0, InRealm::already(&AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx.raw_cx()))), CanGc::note());
363
364        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
365        return true;
366    })());
367    result
368}
369
370unsafe extern "C" fn write_promise_wrapper<D: DomTypes>
371(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
372    let mut result = false;
373    wrap_panic(&mut || result = (|| {
374        let ok = write::<D>(cx, _obj, this, args);
375        if ok {
376          return true;
377        }
378        return exception_to_promise(cx, (*args).rval(), CanGc::note());
379
380    })());
381    result
382}
383
384
385static write_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
386
387pub(crate) fn init_write_methodinfo<D: DomTypes>() {
388    write_methodinfo.set(JSJitInfo {
389    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
390        method: Some(write_promise_wrapper::<D>)
391    },
392    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
393        protoID: PrototypeList::ID::WritableStreamDefaultWriter as u16,
394    },
395    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
396    _bitfield_align_1: [],
397    _bitfield_1: __BindgenBitfieldUnit::new(
398        new_jsjitinfo_bitfield_1!(
399            JSJitInfo_OpType::Method as u8,
400            JSJitInfo_AliasSet::AliasEverything as u8,
401            JSValueType::JSVAL_TYPE_OBJECT as u8,
402            false,
403            false,
404            false,
405            false,
406            false,
407            false,
408            0,
409        ).to_ne_bytes()
410    ),
411});
412}
413unsafe extern "C" fn _finalize<D: DomTypes>
414(_cx: *mut GCContext, obj: *mut JSObject){
415    wrap_panic(&mut || {
416
417        let this = native_from_object_static::<D::WritableStreamDefaultWriter>(obj).unwrap();
418        finalize_common(this);
419    })
420}
421
422unsafe extern "C" fn _trace<D: DomTypes>
423(trc: *mut JSTracer, obj: *mut JSObject){
424    wrap_panic(&mut || {
425
426        let this = native_from_object_static::<D::WritableStreamDefaultWriter>(obj).unwrap();
427        if this.is_null() { return; } // GC during obj creation
428        (*this).trace(trc);
429    })
430}
431
432
433static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
434
435pub(crate) fn init_class_ops<D: DomTypes>() {
436    CLASS_OPS.set(JSClassOps {
437        addProperty: None,
438        delProperty: None,
439        enumerate: None,
440        newEnumerate: None,
441        resolve: None,
442        mayResolve: None,
443        finalize: Some(_finalize::<D>),
444        call: None,
445        construct: None,
446        trace: Some(_trace::<D>),
447    });
448}
449
450pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
451
452pub(crate) fn init_domjs_class<D: DomTypes>() {
453    init_class_ops::<D>();
454    Class.set(DOMJSClass {
455        base: JSClass {
456            name: c"WritableStreamDefaultWriter".as_ptr(),
457            flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
458                   (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
459                   /* JSCLASS_HAS_RESERVED_SLOTS(1) */,
460            cOps: unsafe { CLASS_OPS.get() },
461            spec: ptr::null(),
462            ext: ptr::null(),
463            oOps: ptr::null(),
464        },
465        dom_class:
466DOMClass {
467    interface_chain: [ PrototypeList::ID::WritableStreamDefaultWriter, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
468    depth: 0,
469    type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
470    malloc_size_of: malloc_size_of_including_raw_self::<D::WritableStreamDefaultWriter> as unsafe fn(&mut _, _) -> _,
471    global: Globals::EMPTY,
472},
473    });
474}
475
476#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
477(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::WritableStreamDefaultWriter>, _can_gc: CanGc) -> DomRoot<D::WritableStreamDefaultWriter>{
478
479    let raw = Root::new(MaybeUnreflectedDom::from_box(object));
480
481    let scope = scope.reflector().get_jsobject();
482    assert!(!scope.get().is_null());
483    assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
484    let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
485
486    rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
487    GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
488    assert!(!canonical_proto.is_null());
489
490
491    rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
492    if let Some(given) = given_proto {
493        proto.set(*given);
494        if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
495            assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
496        }
497    } else {
498        proto.set(*canonical_proto);
499    }
500    rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
501        cx.raw_cx(),
502        &Class.get().base,
503        proto.handle(),
504    ));
505    assert!(!obj.is_null());
506    JS_SetReservedSlot(
507        obj.get(),
508        DOM_OBJECT_SLOT,
509        &PrivateValue(raw.as_ptr() as *const libc::c_void),
510    );
511
512    let root = raw.reflect_with(obj.get());
513
514
515
516    DomRoot::from_ref(&*root)
517}
518
519pub trait WritableStreamDefaultWriterMethods<D: DomTypes> {
520    fn Closed(&self, ) -> Rc<D::Promise>;
521    fn GetDesiredSize(&self, ) -> Fallible<Option<f64>>;
522    fn Ready(&self, ) -> Rc<D::Promise>;
523    fn Abort(&self, r#cx: SafeJSContext, r#reason: HandleValue, r#_comp: InRealm, r#_can_gc: CanGc) -> Rc<D::Promise>;
524    fn Close(&self, r#_comp: InRealm, r#_can_gc: CanGc) -> Rc<D::Promise>;
525    fn ReleaseLock(&self, r#_can_gc: CanGc);
526    fn Write(&self, r#cx: SafeJSContext, r#chunk: HandleValue, r#_comp: InRealm, r#_can_gc: CanGc) -> Rc<D::Promise>;
527    fn Constructor(r#global: &D::GlobalScope, r#proto: Option<HandleObject>, r#can_gc: CanGc, r#stream: &D::WritableStream) -> Fallible<DomRoot<D::WritableStreamDefaultWriter>>;
528}
529static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
530
531pub(crate) fn init_sMethods_specs<D: DomTypes>() {
532    sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
533    JSFunctionSpec {
534        name: JSPropertySpec_Name { string_: c"abort".as_ptr() },
535        call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { abort_methodinfo.get() } as *const _ as *const JSJitInfo },
536        nargs: 0,
537        flags: (JSPROP_ENUMERATE) as u16,
538        selfHostedName: ptr::null()
539    },
540    JSFunctionSpec {
541        name: JSPropertySpec_Name { string_: c"close".as_ptr() },
542        call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { close_methodinfo.get() } as *const _ as *const JSJitInfo },
543        nargs: 0,
544        flags: (JSPROP_ENUMERATE) as u16,
545        selfHostedName: ptr::null()
546    },
547    JSFunctionSpec {
548        name: JSPropertySpec_Name { string_: c"releaseLock".as_ptr() },
549        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { releaseLock_methodinfo.get() } as *const _ as *const JSJitInfo },
550        nargs: 0,
551        flags: (JSPROP_ENUMERATE) as u16,
552        selfHostedName: ptr::null()
553    },
554    JSFunctionSpec {
555        name: JSPropertySpec_Name { string_: c"write".as_ptr() },
556        call: JSNativeWrapper { op: Some(generic_method::<true>), info: unsafe { write_methodinfo.get() } as *const _ as *const JSJitInfo },
557        nargs: 0,
558        flags: (JSPROP_ENUMERATE) as u16,
559        selfHostedName: ptr::null()
560    },
561    JSFunctionSpec {
562        name: JSPropertySpec_Name { string_: ptr::null() },
563        call: JSNativeWrapper { op: None, info: ptr::null() },
564        nargs: 0,
565        flags: 0,
566        selfHostedName: ptr::null()
567    }]))[..]
568])));
569}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
570
571pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
572    sMethods.set(Box::leak(Box::new([    Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::PAINT_WORKLET_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEBUGGER_GLOBAL_SCOPE),Condition::Exposed(Globals::DISSIMILAR_ORIGIN_WINDOW),Condition::Exposed(Globals::TEST_WORKLET_GLOBAL_SCOPE)], (unsafe { sMethods_specs.get() })[0])])));
573}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
574
575pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
576    sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
577    JSPropertySpec {
578                    name: JSPropertySpec_Name { string_: c"closed".as_ptr() },
579                    attributes_: (JSPROP_ENUMERATE),
580                    kind_: (JSPropertySpec_Kind::NativeAccessor),
581                    u: JSPropertySpec_AccessorsOrValue {
582                        accessors: JSPropertySpec_AccessorsOrValue_Accessors {
583                            getter: JSPropertySpec_Accessor {
584                                native: JSNativeWrapper { op: Some(generic_getter::<true>), info: unsafe { closed_getterinfo.get() } },
585                            },
586                            setter: JSPropertySpec_Accessor {
587                                native: JSNativeWrapper { op: None, info: ptr::null() },
588                            }
589                        }
590                    }
591                }
592,
593    JSPropertySpec {
594                    name: JSPropertySpec_Name { string_: c"desiredSize".as_ptr() },
595                    attributes_: (JSPROP_ENUMERATE),
596                    kind_: (JSPropertySpec_Kind::NativeAccessor),
597                    u: JSPropertySpec_AccessorsOrValue {
598                        accessors: JSPropertySpec_AccessorsOrValue_Accessors {
599                            getter: JSPropertySpec_Accessor {
600                                native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { desiredSize_getterinfo.get() } },
601                            },
602                            setter: JSPropertySpec_Accessor {
603                                native: JSNativeWrapper { op: None, info: ptr::null() },
604                            }
605                        }
606                    }
607                }
608,
609    JSPropertySpec {
610                    name: JSPropertySpec_Name { string_: c"ready".as_ptr() },
611                    attributes_: (JSPROP_ENUMERATE),
612                    kind_: (JSPropertySpec_Kind::NativeAccessor),
613                    u: JSPropertySpec_AccessorsOrValue {
614                        accessors: JSPropertySpec_AccessorsOrValue_Accessors {
615                            getter: JSPropertySpec_Accessor {
616                                native: JSNativeWrapper { op: Some(generic_getter::<true>), info: unsafe { ready_getterinfo.get() } },
617                            },
618                            setter: JSPropertySpec_Accessor {
619                                native: JSNativeWrapper { op: None, info: ptr::null() },
620                            }
621                        }
622                    }
623                }
624,
625    JSPropertySpec::ZERO]))[..]
626,
627&Box::leak(Box::new([
628    JSPropertySpec {
629                    name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
630                    attributes_: (JSPROP_READONLY),
631                    kind_: (JSPropertySpec_Kind::Value),
632                    u: JSPropertySpec_AccessorsOrValue {
633                        value: JSPropertySpec_ValueWrapper {
634                            type_: JSPropertySpec_ValueWrapper_Type::String,
635                            __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
636                                string: c"WritableStreamDefaultWriter".as_ptr(),
637                            }
638                        }
639                    }
640                }
641,
642    JSPropertySpec::ZERO]))[..]
643])));
644}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
645
646pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
647    sAttributes.set(Box::leak(Box::new([    Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::PAINT_WORKLET_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEBUGGER_GLOBAL_SCOPE),Condition::Exposed(Globals::DISSIMILAR_ORIGIN_WINDOW),Condition::Exposed(Globals::TEST_WORKLET_GLOBAL_SCOPE)], (unsafe { sAttributes_specs.get() })[0]),
648    Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
649}
650pub fn GetProtoObject<D: DomTypes>
651(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
652    /* Get the interface prototype object for this class.  This will create the
653       object as needed. */get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::WritableStreamDefaultWriter), CreateInterfaceObjects::<D>, rval)
654}
655
656
657static PrototypeClass: JSClass = JSClass {
658    name: c"WritableStreamDefaultWriterPrototype".as_ptr(),
659    flags:
660        // JSCLASS_HAS_RESERVED_SLOTS()
661        (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
662    cOps: ptr::null(),
663    spec: ptr::null(),
664    ext: ptr::null(),
665    oOps: ptr::null(),
666};
667
668unsafe extern "C" fn _constructor<D: DomTypes>
669(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
670    let mut result = false;
671    wrap_panic(&mut || result = {
672        let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
673        let args = CallArgs::from_vp(vp, argc);
674        let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
675
676                    call_default_constructor::<D>(
677                        SafeJSContext::from_ptr(cx.raw_cx()),
678                        &args,
679                        &global,
680                        PrototypeList::ID::WritableStreamDefaultWriter,
681                        "WritableStreamDefaultWriter",
682                        CreateInterfaceObjects::<D>,
683                        |cx: SafeJSContext, args: &CallArgs, global: &D::GlobalScope, desired_proto: HandleObject| {
684
685        if argc < 1 {
686            throw_type_error(cx.raw_cx(), "Not enough arguments to \"WritableStreamDefaultWriter.constructor\".");
687            return false;
688        }
689        let arg0: DomRoot<D::WritableStream> = if HandleValue::from_raw(args.get(0)).get().is_object() {
690            match root_from_handlevalue(HandleValue::from_raw(args.get(0)), SafeJSContext::from_ptr(cx.raw_cx())) {
691                Ok(val) => val,
692                Err(()) => {
693                    throw_type_error(cx.raw_cx(), "value does not implement interface WritableStream.");
694                    return false;
695
696                }
697            }
698
699        } else {
700            throw_type_error(cx.raw_cx(), "Value is not an object.");
701            return false;
702
703        };
704        let result: Result<DomRoot<D::WritableStreamDefaultWriter>, Error> = <D::WritableStreamDefaultWriter>::Constructor(global, Some(desired_proto), CanGc::note(), &arg0);
705        let result = match result {
706            Ok(result) => result,
707            Err(e) => {
708                <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), global.upcast::<D::GlobalScope>(), e, CanGc::note());
709                return false;
710            },
711        };
712
713        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
714        return true;
715                        }
716                    )
717
718    });
719    result
720}
721
722
723static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
724
725pub(crate) fn init_interface_object<D: DomTypes>() {
726    INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
727        Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
728        b"function WritableStreamDefaultWriter() {\n    [native code]\n}",
729        PrototypeList::ID::WritableStreamDefaultWriter,
730        0,
731    ));
732}
733
734pub fn DefineDOMInterface<D: DomTypes>
735(cx: SafeJSContext, global: HandleObject){
736    define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::WritableStreamDefaultWriter),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
737}
738
739pub fn ConstructorEnabled<D: DomTypes>
740(aCx: SafeJSContext, aObj: HandleObject) -> bool{
741    is_exposed_in(aObj, Globals::DEBUGGER_GLOBAL_SCOPE | Globals::DEDICATED_WORKER_GLOBAL_SCOPE | Globals::DISSIMILAR_ORIGIN_WINDOW | Globals::PAINT_WORKLET_GLOBAL_SCOPE | Globals::SERVICE_WORKER_GLOBAL_SCOPE | Globals::TEST_WORKLET_GLOBAL_SCOPE | Globals::WINDOW)
742}
743
744unsafe fn CreateInterfaceObjects<D: DomTypes>
745(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
746
747    rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
748    prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
749    assert!(!prototype_proto.is_null());
750
751    rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
752    create_interface_prototype_object::<D>(cx,
753                                      global,
754                                      prototype_proto.handle(),
755                                      &PrototypeClass,
756                                      sMethods.get(),
757                                      sAttributes.get(),
758                                      &[],
759                                      &[],
760                                      prototype.handle_mut());
761    assert!(!prototype.is_null());
762    assert!((*cache)[PrototypeList::ID::WritableStreamDefaultWriter as usize].is_null());
763    (*cache)[PrototypeList::ID::WritableStreamDefaultWriter as usize] = prototype.get();
764    <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::WritableStreamDefaultWriter as isize),
765                                  ptr::null_mut(),
766                                  prototype.get());
767
768    rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
769    interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
770
771    assert!(!interface_proto.is_null());
772
773    rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
774    create_noncallback_interface_object::<D>(cx,
775                                        global,
776                                        interface_proto.handle(),
777                                        INTERFACE_OBJECT_CLASS.get(),
778                                        &[],
779                                        &[],
780                                        &[],
781                                        prototype.handle(),
782                                        c"WritableStreamDefaultWriter",
783                                        1,
784                                        &[],
785                                        interface.handle_mut());
786    assert!(!interface.is_null());
787}
788
789
790        pub(crate) fn init_statics<D: DomTypes>() {
791            init_interface_object::<D>();
792            init_domjs_class::<D>();
793            crate::codegen::GenericBindings::WritableStreamDefaultWriterBinding::WritableStreamDefaultWriter_Binding::init_abort_methodinfo::<D>();
794crate::codegen::GenericBindings::WritableStreamDefaultWriterBinding::WritableStreamDefaultWriter_Binding::init_close_methodinfo::<D>();
795crate::codegen::GenericBindings::WritableStreamDefaultWriterBinding::WritableStreamDefaultWriter_Binding::init_releaseLock_methodinfo::<D>();
796crate::codegen::GenericBindings::WritableStreamDefaultWriterBinding::WritableStreamDefaultWriter_Binding::init_write_methodinfo::<D>();
797            init_closed_getterinfo::<D>();
798init_desiredSize_getterinfo::<D>();
799init_ready_getterinfo::<D>();
800
801
802            init_sMethods_specs::<D>();
803init_sMethods_prefs::<D>();
804init_sAttributes_specs::<D>();
805init_sAttributes_prefs::<D>();
806        }
807        } // mod WritableStreamDefaultWriter_Binding
808
809