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