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::import::base::*;
7
8pub use self::XPathResult_Binding::{XPathResultConstants, Wrap, XPathResultMethods, GetProtoObject, DefineDOMInterface};
9pub mod XPathResult_Binding {
10use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
11use crate::import::module::*;
12
13unsafe extern "C" fn get_resultType<D: DomTypes>
14(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
15 let mut result = false;
16 wrap_panic(&mut || result = (|| {
17 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
18 let this = &*(this as *const D::XPathResult);
19 let result: u16 = this.ResultType();
20
21 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
22 return true;
23 })());
24 result
25}
26
27
28static resultType_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
29
30pub(crate) fn init_resultType_getterinfo<D: DomTypes>() {
31 resultType_getterinfo.set(JSJitInfo {
32 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
33 getter: Some(get_resultType::<D>)
34 },
35 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
36 protoID: PrototypeList::ID::XPathResult as u16,
37 },
38 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
39 _bitfield_align_1: [],
40 _bitfield_1: __BindgenBitfieldUnit::new(
41 new_jsjitinfo_bitfield_1!(
42 JSJitInfo_OpType::Getter as u8,
43 JSJitInfo_AliasSet::AliasEverything as u8,
44 JSValueType::JSVAL_TYPE_INT32 as u8,
45 true,
46 false,
47 false,
48 false,
49 false,
50 false,
51 0,
52 ).to_ne_bytes()
53 ),
54});
55}
56unsafe extern "C" fn get_numberValue<D: DomTypes>
57(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
58 let mut result = false;
59 wrap_panic(&mut || result = (|| {
60 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
61 let this = &*(this as *const D::XPathResult);
62 let result: Result<f64, Error> = this.GetNumberValue();
63 let result = match result {
64 Ok(result) => result,
65 Err(e) => {
66 <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());
67 return false;
68 },
69 };
70
71 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
72 return true;
73 })());
74 result
75}
76
77
78static numberValue_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
79
80pub(crate) fn init_numberValue_getterinfo<D: DomTypes>() {
81 numberValue_getterinfo.set(JSJitInfo {
82 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
83 getter: Some(get_numberValue::<D>)
84 },
85 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
86 protoID: PrototypeList::ID::XPathResult as u16,
87 },
88 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
89 _bitfield_align_1: [],
90 _bitfield_1: __BindgenBitfieldUnit::new(
91 new_jsjitinfo_bitfield_1!(
92 JSJitInfo_OpType::Getter as u8,
93 JSJitInfo_AliasSet::AliasEverything as u8,
94 JSValueType::JSVAL_TYPE_DOUBLE as u8,
95 false,
96 false,
97 false,
98 false,
99 false,
100 false,
101 0,
102 ).to_ne_bytes()
103 ),
104});
105}
106unsafe extern "C" fn get_stringValue<D: DomTypes>
107(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
108 let mut result = false;
109 wrap_panic(&mut || result = (|| {
110 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
111 let this = &*(this as *const D::XPathResult);
112 let result: Result<DOMString, Error> = this.GetStringValue();
113 let result = match result {
114 Ok(result) => result,
115 Err(e) => {
116 <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());
117 return false;
118 },
119 };
120
121 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
122 return true;
123 })());
124 result
125}
126
127
128static stringValue_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
129
130pub(crate) fn init_stringValue_getterinfo<D: DomTypes>() {
131 stringValue_getterinfo.set(JSJitInfo {
132 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
133 getter: Some(get_stringValue::<D>)
134 },
135 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
136 protoID: PrototypeList::ID::XPathResult as u16,
137 },
138 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
139 _bitfield_align_1: [],
140 _bitfield_1: __BindgenBitfieldUnit::new(
141 new_jsjitinfo_bitfield_1!(
142 JSJitInfo_OpType::Getter as u8,
143 JSJitInfo_AliasSet::AliasEverything as u8,
144 JSValueType::JSVAL_TYPE_STRING as u8,
145 false,
146 false,
147 false,
148 false,
149 false,
150 false,
151 0,
152 ).to_ne_bytes()
153 ),
154});
155}
156unsafe extern "C" fn get_booleanValue<D: DomTypes>
157(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
158 let mut result = false;
159 wrap_panic(&mut || result = (|| {
160 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
161 let this = &*(this as *const D::XPathResult);
162 let result: Result<bool, Error> = this.GetBooleanValue();
163 let result = match result {
164 Ok(result) => result,
165 Err(e) => {
166 <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());
167 return false;
168 },
169 };
170
171 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
172 return true;
173 })());
174 result
175}
176
177
178static booleanValue_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
179
180pub(crate) fn init_booleanValue_getterinfo<D: DomTypes>() {
181 booleanValue_getterinfo.set(JSJitInfo {
182 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
183 getter: Some(get_booleanValue::<D>)
184 },
185 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
186 protoID: PrototypeList::ID::XPathResult as u16,
187 },
188 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
189 _bitfield_align_1: [],
190 _bitfield_1: __BindgenBitfieldUnit::new(
191 new_jsjitinfo_bitfield_1!(
192 JSJitInfo_OpType::Getter as u8,
193 JSJitInfo_AliasSet::AliasEverything as u8,
194 JSValueType::JSVAL_TYPE_BOOLEAN as u8,
195 false,
196 false,
197 false,
198 false,
199 false,
200 false,
201 0,
202 ).to_ne_bytes()
203 ),
204});
205}
206unsafe extern "C" fn get_singleNodeValue<D: DomTypes>
207(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
208 let mut result = false;
209 wrap_panic(&mut || result = (|| {
210 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
211 let this = &*(this as *const D::XPathResult);
212 let result: Result<Option<DomRoot<D::Node>>, Error> = this.GetSingleNodeValue();
213 let result = match result {
214 Ok(result) => result,
215 Err(e) => {
216 <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());
217 return false;
218 },
219 };
220
221 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
222 return true;
223 })());
224 result
225}
226
227
228static singleNodeValue_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
229
230pub(crate) fn init_singleNodeValue_getterinfo<D: DomTypes>() {
231 singleNodeValue_getterinfo.set(JSJitInfo {
232 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
233 getter: Some(get_singleNodeValue::<D>)
234 },
235 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
236 protoID: PrototypeList::ID::XPathResult as u16,
237 },
238 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
239 _bitfield_align_1: [],
240 _bitfield_1: __BindgenBitfieldUnit::new(
241 new_jsjitinfo_bitfield_1!(
242 JSJitInfo_OpType::Getter as u8,
243 JSJitInfo_AliasSet::AliasEverything as u8,
244 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
245 false,
246 false,
247 false,
248 false,
249 false,
250 false,
251 0,
252 ).to_ne_bytes()
253 ),
254});
255}
256unsafe extern "C" fn get_invalidIteratorState<D: DomTypes>
257(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
258 let mut result = false;
259 wrap_panic(&mut || result = (|| {
260 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
261 let this = &*(this as *const D::XPathResult);
262 let result: bool = this.InvalidIteratorState();
263
264 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
265 return true;
266 })());
267 result
268}
269
270
271static invalidIteratorState_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
272
273pub(crate) fn init_invalidIteratorState_getterinfo<D: DomTypes>() {
274 invalidIteratorState_getterinfo.set(JSJitInfo {
275 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
276 getter: Some(get_invalidIteratorState::<D>)
277 },
278 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
279 protoID: PrototypeList::ID::XPathResult as u16,
280 },
281 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
282 _bitfield_align_1: [],
283 _bitfield_1: __BindgenBitfieldUnit::new(
284 new_jsjitinfo_bitfield_1!(
285 JSJitInfo_OpType::Getter as u8,
286 JSJitInfo_AliasSet::AliasEverything as u8,
287 JSValueType::JSVAL_TYPE_BOOLEAN as u8,
288 true,
289 false,
290 false,
291 false,
292 false,
293 false,
294 0,
295 ).to_ne_bytes()
296 ),
297});
298}
299unsafe extern "C" fn get_snapshotLength<D: DomTypes>
300(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: JSJitGetterCallArgs) -> bool{
301 let mut result = false;
302 wrap_panic(&mut || result = (|| {
303 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
304 let this = &*(this as *const D::XPathResult);
305 let result: Result<u32, Error> = this.GetSnapshotLength();
306 let result = match result {
307 Ok(result) => result,
308 Err(e) => {
309 <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());
310 return false;
311 },
312 };
313
314 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
315 return true;
316 })());
317 result
318}
319
320
321static snapshotLength_getterinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
322
323pub(crate) fn init_snapshotLength_getterinfo<D: DomTypes>() {
324 snapshotLength_getterinfo.set(JSJitInfo {
325 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
326 getter: Some(get_snapshotLength::<D>)
327 },
328 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
329 protoID: PrototypeList::ID::XPathResult as u16,
330 },
331 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
332 _bitfield_align_1: [],
333 _bitfield_1: __BindgenBitfieldUnit::new(
334 new_jsjitinfo_bitfield_1!(
335 JSJitInfo_OpType::Getter as u8,
336 JSJitInfo_AliasSet::AliasEverything as u8,
337 JSValueType::JSVAL_TYPE_DOUBLE as u8,
338 false,
339 false,
340 false,
341 false,
342 false,
343 false,
344 0,
345 ).to_ne_bytes()
346 ),
347});
348}
349unsafe extern "C" fn iterateNext<D: DomTypes>
350(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> bool{
351 let mut result = false;
352 wrap_panic(&mut || result = (|| {
353 let mut cx = JSContext::from_ptr(ptr::NonNull::new(cx).unwrap());
354 let this = &*(this as *const D::XPathResult);
355 let args = &*args;
356 let argc = args.argc_;
357 let result: Result<Option<DomRoot<D::Node>>, Error> = this.IterateNext();
358 let result = match result {
359 Ok(result) => result,
360 Err(e) => {
361 <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());
362 return false;
363 },
364 };
365
366 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
367 return true;
368 })());
369 result
370}
371
372
373static iterateNext_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
374
375pub(crate) fn init_iterateNext_methodinfo<D: DomTypes>() {
376 iterateNext_methodinfo.set(JSJitInfo {
377 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
378 method: Some(iterateNext::<D>)
379 },
380 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
381 protoID: PrototypeList::ID::XPathResult 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::Method as u8,
388 JSJitInfo_AliasSet::AliasEverything as u8,
389 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
390 false,
391 false,
392 false,
393 false,
394 false,
395 false,
396 0,
397 ).to_ne_bytes()
398 ),
399});
400}
401unsafe extern "C" fn snapshotItem<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::XPathResult);
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 \"XPathResult.snapshotItem\".");
412 return false;
413 }
414 let arg0: u32 = match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(0)), ConversionBehavior::Default) {
415 Ok(ConversionResult::Success(value)) => value,
416 Ok(ConversionResult::Failure(error)) => {
417 throw_type_error(cx.raw_cx(), &error);
418 return false;
419
420 }
421 _ => {
422 return false;
423
424 },
425 }
426 ;
427 let result: Result<Option<DomRoot<D::Node>>, Error> = this.SnapshotItem(arg0);
428 let result = match result {
429 Ok(result) => result,
430 Err(e) => {
431 <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());
432 return false;
433 },
434 };
435
436 (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
437 return true;
438 })());
439 result
440}
441
442
443static snapshotItem_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
444
445pub(crate) fn init_snapshotItem_methodinfo<D: DomTypes>() {
446 snapshotItem_methodinfo.set(JSJitInfo {
447 __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
448 method: Some(snapshotItem::<D>)
449 },
450 __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
451 protoID: PrototypeList::ID::XPathResult as u16,
452 },
453 __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
454 _bitfield_align_1: [],
455 _bitfield_1: __BindgenBitfieldUnit::new(
456 new_jsjitinfo_bitfield_1!(
457 JSJitInfo_OpType::Method as u8,
458 JSJitInfo_AliasSet::AliasEverything as u8,
459 JSValueType::JSVAL_TYPE_UNKNOWN as u8,
460 false,
461 false,
462 false,
463 false,
464 false,
465 false,
466 0,
467 ).to_ne_bytes()
468 ),
469});
470}
471unsafe extern "C" fn _finalize<D: DomTypes>
472(_cx: *mut GCContext, obj: *mut JSObject){
473 wrap_panic(&mut || {
474
475 let this = native_from_object_static::<D::XPathResult>(obj).unwrap();
476 finalize_common(this);
477 })
478}
479
480unsafe extern "C" fn _trace<D: DomTypes>
481(trc: *mut JSTracer, obj: *mut JSObject){
482 wrap_panic(&mut || {
483
484 let this = native_from_object_static::<D::XPathResult>(obj).unwrap();
485 if this.is_null() { return; } (*this).trace(trc);
487 })
488}
489
490pub mod XPathResultConstants {
491 pub const ANY_TYPE: u16 = 0;
492 pub const NUMBER_TYPE: u16 = 1;
493 pub const STRING_TYPE: u16 = 2;
494 pub const BOOLEAN_TYPE: u16 = 3;
495 pub const UNORDERED_NODE_ITERATOR_TYPE: u16 = 4;
496 pub const ORDERED_NODE_ITERATOR_TYPE: u16 = 5;
497 pub const UNORDERED_NODE_SNAPSHOT_TYPE: u16 = 6;
498 pub const ORDERED_NODE_SNAPSHOT_TYPE: u16 = 7;
499 pub const ANY_UNORDERED_NODE_TYPE: u16 = 8;
500 pub const FIRST_ORDERED_NODE_TYPE: u16 = 9;
501} static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
504
505pub(crate) fn init_class_ops<D: DomTypes>() {
506 CLASS_OPS.set(JSClassOps {
507 addProperty: None,
508 delProperty: None,
509 enumerate: None,
510 newEnumerate: None,
511 resolve: None,
512 mayResolve: None,
513 finalize: Some(_finalize::<D>),
514 call: None,
515 construct: None,
516 trace: Some(_trace::<D>),
517 });
518}
519
520pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
521
522pub(crate) fn init_domjs_class<D: DomTypes>() {
523 init_class_ops::<D>();
524 Class.set(DOMJSClass {
525 base: JSClass {
526 name: c"XPathResult".as_ptr(),
527 flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
528 (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
529 ,
530 cOps: unsafe { CLASS_OPS.get() },
531 spec: ptr::null(),
532 ext: ptr::null(),
533 oOps: ptr::null(),
534 },
535 dom_class:
536DOMClass {
537 interface_chain: [ PrototypeList::ID::XPathResult, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
538 depth: 0,
539 type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
540 malloc_size_of: malloc_size_of_including_raw_self::<D::XPathResult> as unsafe fn(&mut _, _) -> _,
541 global: Globals::EMPTY,
542},
543 });
544}
545
546#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
547(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::XPathResult>, _can_gc: CanGc) -> DomRoot<D::XPathResult>{
548
549 let raw = Root::new(MaybeUnreflectedDom::from_box(object));
550
551 let scope = scope.reflector().get_jsobject();
552 assert!(!scope.get().is_null());
553 assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
554 let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
555
556 rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
557 GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
558 assert!(!canonical_proto.is_null());
559
560
561 rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
562 if let Some(given) = given_proto {
563 proto.set(*given);
564 if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
565 assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
566 }
567 } else {
568 proto.set(*canonical_proto);
569 }
570 rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
571 cx.raw_cx(),
572 &Class.get().base,
573 proto.handle(),
574 ));
575 assert!(!obj.is_null());
576 JS_SetReservedSlot(
577 obj.get(),
578 DOM_OBJECT_SLOT,
579 &PrivateValue(raw.as_ptr() as *const libc::c_void),
580 );
581
582 let root = raw.reflect_with(obj.get());
583
584
585
586 DomRoot::from_ref(&*root)
587}
588
589pub trait XPathResultMethods<D: DomTypes> {
590 fn ResultType(&self, ) -> u16;
591 fn GetNumberValue(&self, ) -> Fallible<f64>;
592 fn GetStringValue(&self, ) -> Fallible<DOMString>;
593 fn GetBooleanValue(&self, ) -> Fallible<bool>;
594 fn GetSingleNodeValue(&self, ) -> Fallible<Option<DomRoot<D::Node>>>;
595 fn InvalidIteratorState(&self, ) -> bool;
596 fn GetSnapshotLength(&self, ) -> Fallible<u32>;
597 fn IterateNext(&self, ) -> Fallible<Option<DomRoot<D::Node>>>;
598 fn SnapshotItem(&self, r#index: u32) -> Fallible<Option<DomRoot<D::Node>>>;
599}
600static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
601
602pub(crate) fn init_sMethods_specs<D: DomTypes>() {
603 sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
604 JSFunctionSpec {
605 name: JSPropertySpec_Name { string_: c"iterateNext".as_ptr() },
606 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { iterateNext_methodinfo.get() } as *const _ as *const JSJitInfo },
607 nargs: 0,
608 flags: (JSPROP_ENUMERATE) as u16,
609 selfHostedName: ptr::null()
610 },
611 JSFunctionSpec {
612 name: JSPropertySpec_Name { string_: c"snapshotItem".as_ptr() },
613 call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { snapshotItem_methodinfo.get() } as *const _ as *const JSJitInfo },
614 nargs: 1,
615 flags: (JSPROP_ENUMERATE) as u16,
616 selfHostedName: ptr::null()
617 },
618 JSFunctionSpec {
619 name: JSPropertySpec_Name { string_: ptr::null() },
620 call: JSNativeWrapper { op: None, info: ptr::null() },
621 nargs: 0,
622 flags: 0,
623 selfHostedName: ptr::null()
624 }]))[..]
625])));
626}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
627
628pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
629 sMethods.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sMethods_specs.get() })[0])])));
630}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
631
632pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
633 sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
634 JSPropertySpec {
635 name: JSPropertySpec_Name { string_: c"resultType".as_ptr() },
636 attributes_: (JSPROP_ENUMERATE),
637 kind_: (JSPropertySpec_Kind::NativeAccessor),
638 u: JSPropertySpec_AccessorsOrValue {
639 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
640 getter: JSPropertySpec_Accessor {
641 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { resultType_getterinfo.get() } },
642 },
643 setter: JSPropertySpec_Accessor {
644 native: JSNativeWrapper { op: None, info: ptr::null() },
645 }
646 }
647 }
648 }
649,
650 JSPropertySpec {
651 name: JSPropertySpec_Name { string_: c"numberValue".as_ptr() },
652 attributes_: (JSPROP_ENUMERATE),
653 kind_: (JSPropertySpec_Kind::NativeAccessor),
654 u: JSPropertySpec_AccessorsOrValue {
655 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
656 getter: JSPropertySpec_Accessor {
657 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { numberValue_getterinfo.get() } },
658 },
659 setter: JSPropertySpec_Accessor {
660 native: JSNativeWrapper { op: None, info: ptr::null() },
661 }
662 }
663 }
664 }
665,
666 JSPropertySpec {
667 name: JSPropertySpec_Name { string_: c"stringValue".as_ptr() },
668 attributes_: (JSPROP_ENUMERATE),
669 kind_: (JSPropertySpec_Kind::NativeAccessor),
670 u: JSPropertySpec_AccessorsOrValue {
671 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
672 getter: JSPropertySpec_Accessor {
673 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { stringValue_getterinfo.get() } },
674 },
675 setter: JSPropertySpec_Accessor {
676 native: JSNativeWrapper { op: None, info: ptr::null() },
677 }
678 }
679 }
680 }
681,
682 JSPropertySpec {
683 name: JSPropertySpec_Name { string_: c"booleanValue".as_ptr() },
684 attributes_: (JSPROP_ENUMERATE),
685 kind_: (JSPropertySpec_Kind::NativeAccessor),
686 u: JSPropertySpec_AccessorsOrValue {
687 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
688 getter: JSPropertySpec_Accessor {
689 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { booleanValue_getterinfo.get() } },
690 },
691 setter: JSPropertySpec_Accessor {
692 native: JSNativeWrapper { op: None, info: ptr::null() },
693 }
694 }
695 }
696 }
697,
698 JSPropertySpec {
699 name: JSPropertySpec_Name { string_: c"singleNodeValue".as_ptr() },
700 attributes_: (JSPROP_ENUMERATE),
701 kind_: (JSPropertySpec_Kind::NativeAccessor),
702 u: JSPropertySpec_AccessorsOrValue {
703 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
704 getter: JSPropertySpec_Accessor {
705 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { singleNodeValue_getterinfo.get() } },
706 },
707 setter: JSPropertySpec_Accessor {
708 native: JSNativeWrapper { op: None, info: ptr::null() },
709 }
710 }
711 }
712 }
713,
714 JSPropertySpec {
715 name: JSPropertySpec_Name { string_: c"invalidIteratorState".as_ptr() },
716 attributes_: (JSPROP_ENUMERATE),
717 kind_: (JSPropertySpec_Kind::NativeAccessor),
718 u: JSPropertySpec_AccessorsOrValue {
719 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
720 getter: JSPropertySpec_Accessor {
721 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { invalidIteratorState_getterinfo.get() } },
722 },
723 setter: JSPropertySpec_Accessor {
724 native: JSNativeWrapper { op: None, info: ptr::null() },
725 }
726 }
727 }
728 }
729,
730 JSPropertySpec {
731 name: JSPropertySpec_Name { string_: c"snapshotLength".as_ptr() },
732 attributes_: (JSPROP_ENUMERATE),
733 kind_: (JSPropertySpec_Kind::NativeAccessor),
734 u: JSPropertySpec_AccessorsOrValue {
735 accessors: JSPropertySpec_AccessorsOrValue_Accessors {
736 getter: JSPropertySpec_Accessor {
737 native: JSNativeWrapper { op: Some(generic_getter::<false>), info: unsafe { snapshotLength_getterinfo.get() } },
738 },
739 setter: JSPropertySpec_Accessor {
740 native: JSNativeWrapper { op: None, info: ptr::null() },
741 }
742 }
743 }
744 }
745,
746 JSPropertySpec::ZERO]))[..]
747,
748&Box::leak(Box::new([
749 JSPropertySpec {
750 name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
751 attributes_: (JSPROP_READONLY),
752 kind_: (JSPropertySpec_Kind::Value),
753 u: JSPropertySpec_AccessorsOrValue {
754 value: JSPropertySpec_ValueWrapper {
755 type_: JSPropertySpec_ValueWrapper_Type::String,
756 __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
757 string: c"XPathResult".as_ptr(),
758 }
759 }
760 }
761 }
762,
763 JSPropertySpec::ZERO]))[..]
764])));
765}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
766
767pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
768 sAttributes.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sAttributes_specs.get() })[0]),
769 Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[1])])));
770}static sConstants_specs: ThreadUnsafeOnceLock<&[&[ConstantSpec]]> = ThreadUnsafeOnceLock::new();
771
772pub(crate) fn init_sConstants_specs<D: DomTypes>() {
773 sConstants_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
774 ConstantSpec { name: c"ANY_TYPE", value: ConstantVal::Int(0) },
775 ConstantSpec { name: c"NUMBER_TYPE", value: ConstantVal::Int(1) },
776 ConstantSpec { name: c"STRING_TYPE", value: ConstantVal::Int(2) },
777 ConstantSpec { name: c"BOOLEAN_TYPE", value: ConstantVal::Int(3) },
778 ConstantSpec { name: c"UNORDERED_NODE_ITERATOR_TYPE", value: ConstantVal::Int(4) },
779 ConstantSpec { name: c"ORDERED_NODE_ITERATOR_TYPE", value: ConstantVal::Int(5) },
780 ConstantSpec { name: c"UNORDERED_NODE_SNAPSHOT_TYPE", value: ConstantVal::Int(6) },
781 ConstantSpec { name: c"ORDERED_NODE_SNAPSHOT_TYPE", value: ConstantVal::Int(7) },
782 ConstantSpec { name: c"ANY_UNORDERED_NODE_TYPE", value: ConstantVal::Int(8) },
783 ConstantSpec { name: c"FIRST_ORDERED_NODE_TYPE", value: ConstantVal::Int(9) }]))[..]
784])));
785}static sConstants: ThreadUnsafeOnceLock<&[Guard<&[ConstantSpec]>]> = ThreadUnsafeOnceLock::new();
786
787pub(crate) fn init_sConstants_prefs<D: DomTypes>() {
788 sConstants.set(Box::leak(Box::new([ Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sConstants_specs.get() })[0])])));
789}
790pub fn GetProtoObject<D: DomTypes>
791(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
792 get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XPathResult), CreateInterfaceObjects::<D>, rval)
794}
795
796
797static PrototypeClass: JSClass = JSClass {
798 name: c"XPathResultPrototype".as_ptr(),
799 flags:
800 (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
802 cOps: ptr::null(),
803 spec: ptr::null(),
804 ext: ptr::null(),
805 oOps: ptr::null(),
806};
807
808
809static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
810
811pub(crate) fn init_interface_object<D: DomTypes>() {
812 INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
813 Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
814 b"function XPathResult() {\n [native code]\n}",
815 PrototypeList::ID::XPathResult,
816 0,
817 ));
818}
819
820pub fn DefineDOMInterface<D: DomTypes>
821(cx: SafeJSContext, global: HandleObject){
822 define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XPathResult),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
823}
824
825pub fn ConstructorEnabled<D: DomTypes>
826(aCx: SafeJSContext, aObj: HandleObject) -> bool{
827 is_exposed_in(aObj, Globals::WINDOW)
828}
829
830unsafe fn CreateInterfaceObjects<D: DomTypes>
831(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
832
833 rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
834 prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
835 assert!(!prototype_proto.is_null());
836
837 rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
838 create_interface_prototype_object::<D>(cx,
839 global,
840 prototype_proto.handle(),
841 &PrototypeClass,
842 sMethods.get(),
843 sAttributes.get(),
844 sConstants.get(),
845 &[],
846 prototype.handle_mut());
847 assert!(!prototype.is_null());
848 assert!((*cache)[PrototypeList::ID::XPathResult as usize].is_null());
849 (*cache)[PrototypeList::ID::XPathResult as usize] = prototype.get();
850 <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::XPathResult as isize),
851 ptr::null_mut(),
852 prototype.get());
853
854 rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
855 interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
856
857 assert!(!interface_proto.is_null());
858
859 rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
860 create_noncallback_interface_object::<D>(cx,
861 global,
862 interface_proto.handle(),
863 INTERFACE_OBJECT_CLASS.get(),
864 &[],
865 &[],
866 sConstants.get(),
867 prototype.handle(),
868 c"XPathResult",
869 0,
870 &[],
871 interface.handle_mut());
872 assert!(!interface.is_null());
873}
874
875
876 pub(crate) fn init_statics<D: DomTypes>() {
877 init_interface_object::<D>();
878 init_domjs_class::<D>();
879 crate::codegen::GenericBindings::XPathResultBinding::XPathResult_Binding::init_iterateNext_methodinfo::<D>();
880crate::codegen::GenericBindings::XPathResultBinding::XPathResult_Binding::init_snapshotItem_methodinfo::<D>();
881 init_resultType_getterinfo::<D>();
882init_numberValue_getterinfo::<D>();
883init_stringValue_getterinfo::<D>();
884init_booleanValue_getterinfo::<D>();
885init_singleNodeValue_getterinfo::<D>();
886init_invalidIteratorState_getterinfo::<D>();
887init_snapshotLength_getterinfo::<D>();
888
889
890 init_sMethods_specs::<D>();
891init_sMethods_prefs::<D>();
892init_sAttributes_specs::<D>();
893init_sAttributes_prefs::<D>();
894init_sConstants_specs::<D>();
895init_sConstants_prefs::<D>();
896 }
897 }