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

1/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
2
3#![allow(non_camel_case_types,non_upper_case_globals,unsafe_op_in_unsafe_fn,unused_imports,unused_variables,unused_assignments,unused_mut,clippy::approx_constant,clippy::enum_variant_names,clippy::let_unit_value,clippy::needless_return,clippy::too_many_arguments,clippy::unnecessary_cast,clippy::upper_case_acronyms)]
4
5use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
6use crate::import::base::*;
7
8pub use self::XPathExpression_Binding::{Wrap, XPathExpressionMethods, GetProtoObject, DefineDOMInterface};
9pub mod XPathExpression_Binding {
10use crate::codegen::GenericBindings::EventTargetBinding::EventTarget_Binding;
11use crate::import::module::*;
12
13unsafe extern "C" fn evaluate<D: DomTypes>
14(cx: *mut RawJSContext, _obj: RawHandleObject, this: *mut libc::c_void, args: *const JSJitMethodCallArgs) -> 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::XPathExpression);
19        let args = &*args;
20        let argc = args.argc_;
21
22        if argc < 1 {
23            throw_type_error(cx.raw_cx(), "Not enough arguments to \"XPathExpression.evaluate\".");
24            return false;
25        }
26        let arg0: DomRoot<D::Node> = if HandleValue::from_raw(args.get(0)).get().is_object() {
27            match root_from_handlevalue(HandleValue::from_raw(args.get(0)), SafeJSContext::from_ptr(cx.raw_cx())) {
28                Ok(val) => val,
29                Err(()) => {
30                    throw_type_error(cx.raw_cx(), "value does not implement interface Node.");
31                    return false;
32
33                }
34            }
35
36        } else {
37            throw_type_error(cx.raw_cx(), "Value is not an object.");
38            return false;
39
40        };
41        let arg1: u16 = if args.get(1).is_undefined() {
42            0
43        } else {
44            match FromJSValConvertible::from_jsval(cx.raw_cx(), HandleValue::from_raw(args.get(1)), ConversionBehavior::Default) {
45                Ok(ConversionResult::Success(value)) => value,
46                Ok(ConversionResult::Failure(error)) => {
47                    throw_type_error(cx.raw_cx(), &error);
48            return false;
49
50                }
51                _ => {
52                    return false;
53
54                },
55            }
56
57        };
58        let arg2: Option<DomRoot<D::XPathResult>> = if args.get(2).is_undefined() {
59            None
60        } else if HandleValue::from_raw(args.get(2)).get().is_object() {
61            Some(match root_from_handlevalue(HandleValue::from_raw(args.get(2)), SafeJSContext::from_ptr(cx.raw_cx())) {
62                Ok(val) => val,
63                Err(()) => {
64                    throw_type_error(cx.raw_cx(), "value does not implement interface XPathResult.");
65                    return false;
66
67                }
68            }
69            )
70        } else if HandleValue::from_raw(args.get(2)).get().is_null_or_undefined() {
71            None
72        } else {
73            throw_type_error(cx.raw_cx(), "Value is not an object.");
74            return false;
75
76        };
77        let result: Result<DomRoot<D::XPathResult>, Error> = this.Evaluate(&arg0, arg1, arg2.as_deref(), CanGc::note());
78        let result = match result {
79            Ok(result) => result,
80            Err(e) => {
81                <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());
82                return false;
83            },
84        };
85
86        (result).to_jsval(cx.raw_cx(), MutableHandleValue::from_raw(args.rval()));
87        return true;
88    })());
89    result
90}
91
92
93static evaluate_methodinfo: ThreadUnsafeOnceLock<JSJitInfo> = ThreadUnsafeOnceLock::new();
94
95pub(crate) fn init_evaluate_methodinfo<D: DomTypes>() {
96    evaluate_methodinfo.set(JSJitInfo {
97    __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
98        method: Some(evaluate::<D>)
99    },
100    __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
101        protoID: PrototypeList::ID::XPathExpression as u16,
102    },
103    __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: 0 },
104    _bitfield_align_1: [],
105    _bitfield_1: __BindgenBitfieldUnit::new(
106        new_jsjitinfo_bitfield_1!(
107            JSJitInfo_OpType::Method as u8,
108            JSJitInfo_AliasSet::AliasEverything as u8,
109            JSValueType::JSVAL_TYPE_OBJECT as u8,
110            false,
111            false,
112            false,
113            false,
114            false,
115            false,
116            0,
117        ).to_ne_bytes()
118    ),
119});
120}
121unsafe extern "C" fn _finalize<D: DomTypes>
122(_cx: *mut GCContext, obj: *mut JSObject){
123    wrap_panic(&mut || {
124
125        let this = native_from_object_static::<D::XPathExpression>(obj).unwrap();
126        finalize_common(this);
127    })
128}
129
130unsafe extern "C" fn _trace<D: DomTypes>
131(trc: *mut JSTracer, obj: *mut JSObject){
132    wrap_panic(&mut || {
133
134        let this = native_from_object_static::<D::XPathExpression>(obj).unwrap();
135        if this.is_null() { return; } // GC during obj creation
136        (*this).trace(trc);
137    })
138}
139
140
141static CLASS_OPS: ThreadUnsafeOnceLock<JSClassOps> = ThreadUnsafeOnceLock::new();
142
143pub(crate) fn init_class_ops<D: DomTypes>() {
144    CLASS_OPS.set(JSClassOps {
145        addProperty: None,
146        delProperty: None,
147        enumerate: None,
148        newEnumerate: None,
149        resolve: None,
150        mayResolve: None,
151        finalize: Some(_finalize::<D>),
152        call: None,
153        construct: None,
154        trace: Some(_trace::<D>),
155    });
156}
157
158pub static Class: ThreadUnsafeOnceLock<DOMJSClass> = ThreadUnsafeOnceLock::new();
159
160pub(crate) fn init_domjs_class<D: DomTypes>() {
161    init_class_ops::<D>();
162    Class.set(DOMJSClass {
163        base: JSClass {
164            name: c"XPathExpression".as_ptr(),
165            flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE |
166                   (((1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
167                   /* JSCLASS_HAS_RESERVED_SLOTS(1) */,
168            cOps: unsafe { CLASS_OPS.get() },
169            spec: ptr::null(),
170            ext: ptr::null(),
171            oOps: ptr::null(),
172        },
173        dom_class:
174DOMClass {
175    interface_chain: [ PrototypeList::ID::XPathExpression, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last, PrototypeList::ID::Last ],
176    depth: 0,
177    type_id: crate::codegen::InheritTypes::TopTypeId { alone: () },
178    malloc_size_of: malloc_size_of_including_raw_self::<D::XPathExpression> as unsafe fn(&mut _, _) -> _,
179    global: Globals::EMPTY,
180},
181    });
182}
183
184#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub unsafe fn Wrap<D: DomTypes>
185(cx: SafeJSContext, scope: &D::GlobalScope, given_proto: Option<HandleObject>, object: Box<D::XPathExpression>, _can_gc: CanGc) -> DomRoot<D::XPathExpression>{
186
187    let raw = Root::new(MaybeUnreflectedDom::from_box(object));
188
189    let scope = scope.reflector().get_jsobject();
190    assert!(!scope.get().is_null());
191    assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
192    let _ac = JSAutoRealm::new(cx.raw_cx(), scope.get());
193
194    rooted!(&in(cx) let mut canonical_proto = ptr::null_mut::<JSObject>());
195    GetProtoObject::<D>(cx, scope, canonical_proto.handle_mut());
196    assert!(!canonical_proto.is_null());
197
198
199    rooted!(&in(cx) let mut proto = ptr::null_mut::<JSObject>());
200    if let Some(given) = given_proto {
201        proto.set(*given);
202        if get_context_realm(cx.raw_cx()) != get_object_realm(*given) {
203            assert!(JS_WrapObject(cx.raw_cx(), proto.handle_mut()));
204        }
205    } else {
206        proto.set(*canonical_proto);
207    }
208    rooted!(&in(cx) let obj = JS_NewObjectWithGivenProto(
209        cx.raw_cx(),
210        &Class.get().base,
211        proto.handle(),
212    ));
213    assert!(!obj.is_null());
214    JS_SetReservedSlot(
215        obj.get(),
216        DOM_OBJECT_SLOT,
217        &PrivateValue(raw.as_ptr() as *const libc::c_void),
218    );
219
220    let root = raw.reflect_with(obj.get());
221
222
223
224    DomRoot::from_ref(&*root)
225}
226
227pub trait XPathExpressionMethods<D: DomTypes> {
228    fn Evaluate(&self, r#contextNode: &D::Node, r#type_: u16, r#result: Option<&D::XPathResult>, r#_can_gc: CanGc) -> Fallible<DomRoot<D::XPathResult>>;
229}
230static sMethods_specs: ThreadUnsafeOnceLock<&[&[JSFunctionSpec]]> = ThreadUnsafeOnceLock::new();
231
232pub(crate) fn init_sMethods_specs<D: DomTypes>() {
233    sMethods_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
234    JSFunctionSpec {
235        name: JSPropertySpec_Name { string_: c"evaluate".as_ptr() },
236        call: JSNativeWrapper { op: Some(generic_method::<false>), info: unsafe { evaluate_methodinfo.get() } as *const _ as *const JSJitInfo },
237        nargs: 1,
238        flags: (JSPROP_ENUMERATE) as u16,
239        selfHostedName: ptr::null()
240    },
241    JSFunctionSpec {
242        name: JSPropertySpec_Name { string_: ptr::null() },
243        call: JSNativeWrapper { op: None, info: ptr::null() },
244        nargs: 0,
245        flags: 0,
246        selfHostedName: ptr::null()
247    }]))[..]
248])));
249}static sMethods: ThreadUnsafeOnceLock<&[Guard<&[JSFunctionSpec]>]> = ThreadUnsafeOnceLock::new();
250
251pub(crate) fn init_sMethods_prefs<D: DomTypes>() {
252    sMethods.set(Box::leak(Box::new([    Guard::new(&[Condition::Exposed(Globals::WINDOW)], (unsafe { sMethods_specs.get() })[0])])));
253}static sAttributes_specs: ThreadUnsafeOnceLock<&[&[JSPropertySpec]]> = ThreadUnsafeOnceLock::new();
254
255pub(crate) fn init_sAttributes_specs<D: DomTypes>() {
256    sAttributes_specs.set(Box::leak(Box::new([&Box::leak(Box::new([
257    JSPropertySpec {
258                    name: JSPropertySpec_Name { symbol_: SymbolCode::toStringTag as usize + 1 },
259                    attributes_: (JSPROP_READONLY),
260                    kind_: (JSPropertySpec_Kind::Value),
261                    u: JSPropertySpec_AccessorsOrValue {
262                        value: JSPropertySpec_ValueWrapper {
263                            type_: JSPropertySpec_ValueWrapper_Type::String,
264                            __bindgen_anon_1: JSPropertySpec_ValueWrapper__bindgen_ty_1 {
265                                string: c"XPathExpression".as_ptr(),
266                            }
267                        }
268                    }
269                }
270,
271    JSPropertySpec::ZERO]))[..]
272])));
273}static sAttributes: ThreadUnsafeOnceLock<&[Guard<&[JSPropertySpec]>]> = ThreadUnsafeOnceLock::new();
274
275pub(crate) fn init_sAttributes_prefs<D: DomTypes>() {
276    sAttributes.set(Box::leak(Box::new([    Guard::new(&[Condition::Satisfied], (unsafe { sAttributes_specs.get() })[0])])));
277}
278pub fn GetProtoObject<D: DomTypes>
279(cx: SafeJSContext, global: HandleObject, mut rval: MutableHandleObject){
280    /* Get the interface prototype object for this class.  This will create the
281       object as needed. */get_per_interface_object_handle(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XPathExpression), CreateInterfaceObjects::<D>, rval)
282}
283
284
285static PrototypeClass: JSClass = JSClass {
286    name: c"XPathExpressionPrototype".as_ptr(),
287    flags:
288        // JSCLASS_HAS_RESERVED_SLOTS()
289        (0 ) << JSCLASS_RESERVED_SLOTS_SHIFT,
290    cOps: ptr::null(),
291    spec: ptr::null(),
292    ext: ptr::null(),
293    oOps: ptr::null(),
294};
295
296
297static INTERFACE_OBJECT_CLASS: ThreadUnsafeOnceLock<NonCallbackInterfaceObjectClass> = ThreadUnsafeOnceLock::new();
298
299pub(crate) fn init_interface_object<D: DomTypes>() {
300    INTERFACE_OBJECT_CLASS.set(NonCallbackInterfaceObjectClass::new(
301        Box::leak(Box::new(InterfaceConstructorBehavior::throw())),
302        b"function XPathExpression() {\n    [native code]\n}",
303        PrototypeList::ID::XPathExpression,
304        0,
305    ));
306}
307
308pub fn DefineDOMInterface<D: DomTypes>
309(cx: SafeJSContext, global: HandleObject){
310    define_dom_interface(cx, global, ProtoOrIfaceIndex::ID(PrototypeList::ID::XPathExpression),CreateInterfaceObjects::<D>, ConstructorEnabled::<D>)
311}
312
313pub fn ConstructorEnabled<D: DomTypes>
314(aCx: SafeJSContext, aObj: HandleObject) -> bool{
315    is_exposed_in(aObj, Globals::WINDOW)
316}
317
318unsafe fn CreateInterfaceObjects<D: DomTypes>
319(cx: SafeJSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray){
320
321    rooted!(&in(cx) let mut prototype_proto = ptr::null_mut::<JSObject>());
322    prototype_proto.set(GetRealmObjectPrototype(cx.raw_cx()));
323    assert!(!prototype_proto.is_null());
324
325    rooted!(&in(cx) let mut prototype = ptr::null_mut::<JSObject>());
326    create_interface_prototype_object::<D>(cx,
327                                      global,
328                                      prototype_proto.handle(),
329                                      &PrototypeClass,
330                                      sMethods.get(),
331                                      sAttributes.get(),
332                                      &[],
333                                      &[],
334                                      prototype.handle_mut());
335    assert!(!prototype.is_null());
336    assert!((*cache)[PrototypeList::ID::XPathExpression as usize].is_null());
337    (*cache)[PrototypeList::ID::XPathExpression as usize] = prototype.get();
338    <*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::XPathExpression as isize),
339                                  ptr::null_mut(),
340                                  prototype.get());
341
342    rooted!(&in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
343    interface_proto.set(GetRealmFunctionPrototype(cx.raw_cx()));
344
345    assert!(!interface_proto.is_null());
346
347    rooted!(&in(cx) let mut interface = ptr::null_mut::<JSObject>());
348    create_noncallback_interface_object::<D>(cx,
349                                        global,
350                                        interface_proto.handle(),
351                                        INTERFACE_OBJECT_CLASS.get(),
352                                        &[],
353                                        &[],
354                                        &[],
355                                        prototype.handle(),
356                                        c"XPathExpression",
357                                        0,
358                                        &[],
359                                        interface.handle_mut());
360    assert!(!interface.is_null());
361}
362
363
364        pub(crate) fn init_statics<D: DomTypes>() {
365            init_interface_object::<D>();
366            init_domjs_class::<D>();
367            crate::codegen::GenericBindings::XPathExpressionBinding::XPathExpression_Binding::init_evaluate_methodinfo::<D>();
368
369
370
371            init_sMethods_specs::<D>();
372init_sMethods_prefs::<D>();
373init_sAttributes_specs::<D>();
374init_sAttributes_prefs::<D>();
375        }
376        } // mod XPathExpression_Binding
377
378