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::AudioNodeBinding::AudioNode_Binding;
6use crate::codegen::GenericBindings::AudioNodeBinding::ChannelCountMode;
7use crate::codegen::GenericBindings::AudioNodeBinding::ChannelCountModeValues;
8use crate::codegen::GenericBindings::AudioNodeBinding::ChannelInterpretation;
9use crate::codegen::GenericBindings::AudioNodeBinding::ChannelInterpretationValues;
10use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
11use crate::import::base::*;
12
13#[derive(JSTraceable)]
14pub struct ChannelSplitterOptions {
15 pub parent: crate::codegen::GenericBindings::AudioNodeBinding::AudioNodeOptions,
16 pub numberOfOutputs: u32,
17}
18impl Default for ChannelSplitterOptions {
19 fn default() -> Self {
20 Self::empty()
21 }
22}
23
24impl ChannelSplitterOptions {
25 pub fn empty() -> Self {
26 Self {
27 parent: crate::codegen::GenericBindings::AudioNodeBinding::AudioNodeOptions::empty(),
28 numberOfOutputs: 6,
29 }
30 }
31 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
32 -> Result<ConversionResult<ChannelSplitterOptions>, ()> {
33 unsafe {
34 let object = if val.get().is_null_or_undefined() {
35 ptr::null_mut()
36 } else if val.get().is_object() {
37 val.get().to_object()
38 } else {
39 return Ok(ConversionResult::Failure("Value is not an object.".into()));
40 };
41 rooted!(&in(cx) let object = object);
42 let dictionary = ChannelSplitterOptions {
43 parent: {
44 match crate::codegen::GenericBindings::AudioNodeBinding::AudioNodeOptions::new(cx, val, can_gc)? {
45 ConversionResult::Success(v) => v,
46 ConversionResult::Failure(error) => {
47 throw_type_error(cx.raw_cx(), &error);
48 return Err(());
49 }
50 }
51 },
52 numberOfOutputs: {
53 rooted!(&in(cx) let mut rval = UndefinedValue());
54 if get_dictionary_property(cx.raw_cx(), object.handle(), "numberOfOutputs", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
55 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ConversionBehavior::Default) {
56 Ok(ConversionResult::Success(value)) => value,
57 Ok(ConversionResult::Failure(error)) => {
58 throw_type_error(cx.raw_cx(), &error);
59 return Err(());
60
61 }
62 _ => {
63 return Err(());
64
65 },
66 }
67
68 } else {
69 6
70 }
71 },
72 };
73 Ok(ConversionResult::Success(dictionary))
74 }
75 }
76}
77
78impl FromJSValConvertible for ChannelSplitterOptions {
79 type Config = ();
80 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
81 -> Result<ConversionResult<ChannelSplitterOptions>, ()> {
82 ChannelSplitterOptions::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
83 }
84}
85
86impl ChannelSplitterOptions {
87 #[allow(clippy::wrong_self_convention)]
88 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
89 self.parent.to_jsobject(cx, obj.reborrow());
90 let numberOfOutputs = &self.numberOfOutputs;
91 rooted!(in(cx) let mut numberOfOutputs_js = UndefinedValue());
92 numberOfOutputs.to_jsval(cx, numberOfOutputs_js.handle_mut());
93 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "numberOfOutputs", numberOfOutputs_js.handle()).unwrap();
94 }
95}
96
97impl ToJSValConvertible for ChannelSplitterOptions {
98 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
99 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
100 self.to_jsobject(cx, obj.handle_mut());
101 rval.set(ObjectOrNullValue(obj.get()))
102 }
103}
104
105
106pub use self::ChannelSplitterNode_Binding::{Wrap, ChannelSplitterNodeMethods, GetProtoObject, DefineDOMInterface};
107pub mod ChannelSplitterNode_Binding {
108use crate::codegen::GenericBindings::AudioNodeBinding::AudioNode_Binding;
109use crate::codegen::GenericBindings::AudioNodeBinding::ChannelCountMode;
110use crate::codegen::GenericBindings::AudioNodeBinding::ChannelCountModeValues;
111use crate::codegen::GenericBindings::AudioNodeBinding::ChannelInterpretation;
112use crate::codegen::GenericBindings::AudioNodeBinding::ChannelInterpretationValues;
113use crate::codegen::GenericBindings::ChannelSplitterNodeBinding::ChannelSplitterOptions;
114use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
115use crate::import::module::*;
116
117unsafe extern "C" fn _finalize<D: DomTypes>
118(_cx: *mut GCContext, obj: *mut JSObject){
119 wrap_panic(&mut || {
120
121 let this = native_from_object_static::<D::ChannelSplitterNode>(obj).unwrap();
122 finalize_common(this);
123 })
124}
125
126unsafe extern "C" fn _trace<D: DomTypes>
127(trc: *mut JSTracer, obj: *mut JSObject){
128 wrap_panic(&mut || {
129
130 let this = native_from_object_static::<D::ChannelSplitterNode>(obj).unwrap();
131 if this.is_null() { return; } (*this).trace(trc);
133 })
134}
135
136
137static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
138
139pub(crate) fn init_class_ops<D: DomTypes>() {
140 CLASS_OPS.set(JSClassOps {
141 addProperty: None,
142 delProperty: None,
143 enumerate: None,
144 newEnumerate: None,
145 resolve: None,
146 mayResolve: None,
147 finalize: Some(_finalize::<D>),
148 call: None,
149 construct: None,
150 trace: Some(_trace::<D>),
151 });
152}
153
154pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
155
156pub(crate) fn init_domjs_class<D: DomTypes>() {
157 init_class_ops::<D>();
158 Class.set(DOMJSClass {
159 base: JSClass {
160 name: c"ChannelSplitterNode".as_ptr(),
161 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
162 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
163 ,
164 cOps: unsafe { CLASS_OPS.get() },
165 spec: ptr::null(),
166 ext: ptr::null(),
167 oOps: ptr::null(),
168 },
169 dom_class:
170DOMClass {
171 interface_chain: [ PrototypeList::ID::EventTarget, PrototypeList::ID::AudioNode, PrototypeList::ID::ChannelSplitterNode, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
172 depth: 2,
173 type_id: crate::codegen::InheritTypes::TopTypeId { eventtarget: (crate::codegen::InheritTypes::EventTargetTypeId::AudioNode(crate::codegen::InheritTypes::AudioNodeTypeId::ChannelSplitterNode)) },
174 malloc_size_of: malloc_size_of_including_raw_self::<D::ChannelSplitterNode> as unsafe fn(&mut _, _) -> _,
175 global: Globals::EMPTY,
176},
177 });
178}
179
180#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
181(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::ChannelSplitterNode>, _can_gc: CanGc) -> DomRoot<D::ChannelSplitterNode>{
182
183 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
184
185 let scope = scope.reflector().get_jsobject();
186 assert!(!scope.get().is_null());
187 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
188 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
189
190 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
191 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
192 assert!(!canonical_proto.is_null());
193
194
195 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
196 if let Some(given) = given_proto {
197 proto.set(*given);
198 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
199 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
200 }
201 } else {
202 proto.set(*canonical_proto);
203 }
204 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
205 cx.raw_cx(),
206 &Class.get().base,
207 proto.handle(),
208 ));
209 assert!(!obj.is_null());
210 JS_SetReservedSlot(
211 obj.get(),
212 DOM_OBJECT_SLOT,
213 &PrivateValue(raw.as_ptr() as *const libc::c_void),
214 );
215
216 let root = raw.reflect_with(obj.get());
217
218
219
220 DomRoot::from_ref(&*root)
221}
222
223pub trait ChannelSplitterNodeMethods<D: DomTypes> {
224 fn Constructor(r#global: &D::Window, r#proto: Option<HandleObject>, r#can_gc: CanGc, r#context: &D::BaseAudioContext, r#options: &crate::codegen::GenericBindings::ChannelSplitterNodeBinding::ChannelSplitterOptions) -> Fallible<DomRoot<D::ChannelSplitterNode>>;
225}
226static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
227
228pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
229 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
230 JSPropertySpec {
231 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
232 attributes_: (JSPROP_READONLY),
233 kind_: (JSPropertySpec_Kind::Value),
234 u: JSPropertySpec_AccessorsOrValue {
235 value: JSPropertySpec_ValueWrapper {
236 type_: JSPropertySpec_ValueWrapper_Type::String,
237 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
238 string: c"ChannelSplitterNode".as_ptr(),
239 }
240 }
241 }
242 }
243,
244 JSPropertySpec::ZERO]))[..]
245])));
246}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
247
248pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
249 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[0])])));
250}
251pub fn GetProtoObject<D: DomTypes>
252(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
253 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::ChannelSplitterNode), CreateInterfaceObjects::<D>, rval)
255}
256
257
258static PrototypeClass: JSClass = JSClass {
259 name: c"ChannelSplitterNodePrototype".as_ptr(),
260 flags:
261 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
263 cOps: ptr::null(),
264 spec: ptr::null(),
265 ext: ptr::null(),
266 oOps: ptr::null(),
267};
268
269unsafe extern "C" fn _constructor<D: DomTypes>
270(cx: *mut RawJSContext, argc: u32, vp: *mut JSVal) -> bool{
271 let mut result = false;
272 wrap_panic(&mut || result = {
273 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
274 let args = CallArgs::from_vp(vp, argc);
275 let global = D::GlobalScope::from_object(JS_CALLEE(cx.raw_cx(), vp).to_object());
276
277 call_default_constructor::<D>(
278 SafeJSContext::from_ptr(cx.raw_cx()),
279 &args,
280 &global,
281 PrototypeList::ID::ChannelSplitterNode,
282 "ChannelSplitterNode",
283 CreateInterfaceObjects::<D>,
284 |cx: SafeJSContext, args: &CallArgs, global: &D::GlobalScope, desired_proto: HandleObject| {
285
286 if argc < 1 {
287 throw_type_error(cx.raw_cx(), "Not enough arguments to \"ChannelSplitterNode.constructor\".");
288 return false;
289 }
290 let arg0: DomRoot<D::BaseAudioContext> = if HandleValue::from_raw(args.get(0)).get().is_object() {
291 match root_from_handlevalue(HandleValue::from_raw(args.get(0)), SafeJSContext::from_ptr(cx.raw_cx())) {
292 Ok(val) => val,
293 Err(()) => {
294 throw_type_error(cx.raw_cx(), "value does not implement interface BaseAudioContext.");
295 return false;
296
297 }
298 }
299
300 } else {
301 throw_type_error(cx.raw_cx(), "Value is not an object.");
302 return false;
303
304 };
305 let arg1: crate::codegen::GenericBindings::ChannelSplitterNodeBinding::ChannelSplitterOptions = if args.get(1).is_undefined() {
306 crate::codegen::GenericBindings::ChannelSplitterNodeBinding::ChannelSplitterOptions::empty()
307 } else {
308 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
309 Ok(ConversionResult::Success(value)) => value,
310 Ok(ConversionResult::Failure(error)) => {
311 throw_type_error(cx.raw_cx(), &error);
312 return false;
313
314 }
315 _ => {
316 return false;
317
318 },
319 }
320
321 };
322 let result: Result<DomRoot<D::ChannelSplitterNode>, Error> = <D::ChannelSplitterNode>::Constructor(global.downcast::<D::Window>().unwrap(), Some(desired_proto), CanGc::note(), &arg0, &arg1);
323 let result = match result {
324 Ok(result) => result,
325 Err(e) => {
326 <D as DomHelpers<D>>::throw_dom_exception(SafeJSContext::from_ptr(cx.raw_cx()), global.upcast::<D::GlobalScope>(), e, CanGc::note());
327 return false;
328 },
329 };
330
331 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
332 return true;
333 }
334 )
335
336 });
337 result
338}
339
340
341static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
342
343pub(crate) fn init_interface_object<D: DomTypes>() {
344 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
345 Box::leak(Box::new(InterfaceConstructorBehavior::call(_constructor::<D>))),
346 b"function ChannelSplitterNode() {\n [native code]\n}",
347 PrototypeList::ID::ChannelSplitterNode,
348 2,
349 ));
350}
351
352pub fn DefineDOMInterface<D: DomTypes>
353(cx: SafeJSContext, global: HandleObject){
354 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::ChannelSplitterNode),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
355}
356
357pub fn ConstructorEnabled<D: DomTypes>
358(aCx: SafeJSContext, aObj: HandleObject) -> bool{
359 is_exposed_in(aObj, Globals::WINDOW)
360}
361
362unsafe fn CreateInterfaceObjects<D: DomTypes>
363(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
364
365 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
366 AudioNode_Binding::GetProtoObject::<D>(cx, global, prototype_proto.handle_mut());
367 assert!(!prototype_proto.is_null());
368
369 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
370 create_interface_prototype_object::<D>(cx,
371 global,
372 prototype_proto.handle(),
373 &PrototypeClass,
374 &[],
375 sAttributes.get(),
376 &[],
377 &[],
378 prototype.handle_mut());
379 assert!(!prototype.is_null());
380 assert!((*cache)[PrototypeList::ID::ChannelSplitterNode as usize].is_null());
381 (*cache)[PrototypeList::ID::ChannelSplitterNode as usize] = prototype.get();
382 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::ChannelSplitterNode as isize),
383 ptr::null_mut(),
384 prototype.get());
385
386 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
387
388 AudioNode_Binding::GetConstructorObject::<D>(cx, global, interface_proto.handle_mut());
389
390 assert!(!interface_proto.is_null());
391
392 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
393 create_noncallback_interface_object::<D>(cx,
394 global,
395 interface_proto.handle(),
396 INTERFACE_OBJECT_CLASS.get(),
397 &[],
398 &[],
399 &[],
400 prototype.handle(),
401 c"ChannelSplitterNode",
402 1,
403 &[],
404 interface.handle_mut());
405 assert!(!interface.is_null());
406}
407
408
409 pub(crate) fn init_statics<D: DomTypes>() {
410 init_interface_object::<D>();
411 init_domjs_class::<D>();
412
413
414
415
416 init_sAttributes_specs::<D>();
417init_sAttributes_prefs::<D>();
418 }
419 }