objc2_javascript_core/generated/
JSValueRef.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4#[cfg(feature = "objc2")]
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// A constant identifying the type of a JSValue.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jstype?language=objc)
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct JSType(pub c_uint);
15impl JSType {
16    #[doc(alias = "kJSTypeUndefined")]
17    pub const Undefined: Self = Self(0);
18    #[doc(alias = "kJSTypeNull")]
19    pub const Null: Self = Self(1);
20    #[doc(alias = "kJSTypeBoolean")]
21    pub const Boolean: Self = Self(2);
22    #[doc(alias = "kJSTypeNumber")]
23    pub const Number: Self = Self(3);
24    #[doc(alias = "kJSTypeString")]
25    pub const String: Self = Self(4);
26    #[doc(alias = "kJSTypeObject")]
27    pub const Object: Self = Self(5);
28    #[doc(alias = "kJSTypeSymbol")]
29    pub const Symbol: Self = Self(6);
30    #[doc(alias = "kJSTypeBigInt")]
31    pub const BigInt: Self = Self(7);
32}
33
34#[cfg(feature = "objc2")]
35unsafe impl Encode for JSType {
36    const ENCODING: Encoding = c_uint::ENCODING;
37}
38
39#[cfg(feature = "objc2")]
40unsafe impl RefEncode for JSType {
41    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44/// A constant identifying the Typed Array type of a JSObjectRef.
45///
46/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jstypedarraytype?language=objc)
47#[repr(transparent)]
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
49pub struct JSTypedArrayType(pub c_uint);
50impl JSTypedArrayType {
51    #[doc(alias = "kJSTypedArrayTypeInt8Array")]
52    pub const Int8Array: Self = Self(0);
53    #[doc(alias = "kJSTypedArrayTypeInt16Array")]
54    pub const Int16Array: Self = Self(1);
55    #[doc(alias = "kJSTypedArrayTypeInt32Array")]
56    pub const Int32Array: Self = Self(2);
57    #[doc(alias = "kJSTypedArrayTypeUint8Array")]
58    pub const Uint8Array: Self = Self(3);
59    #[doc(alias = "kJSTypedArrayTypeUint8ClampedArray")]
60    pub const Uint8ClampedArray: Self = Self(4);
61    #[doc(alias = "kJSTypedArrayTypeUint16Array")]
62    pub const Uint16Array: Self = Self(5);
63    #[doc(alias = "kJSTypedArrayTypeUint32Array")]
64    pub const Uint32Array: Self = Self(6);
65    #[doc(alias = "kJSTypedArrayTypeFloat32Array")]
66    pub const Float32Array: Self = Self(7);
67    #[doc(alias = "kJSTypedArrayTypeFloat64Array")]
68    pub const Float64Array: Self = Self(8);
69    #[doc(alias = "kJSTypedArrayTypeArrayBuffer")]
70    pub const ArrayBuffer: Self = Self(9);
71    #[doc(alias = "kJSTypedArrayTypeNone")]
72    pub const None: Self = Self(10);
73    #[doc(alias = "kJSTypedArrayTypeBigInt64Array")]
74    pub const BigInt64Array: Self = Self(11);
75    #[doc(alias = "kJSTypedArrayTypeBigUint64Array")]
76    pub const BigUint64Array: Self = Self(12);
77}
78
79#[cfg(feature = "objc2")]
80unsafe impl Encode for JSTypedArrayType {
81    const ENCODING: Encoding = c_uint::ENCODING;
82}
83
84#[cfg(feature = "objc2")]
85unsafe impl RefEncode for JSTypedArrayType {
86    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
87}
88
89/// A constant identifying the type of JavaScript relation condition.
90///
91/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsrelationcondition?language=objc)
92// NS_ENUM
93#[repr(transparent)]
94#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
95pub struct JSRelationCondition(pub u32);
96impl JSRelationCondition {
97    /// A constant identifying the type of JavaScript relation condition.
98    #[doc(alias = "kJSRelationConditionUndefined")]
99    pub const Undefined: Self = Self(0);
100    /// A constant identifying the type of JavaScript relation condition.
101    #[doc(alias = "kJSRelationConditionEqual")]
102    pub const Equal: Self = Self(1);
103    /// A constant identifying the type of JavaScript relation condition.
104    #[doc(alias = "kJSRelationConditionGreaterThan")]
105    pub const GreaterThan: Self = Self(2);
106    /// A constant identifying the type of JavaScript relation condition.
107    #[doc(alias = "kJSRelationConditionLessThan")]
108    pub const LessThan: Self = Self(3);
109}
110
111#[cfg(feature = "objc2")]
112unsafe impl Encode for JSRelationCondition {
113    const ENCODING: Encoding = u32::ENCODING;
114}
115
116#[cfg(feature = "objc2")]
117unsafe impl RefEncode for JSRelationCondition {
118    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
119}
120
121#[cfg(all(feature = "JSValue", feature = "objc2"))]
122impl JSValue {
123    /// Returns a JavaScript value's type.
124    ///
125    /// Parameter `ctx`: The execution context to use.
126    ///
127    /// Parameter `value`: The JSValue whose type you want to obtain.
128    ///
129    /// Returns: A value of type JSType that identifies value's type.
130    ///
131    /// # Safety
132    ///
133    /// - `ctx` must be a valid pointer.
134    /// - `value` must be a valid pointer.
135    #[doc(alias = "JSValueGetType")]
136    #[cfg(feature = "JSBase")]
137    #[inline]
138    pub unsafe fn r#type(ctx: JSContextRef, value: JSValueRef) -> JSType {
139        extern "C-unwind" {
140            fn JSValueGetType(ctx: JSContextRef, value: JSValueRef) -> JSType;
141        }
142        unsafe { JSValueGetType(ctx, value) }
143    }
144
145    /// Tests whether a JavaScript value's type is the undefined type.
146    ///
147    /// Parameter `ctx`: The execution context to use.
148    ///
149    /// Parameter `value`: The JSValue to test.
150    ///
151    /// Returns: true if value's type is the undefined type, otherwise false.
152    ///
153    /// # Safety
154    ///
155    /// - `ctx` must be a valid pointer.
156    /// - `value` must be a valid pointer.
157    #[doc(alias = "JSValueIsUndefined")]
158    #[cfg(feature = "JSBase")]
159    #[inline]
160    pub unsafe fn is_undefined(ctx: JSContextRef, value: JSValueRef) -> bool {
161        extern "C-unwind" {
162            fn JSValueIsUndefined(ctx: JSContextRef, value: JSValueRef) -> bool;
163        }
164        unsafe { JSValueIsUndefined(ctx, value) }
165    }
166
167    /// Tests whether a JavaScript value's type is the null type.
168    ///
169    /// Parameter `ctx`: The execution context to use.
170    ///
171    /// Parameter `value`: The JSValue to test.
172    ///
173    /// Returns: true if value's type is the null type, otherwise false.
174    ///
175    /// # Safety
176    ///
177    /// - `ctx` must be a valid pointer.
178    /// - `value` must be a valid pointer.
179    #[doc(alias = "JSValueIsNull")]
180    #[cfg(feature = "JSBase")]
181    #[inline]
182    pub unsafe fn is_null(ctx: JSContextRef, value: JSValueRef) -> bool {
183        extern "C-unwind" {
184            fn JSValueIsNull(ctx: JSContextRef, value: JSValueRef) -> bool;
185        }
186        unsafe { JSValueIsNull(ctx, value) }
187    }
188
189    /// Tests whether a JavaScript value's type is the boolean type.
190    ///
191    /// Parameter `ctx`: The execution context to use.
192    ///
193    /// Parameter `value`: The JSValue to test.
194    ///
195    /// Returns: true if value's type is the boolean type, otherwise false.
196    ///
197    /// # Safety
198    ///
199    /// - `ctx` must be a valid pointer.
200    /// - `value` must be a valid pointer.
201    #[doc(alias = "JSValueIsBoolean")]
202    #[cfg(feature = "JSBase")]
203    #[inline]
204    pub unsafe fn is_boolean(ctx: JSContextRef, value: JSValueRef) -> bool {
205        extern "C-unwind" {
206            fn JSValueIsBoolean(ctx: JSContextRef, value: JSValueRef) -> bool;
207        }
208        unsafe { JSValueIsBoolean(ctx, value) }
209    }
210
211    /// Tests whether a JavaScript value's type is the number type.
212    ///
213    /// Parameter `ctx`: The execution context to use.
214    ///
215    /// Parameter `value`: The JSValue to test.
216    ///
217    /// Returns: true if value's type is the number type, otherwise false.
218    ///
219    /// # Safety
220    ///
221    /// - `ctx` must be a valid pointer.
222    /// - `value` must be a valid pointer.
223    #[doc(alias = "JSValueIsNumber")]
224    #[cfg(feature = "JSBase")]
225    #[inline]
226    pub unsafe fn is_number(ctx: JSContextRef, value: JSValueRef) -> bool {
227        extern "C-unwind" {
228            fn JSValueIsNumber(ctx: JSContextRef, value: JSValueRef) -> bool;
229        }
230        unsafe { JSValueIsNumber(ctx, value) }
231    }
232
233    /// Tests whether a JavaScript value's type is the string type.
234    ///
235    /// Parameter `ctx`: The execution context to use.
236    ///
237    /// Parameter `value`: The JSValue to test.
238    ///
239    /// Returns: true if value's type is the string type, otherwise false.
240    ///
241    /// # Safety
242    ///
243    /// - `ctx` must be a valid pointer.
244    /// - `value` must be a valid pointer.
245    #[doc(alias = "JSValueIsString")]
246    #[cfg(feature = "JSBase")]
247    #[inline]
248    pub unsafe fn is_string(ctx: JSContextRef, value: JSValueRef) -> bool {
249        extern "C-unwind" {
250            fn JSValueIsString(ctx: JSContextRef, value: JSValueRef) -> bool;
251        }
252        unsafe { JSValueIsString(ctx, value) }
253    }
254
255    /// Tests whether a JavaScript value's type is the symbol type.
256    ///
257    /// Parameter `ctx`: The execution context to use.
258    ///
259    /// Parameter `value`: The JSValue to test.
260    ///
261    /// Returns: true if value's type is the symbol type, otherwise false.
262    ///
263    /// # Safety
264    ///
265    /// - `ctx` must be a valid pointer.
266    /// - `value` must be a valid pointer.
267    #[doc(alias = "JSValueIsSymbol")]
268    #[cfg(feature = "JSBase")]
269    #[inline]
270    pub unsafe fn is_symbol(ctx: JSContextRef, value: JSValueRef) -> bool {
271        extern "C-unwind" {
272            fn JSValueIsSymbol(ctx: JSContextRef, value: JSValueRef) -> bool;
273        }
274        unsafe { JSValueIsSymbol(ctx, value) }
275    }
276
277    /// Tests whether a JavaScript value's type is the BigInt type.
278    ///
279    /// Parameter `ctx`: The execution context to use.
280    ///
281    /// Parameter `value`: The JSValue to test.
282    ///
283    /// Returns: true if value's type is the BigInt type, otherwise false.
284    ///
285    /// # Safety
286    ///
287    /// - `ctx` must be a valid pointer.
288    /// - `value` must be a valid pointer.
289    #[doc(alias = "JSValueIsBigInt")]
290    #[cfg(feature = "JSBase")]
291    #[inline]
292    pub unsafe fn is_big_int(ctx: JSContextRef, value: JSValueRef) -> bool {
293        extern "C-unwind" {
294            fn JSValueIsBigInt(ctx: JSContextRef, value: JSValueRef) -> bool;
295        }
296        unsafe { JSValueIsBigInt(ctx, value) }
297    }
298
299    /// Tests whether a JavaScript value's type is the object type.
300    ///
301    /// Parameter `ctx`: The execution context to use.
302    ///
303    /// Parameter `value`: The JSValue to test.
304    ///
305    /// Returns: true if value's type is the object type, otherwise false.
306    ///
307    /// # Safety
308    ///
309    /// - `ctx` must be a valid pointer.
310    /// - `value` must be a valid pointer.
311    #[doc(alias = "JSValueIsObject")]
312    #[cfg(feature = "JSBase")]
313    #[inline]
314    pub unsafe fn is_object(ctx: JSContextRef, value: JSValueRef) -> bool {
315        extern "C-unwind" {
316            fn JSValueIsObject(ctx: JSContextRef, value: JSValueRef) -> bool;
317        }
318        unsafe { JSValueIsObject(ctx, value) }
319    }
320
321    /// Tests whether a JavaScript value is an object with a given class in its class chain.
322    ///
323    /// Parameter `ctx`: The execution context to use.
324    ///
325    /// Parameter `value`: The JSValue to test.
326    ///
327    /// Parameter `jsClass`: The JSClass to test against.
328    ///
329    /// Returns: true if value is an object and has jsClass in its class chain, otherwise false.
330    ///
331    /// # Safety
332    ///
333    /// - `ctx` must be a valid pointer.
334    /// - `value` must be a valid pointer.
335    /// - `js_class` must be a valid pointer.
336    #[doc(alias = "JSValueIsObjectOfClass")]
337    #[cfg(feature = "JSBase")]
338    #[inline]
339    pub unsafe fn is_object_of_class(
340        ctx: JSContextRef,
341        value: JSValueRef,
342        js_class: JSClassRef,
343    ) -> bool {
344        extern "C-unwind" {
345            fn JSValueIsObjectOfClass(
346                ctx: JSContextRef,
347                value: JSValueRef,
348                js_class: JSClassRef,
349            ) -> bool;
350        }
351        unsafe { JSValueIsObjectOfClass(ctx, value, js_class) }
352    }
353
354    /// Tests whether a JavaScript value is an array.
355    ///
356    /// Parameter `ctx`: The execution context to use.
357    ///
358    /// Parameter `value`: The JSValue to test.
359    ///
360    /// Returns: true if value is an array, otherwise false.
361    ///
362    /// # Safety
363    ///
364    /// - `ctx` must be a valid pointer.
365    /// - `value` must be a valid pointer.
366    #[doc(alias = "JSValueIsArray")]
367    #[cfg(feature = "JSBase")]
368    #[inline]
369    pub unsafe fn is_array(ctx: JSContextRef, value: JSValueRef) -> bool {
370        extern "C-unwind" {
371            fn JSValueIsArray(ctx: JSContextRef, value: JSValueRef) -> bool;
372        }
373        unsafe { JSValueIsArray(ctx, value) }
374    }
375
376    /// Tests whether a JavaScript value is a date.
377    ///
378    /// Parameter `ctx`: The execution context to use.
379    ///
380    /// Parameter `value`: The JSValue to test.
381    ///
382    /// Returns: true if value is a date, otherwise false.
383    ///
384    /// # Safety
385    ///
386    /// - `ctx` must be a valid pointer.
387    /// - `value` must be a valid pointer.
388    #[doc(alias = "JSValueIsDate")]
389    #[cfg(feature = "JSBase")]
390    #[inline]
391    pub unsafe fn is_date(ctx: JSContextRef, value: JSValueRef) -> bool {
392        extern "C-unwind" {
393            fn JSValueIsDate(ctx: JSContextRef, value: JSValueRef) -> bool;
394        }
395        unsafe { JSValueIsDate(ctx, value) }
396    }
397
398    /// Returns a JavaScript value's Typed Array type.
399    ///
400    /// Parameter `ctx`: The execution context to use.
401    ///
402    /// Parameter `value`: The JSValue whose Typed Array type to return.
403    ///
404    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
405    ///
406    /// Returns: A value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object.
407    ///
408    /// # Safety
409    ///
410    /// - `ctx` must be a valid pointer.
411    /// - `value` must be a valid pointer.
412    /// - `exception` must be a valid pointer.
413    #[doc(alias = "JSValueGetTypedArrayType")]
414    #[cfg(feature = "JSBase")]
415    #[inline]
416    pub unsafe fn typed_array_type(
417        ctx: JSContextRef,
418        value: JSValueRef,
419        exception: *mut JSValueRef,
420    ) -> JSTypedArrayType {
421        extern "C-unwind" {
422            fn JSValueGetTypedArrayType(
423                ctx: JSContextRef,
424                value: JSValueRef,
425                exception: *mut JSValueRef,
426            ) -> JSTypedArrayType;
427        }
428        unsafe { JSValueGetTypedArrayType(ctx, value, exception) }
429    }
430
431    /// Tests whether two JavaScript values are equal, as compared by the JS == operator.
432    ///
433    /// Parameter `ctx`: The execution context to use.
434    ///
435    /// Parameter `a`: The first value to test.
436    ///
437    /// Parameter `b`: The second value to test.
438    ///
439    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
440    ///
441    /// Returns: true if the two values are equal, false if they are not equal or an exception is thrown.
442    ///
443    /// # Safety
444    ///
445    /// - `ctx` must be a valid pointer.
446    /// - `a` must be a valid pointer.
447    /// - `b` must be a valid pointer.
448    /// - `exception` must be a valid pointer.
449    #[doc(alias = "JSValueIsEqual")]
450    #[cfg(feature = "JSBase")]
451    #[inline]
452    pub unsafe fn is_equal(
453        ctx: JSContextRef,
454        a: JSValueRef,
455        b: JSValueRef,
456        exception: *mut JSValueRef,
457    ) -> bool {
458        extern "C-unwind" {
459            fn JSValueIsEqual(
460                ctx: JSContextRef,
461                a: JSValueRef,
462                b: JSValueRef,
463                exception: *mut JSValueRef,
464            ) -> bool;
465        }
466        unsafe { JSValueIsEqual(ctx, a, b, exception) }
467    }
468
469    /// Tests whether two JavaScript values are strict equal, as compared by the JS === operator.
470    ///
471    /// Parameter `ctx`: The execution context to use.
472    ///
473    /// Parameter `a`: The first value to test.
474    ///
475    /// Parameter `b`: The second value to test.
476    ///
477    /// Returns: true if the two values are strict equal, otherwise false.
478    ///
479    /// # Safety
480    ///
481    /// - `ctx` must be a valid pointer.
482    /// - `a` must be a valid pointer.
483    /// - `b` must be a valid pointer.
484    #[doc(alias = "JSValueIsStrictEqual")]
485    #[cfg(feature = "JSBase")]
486    #[inline]
487    pub unsafe fn is_strict_equal(ctx: JSContextRef, a: JSValueRef, b: JSValueRef) -> bool {
488        extern "C-unwind" {
489            fn JSValueIsStrictEqual(ctx: JSContextRef, a: JSValueRef, b: JSValueRef) -> bool;
490        }
491        unsafe { JSValueIsStrictEqual(ctx, a, b) }
492    }
493
494    /// Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.
495    ///
496    /// Parameter `ctx`: The execution context to use.
497    ///
498    /// Parameter `value`: The JSValue to test.
499    ///
500    /// Parameter `constructor`: The constructor to test against.
501    ///
502    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
503    ///
504    /// Returns: true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false.
505    ///
506    /// # Safety
507    ///
508    /// - `ctx` must be a valid pointer.
509    /// - `value` must be a valid pointer.
510    /// - `constructor` must be a valid pointer.
511    /// - `exception` must be a valid pointer.
512    #[doc(alias = "JSValueIsInstanceOfConstructor")]
513    #[cfg(feature = "JSBase")]
514    #[inline]
515    pub unsafe fn is_instance_of_constructor(
516        ctx: JSContextRef,
517        value: JSValueRef,
518        constructor: JSObjectRef,
519        exception: *mut JSValueRef,
520    ) -> bool {
521        extern "C-unwind" {
522            fn JSValueIsInstanceOfConstructor(
523                ctx: JSContextRef,
524                value: JSValueRef,
525                constructor: JSObjectRef,
526                exception: *mut JSValueRef,
527            ) -> bool;
528        }
529        unsafe { JSValueIsInstanceOfConstructor(ctx, value, constructor, exception) }
530    }
531
532    /// Compares two JSValues.
533    ///
534    /// Parameter `ctx`: The execution context to use.
535    ///
536    /// Parameter `left`: The JSValue as the left operand.
537    ///
538    /// Parameter `right`: The JSValue as the right operand.
539    ///
540    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
541    ///
542    /// Returns: A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.
543    ///
544    /// The result is computed by comparing the results of JavaScript's `==`, `
545    /// <
546    /// `, and `>` operators. If either `left` or `right` is (or would coerce to) `NaN` in JavaScript, then the result is kJSRelationConditionUndefined.
547    ///
548    /// # Safety
549    ///
550    /// - `ctx` must be a valid pointer.
551    /// - `left` must be a valid pointer.
552    /// - `right` must be a valid pointer.
553    /// - `exception` must be a valid pointer or null.
554    #[doc(alias = "JSValueCompare")]
555    #[cfg(feature = "JSBase")]
556    #[inline]
557    pub unsafe fn compare(
558        ctx: JSContextRef,
559        left: JSValueRef,
560        right: JSValueRef,
561        exception: *mut JSValueRef,
562    ) -> JSRelationCondition {
563        extern "C-unwind" {
564            fn JSValueCompare(
565                ctx: JSContextRef,
566                left: JSValueRef,
567                right: JSValueRef,
568                exception: *mut JSValueRef,
569            ) -> JSRelationCondition;
570        }
571        unsafe { JSValueCompare(ctx, left, right, exception) }
572    }
573
574    /// Compares a JSValue with a signed 64-bit integer.
575    ///
576    /// Parameter `ctx`: The execution context to use.
577    ///
578    /// Parameter `left`: The JSValue as the left operand.
579    ///
580    /// Parameter `right`: The int64_t as the right operand.
581    ///
582    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
583    ///
584    /// Returns: A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.
585    ///
586    /// `left` is converted to an integer according to the rules specified by the JavaScript language then compared with `right`.
587    ///
588    /// # Safety
589    ///
590    /// - `ctx` must be a valid pointer.
591    /// - `left` must be a valid pointer.
592    /// - `exception` must be a valid pointer or null.
593    #[doc(alias = "JSValueCompareInt64")]
594    #[cfg(feature = "JSBase")]
595    #[inline]
596    pub unsafe fn compare_int64(
597        ctx: JSContextRef,
598        left: JSValueRef,
599        right: i64,
600        exception: *mut JSValueRef,
601    ) -> JSRelationCondition {
602        extern "C-unwind" {
603            fn JSValueCompareInt64(
604                ctx: JSContextRef,
605                left: JSValueRef,
606                right: i64,
607                exception: *mut JSValueRef,
608            ) -> JSRelationCondition;
609        }
610        unsafe { JSValueCompareInt64(ctx, left, right, exception) }
611    }
612
613    /// Compares a JSValue with an unsigned 64-bit integer.
614    ///
615    /// Parameter `ctx`: The execution context to use.
616    ///
617    /// Parameter `left`: The JSValue as the left operand.
618    ///
619    /// Parameter `right`: The uint64_t as the right operand.
620    ///
621    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
622    ///
623    /// Returns: A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.
624    ///
625    /// `left` is converted to an integer according to the rules specified by the JavaScript language then compared with `right`.
626    ///
627    /// # Safety
628    ///
629    /// - `ctx` must be a valid pointer.
630    /// - `left` must be a valid pointer.
631    /// - `exception` must be a valid pointer or null.
632    #[doc(alias = "JSValueCompareUInt64")]
633    #[cfg(feature = "JSBase")]
634    #[inline]
635    pub unsafe fn compare_u_int64(
636        ctx: JSContextRef,
637        left: JSValueRef,
638        right: u64,
639        exception: *mut JSValueRef,
640    ) -> JSRelationCondition {
641        extern "C-unwind" {
642            fn JSValueCompareUInt64(
643                ctx: JSContextRef,
644                left: JSValueRef,
645                right: u64,
646                exception: *mut JSValueRef,
647            ) -> JSRelationCondition;
648        }
649        unsafe { JSValueCompareUInt64(ctx, left, right, exception) }
650    }
651
652    /// Compares a JSValue with a double.
653    ///
654    /// Parameter `ctx`: The execution context to use.
655    ///
656    /// Parameter `left`: The JSValue as the left operand.
657    ///
658    /// Parameter `right`: The double as the right operand.
659    ///
660    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
661    ///
662    /// Returns: A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.
663    ///
664    /// `left` is converted to a double according to the rules specified by the JavaScript language then compared with `right`.
665    ///
666    /// # Safety
667    ///
668    /// - `ctx` must be a valid pointer.
669    /// - `left` must be a valid pointer.
670    /// - `exception` must be a valid pointer or null.
671    #[doc(alias = "JSValueCompareDouble")]
672    #[cfg(feature = "JSBase")]
673    #[inline]
674    pub unsafe fn compare_double(
675        ctx: JSContextRef,
676        left: JSValueRef,
677        right: c_double,
678        exception: *mut JSValueRef,
679    ) -> JSRelationCondition {
680        extern "C-unwind" {
681            fn JSValueCompareDouble(
682                ctx: JSContextRef,
683                left: JSValueRef,
684                right: c_double,
685                exception: *mut JSValueRef,
686            ) -> JSRelationCondition;
687        }
688        unsafe { JSValueCompareDouble(ctx, left, right, exception) }
689    }
690
691    /// Creates a JavaScript value of the undefined type.
692    ///
693    /// Parameter `ctx`: The execution context to use.
694    ///
695    /// Returns: The unique undefined value.
696    ///
697    /// # Safety
698    ///
699    /// `ctx` must be a valid pointer.
700    #[doc(alias = "JSValueMakeUndefined")]
701    #[cfg(feature = "JSBase")]
702    #[inline]
703    pub unsafe fn new_undefined(ctx: JSContextRef) -> JSValueRef {
704        extern "C-unwind" {
705            fn JSValueMakeUndefined(ctx: JSContextRef) -> JSValueRef;
706        }
707        unsafe { JSValueMakeUndefined(ctx) }
708    }
709
710    /// Creates a JavaScript value of the null type.
711    ///
712    /// Parameter `ctx`: The execution context to use.
713    ///
714    /// Returns: The unique null value.
715    ///
716    /// # Safety
717    ///
718    /// `ctx` must be a valid pointer.
719    #[doc(alias = "JSValueMakeNull")]
720    #[cfg(feature = "JSBase")]
721    #[inline]
722    pub unsafe fn new_null(ctx: JSContextRef) -> JSValueRef {
723        extern "C-unwind" {
724            fn JSValueMakeNull(ctx: JSContextRef) -> JSValueRef;
725        }
726        unsafe { JSValueMakeNull(ctx) }
727    }
728
729    /// Creates a JavaScript value of the boolean type.
730    ///
731    /// Parameter `ctx`: The execution context to use.
732    ///
733    /// Parameter `boolean`: The bool to assign to the newly created JSValue.
734    ///
735    /// Returns: A JSValue of the boolean type, representing the value of boolean.
736    ///
737    /// # Safety
738    ///
739    /// `ctx` must be a valid pointer.
740    #[doc(alias = "JSValueMakeBoolean")]
741    #[cfg(feature = "JSBase")]
742    #[inline]
743    pub unsafe fn new_boolean(ctx: JSContextRef, boolean: bool) -> JSValueRef {
744        extern "C-unwind" {
745            fn JSValueMakeBoolean(ctx: JSContextRef, boolean: bool) -> JSValueRef;
746        }
747        unsafe { JSValueMakeBoolean(ctx, boolean) }
748    }
749
750    /// Creates a JavaScript value of the number type.
751    ///
752    /// Parameter `ctx`: The execution context to use.
753    ///
754    /// Parameter `number`: The double to assign to the newly created JSValue.
755    ///
756    /// Returns: A JSValue of the number type, representing the value of number.
757    ///
758    /// # Safety
759    ///
760    /// `ctx` must be a valid pointer.
761    #[doc(alias = "JSValueMakeNumber")]
762    #[cfg(feature = "JSBase")]
763    #[inline]
764    pub unsafe fn new_number(ctx: JSContextRef, number: c_double) -> JSValueRef {
765        extern "C-unwind" {
766            fn JSValueMakeNumber(ctx: JSContextRef, number: c_double) -> JSValueRef;
767        }
768        unsafe { JSValueMakeNumber(ctx, number) }
769    }
770
771    /// Creates a JavaScript value of the string type.
772    ///
773    /// Parameter `ctx`: The execution context to use.
774    ///
775    /// Parameter `string`: The JSString to assign to the newly created JSValue. The
776    /// newly created JSValue retains string, and releases it upon garbage collection.
777    ///
778    /// Returns: A JSValue of the string type, representing the value of string.
779    ///
780    /// # Safety
781    ///
782    /// - `ctx` must be a valid pointer.
783    /// - `string` must be a valid pointer.
784    #[doc(alias = "JSValueMakeString")]
785    #[cfg(feature = "JSBase")]
786    #[inline]
787    pub unsafe fn new_string(ctx: JSContextRef, string: JSStringRef) -> JSValueRef {
788        extern "C-unwind" {
789            fn JSValueMakeString(ctx: JSContextRef, string: JSStringRef) -> JSValueRef;
790        }
791        unsafe { JSValueMakeString(ctx, string) }
792    }
793
794    /// Creates a JavaScript value of the symbol type.
795    ///
796    /// Parameter `ctx`: The execution context to use.
797    ///
798    /// Parameter `description`: A description of the newly created symbol value.
799    ///
800    /// Returns: A unique JSValue of the symbol type, whose description matches the one provided.
801    ///
802    /// # Safety
803    ///
804    /// - `ctx` must be a valid pointer.
805    /// - `description` must be a valid pointer.
806    #[doc(alias = "JSValueMakeSymbol")]
807    #[cfg(feature = "JSBase")]
808    #[inline]
809    pub unsafe fn new_symbol(ctx: JSContextRef, description: JSStringRef) -> JSValueRef {
810        extern "C-unwind" {
811            fn JSValueMakeSymbol(ctx: JSContextRef, description: JSStringRef) -> JSValueRef;
812        }
813        unsafe { JSValueMakeSymbol(ctx, description) }
814    }
815}
816
817extern "C-unwind" {
818    /// Creates a JavaScript BigInt with a double.
819    ///
820    /// Parameter `ctx`: The execution context to use.
821    ///
822    /// Parameter `value`: The value to copy into the new BigInt JSValue.
823    ///
824    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
825    ///
826    /// Returns: A BigInt JSValue of the value, or NULL if an exception is thrown.
827    ///
828    /// If the value is not an integer, an exception is thrown.
829    ///
830    /// # Safety
831    ///
832    /// - `ctx` must be a valid pointer.
833    /// - `exception` must be a valid pointer or null.
834    #[cfg(feature = "JSBase")]
835    pub fn JSBigIntCreateWithDouble(
836        ctx: JSContextRef,
837        value: c_double,
838        exception: *mut JSValueRef,
839    ) -> JSValueRef;
840}
841
842extern "C-unwind" {
843    /// Creates a JavaScript BigInt with a 64-bit signed integer.
844    ///
845    /// Parameter `ctx`: The execution context to use.
846    ///
847    /// Parameter `integer`: The 64-bit signed integer to copy into the new BigInt JSValue.
848    ///
849    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
850    ///
851    /// Returns: A BigInt JSValue of the integer, or NULL if an exception is thrown.
852    ///
853    /// # Safety
854    ///
855    /// - `ctx` must be a valid pointer.
856    /// - `exception` must be a valid pointer or null.
857    #[cfg(feature = "JSBase")]
858    pub fn JSBigIntCreateWithInt64(
859        ctx: JSContextRef,
860        integer: i64,
861        exception: *mut JSValueRef,
862    ) -> JSValueRef;
863}
864
865extern "C-unwind" {
866    /// Creates a JavaScript BigInt with a 64-bit unsigned integer.
867    ///
868    /// Parameter `ctx`: The execution context to use.
869    ///
870    /// Parameter `integer`: The 64-bit unsigned integer to copy into the new BigInt JSValue.
871    ///
872    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
873    ///
874    /// Returns: A BigInt JSValue of the integer, or NULL if an exception is thrown.
875    ///
876    /// # Safety
877    ///
878    /// - `ctx` must be a valid pointer.
879    /// - `exception` must be a valid pointer or null.
880    #[cfg(feature = "JSBase")]
881    pub fn JSBigIntCreateWithUInt64(
882        ctx: JSContextRef,
883        integer: u64,
884        exception: *mut JSValueRef,
885    ) -> JSValueRef;
886}
887
888extern "C-unwind" {
889    /// Creates a JavaScript BigInt with an integer represented in string.
890    ///
891    /// Parameter `ctx`: The execution context to use.
892    ///
893    /// Parameter `string`: The JSStringRef representation of an integer.
894    ///
895    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
896    ///
897    /// Returns: A BigInt JSValue of the string, or NULL if an exception is thrown.
898    ///
899    /// This is equivalent to calling the `BigInt` constructor from JavaScript with a string argument.
900    ///
901    /// # Safety
902    ///
903    /// - `ctx` must be a valid pointer.
904    /// - `string` must be a valid pointer.
905    /// - `exception` must be a valid pointer or null.
906    #[cfg(feature = "JSBase")]
907    pub fn JSBigIntCreateWithString(
908        ctx: JSContextRef,
909        string: JSStringRef,
910        exception: *mut JSValueRef,
911    ) -> JSValueRef;
912}
913
914#[cfg(all(feature = "JSValue", feature = "objc2"))]
915impl JSValue {
916    /// Creates a JavaScript value from a JSON formatted string.
917    ///
918    /// Parameter `ctx`: The execution context to use.
919    ///
920    /// Parameter `string`: The JSString containing the JSON string to be parsed.
921    ///
922    /// Returns: A JSValue containing the parsed value, or NULL if the input is invalid.
923    ///
924    /// # Safety
925    ///
926    /// - `ctx` must be a valid pointer.
927    /// - `string` must be a valid pointer.
928    #[doc(alias = "JSValueMakeFromJSONString")]
929    #[cfg(feature = "JSBase")]
930    #[inline]
931    pub unsafe fn from_json_string(ctx: JSContextRef, string: JSStringRef) -> JSValueRef {
932        extern "C-unwind" {
933            fn JSValueMakeFromJSONString(ctx: JSContextRef, string: JSStringRef) -> JSValueRef;
934        }
935        unsafe { JSValueMakeFromJSONString(ctx, string) }
936    }
937
938    /// Creates a JavaScript string containing the JSON serialized representation of a JS value.
939    ///
940    /// Parameter `ctx`: The execution context to use.
941    ///
942    /// Parameter `value`: The value to serialize.
943    ///
944    /// Parameter `indent`: The number of spaces to indent when nesting.  If 0, the resulting JSON will not contains newlines.  The size of the indent is clamped to 10 spaces.
945    ///
946    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
947    ///
948    /// Returns: A JSString with the result of serialization, or NULL if an exception is thrown.
949    ///
950    /// # Safety
951    ///
952    /// - `ctx` must be a valid pointer.
953    /// - `value` must be a valid pointer.
954    /// - `exception` must be a valid pointer.
955    #[doc(alias = "JSValueCreateJSONString")]
956    #[cfg(feature = "JSBase")]
957    #[inline]
958    pub unsafe fn create_json_string(
959        ctx: JSContextRef,
960        value: JSValueRef,
961        indent: c_uint,
962        exception: *mut JSValueRef,
963    ) -> JSStringRef {
964        extern "C-unwind" {
965            fn JSValueCreateJSONString(
966                ctx: JSContextRef,
967                value: JSValueRef,
968                indent: c_uint,
969                exception: *mut JSValueRef,
970            ) -> JSStringRef;
971        }
972        unsafe { JSValueCreateJSONString(ctx, value, indent, exception) }
973    }
974
975    /// Converts a JavaScript value to boolean and returns the resulting boolean.
976    ///
977    /// Parameter `ctx`: The execution context to use.
978    ///
979    /// Parameter `value`: The JSValue to convert.
980    ///
981    /// Returns: The boolean result of conversion.
982    ///
983    /// # Safety
984    ///
985    /// - `ctx` must be a valid pointer.
986    /// - `value` must be a valid pointer.
987    #[doc(alias = "JSValueToBoolean")]
988    #[cfg(feature = "JSBase")]
989    #[inline]
990    pub unsafe fn to_boolean(ctx: JSContextRef, value: JSValueRef) -> bool {
991        extern "C-unwind" {
992            fn JSValueToBoolean(ctx: JSContextRef, value: JSValueRef) -> bool;
993        }
994        unsafe { JSValueToBoolean(ctx, value) }
995    }
996
997    /// Converts a JavaScript value to number and returns the resulting number.
998    ///
999    /// Parameter `ctx`: The execution context to use.
1000    ///
1001    /// Parameter `value`: The JSValue to convert.
1002    ///
1003    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
1004    ///
1005    /// Returns: The numeric result of conversion, or NaN if an exception is thrown.
1006    ///
1007    /// The result is equivalent to `Number(value)` in JavaScript.
1008    ///
1009    /// # Safety
1010    ///
1011    /// - `ctx` must be a valid pointer.
1012    /// - `value` must be a valid pointer.
1013    /// - `exception` must be a valid pointer.
1014    #[doc(alias = "JSValueToNumber")]
1015    #[cfg(feature = "JSBase")]
1016    #[inline]
1017    pub unsafe fn to_number(
1018        ctx: JSContextRef,
1019        value: JSValueRef,
1020        exception: *mut JSValueRef,
1021    ) -> c_double {
1022        extern "C-unwind" {
1023            fn JSValueToNumber(
1024                ctx: JSContextRef,
1025                value: JSValueRef,
1026                exception: *mut JSValueRef,
1027            ) -> c_double;
1028        }
1029        unsafe { JSValueToNumber(ctx, value, exception) }
1030    }
1031
1032    /// Converts a JSValue to a singed 32-bit integer and returns the resulting integer.
1033    ///
1034    /// Parameter `ctx`: The execution context to use.
1035    ///
1036    /// Parameter `value`: The JSValue to convert.
1037    ///
1038    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
1039    ///
1040    /// Returns: An int32_t with the result of conversion, or 0 if an exception is thrown. Since 0 is valid value, `exception` must be checked after the call.
1041    ///
1042    /// The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the JSValue is truncated to an int32_t.
1043    ///
1044    /// # Safety
1045    ///
1046    /// - `ctx` must be a valid pointer.
1047    /// - `value` must be a valid pointer.
1048    /// - `exception` must be a valid pointer or null.
1049    #[doc(alias = "JSValueToInt32")]
1050    #[cfg(feature = "JSBase")]
1051    #[inline]
1052    pub unsafe fn to_int32(
1053        ctx: JSContextRef,
1054        value: JSValueRef,
1055        exception: *mut JSValueRef,
1056    ) -> i32 {
1057        extern "C-unwind" {
1058            fn JSValueToInt32(
1059                ctx: JSContextRef,
1060                value: JSValueRef,
1061                exception: *mut JSValueRef,
1062            ) -> i32;
1063        }
1064        unsafe { JSValueToInt32(ctx, value, exception) }
1065    }
1066
1067    /// Converts a JSValue to an unsigned 32-bit integer and returns the resulting integer.
1068    ///
1069    /// Parameter `ctx`: The execution context to use.
1070    ///
1071    /// Parameter `value`: The JSValue to convert.
1072    ///
1073    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
1074    ///
1075    /// Returns: A uint32_t with the result of conversion, or 0 if an exception is thrown. Since 0 is valid value, `exception` must be checked after the call.
1076    ///
1077    /// The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the JSValue is truncated to a uint32_t.
1078    ///
1079    /// # Safety
1080    ///
1081    /// - `ctx` must be a valid pointer.
1082    /// - `value` must be a valid pointer.
1083    /// - `exception` must be a valid pointer or null.
1084    #[doc(alias = "JSValueToUInt32")]
1085    #[cfg(feature = "JSBase")]
1086    #[inline]
1087    pub unsafe fn to_u_int32(
1088        ctx: JSContextRef,
1089        value: JSValueRef,
1090        exception: *mut JSValueRef,
1091    ) -> u32 {
1092        extern "C-unwind" {
1093            fn JSValueToUInt32(
1094                ctx: JSContextRef,
1095                value: JSValueRef,
1096                exception: *mut JSValueRef,
1097            ) -> u32;
1098        }
1099        unsafe { JSValueToUInt32(ctx, value, exception) }
1100    }
1101
1102    /// Converts a JSValue to a singed 64-bit integer and returns the resulting integer.
1103    ///
1104    /// Parameter `ctx`: The execution context to use.
1105    ///
1106    /// Parameter `value`: The JSValue to convert.
1107    ///
1108    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
1109    ///
1110    /// Returns: An int64_t with the result of conversion, or 0 if an exception is thrown. Since 0 is valid value, `exception` must be checked after the call.
1111    ///
1112    /// The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the JSValue is truncated to an int64_t.
1113    ///
1114    /// # Safety
1115    ///
1116    /// - `ctx` must be a valid pointer.
1117    /// - `value` must be a valid pointer.
1118    /// - `exception` must be a valid pointer or null.
1119    #[doc(alias = "JSValueToInt64")]
1120    #[cfg(feature = "JSBase")]
1121    #[inline]
1122    pub unsafe fn to_int64(
1123        ctx: JSContextRef,
1124        value: JSValueRef,
1125        exception: *mut JSValueRef,
1126    ) -> i64 {
1127        extern "C-unwind" {
1128            fn JSValueToInt64(
1129                ctx: JSContextRef,
1130                value: JSValueRef,
1131                exception: *mut JSValueRef,
1132            ) -> i64;
1133        }
1134        unsafe { JSValueToInt64(ctx, value, exception) }
1135    }
1136
1137    /// Converts a JSValue to an unsigned 64-bit integer and returns the resulting integer.
1138    ///
1139    /// Parameter `ctx`: The execution context to use.
1140    ///
1141    /// Parameter `value`: The JSValue to convert.
1142    ///
1143    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
1144    ///
1145    /// Returns: A uint64_t with the result of conversion, or 0 if an exception is thrown. Since 0 is valid value, `exception` must be checked after the call.
1146    ///
1147    /// The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the JSValue is truncated to a uint64_t.
1148    ///
1149    /// # Safety
1150    ///
1151    /// - `ctx` must be a valid pointer.
1152    /// - `value` must be a valid pointer.
1153    /// - `exception` must be a valid pointer or null.
1154    #[doc(alias = "JSValueToUInt64")]
1155    #[cfg(feature = "JSBase")]
1156    #[inline]
1157    pub unsafe fn to_u_int64(
1158        ctx: JSContextRef,
1159        value: JSValueRef,
1160        exception: *mut JSValueRef,
1161    ) -> u64 {
1162        extern "C-unwind" {
1163            fn JSValueToUInt64(
1164                ctx: JSContextRef,
1165                value: JSValueRef,
1166                exception: *mut JSValueRef,
1167            ) -> u64;
1168        }
1169        unsafe { JSValueToUInt64(ctx, value, exception) }
1170    }
1171
1172    /// Converts a JavaScript value to string and copies the result into a JavaScript string.
1173    ///
1174    /// Parameter `ctx`: The execution context to use.
1175    ///
1176    /// Parameter `value`: The JSValue to convert.
1177    ///
1178    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
1179    ///
1180    /// Returns: A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule.
1181    ///
1182    /// # Safety
1183    ///
1184    /// - `ctx` must be a valid pointer.
1185    /// - `value` must be a valid pointer.
1186    /// - `exception` must be a valid pointer.
1187    #[doc(alias = "JSValueToStringCopy")]
1188    #[cfg(feature = "JSBase")]
1189    #[inline]
1190    pub unsafe fn to_string_copy(
1191        ctx: JSContextRef,
1192        value: JSValueRef,
1193        exception: *mut JSValueRef,
1194    ) -> JSStringRef {
1195        extern "C-unwind" {
1196            fn JSValueToStringCopy(
1197                ctx: JSContextRef,
1198                value: JSValueRef,
1199                exception: *mut JSValueRef,
1200            ) -> JSStringRef;
1201        }
1202        unsafe { JSValueToStringCopy(ctx, value, exception) }
1203    }
1204
1205    /// Converts a JavaScript value to object and returns the resulting object.
1206    ///
1207    /// Parameter `ctx`: The execution context to use.
1208    ///
1209    /// Parameter `value`: The JSValue to convert.
1210    ///
1211    /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. To reliable detect exception, initialize this to null before the call. Pass NULL if you do not care to store an exception.
1212    ///
1213    /// Returns: The JSObject result of conversion, or NULL if an exception is thrown.
1214    ///
1215    /// # Safety
1216    ///
1217    /// - `ctx` must be a valid pointer.
1218    /// - `value` must be a valid pointer.
1219    /// - `exception` must be a valid pointer.
1220    #[doc(alias = "JSValueToObject")]
1221    #[cfg(feature = "JSBase")]
1222    #[inline]
1223    pub unsafe fn to_object(
1224        ctx: JSContextRef,
1225        value: JSValueRef,
1226        exception: *mut JSValueRef,
1227    ) -> JSObjectRef {
1228        extern "C-unwind" {
1229            fn JSValueToObject(
1230                ctx: JSContextRef,
1231                value: JSValueRef,
1232                exception: *mut JSValueRef,
1233            ) -> JSObjectRef;
1234        }
1235        unsafe { JSValueToObject(ctx, value, exception) }
1236    }
1237
1238    /// Protects a JavaScript value from garbage collection.
1239    ///
1240    /// Parameter `ctx`: The execution context to use.
1241    ///
1242    /// Parameter `value`: The JSValue to protect.
1243    ///
1244    /// Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it.
1245    ///
1246    /// A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection.
1247    ///
1248    /// # Safety
1249    ///
1250    /// - `ctx` must be a valid pointer.
1251    /// - `value` must be a valid pointer.
1252    #[doc(alias = "JSValueProtect")]
1253    #[cfg(feature = "JSBase")]
1254    #[inline]
1255    pub unsafe fn protect(ctx: JSContextRef, value: JSValueRef) {
1256        extern "C-unwind" {
1257            fn JSValueProtect(ctx: JSContextRef, value: JSValueRef);
1258        }
1259        unsafe { JSValueProtect(ctx, value) }
1260    }
1261
1262    /// Unprotects a JavaScript value from garbage collection.
1263    ///
1264    /// Parameter `ctx`: The execution context to use.
1265    ///
1266    /// Parameter `value`: The JSValue to unprotect.
1267    ///
1268    /// A value may be protected multiple times and must be unprotected an
1269    /// equal number of times before becoming eligible for garbage collection.
1270    ///
1271    /// # Safety
1272    ///
1273    /// - `ctx` must be a valid pointer.
1274    /// - `value` must be a valid pointer.
1275    #[doc(alias = "JSValueUnprotect")]
1276    #[cfg(feature = "JSBase")]
1277    #[inline]
1278    pub unsafe fn unprotect(ctx: JSContextRef, value: JSValueRef) {
1279        extern "C-unwind" {
1280            fn JSValueUnprotect(ctx: JSContextRef, value: JSValueRef);
1281        }
1282        unsafe { JSValueUnprotect(ctx, value) }
1283    }
1284}
1285
1286extern "C-unwind" {
1287    #[cfg(feature = "JSBase")]
1288    #[deprecated = "renamed to `JSValue::type`"]
1289    pub fn JSValueGetType(ctx: JSContextRef, value: JSValueRef) -> JSType;
1290}
1291
1292extern "C-unwind" {
1293    #[cfg(feature = "JSBase")]
1294    #[deprecated = "renamed to `JSValue::is_undefined`"]
1295    pub fn JSValueIsUndefined(ctx: JSContextRef, value: JSValueRef) -> bool;
1296}
1297
1298extern "C-unwind" {
1299    #[cfg(feature = "JSBase")]
1300    #[deprecated = "renamed to `JSValue::is_null`"]
1301    pub fn JSValueIsNull(ctx: JSContextRef, value: JSValueRef) -> bool;
1302}
1303
1304extern "C-unwind" {
1305    #[cfg(feature = "JSBase")]
1306    #[deprecated = "renamed to `JSValue::is_boolean`"]
1307    pub fn JSValueIsBoolean(ctx: JSContextRef, value: JSValueRef) -> bool;
1308}
1309
1310extern "C-unwind" {
1311    #[cfg(feature = "JSBase")]
1312    #[deprecated = "renamed to `JSValue::is_number`"]
1313    pub fn JSValueIsNumber(ctx: JSContextRef, value: JSValueRef) -> bool;
1314}
1315
1316extern "C-unwind" {
1317    #[cfg(feature = "JSBase")]
1318    #[deprecated = "renamed to `JSValue::is_string`"]
1319    pub fn JSValueIsString(ctx: JSContextRef, value: JSValueRef) -> bool;
1320}
1321
1322extern "C-unwind" {
1323    #[cfg(feature = "JSBase")]
1324    #[deprecated = "renamed to `JSValue::is_symbol`"]
1325    pub fn JSValueIsSymbol(ctx: JSContextRef, value: JSValueRef) -> bool;
1326}
1327
1328extern "C-unwind" {
1329    #[cfg(feature = "JSBase")]
1330    #[deprecated = "renamed to `JSValue::is_big_int`"]
1331    pub fn JSValueIsBigInt(ctx: JSContextRef, value: JSValueRef) -> bool;
1332}
1333
1334extern "C-unwind" {
1335    #[cfg(feature = "JSBase")]
1336    #[deprecated = "renamed to `JSValue::is_object`"]
1337    pub fn JSValueIsObject(ctx: JSContextRef, value: JSValueRef) -> bool;
1338}
1339
1340extern "C-unwind" {
1341    #[cfg(feature = "JSBase")]
1342    #[deprecated = "renamed to `JSValue::is_object_of_class`"]
1343    pub fn JSValueIsObjectOfClass(
1344        ctx: JSContextRef,
1345        value: JSValueRef,
1346        js_class: JSClassRef,
1347    ) -> bool;
1348}
1349
1350extern "C-unwind" {
1351    #[cfg(feature = "JSBase")]
1352    #[deprecated = "renamed to `JSValue::is_array`"]
1353    pub fn JSValueIsArray(ctx: JSContextRef, value: JSValueRef) -> bool;
1354}
1355
1356extern "C-unwind" {
1357    #[cfg(feature = "JSBase")]
1358    #[deprecated = "renamed to `JSValue::is_date`"]
1359    pub fn JSValueIsDate(ctx: JSContextRef, value: JSValueRef) -> bool;
1360}
1361
1362extern "C-unwind" {
1363    #[cfg(feature = "JSBase")]
1364    #[deprecated = "renamed to `JSValue::typed_array_type`"]
1365    pub fn JSValueGetTypedArrayType(
1366        ctx: JSContextRef,
1367        value: JSValueRef,
1368        exception: *mut JSValueRef,
1369    ) -> JSTypedArrayType;
1370}
1371
1372extern "C-unwind" {
1373    #[cfg(feature = "JSBase")]
1374    #[deprecated = "renamed to `JSValue::is_equal`"]
1375    pub fn JSValueIsEqual(
1376        ctx: JSContextRef,
1377        a: JSValueRef,
1378        b: JSValueRef,
1379        exception: *mut JSValueRef,
1380    ) -> bool;
1381}
1382
1383extern "C-unwind" {
1384    #[cfg(feature = "JSBase")]
1385    #[deprecated = "renamed to `JSValue::is_strict_equal`"]
1386    pub fn JSValueIsStrictEqual(ctx: JSContextRef, a: JSValueRef, b: JSValueRef) -> bool;
1387}
1388
1389extern "C-unwind" {
1390    #[cfg(feature = "JSBase")]
1391    #[deprecated = "renamed to `JSValue::is_instance_of_constructor`"]
1392    pub fn JSValueIsInstanceOfConstructor(
1393        ctx: JSContextRef,
1394        value: JSValueRef,
1395        constructor: JSObjectRef,
1396        exception: *mut JSValueRef,
1397    ) -> bool;
1398}
1399
1400extern "C-unwind" {
1401    #[cfg(feature = "JSBase")]
1402    #[deprecated = "renamed to `JSValue::compare`"]
1403    pub fn JSValueCompare(
1404        ctx: JSContextRef,
1405        left: JSValueRef,
1406        right: JSValueRef,
1407        exception: *mut JSValueRef,
1408    ) -> JSRelationCondition;
1409}
1410
1411extern "C-unwind" {
1412    #[cfg(feature = "JSBase")]
1413    #[deprecated = "renamed to `JSValue::compare_int64`"]
1414    pub fn JSValueCompareInt64(
1415        ctx: JSContextRef,
1416        left: JSValueRef,
1417        right: i64,
1418        exception: *mut JSValueRef,
1419    ) -> JSRelationCondition;
1420}
1421
1422extern "C-unwind" {
1423    #[cfg(feature = "JSBase")]
1424    #[deprecated = "renamed to `JSValue::compare_u_int64`"]
1425    pub fn JSValueCompareUInt64(
1426        ctx: JSContextRef,
1427        left: JSValueRef,
1428        right: u64,
1429        exception: *mut JSValueRef,
1430    ) -> JSRelationCondition;
1431}
1432
1433extern "C-unwind" {
1434    #[cfg(feature = "JSBase")]
1435    #[deprecated = "renamed to `JSValue::compare_double`"]
1436    pub fn JSValueCompareDouble(
1437        ctx: JSContextRef,
1438        left: JSValueRef,
1439        right: c_double,
1440        exception: *mut JSValueRef,
1441    ) -> JSRelationCondition;
1442}
1443
1444extern "C-unwind" {
1445    #[cfg(feature = "JSBase")]
1446    #[deprecated = "renamed to `JSValue::new_undefined`"]
1447    pub fn JSValueMakeUndefined(ctx: JSContextRef) -> JSValueRef;
1448}
1449
1450extern "C-unwind" {
1451    #[cfg(feature = "JSBase")]
1452    #[deprecated = "renamed to `JSValue::new_null`"]
1453    pub fn JSValueMakeNull(ctx: JSContextRef) -> JSValueRef;
1454}
1455
1456extern "C-unwind" {
1457    #[cfg(feature = "JSBase")]
1458    #[deprecated = "renamed to `JSValue::new_boolean`"]
1459    pub fn JSValueMakeBoolean(ctx: JSContextRef, boolean: bool) -> JSValueRef;
1460}
1461
1462extern "C-unwind" {
1463    #[cfg(feature = "JSBase")]
1464    #[deprecated = "renamed to `JSValue::new_number`"]
1465    pub fn JSValueMakeNumber(ctx: JSContextRef, number: c_double) -> JSValueRef;
1466}
1467
1468extern "C-unwind" {
1469    #[cfg(feature = "JSBase")]
1470    #[deprecated = "renamed to `JSValue::new_string`"]
1471    pub fn JSValueMakeString(ctx: JSContextRef, string: JSStringRef) -> JSValueRef;
1472}
1473
1474extern "C-unwind" {
1475    #[cfg(feature = "JSBase")]
1476    #[deprecated = "renamed to `JSValue::new_symbol`"]
1477    pub fn JSValueMakeSymbol(ctx: JSContextRef, description: JSStringRef) -> JSValueRef;
1478}
1479
1480extern "C-unwind" {
1481    #[cfg(feature = "JSBase")]
1482    #[deprecated = "renamed to `JSValue::from_json_string`"]
1483    pub fn JSValueMakeFromJSONString(ctx: JSContextRef, string: JSStringRef) -> JSValueRef;
1484}
1485
1486extern "C-unwind" {
1487    #[cfg(feature = "JSBase")]
1488    #[deprecated = "renamed to `JSValue::create_json_string`"]
1489    pub fn JSValueCreateJSONString(
1490        ctx: JSContextRef,
1491        value: JSValueRef,
1492        indent: c_uint,
1493        exception: *mut JSValueRef,
1494    ) -> JSStringRef;
1495}
1496
1497extern "C-unwind" {
1498    #[cfg(feature = "JSBase")]
1499    #[deprecated = "renamed to `JSValue::to_boolean`"]
1500    pub fn JSValueToBoolean(ctx: JSContextRef, value: JSValueRef) -> bool;
1501}
1502
1503extern "C-unwind" {
1504    #[cfg(feature = "JSBase")]
1505    #[deprecated = "renamed to `JSValue::to_number`"]
1506    pub fn JSValueToNumber(
1507        ctx: JSContextRef,
1508        value: JSValueRef,
1509        exception: *mut JSValueRef,
1510    ) -> c_double;
1511}
1512
1513extern "C-unwind" {
1514    #[cfg(feature = "JSBase")]
1515    #[deprecated = "renamed to `JSValue::to_int32`"]
1516    pub fn JSValueToInt32(ctx: JSContextRef, value: JSValueRef, exception: *mut JSValueRef) -> i32;
1517}
1518
1519extern "C-unwind" {
1520    #[cfg(feature = "JSBase")]
1521    #[deprecated = "renamed to `JSValue::to_u_int32`"]
1522    pub fn JSValueToUInt32(ctx: JSContextRef, value: JSValueRef, exception: *mut JSValueRef)
1523        -> u32;
1524}
1525
1526extern "C-unwind" {
1527    #[cfg(feature = "JSBase")]
1528    #[deprecated = "renamed to `JSValue::to_int64`"]
1529    pub fn JSValueToInt64(ctx: JSContextRef, value: JSValueRef, exception: *mut JSValueRef) -> i64;
1530}
1531
1532extern "C-unwind" {
1533    #[cfg(feature = "JSBase")]
1534    #[deprecated = "renamed to `JSValue::to_u_int64`"]
1535    pub fn JSValueToUInt64(ctx: JSContextRef, value: JSValueRef, exception: *mut JSValueRef)
1536        -> u64;
1537}
1538
1539extern "C-unwind" {
1540    #[cfg(feature = "JSBase")]
1541    #[deprecated = "renamed to `JSValue::to_string_copy`"]
1542    pub fn JSValueToStringCopy(
1543        ctx: JSContextRef,
1544        value: JSValueRef,
1545        exception: *mut JSValueRef,
1546    ) -> JSStringRef;
1547}
1548
1549extern "C-unwind" {
1550    #[cfg(feature = "JSBase")]
1551    #[deprecated = "renamed to `JSValue::to_object`"]
1552    pub fn JSValueToObject(
1553        ctx: JSContextRef,
1554        value: JSValueRef,
1555        exception: *mut JSValueRef,
1556    ) -> JSObjectRef;
1557}
1558
1559extern "C-unwind" {
1560    #[cfg(feature = "JSBase")]
1561    #[deprecated = "renamed to `JSValue::protect`"]
1562    pub fn JSValueProtect(ctx: JSContextRef, value: JSValueRef);
1563}
1564
1565extern "C-unwind" {
1566    #[cfg(feature = "JSBase")]
1567    #[deprecated = "renamed to `JSValue::unprotect`"]
1568    pub fn JSValueUnprotect(ctx: JSContextRef, value: JSValueRef);
1569}