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::IDBCursorBinding::IDBCursorDirection;
7use crate::codegen::GenericBindings::IDBCursorBinding::IDBCursorDirectionValues;
8use crate::import::base::*;
9
10#[derive(JSTraceable)]
11pub struct IDBIndexParameters {
12 pub multiEntry: bool,
13 pub unique: bool,
14}
15impl Default for IDBIndexParameters {
16 fn default() -> Self {
17 Self::empty()
18 }
19}
20
21impl IDBIndexParameters {
22 pub fn empty() -> Self {
23 Self {
24 multiEntry: false,
25 unique: false,
26 }
27 }
28 pub fn new(cx: SafeJSContext, val: HandleValue, can_gc: CanGc)
29 -> Result<ConversionResult<IDBIndexParameters>, ()> {
30 unsafe {
31 let object = if val.get().is_null_or_undefined() {
32 ptr::null_mut()
33 } else if val.get().is_object() {
34 val.get().to_object()
35 } else {
36 return Ok(ConversionResult::Failure("Value is not an object.".into()));
37 };
38 rooted!(&in(cx) let object = object);
39 let dictionary = IDBIndexParameters {
40 multiEntry: {
41 rooted!(&in(cx) let mut rval = UndefinedValue());
42 if get_dictionary_property(cx.raw_cx(), object.handle(), "multiEntry", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
43 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
44 Ok(ConversionResult::Success(value)) => value,
45 Ok(ConversionResult::Failure(error)) => {
46 throw_type_error(cx.raw_cx(), &error);
47 return Err(());
48
49 }
50 _ => {
51 return Err(());
52
53 },
54 }
55
56 } else {
57 false
58 }
59 },
60 unique: {
61 rooted!(&in(cx) let mut rval = UndefinedValue());
62 if get_dictionary_property(cx.raw_cx(), object.handle(), "unique", rval.handle_mut(), can_gc)? && !rval.is_undefined() {
63 match FromJSValConvertible::from_jsval(cx.raw_cx(), rval.handle(), ()) {
64 Ok(ConversionResult::Success(value)) => value,
65 Ok(ConversionResult::Failure(error)) => {
66 throw_type_error(cx.raw_cx(), &error);
67 return Err(());
68
69 }
70 _ => {
71 return Err(());
72
73 },
74 }
75
76 } else {
77 false
78 }
79 },
80 };
81 Ok(ConversionResult::Success(dictionary))
82 }
83 }
84}
85
86impl FromJSValConvertible for IDBIndexParameters {
87 type Config = ();
88 unsafe fn from_jsval(cx: *mut RawJSContext, value: HandleValue, _option: ())
89 -> Result<ConversionResult<IDBIndexParameters>, ()> {
90 IDBIndexParameters::new(SafeJSContext::from_ptr(cx), value, CanGc::note())
91 }
92}
93
94impl IDBIndexParameters {
95 #[allow(clippy::wrong_self_convention)]
96 pub unsafe fn to_jsobject(&self, cx: *mut RawJSContext, mut obj: MutableHandleObject) {
97 let multiEntry = &self.multiEntry;
98 rooted!(in(cx) let mut multiEntry_js = UndefinedValue());
99 multiEntry.to_jsval(cx, multiEntry_js.handle_mut());
100 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "multiEntry", multiEntry_js.handle()).unwrap();
101 let unique = &self.unique;
102 rooted!(in(cx) let mut unique_js = UndefinedValue());
103 unique.to_jsval(cx, unique_js.handle_mut());
104 set_dictionary_property(SafeJSContext::from_ptr(cx), obj.handle(), "unique", unique_js.handle()).unwrap();
105 }
106}
107
108impl ToJSValConvertible for IDBIndexParameters {
109 unsafe fn to_jsval(&self, cx: *mut RawJSContext, mut rval: MutableHandleValue) {
110 rooted!(in(cx) let mut obj = JS_NewObject(cx, ptr::null()));
111 self.to_jsobject(cx, obj.handle_mut());
112 rval.set(ObjectOrNullValue(obj.get()))
113 }
114}
115
116
117pub use self::IDBObjectStore_Binding::{Wrap, IDBObjectStoreMethods, GetProtoObject, DefineDOMInterface};
118pub mod IDBObjectStore_Binding {
119use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
120use crate::codegen::GenericBindings::IDBCursorBinding::IDBCursorDirection;
121use crate::codegen::GenericBindings::IDBCursorBinding::IDBCursorDirectionValues;
122use crate::import::module::*;
123
124unsafe extern "C" fn get_name<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::IDBObjectStore);
130 let result: DOMString = this.Name();
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 set_name<D: DomTypes>
139(cx: *mut RawJSContext, obj: RawHandleObject, this: *mut libc::c_void, args: JSJitSetterCallArgs) -> bool{
140 let mut result = false;
141 wrap_panic(&mut || result = (|| {
142 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
143 let this = &*(this as *const D::IDBObjectStore);
144 let arg0: DOMString = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), StringificationBehavior::Default) {
145 Ok(ConversionResult::Success(value)) => value,
146 Ok(ConversionResult::Failure(error)) => {
147 throw_type_error(cx.raw_cx(), &error);
148 return false;
149
150 }
151 _ => {
152 return false;
153
154 },
155 }
156 ;
157 let result: Result<(), Error> = this.SetName(arg0);
158 let result = match result {
159 Ok(result) => result,
160 Err(e) => {
161 <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());
162 return false;
163 },
164 };
165
166 true
167 })());
168 result
169}
170
171
172static name_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
173
174pub(crate) fn init_name_getterinfo<D: DomTypes>() {
175 name_getterinfo.set(JSJitInfo {
176 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
177 getter: Some(get_name::<D>)
178 },
179 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
180 protoID: PrototypeList::ID::IDBObjectStore as u16,
181 },
182 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
183 _bitfield_align_1: [],
184 _bitfield_1: __BindgenBitfieldUnit::new(
185 new_jsjitinfo_bitfield_1!(
186 JSJitInfo_OpType::Getter as u8,
187 JSJitInfo_AliasSet::AliasEverything as u8,
188 JSValueType::JSVAL_TYPE_STRING as u8,
189 true,
190 false,
191 false,
192 false,
193 false,
194 false,
195 0,
196 ).to_ne_bytes()
197 ),
198});
199}
200static name_setterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
201
202pub(crate) fn init_name_setterinfo<D: DomTypes>() {
203 name_setterinfo.set(JSJitInfo {
204 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
205 setter: Some(set_name::<D>)
206 },
207 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
208 protoID: PrototypeList::ID::IDBObjectStore as u16,
209 },
210 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
211 _bitfield_align_1: [],
212 _bitfield_1: __BindgenBitfieldUnit::new(
213 new_jsjitinfo_bitfield_1!(
214 JSJitInfo_OpType::Setter as u8,
215 JSJitInfo_AliasSet::AliasEverything as u8,
216 JSValueType::JSVAL_TYPE_UNDEFINED as u8,
217 false,
218 false,
219 false,
220 false,
221 false,
222 false,
223 0,
224 ).to_ne_bytes()
225 ),
226});
227}
228unsafe extern "C" fn get_keyPath<D: DomTypes>
229(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
230 let mut result = false;
231 wrap_panic(&mut || result = (|| {
232 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
233 let this = &*(this as *const D::IDBObjectStore);
234 rooted!(&in(cx) let mut retval: JSVal);
235 let result: () = this.KeyPath(SafeJSContext::from_ptr(cx.raw_cx()), retval.handle_mut());
236
237 (retval).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
238 return true;
239 })());
240 result
241}
242
243
244static keyPath_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
245
246pub(crate) fn init_keyPath_getterinfo<D: DomTypes>() {
247 keyPath_getterinfo.set(JSJitInfo {
248 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
249 getter: Some(get_keyPath::<D>)
250 },
251 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
252 protoID: PrototypeList::ID::IDBObjectStore as u16,
253 },
254 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
255 _bitfield_align_1: [],
256 _bitfield_1: __BindgenBitfieldUnit::new(
257 new_jsjitinfo_bitfield_1!(
258 JSJitInfo_OpType::Getter as u8,
259 JSJitInfo_AliasSet::AliasEverything as u8,
260 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
261 true,
262 false,
263 false,
264 false,
265 false,
266 false,
267 0,
268 ).to_ne_bytes()
269 ),
270});
271}
272unsafe extern "C" fn get_indexNames<D: DomTypes>
273(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
274 let mut result = false;
275 wrap_panic(&mut || result = (|| {
276 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
277 let this = &*(this as *const D::IDBObjectStore);
278 let result: DomRoot<D::DOMStringList> = this.IndexNames();
279
280 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
281 return true;
282 })());
283 result
284}
285
286
287static indexNames_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
288
289pub(crate) fn init_indexNames_getterinfo<D: DomTypes>() {
290 indexNames_getterinfo.set(JSJitInfo {
291 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
292 getter: Some(get_indexNames::<D>)
293 },
294 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
295 protoID: PrototypeList::ID::IDBObjectStore as u16,
296 },
297 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
298 _bitfield_align_1: [],
299 _bitfield_1: __BindgenBitfieldUnit::new(
300 new_jsjitinfo_bitfield_1!(
301 JSJitInfo_OpType::Getter as u8,
302 JSJitInfo_AliasSet::AliasEverything as u8,
303 JSValueType::JSVAL_TYPE_OBJECT as u8,
304 true,
305 false,
306 false,
307 false,
308 false,
309 false,
310 0,
311 ).to_ne_bytes()
312 ),
313});
314}
315unsafe extern "C" fn get_transaction<D: DomTypes>
316(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
317 let mut result = false;
318 wrap_panic(&mut || result = (|| {
319 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
320 let this = &*(this as *const D::IDBObjectStore);
321 let result: DomRoot<D::IDBTransaction> = this.Transaction();
322
323 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
324 return true;
325 })());
326 result
327}
328
329
330static transaction_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
331
332pub(crate) fn init_transaction_getterinfo<D: DomTypes>() {
333 transaction_getterinfo.set(JSJitInfo {
334 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
335 getter: Some(get_transaction::<D>)
336 },
337 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
338 protoID: PrototypeList::ID::IDBObjectStore as u16,
339 },
340 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
341 _bitfield_align_1: [],
342 _bitfield_1: __BindgenBitfieldUnit::new(
343 new_jsjitinfo_bitfield_1!(
344 JSJitInfo_OpType::Getter as u8,
345 JSJitInfo_AliasSet::AliasNone as u8,
346 JSValueType::JSVAL_TYPE_OBJECT as u8,
347 true,
348 true,
349 false,
350 false,
351 false,
352 false,
353 0,
354 ).to_ne_bytes()
355 ),
356});
357}
358unsafe extern "C" fn get_autoIncrement<D: DomTypes>
359(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
360 let mut result = false;
361 wrap_panic(&mut || result = (|| {
362 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
363 let this = &*(this as *const D::IDBObjectStore);
364 let result: bool = this.AutoIncrement();
365
366 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
367 return true;
368 })());
369 result
370}
371
372
373static autoIncrement_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
374
375pub(crate) fn init_autoIncrement_getterinfo<D: DomTypes>() {
376 autoIncrement_getterinfo.set(JSJitInfo {
377 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
378 getter: Some(get_autoIncrement::<D>)
379 },
380 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
381 protoID: PrototypeList::ID::IDBObjectStore as u16,
382 },
383 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
384 _bitfield_align_1: [],
385 _bitfield_1: __BindgenBitfieldUnit::new(
386 new_jsjitinfo_bitfield_1!(
387 JSJitInfo_OpType::Getter as u8,
388 JSJitInfo_AliasSet::AliasEverything as u8,
389 JSValueType::JSVAL_TYPE_BOOLEAN as u8,
390 true,
391 false,
392 false,
393 false,
394 false,
395 false,
396 0,
397 ).to_ne_bytes()
398 ),
399});
400}
401unsafe extern "C" fn put<D: DomTypes>
402(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
403 let mut result = false;
404 wrap_panic(&mut || result = (|| {
405 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
406 let this = &*(this as *const D::IDBObjectStore);
407 let args = &*args;
408 let argc = args.argc_;
409
410 if argc < 1 {
411 throw_type_error(cx.raw_cx(), "Not enough arguments to \"IDBObjectStore.put\".");
412 return false;
413 }
414 let arg0: HandleValue = HandleValue::from_raw(args.get(0));
415 let arg1: HandleValue = if args.get(1).is_undefined() {
416 HandleValue::undefined()
417 } else {
418 HandleValue::from_raw(args.get(1))
419 };
420 let result: Result<DomRoot<D::IDBRequest>, Error> = this.Put(SafeJSContext::from_ptr(cx.raw_cx()), arg0, arg1);
421 let result = match result {
422 Ok(result) => result,
423 Err(e) => {
424 <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());
425 return false;
426 },
427 };
428
429 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
430 return true;
431 })());
432 result
433}
434
435
436static put_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
437
438pub(crate) fn init_put_methodinfo<D: DomTypes>() {
439 put_methodinfo.set(JSJitInfo {
440 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
441 method: Some(put::<D>)
442 },
443 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
444 protoID: PrototypeList::ID::IDBObjectStore as u16,
445 },
446 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
447 _bitfield_align_1: [],
448 _bitfield_1: __BindgenBitfieldUnit::new(
449 new_jsjitinfo_bitfield_1!(
450 JSJitInfo_OpType::Method as u8,
451 JSJitInfo_AliasSet::AliasEverything as u8,
452 JSValueType::JSVAL_TYPE_OBJECT as u8,
453 false,
454 false,
455 false,
456 false,
457 false,
458 false,
459 0,
460 ).to_ne_bytes()
461 ),
462});
463}
464unsafe extern "C" fn add<D: DomTypes>
465(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
466 let mut result = false;
467 wrap_panic(&mut || result = (|| {
468 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
469 let this = &*(this as *const D::IDBObjectStore);
470 let args = &*args;
471 let argc = args.argc_;
472
473 if argc < 1 {
474 throw_type_error(cx.raw_cx(), "Not enough arguments to \"IDBObjectStore.add\".");
475 return false;
476 }
477 let arg0: HandleValue = HandleValue::from_raw(args.get(0));
478 let arg1: HandleValue = if args.get(1).is_undefined() {
479 HandleValue::undefined()
480 } else {
481 HandleValue::from_raw(args.get(1))
482 };
483 let result: Result<DomRoot<D::IDBRequest>, Error> = this.Add(SafeJSContext::from_ptr(cx.raw_cx()), arg0, arg1);
484 let result = match result {
485 Ok(result) => result,
486 Err(e) => {
487 <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());
488 return false;
489 },
490 };
491
492 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
493 return true;
494 })());
495 result
496}
497
498
499static add_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
500
501pub(crate) fn init_add_methodinfo<D: DomTypes>() {
502 add_methodinfo.set(JSJitInfo {
503 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
504 method: Some(add::<D>)
505 },
506 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
507 protoID: PrototypeList::ID::IDBObjectStore as u16,
508 },
509 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
510 _bitfield_align_1: [],
511 _bitfield_1: __BindgenBitfieldUnit::new(
512 new_jsjitinfo_bitfield_1!(
513 JSJitInfo_OpType::Method as u8,
514 JSJitInfo_AliasSet::AliasEverything as u8,
515 JSValueType::JSVAL_TYPE_OBJECT as u8,
516 false,
517 false,
518 false,
519 false,
520 false,
521 false,
522 0,
523 ).to_ne_bytes()
524 ),
525});
526}
527unsafe extern "C" fn delete<D: DomTypes>
528(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
529 let mut result = false;
530 wrap_panic(&mut || result = (|| {
531 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
532 let this = &*(this as *const D::IDBObjectStore);
533 let args = &*args;
534 let argc = args.argc_;
535
536 if argc < 1 {
537 throw_type_error(cx.raw_cx(), "Not enough arguments to \"IDBObjectStore.delete\".");
538 return false;
539 }
540 let arg0: HandleValue = HandleValue::from_raw(args.get(0));
541 let result: Result<DomRoot<D::IDBRequest>, Error> = this.Delete(SafeJSContext::from_ptr(cx.raw_cx()), arg0);
542 let result = match result {
543 Ok(result) => result,
544 Err(e) => {
545 <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());
546 return false;
547 },
548 };
549
550 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
551 return true;
552 })());
553 result
554}
555
556
557static delete_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
558
559pub(crate) fn init_delete_methodinfo<D: DomTypes>() {
560 delete_methodinfo.set(JSJitInfo {
561 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
562 method: Some(delete::<D>)
563 },
564 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
565 protoID: PrototypeList::ID::IDBObjectStore as u16,
566 },
567 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
568 _bitfield_align_1: [],
569 _bitfield_1: __BindgenBitfieldUnit::new(
570 new_jsjitinfo_bitfield_1!(
571 JSJitInfo_OpType::Method as u8,
572 JSJitInfo_AliasSet::AliasEverything as u8,
573 JSValueType::JSVAL_TYPE_OBJECT as u8,
574 false,
575 false,
576 false,
577 false,
578 false,
579 false,
580 0,
581 ).to_ne_bytes()
582 ),
583});
584}
585unsafe extern "C" fn clear<D: DomTypes>
586(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
587 let mut result = false;
588 wrap_panic(&mut || result = (|| {
589 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
590 let this = &*(this as *const D::IDBObjectStore);
591 let args = &*args;
592 let argc = args.argc_;
593 let result: Result<DomRoot<D::IDBRequest>, Error> = this.Clear();
594 let result = match result {
595 Ok(result) => result,
596 Err(e) => {
597 <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());
598 return false;
599 },
600 };
601
602 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
603 return true;
604 })());
605 result
606}
607
608
609static clear_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
610
611pub(crate) fn init_clear_methodinfo<D: DomTypes>() {
612 clear_methodinfo.set(JSJitInfo {
613 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
614 method: Some(clear::<D>)
615 },
616 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
617 protoID: PrototypeList::ID::IDBObjectStore as u16,
618 },
619 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
620 _bitfield_align_1: [],
621 _bitfield_1: __BindgenBitfieldUnit::new(
622 new_jsjitinfo_bitfield_1!(
623 JSJitInfo_OpType::Method as u8,
624 JSJitInfo_AliasSet::AliasEverything as u8,
625 JSValueType::JSVAL_TYPE_OBJECT as u8,
626 false,
627 false,
628 false,
629 false,
630 false,
631 false,
632 0,
633 ).to_ne_bytes()
634 ),
635});
636}
637unsafe extern "C" fn get<D: DomTypes>
638(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
639 let mut result = false;
640 wrap_panic(&mut || result = (|| {
641 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
642 let this = &*(this as *const D::IDBObjectStore);
643 let args = &*args;
644 let argc = args.argc_;
645
646 if argc < 1 {
647 throw_type_error(cx.raw_cx(), "Not enough arguments to \"IDBObjectStore.get\".");
648 return false;
649 }
650 let arg0: HandleValue = HandleValue::from_raw(args.get(0));
651 let result: Result<DomRoot<D::IDBRequest>, Error> = this.Get(SafeJSContext::from_ptr(cx.raw_cx()), arg0);
652 let result = match result {
653 Ok(result) => result,
654 Err(e) => {
655 <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());
656 return false;
657 },
658 };
659
660 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
661 return true;
662 })());
663 result
664}
665
666
667static get_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
668
669pub(crate) fn init_get_methodinfo<D: DomTypes>() {
670 get_methodinfo.set(JSJitInfo {
671 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
672 method: Some(get::<D>)
673 },
674 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
675 protoID: PrototypeList::ID::IDBObjectStore as u16,
676 },
677 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
678 _bitfield_align_1: [],
679 _bitfield_1: __BindgenBitfieldUnit::new(
680 new_jsjitinfo_bitfield_1!(
681 JSJitInfo_OpType::Method as u8,
682 JSJitInfo_AliasSet::AliasEverything as u8,
683 JSValueType::JSVAL_TYPE_OBJECT as u8,
684 false,
685 false,
686 false,
687 false,
688 false,
689 false,
690 0,
691 ).to_ne_bytes()
692 ),
693});
694}
695unsafe extern "C" fn getKey<D: DomTypes>
696(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
697 let mut result = false;
698 wrap_panic(&mut || result = (|| {
699 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
700 let this = &*(this as *const D::IDBObjectStore);
701 let args = &*args;
702 let argc = args.argc_;
703
704 if argc < 1 {
705 throw_type_error(cx.raw_cx(), "Not enough arguments to \"IDBObjectStore.getKey\".");
706 return false;
707 }
708 let arg0: HandleValue = HandleValue::from_raw(args.get(0));
709 let result: Result<DomRoot<D::IDBRequest>, Error> = this.GetKey(SafeJSContext::from_ptr(cx.raw_cx()), arg0);
710 let result = match result {
711 Ok(result) => result,
712 Err(e) => {
713 <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());
714 return false;
715 },
716 };
717
718 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
719 return true;
720 })());
721 result
722}
723
724
725static getKey_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
726
727pub(crate) fn init_getKey_methodinfo<D: DomTypes>() {
728 getKey_methodinfo.set(JSJitInfo {
729 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
730 method: Some(getKey::<D>)
731 },
732 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
733 protoID: PrototypeList::ID::IDBObjectStore as u16,
734 },
735 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
736 _bitfield_align_1: [],
737 _bitfield_1: __BindgenBitfieldUnit::new(
738 new_jsjitinfo_bitfield_1!(
739 JSJitInfo_OpType::Method as u8,
740 JSJitInfo_AliasSet::AliasEverything as u8,
741 JSValueType::JSVAL_TYPE_OBJECT as u8,
742 false,
743 false,
744 false,
745 false,
746 false,
747 false,
748 0,
749 ).to_ne_bytes()
750 ),
751});
752}
753unsafe extern "C" fn getAll<D: DomTypes>
754(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
755 let mut result = false;
756 wrap_panic(&mut || result = (|| {
757 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
758 let this = &*(this as *const D::IDBObjectStore);
759 let args = &*args;
760 let argc = args.argc_;
761 let arg0: HandleValue = if args.get(0).is_undefined() {
762 HandleValue::undefined()
763 } else {
764 HandleValue::from_raw(args.get(0))
765 };
766 let arg1: Option<u32> = if args.get(1).is_undefined() {
767 None
768 } else {
769 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ConversionBehavior::EnforceRange) {
770 Ok(ConversionResult::Success(value)) => value,
771 Ok(ConversionResult::Failure(error)) => {
772 throw_type_error(cx.raw_cx(), &error);
773 return false;
774
775 }
776 _ => {
777 return false;
778
779 },
780 }
781 )
782 };
783 let result: Result<DomRoot<D::IDBRequest>, Error> = this.GetAll(SafeJSContext::from_ptr(cx.raw_cx()), arg0, arg1);
784 let result = match result {
785 Ok(result) => result,
786 Err(e) => {
787 <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());
788 return false;
789 },
790 };
791
792 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
793 return true;
794 })());
795 result
796}
797
798
799static getAll_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
800
801pub(crate) fn init_getAll_methodinfo<D: DomTypes>() {
802 getAll_methodinfo.set(JSJitInfo {
803 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
804 method: Some(getAll::<D>)
805 },
806 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
807 protoID: PrototypeList::ID::IDBObjectStore as u16,
808 },
809 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
810 _bitfield_align_1: [],
811 _bitfield_1: __BindgenBitfieldUnit::new(
812 new_jsjitinfo_bitfield_1!(
813 JSJitInfo_OpType::Method as u8,
814 JSJitInfo_AliasSet::AliasEverything as u8,
815 JSValueType::JSVAL_TYPE_OBJECT as u8,
816 false,
817 false,
818 false,
819 false,
820 false,
821 false,
822 0,
823 ).to_ne_bytes()
824 ),
825});
826}
827unsafe extern "C" fn getAllKeys<D: DomTypes>
828(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
829 let mut result = false;
830 wrap_panic(&mut || result = (|| {
831 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
832 let this = &*(this as *const D::IDBObjectStore);
833 let args = &*args;
834 let argc = args.argc_;
835 let arg0: HandleValue = if args.get(0).is_undefined() {
836 HandleValue::undefined()
837 } else {
838 HandleValue::from_raw(args.get(0))
839 };
840 let arg1: Option<u32> = if args.get(1).is_undefined() {
841 None
842 } else {
843 Some(match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ConversionBehavior::EnforceRange) {
844 Ok(ConversionResult::Success(value)) => value,
845 Ok(ConversionResult::Failure(error)) => {
846 throw_type_error(cx.raw_cx(), &error);
847 return false;
848
849 }
850 _ => {
851 return false;
852
853 },
854 }
855 )
856 };
857 let result: Result<DomRoot<D::IDBRequest>, Error> = this.GetAllKeys(SafeJSContext::from_ptr(cx.raw_cx()), arg0, arg1);
858 let result = match result {
859 Ok(result) => result,
860 Err(e) => {
861 <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());
862 return false;
863 },
864 };
865
866 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
867 return true;
868 })());
869 result
870}
871
872
873static getAllKeys_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
874
875pub(crate) fn init_getAllKeys_methodinfo<D: DomTypes>() {
876 getAllKeys_methodinfo.set(JSJitInfo {
877 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
878 method: Some(getAllKeys::<D>)
879 },
880 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
881 protoID: PrototypeList::ID::IDBObjectStore as u16,
882 },
883 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
884 _bitfield_align_1: [],
885 _bitfield_1: __BindgenBitfieldUnit::new(
886 new_jsjitinfo_bitfield_1!(
887 JSJitInfo_OpType::Method as u8,
888 JSJitInfo_AliasSet::AliasEverything as u8,
889 JSValueType::JSVAL_TYPE_OBJECT as u8,
890 false,
891 false,
892 false,
893 false,
894 false,
895 false,
896 0,
897 ).to_ne_bytes()
898 ),
899});
900}
901unsafe extern "C" fn count<D: DomTypes>
902(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
903 let mut result = false;
904 wrap_panic(&mut || result = (|| {
905 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
906 let this = &*(this as *const D::IDBObjectStore);
907 let args = &*args;
908 let argc = args.argc_;
909 let arg0: HandleValue = if args.get(0).is_undefined() {
910 HandleValue::undefined()
911 } else {
912 HandleValue::from_raw(args.get(0))
913 };
914 let result: Result<DomRoot<D::IDBRequest>, Error> = this.Count(SafeJSContext::from_ptr(cx.raw_cx()), arg0);
915 let result = match result {
916 Ok(result) => result,
917 Err(e) => {
918 <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());
919 return false;
920 },
921 };
922
923 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
924 return true;
925 })());
926 result
927}
928
929
930static count_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
931
932pub(crate) fn init_count_methodinfo<D: DomTypes>() {
933 count_methodinfo.set(JSJitInfo {
934 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
935 method: Some(count::<D>)
936 },
937 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
938 protoID: PrototypeList::ID::IDBObjectStore as u16,
939 },
940 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
941 _bitfield_align_1: [],
942 _bitfield_1: __BindgenBitfieldUnit::new(
943 new_jsjitinfo_bitfield_1!(
944 JSJitInfo_OpType::Method as u8,
945 JSJitInfo_AliasSet::AliasEverything as u8,
946 JSValueType::JSVAL_TYPE_OBJECT as u8,
947 false,
948 false,
949 false,
950 false,
951 false,
952 false,
953 0,
954 ).to_ne_bytes()
955 ),
956});
957}
958unsafe extern "C" fn openCursor<D: DomTypes>
959(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
960 let mut result = false;
961 wrap_panic(&mut || result = (|| {
962 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
963 let this = &*(this as *const D::IDBObjectStore);
964 let args = &*args;
965 let argc = args.argc_;
966 let arg0: HandleValue = if args.get(0).is_undefined() {
967 HandleValue::undefined()
968 } else {
969 HandleValue::from_raw(args.get(0))
970 };
971 let arg1: IDBCursorDirection = if args.get(1).is_undefined() {
972 IDBCursorDirection::Next
973 } else {
974 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
975 Ok(ConversionResult::Success(value)) => value,
976 Ok(ConversionResult::Failure(error)) => {
977 throw_type_error(cx.raw_cx(), &error); return false;
978
979 }
980 _ => {
981 return false;
982
983 },
984 }
985
986 };
987 let result: Result<DomRoot<D::IDBRequest>, Error> = this.OpenCursor(SafeJSContext::from_ptr(cx.raw_cx()), arg0, arg1);
988 let result = match result {
989 Ok(result) => result,
990 Err(e) => {
991 <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());
992 return false;
993 },
994 };
995
996 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
997 return true;
998 })());
999 result
1000}
1001
1002
1003static openCursor_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1004
1005pub(crate) fn init_openCursor_methodinfo<D: DomTypes>() {
1006 openCursor_methodinfo.set(JSJitInfo {
1007 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1008 method: Some(openCursor::<D>)
1009 },
1010 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1011 protoID: PrototypeList::ID::IDBObjectStore as u16,
1012 },
1013 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1014 _bitfield_align_1: [],
1015 _bitfield_1: __BindgenBitfieldUnit::new(
1016 new_jsjitinfo_bitfield_1!(
1017 JSJitInfo_OpType::Method as u8,
1018 JSJitInfo_AliasSet::AliasEverything as u8,
1019 JSValueType::JSVAL_TYPE_OBJECT as u8,
1020 false,
1021 false,
1022 false,
1023 false,
1024 false,
1025 false,
1026 0,
1027 ).to_ne_bytes()
1028 ),
1029});
1030}
1031unsafe extern "C" fn openKeyCursor<D: DomTypes>
1032(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
1033 let mut result = false;
1034 wrap_panic(&mut || result = (|| {
1035 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
1036 let this = &*(this as *const D::IDBObjectStore);
1037 let args = &*args;
1038 let argc = args.argc_;
1039 let arg0: HandleValue = if args.get(0).is_undefined() {
1040 HandleValue::undefined()
1041 } else {
1042 HandleValue::from_raw(args.get(0))
1043 };
1044 let arg1: IDBCursorDirection = if args.get(1).is_undefined() {
1045 IDBCursorDirection::Next
1046 } else {
1047 match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ()) {
1048 Ok(ConversionResult::Success(value)) => value,
1049 Ok(ConversionResult::Failure(error)) => {
1050 throw_type_error(cx.raw_cx(), &error); return false;
1051
1052 }
1053 _ => {
1054 return false;
1055
1056 },
1057 }
1058
1059 };
1060 let result: Result<DomRoot<D::IDBRequest>, Error> = this.OpenKeyCursor(SafeJSContext::from_ptr(cx.raw_cx()), arg0, arg1);
1061 let result = match result {
1062 Ok(result) => result,
1063 Err(e) => {
1064 <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());
1065 return false;
1066 },
1067 };
1068
1069 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
1070 return true;
1071 })());
1072 result
1073}
1074
1075
1076static openKeyCursor_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
1077
1078pub(crate) fn init_openKeyCursor_methodinfo<D: DomTypes>() {
1079 openKeyCursor_methodinfo.set(JSJitInfo {
1080 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
1081 method: Some(openKeyCursor::<D>)
1082 },
1083 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
1084 protoID: PrototypeList::ID::IDBObjectStore as u16,
1085 },
1086 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
1087 _bitfield_align_1: [],
1088 _bitfield_1: __BindgenBitfieldUnit::new(
1089 new_jsjitinfo_bitfield_1!(
1090 JSJitInfo_OpType::Method as u8,
1091 JSJitInfo_AliasSet::AliasEverything as u8,
1092 JSValueType::JSVAL_TYPE_OBJECT as u8,
1093 false,
1094 false,
1095 false,
1096 false,
1097 false,
1098 false,
1099 0,
1100 ).to_ne_bytes()
1101 ),
1102});
1103}
1104unsafe extern "C" fn _finalize<D: DomTypes>
1105(_cx: *mut GCContext, obj: *mut JSObject){
1106 wrap_panic(&mut || {
1107
1108 let this = native_from_object_static::<D::IDBObjectStore>(obj).unwrap();
1109 finalize_common(this);
1110 })
1111}
1112
1113unsafe extern "C" fn _trace<D: DomTypes>
1114(trc: *mut JSTracer, obj: *mut JSObject){
1115 wrap_panic(&mut || {
1116
1117 let this = native_from_object_static::<D::IDBObjectStore>(obj).unwrap();
1118 if this.is_null() { return; } (*this).trace(trc);
1120 })
1121}
1122
1123
1124static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
1125
1126pub(crate) fn init_class_ops<D: DomTypes>() {
1127 CLASS_OPS.set(JSClassOps {
1128 addProperty: None,
1129 delProperty: None,
1130 enumerate: None,
1131 newEnumerate: None,
1132 resolve: None,
1133 mayResolve: None,
1134 finalize: Some(_finalize::<D>),
1135 call: None,
1136 construct: None,
1137 trace: Some(_trace::<D>),
1138 });
1139}
1140
1141pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
1142
1143pub(crate) fn init_domjs_class<D: DomTypes>() {
1144 init_class_ops::<D>();
1145 Class.set(DOMJSClass {
1146 base: JSClass {
1147 name: c"IDBObjectStore".as_ptr(),
1148 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
1149 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
1150 ,
1151 cOps: unsafe { CLASS_OPS.get() },
1152 spec: ptr::null(),
1153 ext: ptr::null(),
1154 oOps: ptr::null(),
1155 },
1156 dom_class:
1157DOMClass {
1158 interface_chain: [ PrototypeList::ID::IDBObjectStore, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
1159 depth: 0,
1160 type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
1161 malloc_size_of: malloc_size_of_including_raw_self::<D::IDBObjectStore> as unsafe fn(&mut _, _) -> _,
1162 global: Globals::EMPTY,
1163},
1164 });
1165}
1166
1167#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
1168(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::IDBObjectStore>, _can_gc: CanGc) -> DomRoot<D::IDBObjectStore>{
1169
1170 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
1171
1172 let scope = scope.reflector().get_jsobject();
1173 assert!(!scope.get().is_null());
1174 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
1175 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
1176
1177 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
1178 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
1179 assert!(!canonical_proto.is_null());
1180
1181
1182 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
1183 if let Some(given) = given_proto {
1184 proto.set(*given);
1185 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
1186 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
1187 }
1188 } else {
1189 proto.set(*canonical_proto);
1190 }
1191 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
1192 cx.raw_cx(),
1193 &Class.get().base,
1194 proto.handle(),
1195 ));
1196 assert!(!obj.is_null());
1197 JS_SetReservedSlot(
1198 obj.get(),
1199 DOM_OBJECT_SLOT,
1200 &PrivateValue(raw.as_ptr() as *const libc::c_void),
1201 );
1202
1203 let root = raw.reflect_with(obj.get());
1204
1205
1206
1207 DomRoot::from_ref(&*root)
1208}
1209
1210pub trait IDBObjectStoreMethods<D: DomTypes> {
1211 fn Name(&self, ) -> DOMString;
1212 fn SetName(&self, r#value: DOMString) -> ErrorResult;
1213 fn KeyPath(&self, r#cx: SafeJSContext, r#retval: MutableHandleValue);
1214 fn IndexNames(&self, ) -> DomRoot<D::DOMStringList>;
1215 fn Transaction(&self, ) -> DomRoot<D::IDBTransaction>;
1216 fn AutoIncrement(&self, ) -> bool;
1217 fn Put(&self, r#cx: SafeJSContext, r#value: HandleValue, r#key: HandleValue) -> Fallible<DomRoot<D::IDBRequest>>;
1218 fn Add(&self, r#cx: SafeJSContext, r#value: HandleValue, r#key: HandleValue) -> Fallible<DomRoot<D::IDBRequest>>;
1219 fn Delete(&self, r#cx: SafeJSContext, r#query: HandleValue) -> Fallible<DomRoot<D::IDBRequest>>;
1220 fn Clear(&self, ) -> Fallible<DomRoot<D::IDBRequest>>;
1221 fn Get(&self, r#cx: SafeJSContext, r#query: HandleValue) -> Fallible<DomRoot<D::IDBRequest>>;
1222 fn GetKey(&self, r#cx: SafeJSContext, r#query: HandleValue) -> Fallible<DomRoot<D::IDBRequest>>;
1223 fn GetAll(&self, r#cx: SafeJSContext, r#query: HandleValue, r#count: Option<u32>) -> Fallible<DomRoot<D::IDBRequest>>;
1224 fn GetAllKeys(&self, r#cx: SafeJSContext, r#query: HandleValue, r#count: Option<u32>) -> Fallible<DomRoot<D::IDBRequest>>;
1225 fn Count(&self, r#cx: SafeJSContext, r#query: HandleValue) -> Fallible<DomRoot<D::IDBRequest>>;
1226 fn OpenCursor(&self, r#cx: SafeJSContext, r#query: HandleValue, r#direction: IDBCursorDirection) -> Fallible<DomRoot<D::IDBRequest>>;
1227 fn OpenKeyCursor(&self, r#cx: SafeJSContext, r#query: HandleValue, r#direction: IDBCursorDirection) -> Fallible<DomRoot<D::IDBRequest>>;
1228}
1229static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
1230
1231pub(crate) fn init_sMethods_specs<D: DomTypes>() {
1232 sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
1233 JSFunctionSpec {
1234 name: JSPropertySpec_Name { string_: c"put".as_ptr() },
1235 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { put_methodinfo.get() } as *const _ as *const JSJitInfo },
1236 nargs: 1,
1237 flags: (JSPROP_ENUMERATE) as u16,
1238 selfHostedName: ptr::null()
1239 },
1240 JSFunctionSpec {
1241 name: JSPropertySpec_Name { string_: c"add".as_ptr() },
1242 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { add_methodinfo.get() } as *const _ as *const JSJitInfo },
1243 nargs: 1,
1244 flags: (JSPROP_ENUMERATE) as u16,
1245 selfHostedName: ptr::null()
1246 },
1247 JSFunctionSpec {
1248 name: JSPropertySpec_Name { string_: c"delete".as_ptr() },
1249 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { delete_methodinfo.get() } as *const _ as *const JSJitInfo },
1250 nargs: 1,
1251 flags: (JSPROP_ENUMERATE) as u16,
1252 selfHostedName: ptr::null()
1253 },
1254 JSFunctionSpec {
1255 name: JSPropertySpec_Name { string_: c"clear".as_ptr() },
1256 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { clear_methodinfo.get() } as *const _ as *const JSJitInfo },
1257 nargs: 0,
1258 flags: (JSPROP_ENUMERATE) as u16,
1259 selfHostedName: ptr::null()
1260 },
1261 JSFunctionSpec {
1262 name: JSPropertySpec_Name { string_: c"get".as_ptr() },
1263 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { get_methodinfo.get() } as *const _ as *const JSJitInfo },
1264 nargs: 1,
1265 flags: (JSPROP_ENUMERATE) as u16,
1266 selfHostedName: ptr::null()
1267 },
1268 JSFunctionSpec {
1269 name: JSPropertySpec_Name { string_: c"getKey".as_ptr() },
1270 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { getKey_methodinfo.get() } as *const _ as *const JSJitInfo },
1271 nargs: 1,
1272 flags: (JSPROP_ENUMERATE) as u16,
1273 selfHostedName: ptr::null()
1274 },
1275 JSFunctionSpec {
1276 name: JSPropertySpec_Name { string_: c"getAll".as_ptr() },
1277 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { getAll_methodinfo.get() } as *const _ as *const JSJitInfo },
1278 nargs: 0,
1279 flags: (JSPROP_ENUMERATE) as u16,
1280 selfHostedName: ptr::null()
1281 },
1282 JSFunctionSpec {
1283 name: JSPropertySpec_Name { string_: c"getAllKeys".as_ptr() },
1284 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { getAllKeys_methodinfo.get() } as *const _ as *const JSJitInfo },
1285 nargs: 0,
1286 flags: (JSPROP_ENUMERATE) as u16,
1287 selfHostedName: ptr::null()
1288 },
1289 JSFunctionSpec {
1290 name: JSPropertySpec_Name { string_: c"count".as_ptr() },
1291 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { count_methodinfo.get() } as *const _ as *const JSJitInfo },
1292 nargs: 0,
1293 flags: (JSPROP_ENUMERATE) as u16,
1294 selfHostedName: ptr::null()
1295 },
1296 JSFunctionSpec {
1297 name: JSPropertySpec_Name { string_: c"openCursor".as_ptr() },
1298 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { openCursor_methodinfo.get() } as *const _ as *const JSJitInfo },
1299 nargs: 0,
1300 flags: (JSPROP_ENUMERATE) as u16,
1301 selfHostedName: ptr::null()
1302 },
1303 JSFunctionSpec {
1304 name: JSPropertySpec_Name { string_: c"openKeyCursor".as_ptr() },
1305 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { openKeyCursor_methodinfo.get() } as *const _ as *const JSJitInfo },
1306 nargs: 0,
1307 flags: (JSPROP_ENUMERATE) as u16,
1308 selfHostedName: ptr::null()
1309 },
1310 JSFunctionSpec {
1311 name: JSPropertySpec_Name { string_: ptr::null() },
1312 call: JSNativeWrapper { op: None, info: ptr::null() },
1313 nargs: 0,
1314 flags: 0,
1315 selfHostedName: ptr::null()
1316 }]))[..]
1317])));
1318}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
1319
1320pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
1321 sMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE)], (unsafe { sMethods_specs.get() })[0])])));
1322}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
1323
1324pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
1325 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
1326 JSPropertySpec {
1327 name: JSPropertySpec_Name { string_: c"name".as_ptr() },
1328 attributes_: (JSPROP_ENUMERATE),
1329 kind_: (JSPropertySpec_Kind::NativeAccessor),
1330 u: JSPropertySpec_AccessorsOrValue {
1331 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
1332 getter: JSPropertySpec_Accessor {
1333 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { name_getterinfo.get() } },
1334 },
1335 setter: JSPropertySpec_Accessor {
1336 native: JSNativeWrapper { op: Some(generic_setter), info: unsafe { name_setterinfo.get() } },
1337 }
1338 }
1339 }
1340 }
1341,
1342 JSPropertySpec {
1343 name: JSPropertySpec_Name { string_: c"keyPath".as_ptr() },
1344 attributes_: (JSPROP_ENUMERATE),
1345 kind_: (JSPropertySpec_Kind::NativeAccessor),
1346 u: JSPropertySpec_AccessorsOrValue {
1347 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
1348 getter: JSPropertySpec_Accessor {
1349 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { keyPath_getterinfo.get() } },
1350 },
1351 setter: JSPropertySpec_Accessor {
1352 native: JSNativeWrapper { op: None, info: ptr::null() },
1353 }
1354 }
1355 }
1356 }
1357,
1358 JSPropertySpec {
1359 name: JSPropertySpec_Name { string_: c"indexNames".as_ptr() },
1360 attributes_: (JSPROP_ENUMERATE),
1361 kind_: (JSPropertySpec_Kind::NativeAccessor),
1362 u: JSPropertySpec_AccessorsOrValue {
1363 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
1364 getter: JSPropertySpec_Accessor {
1365 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { indexNames_getterinfo.get() } },
1366 },
1367 setter: JSPropertySpec_Accessor {
1368 native: JSNativeWrapper { op: None, info: ptr::null() },
1369 }
1370 }
1371 }
1372 }
1373,
1374 JSPropertySpec {
1375 name: JSPropertySpec_Name { string_: c"transaction".as_ptr() },
1376 attributes_: (JSPROP_ENUMERATE),
1377 kind_: (JSPropertySpec_Kind::NativeAccessor),
1378 u: JSPropertySpec_AccessorsOrValue {
1379 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
1380 getter: JSPropertySpec_Accessor {
1381 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { transaction_getterinfo.get() } },
1382 },
1383 setter: JSPropertySpec_Accessor {
1384 native: JSNativeWrapper { op: None, info: ptr::null() },
1385 }
1386 }
1387 }
1388 }
1389,
1390 JSPropertySpec {
1391 name: JSPropertySpec_Name { string_: c"autoIncrement".as_ptr() },
1392 attributes_: (JSPROP_ENUMERATE),
1393 kind_: (JSPropertySpec_Kind::NativeAccessor),
1394 u: JSPropertySpec_AccessorsOrValue {
1395 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
1396 getter: JSPropertySpec_Accessor {
1397 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { autoIncrement_getterinfo.get() } },
1398 },
1399 setter: JSPropertySpec_Accessor {
1400 native: JSNativeWrapper { op: None, info: ptr::null() },
1401 }
1402 }
1403 }
1404 }
1405,
1406 JSPropertySpec::ZERO]))[..]
1407,
1408&Box::leak(Box::new([
1409 JSPropertySpec {
1410 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
1411 attributes_: (JSPROP_READONLY),
1412 kind_: (JSPropertySpec_Kind::Value),
1413 u: JSPropertySpec_AccessorsOrValue {
1414 value: JSPropertySpec_ValueWrapper {
1415 type_: JSPropertySpec_ValueWrapper_Type::String,
1416 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
1417 string: c"IDBObjectStore".as_ptr(),
1418 }
1419 }
1420 }
1421 }
1422,
1423 JSPropertySpec::ZERO]))[..]
1424])));
1425}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
1426
1427pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
1428 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW),Condition::Exposed(Globals::SERVICE_WORKER_GLOBAL_SCOPE),Condition::Exposed(Globals::DEDICATED_WORKER_GLOBAL_SCOPE)], (unsafe { sAttributes_specs.get() })[0]),
1429 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
1430}
1431pub fn GetProtoObject<D: DomTypes>
1432(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
1433 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::IDBObjectStore), CreateInterfaceObjects::<D>, rval)
1435}
1436
1437
1438static PrototypeClass: JSClass = JSClass {
1439 name: c"IDBObjectStorePrototype".as_ptr(),
1440 flags:
1441 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
1443 cOps: ptr::null(),
1444 spec: ptr::null(),
1445 ext: ptr::null(),
1446 oOps: ptr::null(),
1447};
1448
1449
1450static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
1451
1452pub(crate) fn init_interface_object<D: DomTypes>() {
1453 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
1454 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
1455 b"function IDBObjectStore() {\n [native code]\n}",
1456 PrototypeList::ID::IDBObjectStore,
1457 0,
1458 ));
1459}
1460
1461pub fn DefineDOMInterface<D: DomTypes>
1462(cx: SafeJSContext, global: HandleObject){
1463 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::IDBObjectStore),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
1464}
1465
1466pub fn ConstructorEnabled<D: DomTypes>
1467(aCx: SafeJSContext, aObj: HandleObject) -> bool{
1468 is_exposed_in(aObj, Globals::DEDICATED_WORKER_GLOBAL_SCOPE | Globals::SERVICE_WORKER_GLOBAL_SCOPE | Globals::WINDOW) &&
1469 pref!(dom_indexeddb_enabled)
1470}
1471
1472unsafe fn CreateInterfaceObjects<D: DomTypes>
1473(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
1474
1475 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
1476 prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
1477 assert!(!prototype_proto.is_null());
1478
1479 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
1480 create_interface_prototype_object::<D>(cx,
1481 global,
1482 prototype_proto.handle(),
1483 &PrototypeClass,
1484 sMethods.get(),
1485 sAttributes.get(),
1486 &[],
1487 &[],
1488 prototype.handle_mut());
1489 assert!(!prototype.is_null());
1490 assert!((*cache)[PrototypeList::ID::IDBObjectStore as usize].is_null());
1491 (*cache)[PrototypeList::ID::IDBObjectStore as usize] = prototype.get();
1492 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::IDBObjectStore as isize),
1493 ptr::null_mut(),
1494 prototype.get());
1495
1496 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
1497 interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
1498
1499 assert!(!interface_proto.is_null());
1500
1501 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
1502 create_noncallback_interface_object::<D>(cx,
1503 global,
1504 interface_proto.handle(),
1505 INTERFACE_OBJECT_CLASS.get(),
1506 &[],
1507 &[],
1508 &[],
1509 prototype.handle(),
1510 c"IDBObjectStore",
1511 0,
1512 &[],
1513 interface.handle_mut());
1514 assert!(!interface.is_null());
1515}
1516
1517
1518 pub(crate) fn init_statics<D: DomTypes>() {
1519 init_interface_object::<D>();
1520 init_domjs_class::<D>();
1521 crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_put_methodinfo::<D>();
1522crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_add_methodinfo::<D>();
1523crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_delete_methodinfo::<D>();
1524crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_clear_methodinfo::<D>();
1525crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_get_methodinfo::<D>();
1526crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_getKey_methodinfo::<D>();
1527crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_getAll_methodinfo::<D>();
1528crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_getAllKeys_methodinfo::<D>();
1529crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_count_methodinfo::<D>();
1530crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_openCursor_methodinfo::<D>();
1531crate::codegen::GenericBindings::IDBObjectStoreBinding::IDBObjectStore_Binding::init_openKeyCursor_methodinfo::<D>();
1532 init_name_getterinfo::<D>();
1533init_keyPath_getterinfo::<D>();
1534init_indexNames_getterinfo::<D>();
1535init_transaction_getterinfo::<D>();
1536init_autoIncrement_getterinfo::<D>();
1537 init_name_setterinfo::<D>();
1538
1539 init_sMethods_specs::<D>();
1540init_sMethods_prefs::<D>();
1541init_sAttributes_specs::<D>();
1542init_sAttributes_prefs::<D>();
1543 }
1544 }