objc2_javascript_core/generated/
JSValue.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7#[cfg(feature = "objc2-core-foundation")]
8use objc2_core_foundation::*;
9#[cfg(feature = "objc2-foundation")]
10use objc2_foundation::*;
11
12use crate::*;
13
14#[cfg(feature = "objc2")]
15extern_class!(
16    /// A JSValue is a reference to a JavaScript value. Every JSValue
17    /// originates from a JSContext and holds a strong reference to it.
18    /// When a JSValue instance method creates a new JSValue, the new value
19    /// originates from the same JSContext.
20    ///
21    /// All JSValues values also originate from a JSVirtualMachine
22    /// (available indirectly via the context property). It is an error to pass a
23    /// JSValue to a method or property of a JSValue or JSContext originating from a
24    /// different JSVirtualMachine. Doing so will raise an Objective-C exception.
25    ///
26    /// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsvalue?language=objc)
27    #[unsafe(super(NSObject))]
28    #[derive(Debug, PartialEq, Eq, Hash)]
29    #[cfg(feature = "objc2")]
30    pub struct JSValue;
31);
32
33#[cfg(feature = "objc2")]
34extern_conformance!(
35    unsafe impl NSObjectProtocol for JSValue {}
36);
37
38#[cfg(feature = "objc2")]
39impl JSValue {
40    extern_methods!(
41        #[cfg(feature = "JSContext")]
42        /// The JSContext that this value originates from.
43        #[unsafe(method(context))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn context(&self) -> Option<Retained<JSContext>>;
46
47        #[cfg(feature = "JSContext")]
48        /// Create a JSValue by converting an Objective-C object.
49        ///
50        /// The resulting JSValue retains the provided Objective-C object.
51        ///
52        /// Parameter `value`: The Objective-C object to be converted.
53        ///
54        /// Returns: The new JSValue.
55        #[unsafe(method(valueWithObject:inContext:))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn valueWithObject_inContext(
58            value: Option<&AnyObject>,
59            context: Option<&JSContext>,
60        ) -> Option<Retained<JSValue>>;
61
62        #[cfg(feature = "JSContext")]
63        /// Create a JavaScript value from a BOOL primitive.
64        ///
65        /// Parameter `context`: The JSContext in which the resulting JSValue will be created.
66        ///
67        /// Returns: The new JSValue representing the equivalent boolean value.
68        #[unsafe(method(valueWithBool:inContext:))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn valueWithBool_inContext(
71            value: bool,
72            context: Option<&JSContext>,
73        ) -> Option<Retained<JSValue>>;
74
75        #[cfg(feature = "JSContext")]
76        /// Create a JavaScript value from a double primitive.
77        ///
78        /// Parameter `context`: The JSContext in which the resulting JSValue will be created.
79        ///
80        /// Returns: The new JSValue representing the equivalent boolean value.
81        #[unsafe(method(valueWithDouble:inContext:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn valueWithDouble_inContext(
84            value: c_double,
85            context: Option<&JSContext>,
86        ) -> Option<Retained<JSValue>>;
87
88        #[cfg(feature = "JSContext")]
89        /// Create a JavaScript value from an
90        /// <code>
91        /// int32_t
92        /// </code>
93        /// primitive.
94        ///
95        /// Parameter `context`: The JSContext in which the resulting JSValue will be created.
96        ///
97        /// Returns: The new JSValue representing the equivalent boolean value.
98        #[unsafe(method(valueWithInt32:inContext:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn valueWithInt32_inContext(
101            value: i32,
102            context: Option<&JSContext>,
103        ) -> Option<Retained<JSValue>>;
104
105        #[cfg(feature = "JSContext")]
106        /// Create a JavaScript value from a
107        /// <code>
108        /// uint32_t
109        /// </code>
110        /// primitive.
111        ///
112        /// Parameter `context`: The JSContext in which the resulting JSValue will be created.
113        ///
114        /// Returns: The new JSValue representing the equivalent boolean value.
115        #[unsafe(method(valueWithUInt32:inContext:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn valueWithUInt32_inContext(
118            value: u32,
119            context: Option<&JSContext>,
120        ) -> Option<Retained<JSValue>>;
121
122        #[cfg(feature = "JSContext")]
123        /// Create a new, empty JavaScript object.
124        ///
125        /// Parameter `context`: The JSContext in which the resulting object will be created.
126        ///
127        /// Returns: The new JavaScript object.
128        #[unsafe(method(valueWithNewObjectInContext:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn valueWithNewObjectInContext(
131            context: Option<&JSContext>,
132        ) -> Option<Retained<JSValue>>;
133
134        #[cfg(feature = "JSContext")]
135        /// Create a new, empty JavaScript array.
136        ///
137        /// Parameter `context`: The JSContext in which the resulting array will be created.
138        ///
139        /// Returns: The new JavaScript array.
140        #[unsafe(method(valueWithNewArrayInContext:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn valueWithNewArrayInContext(
143            context: Option<&JSContext>,
144        ) -> Option<Retained<JSValue>>;
145
146        #[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
147        /// Create a new JavaScript regular expression object.
148        ///
149        /// Parameter `pattern`: The regular expression pattern.
150        ///
151        /// Parameter `flags`: The regular expression flags.
152        ///
153        /// Parameter `context`: The JSContext in which the resulting regular expression object will be created.
154        ///
155        /// Returns: The new JavaScript regular expression object.
156        #[unsafe(method(valueWithNewRegularExpressionFromPattern:flags:inContext:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn valueWithNewRegularExpressionFromPattern_flags_inContext(
159            pattern: Option<&NSString>,
160            flags: Option<&NSString>,
161            context: Option<&JSContext>,
162        ) -> Option<Retained<JSValue>>;
163
164        #[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
165        /// Create a new JavaScript error object.
166        ///
167        /// Parameter `message`: The error message.
168        ///
169        /// Parameter `context`: The JSContext in which the resulting error object will be created.
170        ///
171        /// Returns: The new JavaScript error object.
172        #[unsafe(method(valueWithNewErrorFromMessage:inContext:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn valueWithNewErrorFromMessage_inContext(
175            message: Option<&NSString>,
176            context: Option<&JSContext>,
177        ) -> Option<Retained<JSValue>>;
178
179        #[cfg(all(feature = "JSContext", feature = "block2"))]
180        /// Create a new promise object using the provided executor callback.
181        ///
182        /// Parameter `callback`: A callback block invoked while the promise object is being initialized. The resolve and reject parameters are functions that can be called to notify any pending reactions about the state of the new promise object.
183        ///
184        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
185        ///
186        /// Returns: The JSValue representing a new promise JavaScript object.
187        ///
188        /// This method is equivalent to calling the Promise constructor in JavaScript. the resolve and reject callbacks each normally take a single value, which they forward to all relevent pending reactions. While inside the executor callback context will act as if it were in any other callback, except calleeFunction will be
189        /// <code>
190        /// nil
191        /// </code>
192        /// . This also means means the new promise object may be accessed via
193        /// <code>
194        /// [context thisValue]
195        /// </code>
196        /// .
197        #[unsafe(method(valueWithNewPromiseInContext:fromExecutor:))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn valueWithNewPromiseInContext_fromExecutor(
200            context: Option<&JSContext>,
201            callback: Option<&block2::DynBlock<dyn Fn(*mut JSValue, *mut JSValue)>>,
202        ) -> Option<Retained<JSValue>>;
203
204        #[cfg(feature = "JSContext")]
205        /// Create a new resolved promise object with the provided value.
206        ///
207        /// Parameter `result`: The result value to be passed to any reactions.
208        ///
209        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
210        ///
211        /// Returns: The JSValue representing a new promise JavaScript object.
212        ///
213        /// This method is equivalent to calling
214        /// <code>
215        /// [JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [resolve callWithArguments:
216        /// @
217        /// [result]]; } inContext:context]
218        /// </code>
219        #[unsafe(method(valueWithNewPromiseResolvedWithResult:inContext:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn valueWithNewPromiseResolvedWithResult_inContext(
222            result: Option<&AnyObject>,
223            context: Option<&JSContext>,
224        ) -> Option<Retained<JSValue>>;
225
226        #[cfg(feature = "JSContext")]
227        /// Create a new rejected promise object with the provided value.
228        ///
229        /// Parameter `reason`: The result value to be passed to any reactions.
230        ///
231        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
232        ///
233        /// Returns: The JSValue representing a new promise JavaScript object.
234        ///
235        /// This method is equivalent to calling
236        /// <code>
237        /// [JSValue valueWithNewPromiseFromExecutor:^(JSValue *resolve, JSValue *reject) { [reject callWithArguments:
238        /// @
239        /// [reason]]; } inContext:context]
240        /// </code>
241        #[unsafe(method(valueWithNewPromiseRejectedWithReason:inContext:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn valueWithNewPromiseRejectedWithReason_inContext(
244            reason: Option<&AnyObject>,
245            context: Option<&JSContext>,
246        ) -> Option<Retained<JSValue>>;
247
248        #[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
249        /// Create a new, unique, symbol object.
250        ///
251        /// Parameter `description`: The description of the symbol object being created.
252        ///
253        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
254        ///
255        /// Returns: The JSValue representing a unique JavaScript value with type symbol.
256        #[unsafe(method(valueWithNewSymbolFromDescription:inContext:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn valueWithNewSymbolFromDescription_inContext(
259            description: Option<&NSString>,
260            context: Option<&JSContext>,
261        ) -> Option<Retained<JSValue>>;
262
263        #[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
264        /// Create a new BigInt value from a numeric string.
265        ///
266        /// Parameter `string`: The string representation of the BigInt JavaScript value being created.
267        ///
268        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
269        ///
270        /// Returns: The JSValue representing a JavaScript value with type BigInt.
271        ///
272        /// This is equivalent to calling the
273        /// <code>
274        /// BigInt
275        /// </code>
276        /// constructor from JavaScript with a string argument.
277        #[unsafe(method(valueWithNewBigIntFromString:inContext:))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn valueWithNewBigIntFromString_inContext(
280            string: &NSString,
281            context: &JSContext,
282        ) -> Option<Retained<JSValue>>;
283
284        #[cfg(feature = "JSContext")]
285        /// Create a new BigInt value from a
286        /// <code>
287        /// int64_t
288        /// </code>
289        /// .
290        ///
291        /// Parameter `int64`: The signed 64-bit integer of the BigInt JavaScript value being created.
292        ///
293        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
294        ///
295        /// Returns: The JSValue representing a JavaScript value with type BigInt.
296        #[unsafe(method(valueWithNewBigIntFromInt64:inContext:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn valueWithNewBigIntFromInt64_inContext(
299            int64: i64,
300            context: &JSContext,
301        ) -> Option<Retained<JSValue>>;
302
303        #[cfg(feature = "JSContext")]
304        /// Create a new BigInt value from a
305        /// <code>
306        /// uint64_t
307        /// </code>
308        /// .
309        ///
310        /// Parameter `uint64`: The unsigned 64-bit integer of the BigInt JavaScript value being created.
311        ///
312        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
313        ///
314        /// Returns: The JSValue representing a JavaScript value with type BigInt.
315        #[unsafe(method(valueWithNewBigIntFromUInt64:inContext:))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn valueWithNewBigIntFromUInt64_inContext(
318            uint64: u64,
319            context: &JSContext,
320        ) -> Option<Retained<JSValue>>;
321
322        #[cfg(feature = "JSContext")]
323        /// Create a new BigInt value from a double.
324        ///
325        /// Parameter `value`: The value of the BigInt JavaScript value being created.
326        ///
327        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
328        ///
329        /// Returns: The JSValue representing a JavaScript value with type BigInt.
330        ///
331        /// If the value is not an integer, an exception is thrown.
332        #[unsafe(method(valueWithNewBigIntFromDouble:inContext:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn valueWithNewBigIntFromDouble_inContext(
335            value: c_double,
336            context: &JSContext,
337        ) -> Option<Retained<JSValue>>;
338
339        #[cfg(feature = "JSContext")]
340        /// Create the JavaScript value
341        /// <code>
342        /// null
343        /// </code>
344        /// .
345        ///
346        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
347        ///
348        /// Returns: The JSValue representing the JavaScript value
349        /// <code>
350        /// null
351        /// </code>
352        /// .
353        #[unsafe(method(valueWithNullInContext:))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn valueWithNullInContext(
356            context: Option<&JSContext>,
357        ) -> Option<Retained<JSValue>>;
358
359        #[cfg(feature = "JSContext")]
360        /// Create the JavaScript value
361        /// <code>
362        /// undefined
363        /// </code>
364        /// .
365        ///
366        /// Parameter `context`: The JSContext to which the resulting JSValue belongs.
367        ///
368        /// Returns: The JSValue representing the JavaScript value
369        /// <code>
370        /// undefined
371        /// </code>
372        /// .
373        #[unsafe(method(valueWithUndefinedInContext:))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn valueWithUndefinedInContext(
376            context: Option<&JSContext>,
377        ) -> Option<Retained<JSValue>>;
378
379        /// When converting between JavaScript values and Objective-C objects a copy is
380        /// performed. Values of types listed below are copied to the corresponding
381        /// types on conversion in each direction. For NSDictionaries, entries in the
382        /// dictionary that are keyed by strings are copied onto a JavaScript object.
383        /// For dictionaries and arrays, conversion is recursive, with the same object
384        /// conversion being applied to all entries in the collection.
385        ///
386        /// <pre>
387        ///
388        /// ```text
389        ///    Objective-C type  |   JavaScript type
390        ///  --------------------+---------------------
391        ///          nil         |     undefined
392        ///         NSNull       |        null
393        ///        NSString      |       string
394        ///        NSNumber      |   number, boolean
395        ///      NSDictionary    |   Object object
396        ///        NSArray       |    Array object
397        ///         NSDate       |     Date object
398        ///        NSBlock (1)   |   Function object (1)
399        ///           id (2)     |   Wrapper object (2)
400        ///         Class (3)    | Constructor object (3)
401        /// ```
402        ///
403        /// </pre>
404        ///
405        /// (1) Instances of NSBlock with supported arguments types will be presented to
406        /// JavaScript as a callable Function object. For more information on supported
407        /// argument types see JSExport.h. If a JavaScript Function originating from an
408        /// Objective-C block is converted back to an Objective-C object the block will
409        /// be returned. All other JavaScript functions will be converted in the same
410        /// manner as a JavaScript object of type Object.
411        ///
412        /// (2) For Objective-C instances that do not derive from the set of types listed
413        /// above, a wrapper object to provide a retaining handle to the Objective-C
414        /// instance from JavaScript. For more information on these wrapper objects, see
415        /// JSExport.h. When a JavaScript wrapper object is converted back to Objective-C
416        /// the Objective-C instance being retained by the wrapper is returned.
417        ///
418        /// (3) For Objective-C Class objects a constructor object containing exported
419        /// class methods will be returned. See JSExport.h for more information on
420        /// constructor objects.
421        ///
422        /// For all methods taking arguments of type id, arguments will be converted
423        /// into a JavaScript value according to the above conversion.
424        ///
425        /// Convert this JSValue to an Objective-C object.
426        ///
427        /// The JSValue is converted to an Objective-C object according
428        /// to the conversion rules specified above.
429        ///
430        /// Returns: The Objective-C representation of this JSValue.
431        #[unsafe(method(toObject))]
432        #[unsafe(method_family = none)]
433        pub unsafe fn toObject(&self) -> Option<Retained<AnyObject>>;
434
435        /// Convert a JSValue to an Objective-C object of a specific class.
436        ///
437        /// The JSValue is converted to an Objective-C object of the specified Class.
438        /// If the result is not of the specified Class then
439        /// <code>
440        /// nil
441        /// </code>
442        /// will be returned.
443        ///
444        /// Returns: An Objective-C object of the specified Class or
445        /// <code>
446        /// nil
447        /// </code>
448        /// .
449        #[unsafe(method(toObjectOfClass:))]
450        #[unsafe(method_family = none)]
451        pub unsafe fn toObjectOfClass(
452            &self,
453            expected_class: Option<&AnyClass>,
454        ) -> Option<Retained<AnyObject>>;
455
456        /// Convert a JSValue to a boolean.
457        ///
458        /// The JSValue is converted to a boolean according to the rules specified
459        /// by the JavaScript language.
460        ///
461        /// Returns: The boolean result of the conversion.
462        #[unsafe(method(toBool))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn toBool(&self) -> bool;
465
466        /// Convert a JSValue to a double.
467        ///
468        /// Returns: The double result of the conversion.
469        ///
470        /// Convert the JSValue to a number according to the rules specified by the JavaScript language. Unless the JSValue is a BigInt then this is equivalent to
471        /// <code>
472        /// Number(value)
473        /// </code>
474        /// in JavaScript.
475        #[unsafe(method(toDouble))]
476        #[unsafe(method_family = none)]
477        pub unsafe fn toDouble(&self) -> c_double;
478
479        /// Convert a JSValue to an
480        /// <code>
481        /// int32_t
482        /// </code>
483        /// .
484        ///
485        /// The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the JSValue is a BigInt, then the value is truncated to an
486        /// <code>
487        /// int32_t
488        /// </code>
489        /// .
490        ///
491        /// Returns: The
492        /// <code>
493        /// int32_t
494        /// </code>
495        /// result of the conversion.
496        #[unsafe(method(toInt32))]
497        #[unsafe(method_family = none)]
498        pub unsafe fn toInt32(&self) -> i32;
499
500        /// Convert a JSValue to a
501        /// <code>
502        /// uint32_t
503        /// </code>
504        /// .
505        ///
506        /// The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the JSValue is a BigInt, then the value is truncated to a
507        /// <code>
508        /// uint32_t
509        /// </code>
510        /// .
511        ///
512        /// Returns: The
513        /// <code>
514        /// uint32_t
515        /// </code>
516        /// result of the conversion.
517        #[unsafe(method(toUInt32))]
518        #[unsafe(method_family = none)]
519        pub unsafe fn toUInt32(&self) -> u32;
520
521        /// Convert a JSValue to a
522        /// <code>
523        /// int64_t
524        /// </code>
525        /// .
526        ///
527        /// The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the value is truncated to an
528        /// <code>
529        /// int64_t
530        /// </code>
531        /// .
532        #[unsafe(method(toInt64))]
533        #[unsafe(method_family = none)]
534        pub unsafe fn toInt64(&self) -> i64;
535
536        /// Convert a JSValue to a
537        /// <code>
538        /// uint64_t
539        /// </code>
540        /// .
541        ///
542        /// The JSValue is converted to an integer according to the rules specified by the JavaScript language. If the value is a BigInt, then the value is truncated to a
543        /// <code>
544        /// uint64_t
545        /// </code>
546        /// .
547        #[unsafe(method(toUInt64))]
548        #[unsafe(method_family = none)]
549        pub unsafe fn toUInt64(&self) -> u64;
550
551        #[cfg(feature = "objc2-foundation")]
552        /// Convert a JSValue to a NSNumber.
553        ///
554        /// If the JSValue represents a boolean, a NSNumber value of YES or NO
555        /// will be returned. For all other types, the result is equivalent to
556        /// <code>
557        /// Number(value)
558        /// </code>
559        /// in JavaScript.
560        ///
561        /// Returns: The NSNumber result of the conversion.
562        #[unsafe(method(toNumber))]
563        #[unsafe(method_family = none)]
564        pub unsafe fn toNumber(&self) -> Option<Retained<NSNumber>>;
565
566        #[cfg(feature = "objc2-foundation")]
567        /// Convert a JSValue to a NSString.
568        ///
569        /// The JSValue is converted to a string according to the rules specified
570        /// by the JavaScript language.
571        ///
572        /// Returns: The NSString containing the result of the conversion.
573        #[unsafe(method(toString))]
574        #[unsafe(method_family = none)]
575        pub unsafe fn toString(&self) -> Option<Retained<NSString>>;
576
577        #[cfg(feature = "objc2-foundation")]
578        /// Convert a JSValue to a NSDate.
579        ///
580        /// The value is converted to a number representing a time interval
581        /// since 1970 which is then used to create a new NSDate instance.
582        ///
583        /// Returns: The NSDate created using the converted time interval.
584        #[unsafe(method(toDate))]
585        #[unsafe(method_family = none)]
586        pub unsafe fn toDate(&self) -> Option<Retained<NSDate>>;
587
588        #[cfg(feature = "objc2-foundation")]
589        /// Convert a JSValue to a NSArray.
590        ///
591        /// If the value is
592        /// <code>
593        /// null
594        /// </code>
595        /// or
596        /// <code>
597        /// undefined
598        /// </code>
599        /// then
600        /// <code>
601        /// nil
602        /// </code>
603        /// is returned.
604        /// If the value is not an object then a JavaScript TypeError will be thrown.
605        /// The property
606        /// <code>
607        /// length
608        /// </code>
609        /// is read from the object, converted to an unsigned
610        /// integer, and an NSArray of this size is allocated. Properties corresponding
611        /// to indices within the array bounds will be copied to the array, with
612        /// JSValues converted to equivalent Objective-C objects as specified.
613        ///
614        /// Returns: The NSArray containing the recursively converted contents of the
615        /// converted JavaScript array.
616        #[unsafe(method(toArray))]
617        #[unsafe(method_family = none)]
618        pub unsafe fn toArray(&self) -> Option<Retained<NSArray>>;
619
620        #[cfg(feature = "objc2-foundation")]
621        /// Convert a JSValue to a NSDictionary.
622        ///
623        /// If the value is
624        /// <code>
625        /// null
626        /// </code>
627        /// or
628        /// <code>
629        /// undefined
630        /// </code>
631        /// then
632        /// <code>
633        /// nil
634        /// </code>
635        /// is returned.
636        /// If the value is not an object then a JavaScript TypeError will be thrown.
637        /// All enumerable properties of the object are copied to the dictionary, with
638        /// JSValues converted to equivalent Objective-C objects as specified.
639        ///
640        /// Returns: The NSDictionary containing the recursively converted contents of
641        /// the converted JavaScript object.
642        #[unsafe(method(toDictionary))]
643        #[unsafe(method_family = none)]
644        pub unsafe fn toDictionary(&self) -> Option<Retained<NSDictionary>>;
645
646        /// Check if a JSValue corresponds to the JavaScript value
647        /// <code>
648        /// undefined
649        /// </code>
650        /// .
651        #[unsafe(method(isUndefined))]
652        #[unsafe(method_family = none)]
653        pub unsafe fn isUndefined(&self) -> bool;
654
655        /// Check if a JSValue corresponds to the JavaScript value
656        /// <code>
657        /// null
658        /// </code>
659        /// .
660        #[unsafe(method(isNull))]
661        #[unsafe(method_family = none)]
662        pub unsafe fn isNull(&self) -> bool;
663
664        /// Check if a JSValue is a boolean.
665        #[unsafe(method(isBoolean))]
666        #[unsafe(method_family = none)]
667        pub unsafe fn isBoolean(&self) -> bool;
668
669        /// Check if a JSValue is a number.
670        ///
671        /// In JavaScript, there is no differentiation between types of numbers.
672        /// Semantically all numbers behave like doubles except in special cases like bit
673        /// operations.
674        #[unsafe(method(isNumber))]
675        #[unsafe(method_family = none)]
676        pub unsafe fn isNumber(&self) -> bool;
677
678        /// Check if a JSValue is a string.
679        #[unsafe(method(isString))]
680        #[unsafe(method_family = none)]
681        pub unsafe fn isString(&self) -> bool;
682
683        /// Check if a JSValue is an object.
684        #[unsafe(method(isObject))]
685        #[unsafe(method_family = none)]
686        pub unsafe fn isObject(&self) -> bool;
687
688        /// Check if a JSValue is an array.
689        #[unsafe(method(isArray))]
690        #[unsafe(method_family = none)]
691        pub unsafe fn isArray(&self) -> bool;
692
693        /// Check if a JSValue is a date.
694        #[unsafe(method(isDate))]
695        #[unsafe(method_family = none)]
696        pub unsafe fn isDate(&self) -> bool;
697
698        /// Check if a JSValue is a symbol.
699        #[unsafe(method(isSymbol))]
700        #[unsafe(method_family = none)]
701        pub unsafe fn isSymbol(&self) -> bool;
702
703        /// Check if a JSValue is a BigInt.
704        #[unsafe(method(isBigInt))]
705        #[unsafe(method_family = none)]
706        pub unsafe fn isBigInt(&self) -> bool;
707
708        /// Check if a JSValue is an instance of another object.
709        ///
710        /// This method has the same function as the JavaScript operator
711        /// <code>
712        /// instanceof
713        /// </code>
714        /// .
715        /// If an object other than a JSValue is passed, it will first be converted according to
716        /// the aforementioned rules.
717        #[unsafe(method(isInstanceOf:))]
718        #[unsafe(method_family = none)]
719        pub unsafe fn isInstanceOf(&self, value: Option<&AnyObject>) -> bool;
720
721        /// Compare two JSValues using JavaScript's
722        /// <code>
723        /// ===
724        /// </code>
725        /// operator.
726        #[unsafe(method(isEqualToObject:))]
727        #[unsafe(method_family = none)]
728        pub unsafe fn isEqualToObject(&self, value: Option<&AnyObject>) -> bool;
729
730        /// Compare two JSValues using JavaScript's
731        /// <code>
732        /// ==
733        /// </code>
734        /// operator.
735        #[unsafe(method(isEqualWithTypeCoercionToObject:))]
736        #[unsafe(method_family = none)]
737        pub unsafe fn isEqualWithTypeCoercionToObject(&self, value: Option<&AnyObject>) -> bool;
738
739        #[cfg(feature = "JSValueRef")]
740        /// Compare two JSValues.
741        /// The JSValue to compare with.
742        ///
743        /// Returns: A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.
744        ///
745        /// The result is computed by comparing the results of JavaScript's
746        /// <code>
747        /// ==
748        /// </code>
749        /// ,
750        /// <code>
751        /// <
752        /// </code>
753        /// , and
754        /// <code>
755        /// >
756        /// </code>
757        /// operators. If either
758        /// <code>
759        /// self
760        /// </code>
761        /// or
762        /// <code>
763        /// other
764        /// </code>
765        /// is (or would coerce to)
766        /// <code>
767        /// NaN
768        /// </code>
769        /// in JavaScript, then the result is kJSRelationConditionUndefined.
770        #[unsafe(method(compareJSValue:))]
771        #[unsafe(method_family = none)]
772        pub unsafe fn compareJSValue(&self, other: &JSValue) -> JSRelationCondition;
773
774        #[cfg(feature = "JSValueRef")]
775        /// Compare a JSValue with a
776        /// <code>
777        /// int64_t
778        /// </code>
779        /// .
780        /// The
781        /// <code>
782        /// int64_t
783        /// </code>
784        /// to compare with.
785        ///
786        /// Returns: A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.
787        ///
788        /// The JSValue is converted to an integer according to the rules specified by the JavaScript language then compared with
789        /// <code>
790        /// other
791        /// </code>
792        /// .
793        #[unsafe(method(compareInt64:))]
794        #[unsafe(method_family = none)]
795        pub unsafe fn compareInt64(&self, other: i64) -> JSRelationCondition;
796
797        #[cfg(feature = "JSValueRef")]
798        /// Compare a JSValue with a
799        /// <code>
800        /// uint64_t
801        /// </code>
802        /// .
803        /// The
804        /// <code>
805        /// uint64_t
806        /// </code>
807        /// to compare with.
808        ///
809        /// Returns: A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.
810        ///
811        /// The JSValue is converted to an integer according to the rules specified by the JavaScript language then compared with
812        /// <code>
813        /// other
814        /// </code>
815        /// .
816        #[unsafe(method(compareUInt64:))]
817        #[unsafe(method_family = none)]
818        pub unsafe fn compareUInt64(&self, other: u64) -> JSRelationCondition;
819
820        #[cfg(feature = "JSValueRef")]
821        /// Compare a JSValue with a double.
822        /// The double to compare with.
823        ///
824        /// Returns: A value of JSRelationCondition, a kJSRelationConditionUndefined is returned if an exception is thrown.
825        ///
826        /// The JSValue is converted to a double according to the rules specified by the JavaScript language then compared with
827        /// <code>
828        /// other
829        /// </code>
830        /// .
831        #[unsafe(method(compareDouble:))]
832        #[unsafe(method_family = none)]
833        pub unsafe fn compareDouble(&self, other: c_double) -> JSRelationCondition;
834
835        #[cfg(feature = "objc2-foundation")]
836        /// Invoke a JSValue as a function.
837        ///
838        /// In JavaScript, if a function doesn't explicitly return a value then it
839        /// implicitly returns the JavaScript value
840        /// <code>
841        /// undefined
842        /// </code>
843        /// .
844        ///
845        /// Parameter `arguments`: The arguments to pass to the function.
846        ///
847        /// Returns: The return value of the function call.
848        #[unsafe(method(callWithArguments:))]
849        #[unsafe(method_family = none)]
850        pub unsafe fn callWithArguments(
851            &self,
852            arguments: Option<&NSArray>,
853        ) -> Option<Retained<JSValue>>;
854
855        #[cfg(feature = "objc2-foundation")]
856        /// Invoke a JSValue as a constructor.
857        ///
858        /// This is equivalent to using the
859        /// <code>
860        /// new
861        /// </code>
862        /// syntax in JavaScript.
863        ///
864        /// Parameter `arguments`: The arguments to pass to the constructor.
865        ///
866        /// Returns: The return value of the constructor call.
867        #[unsafe(method(constructWithArguments:))]
868        #[unsafe(method_family = none)]
869        pub unsafe fn constructWithArguments(
870            &self,
871            arguments: Option<&NSArray>,
872        ) -> Option<Retained<JSValue>>;
873
874        #[cfg(feature = "objc2-foundation")]
875        /// Invoke a method on a JSValue.
876        ///
877        /// Accesses the property named
878        /// <code>
879        /// method
880        /// </code>
881        /// from this value and
882        /// calls the resulting value as a function, passing this JSValue as the
883        /// <code>
884        /// this
885        /// </code>
886        /// value along with the specified arguments.
887        ///
888        /// Parameter `method`: The name of the method to be invoked.
889        ///
890        /// Parameter `arguments`: The arguments to pass to the method.
891        ///
892        /// Returns: The return value of the method call.
893        #[unsafe(method(invokeMethod:withArguments:))]
894        #[unsafe(method_family = none)]
895        pub unsafe fn invokeMethod_withArguments(
896            &self,
897            method: Option<&NSString>,
898            arguments: Option<&NSArray>,
899        ) -> Option<Retained<JSValue>>;
900    );
901}
902
903/// Methods declared on superclass `NSObject`.
904#[cfg(feature = "objc2")]
905impl JSValue {
906    extern_methods!(
907        #[unsafe(method(init))]
908        #[unsafe(method_family = init)]
909        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
910
911        #[unsafe(method(new))]
912        #[unsafe(method_family = new)]
913        pub unsafe fn new() -> Retained<Self>;
914    );
915}
916
917/// StructSupport.
918/// Objective-C methods exported to JavaScript may have argument and/or return
919/// values of struct types, provided that conversion to and from the struct is
920/// supported by JSValue. Support is provided for any types where JSValue
921/// contains both a class method
922/// <code>
923/// valueWith
924/// <Type
925/// >:inContext:
926/// </code>
927/// , and and instance
928/// method
929/// <code>
930/// to
931/// <Type
932/// >
933/// </code>
934/// - where the string
935/// <code>
936/// <Type
937/// >
938/// </code>
939/// in these selector names match,
940/// with the first argument to the former being of the same struct type as the
941/// return type of the latter.
942/// Support is provided for structs of type CGPoint, NSRange, CGRect and CGSize.
943#[cfg(feature = "objc2")]
944impl JSValue {
945    extern_methods!(
946        #[cfg(all(feature = "JSContext", feature = "objc2-core-foundation"))]
947        /// Create a JSValue from a CGPoint.
948        ///
949        /// Returns: A newly allocated JavaScript object containing properties
950        /// named
951        /// <code>
952        /// x
953        /// </code>
954        /// and
955        /// <code>
956        /// y
957        /// </code>
958        /// , with values from the CGPoint.
959        #[unsafe(method(valueWithPoint:inContext:))]
960        #[unsafe(method_family = none)]
961        pub unsafe fn valueWithPoint_inContext(
962            point: CGPoint,
963            context: Option<&JSContext>,
964        ) -> Option<Retained<JSValue>>;
965
966        #[cfg(all(feature = "JSContext", feature = "objc2-foundation"))]
967        /// Create a JSValue from a NSRange.
968        ///
969        /// Returns: A newly allocated JavaScript object containing properties
970        /// named
971        /// <code>
972        /// location
973        /// </code>
974        /// and
975        /// <code>
976        /// length
977        /// </code>
978        /// , with values from the NSRange.
979        #[unsafe(method(valueWithRange:inContext:))]
980        #[unsafe(method_family = none)]
981        pub unsafe fn valueWithRange_inContext(
982            range: NSRange,
983            context: Option<&JSContext>,
984        ) -> Option<Retained<JSValue>>;
985
986        #[cfg(all(feature = "JSContext", feature = "objc2-core-foundation"))]
987        /// Create a JSValue from a CGRect.
988        ///
989        /// Returns: A newly allocated JavaScript object containing properties
990        /// named
991        /// <code>
992        /// x
993        /// </code>
994        /// ,
995        /// <code>
996        /// y
997        /// </code>
998        /// ,
999        /// <code>
1000        /// width
1001        /// </code>
1002        /// , and
1003        /// <code>
1004        /// height
1005        /// </code>
1006        /// , with values from the CGRect.
1007        #[unsafe(method(valueWithRect:inContext:))]
1008        #[unsafe(method_family = none)]
1009        pub unsafe fn valueWithRect_inContext(
1010            rect: CGRect,
1011            context: Option<&JSContext>,
1012        ) -> Option<Retained<JSValue>>;
1013
1014        #[cfg(all(feature = "JSContext", feature = "objc2-core-foundation"))]
1015        /// Create a JSValue from a CGSize.
1016        ///
1017        /// Returns: A newly allocated JavaScript object containing properties
1018        /// named
1019        /// <code>
1020        /// width
1021        /// </code>
1022        /// and
1023        /// <code>
1024        /// height
1025        /// </code>
1026        /// , with values from the CGSize.
1027        #[unsafe(method(valueWithSize:inContext:))]
1028        #[unsafe(method_family = none)]
1029        pub unsafe fn valueWithSize_inContext(
1030            size: CGSize,
1031            context: Option<&JSContext>,
1032        ) -> Option<Retained<JSValue>>;
1033
1034        #[cfg(feature = "objc2-core-foundation")]
1035        /// Convert a JSValue to a CGPoint.
1036        ///
1037        /// Reads the properties named
1038        /// <code>
1039        /// x
1040        /// </code>
1041        /// and
1042        /// <code>
1043        /// y
1044        /// </code>
1045        /// from
1046        /// this JSValue, and converts the results to double.
1047        ///
1048        /// Returns: The new CGPoint.
1049        #[unsafe(method(toPoint))]
1050        #[unsafe(method_family = none)]
1051        pub unsafe fn toPoint(&self) -> CGPoint;
1052
1053        #[cfg(feature = "objc2-foundation")]
1054        /// Convert a JSValue to an NSRange.
1055        ///
1056        /// Reads the properties named
1057        /// <code>
1058        /// location
1059        /// </code>
1060        /// and
1061        /// <code>
1062        /// length
1063        /// </code>
1064        /// from this JSValue and converts the results to double.
1065        ///
1066        /// Returns: The new NSRange.
1067        #[unsafe(method(toRange))]
1068        #[unsafe(method_family = none)]
1069        pub unsafe fn toRange(&self) -> NSRange;
1070
1071        #[cfg(feature = "objc2-core-foundation")]
1072        /// Convert a JSValue to a CGRect.
1073        ///
1074        /// Reads the properties named
1075        /// <code>
1076        /// x
1077        /// </code>
1078        /// ,
1079        /// <code>
1080        /// y
1081        /// </code>
1082        /// ,
1083        /// <code>
1084        /// width
1085        /// </code>
1086        /// , and
1087        /// <code>
1088        /// height
1089        /// </code>
1090        /// from this JSValue and converts the results to double.
1091        ///
1092        /// Returns: The new CGRect.
1093        #[unsafe(method(toRect))]
1094        #[unsafe(method_family = none)]
1095        pub unsafe fn toRect(&self) -> CGRect;
1096
1097        #[cfg(feature = "objc2-core-foundation")]
1098        /// Convert a JSValue to a CGSize.
1099        ///
1100        /// Reads the properties named
1101        /// <code>
1102        /// width
1103        /// </code>
1104        /// and
1105        /// <code>
1106        /// height
1107        /// </code>
1108        /// from this JSValue and converts the results to double.
1109        ///
1110        /// Returns: The new CGSize.
1111        #[unsafe(method(toSize))]
1112        #[unsafe(method_family = none)]
1113        pub unsafe fn toSize(&self) -> CGSize;
1114    );
1115}
1116
1117/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsvalueproperty?language=objc)
1118#[cfg(feature = "objc2-foundation")]
1119pub type JSValueProperty = NSString;
1120
1121/// PropertyAccess.
1122/// These methods enable querying properties on a JSValue.
1123#[cfg(feature = "objc2")]
1124impl JSValue {
1125    extern_methods!(
1126        #[cfg(feature = "objc2-foundation")]
1127        /// Access a property of a JSValue.
1128        ///
1129        /// Returns: The JSValue for the requested property or the JSValue
1130        /// <code>
1131        /// undefined
1132        /// </code>
1133        /// if the property does not exist.
1134        ///
1135        /// Corresponds to the JavaScript operation
1136        /// <code>
1137        /// object[property]
1138        /// </code>
1139        /// . Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of
1140        /// <code>
1141        /// valueWithObject:inContext:
1142        /// </code>
1143        /// . Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
1144        #[unsafe(method(valueForProperty:))]
1145        #[unsafe(method_family = none)]
1146        pub unsafe fn valueForProperty(
1147            &self,
1148            property: Option<&JSValueProperty>,
1149        ) -> Option<Retained<JSValue>>;
1150
1151        #[cfg(feature = "objc2-foundation")]
1152        /// Set a property on a JSValue.
1153        ///
1154        /// Corresponds to the JavaScript operation
1155        /// <code>
1156        /// object[property] = value
1157        /// </code>
1158        /// . Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of
1159        /// <code>
1160        /// valueWithObject:inContext:
1161        /// </code>
1162        /// . Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
1163        #[unsafe(method(setValue:forProperty:))]
1164        #[unsafe(method_family = none)]
1165        pub unsafe fn setValue_forProperty(
1166            &self,
1167            value: Option<&AnyObject>,
1168            property: Option<&JSValueProperty>,
1169        );
1170
1171        #[cfg(feature = "objc2-foundation")]
1172        /// Delete a property from a JSValue.
1173        ///
1174        /// Returns: YES if deletion is successful, NO otherwise.
1175        ///
1176        /// Corresponds to the JavaScript operation
1177        /// <code>
1178        /// delete object[property]
1179        /// </code>
1180        /// . Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of
1181        /// <code>
1182        /// valueWithObject:inContext:
1183        /// </code>
1184        /// . Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
1185        #[unsafe(method(deleteProperty:))]
1186        #[unsafe(method_family = none)]
1187        pub unsafe fn deleteProperty(&self, property: Option<&JSValueProperty>) -> bool;
1188
1189        #[cfg(feature = "objc2-foundation")]
1190        /// Check if a JSValue has a property.
1191        ///
1192        /// This method has the same function as the JavaScript operator
1193        /// <code>
1194        /// in
1195        /// </code>
1196        /// .
1197        ///
1198        /// Returns: Returns YES if property is present on the value.
1199        ///
1200        /// Corresponds to the JavaScript operation
1201        /// <code>
1202        /// property in object
1203        /// </code>
1204        /// . Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of
1205        /// <code>
1206        /// valueWithObject:inContext:
1207        /// </code>
1208        /// . Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
1209        #[unsafe(method(hasProperty:))]
1210        #[unsafe(method_family = none)]
1211        pub unsafe fn hasProperty(&self, property: Option<&JSValueProperty>) -> bool;
1212
1213        #[cfg(feature = "objc2-foundation")]
1214        /// Define properties with custom descriptors on JSValues.
1215        ///
1216        /// This method may be used to create a data or accessor property on an object.
1217        /// This method operates in accordance with the Object.defineProperty method in the JavaScript language. Starting with macOS 10.15 and iOS 13, 'property' can be any 'id' and will be converted to a JSValue using the conversion rules of
1218        /// <code>
1219        /// valueWithObject:inContext:
1220        /// </code>
1221        /// . Prior to macOS 10.15 and iOS 13, 'property' was expected to be an NSString *.
1222        #[unsafe(method(defineProperty:descriptor:))]
1223        #[unsafe(method_family = none)]
1224        pub unsafe fn defineProperty_descriptor(
1225            &self,
1226            property: Option<&JSValueProperty>,
1227            descriptor: Option<&AnyObject>,
1228        );
1229
1230        /// Access an indexed (numerical) property on a JSValue.
1231        ///
1232        /// Returns: The JSValue for the property at the specified index.
1233        /// Returns the JavaScript value
1234        /// <code>
1235        /// undefined
1236        /// </code>
1237        /// if no property exists at that index.
1238        #[unsafe(method(valueAtIndex:))]
1239        #[unsafe(method_family = none)]
1240        pub unsafe fn valueAtIndex(&self, index: NSUInteger) -> Option<Retained<JSValue>>;
1241
1242        /// Set an indexed (numerical) property on a JSValue.
1243        ///
1244        /// For JSValues that are JavaScript arrays, indices greater than
1245        /// UINT_MAX - 1 will not affect the length of the array.
1246        #[unsafe(method(setValue:atIndex:))]
1247        #[unsafe(method_family = none)]
1248        pub unsafe fn setValue_atIndex(&self, value: Option<&AnyObject>, index: NSUInteger);
1249    );
1250}
1251
1252/// SubscriptSupport.
1253/// Instances of JSValue implement the following methods in order to enable
1254/// support for subscript access by key and index, for example:
1255///
1256/// ```text
1257///     JSValue *objectA, *objectB;
1258///     JSValue *v1 = object[@"X"]; // Get value for property "X" from 'object'.
1259///     JSValue *v2 = object[42];   // Get value for index 42 from 'object'.
1260///     object[@"Y"] = v1;          // Assign 'v1' to property "Y" of 'object'.
1261///     object[101] = v2;           // Assign 'v2' to index 101 of 'object'.
1262/// ```
1263///
1264/// An object key passed as a subscript will be converted to a JavaScript value,
1265/// and then the value using the same rules as
1266/// <code>
1267/// valueWithObject:inContext:
1268/// </code>
1269/// . In macOS
1270/// 10.14 and iOS 12 and below, the
1271/// <code>
1272/// key
1273/// </code>
1274/// argument of
1275/// <code>
1276/// setObject:object forKeyedSubscript:key
1277/// </code>
1278/// was restricted to an
1279/// <code>
1280/// NSObject
1281/// <NSCopying
1282/// > *
1283/// </code>
1284/// but that restriction was never used internally.
1285#[cfg(feature = "objc2")]
1286impl JSValue {
1287    extern_methods!(
1288        #[unsafe(method(objectForKeyedSubscript:))]
1289        #[unsafe(method_family = none)]
1290        pub unsafe fn objectForKeyedSubscript(
1291            &self,
1292            key: Option<&AnyObject>,
1293        ) -> Option<Retained<JSValue>>;
1294
1295        #[unsafe(method(objectAtIndexedSubscript:))]
1296        #[unsafe(method_family = none)]
1297        pub unsafe fn objectAtIndexedSubscript(
1298            &self,
1299            index: NSUInteger,
1300        ) -> Option<Retained<JSValue>>;
1301
1302        #[unsafe(method(setObject:forKeyedSubscript:))]
1303        #[unsafe(method_family = none)]
1304        pub unsafe fn setObject_forKeyedSubscript(
1305            &self,
1306            object: Option<&AnyObject>,
1307            key: Option<&AnyObject>,
1308        );
1309
1310        #[unsafe(method(setObject:atIndexedSubscript:))]
1311        #[unsafe(method_family = none)]
1312        pub unsafe fn setObject_atIndexedSubscript(
1313            &self,
1314            object: Option<&AnyObject>,
1315            index: NSUInteger,
1316        );
1317    );
1318}
1319
1320/// JSValueRefSupport.
1321/// These functions are for bridging between the C API and the Objective-C API.
1322#[cfg(feature = "objc2")]
1323impl JSValue {
1324    extern_methods!(
1325        #[cfg(all(feature = "JSBase", feature = "JSContext"))]
1326        /// Creates a JSValue, wrapping its C API counterpart.
1327        ///
1328        /// Returns: The Objective-C API equivalent of the specified JSValueRef.
1329        #[unsafe(method(valueWithJSValueRef:inContext:))]
1330        #[unsafe(method_family = none)]
1331        pub unsafe fn valueWithJSValueRef_inContext(
1332            value: JSValueRef,
1333            context: Option<&JSContext>,
1334        ) -> Option<Retained<JSValue>>;
1335
1336        #[cfg(feature = "JSBase")]
1337        /// Returns the C API counterpart wrapped by a JSContext.
1338        ///
1339        /// Returns: The C API equivalent of this JSValue.
1340        #[unsafe(method(JSValueRef))]
1341        #[unsafe(method_family = none)]
1342        pub unsafe fn JSValueRef(&self) -> JSValueRef;
1343    );
1344}
1345
1346extern "C" {
1347    /// Property Descriptor Constants
1348    ///
1349    /// These keys may assist in creating a property descriptor for use with the
1350    /// defineProperty method on JSValue.
1351    /// Property descriptors must fit one of three descriptions:
1352    ///
1353    /// Data Descriptor:
1354    /// - A descriptor containing one or both of the keys
1355    /// <code>
1356    /// value
1357    /// </code>
1358    /// and
1359    /// <code>
1360    /// writable
1361    /// </code>
1362    /// ,
1363    /// and optionally containing one or both of the keys
1364    /// <code>
1365    /// enumerable
1366    /// </code>
1367    /// and
1368    /// <code>
1369    /// configurable
1370    /// </code>
1371    /// . A data descriptor may not contain either the
1372    /// <code>
1373    /// get
1374    /// </code>
1375    /// or
1376    /// <code>
1377    /// set
1378    /// </code>
1379    /// key.
1380    /// A data descriptor may be used to create or modify the attributes of a
1381    /// data property on an object (replacing any existing accessor property).
1382    ///
1383    /// Accessor Descriptor:
1384    /// - A descriptor containing one or both of the keys
1385    /// <code>
1386    /// get
1387    /// </code>
1388    /// and
1389    /// <code>
1390    /// set
1391    /// </code>
1392    /// , and
1393    /// optionally containing one or both of the keys
1394    /// <code>
1395    /// enumerable
1396    /// </code>
1397    /// and
1398    /// <code>
1399    /// configurable
1400    /// </code>
1401    /// . An accessor descriptor may not contain either the
1402    /// <code>
1403    /// value
1404    /// </code>
1405    /// or
1406    /// <code>
1407    /// writable
1408    /// </code>
1409    /// key.
1410    /// An accessor descriptor may be used to create or modify the attributes of
1411    /// an accessor property on an object (replacing any existing data property).
1412    ///
1413    /// Generic Descriptor:
1414    /// - A descriptor containing one or both of the keys
1415    /// <code>
1416    /// enumerable
1417    /// </code>
1418    /// and
1419    /// <code>
1420    /// configurable
1421    /// </code>
1422    /// . A generic descriptor may not contain any of the keys
1423    /// <code>
1424    /// value
1425    /// </code>
1426    /// ,
1427    /// <code>
1428    /// writable
1429    /// </code>
1430    /// ,
1431    /// <code>
1432    /// get
1433    /// </code>
1434    /// , or
1435    /// <code>
1436    /// set
1437    /// </code>
1438    /// .
1439    /// A generic descriptor may be used to modify the attributes of an existing
1440    /// data or accessor property, or to create a new data property.
1441    ///
1442    /// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertydescriptorwritablekey?language=objc)
1443    #[cfg(feature = "objc2-foundation")]
1444    pub static JSPropertyDescriptorWritableKey: Option<&'static NSString>;
1445}
1446
1447extern "C" {
1448    /// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertydescriptorenumerablekey?language=objc)
1449    #[cfg(feature = "objc2-foundation")]
1450    pub static JSPropertyDescriptorEnumerableKey: Option<&'static NSString>;
1451}
1452
1453extern "C" {
1454    /// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertydescriptorconfigurablekey?language=objc)
1455    #[cfg(feature = "objc2-foundation")]
1456    pub static JSPropertyDescriptorConfigurableKey: Option<&'static NSString>;
1457}
1458
1459extern "C" {
1460    /// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertydescriptorvaluekey?language=objc)
1461    #[cfg(feature = "objc2-foundation")]
1462    pub static JSPropertyDescriptorValueKey: Option<&'static NSString>;
1463}
1464
1465extern "C" {
1466    /// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertydescriptorgetkey?language=objc)
1467    #[cfg(feature = "objc2-foundation")]
1468    pub static JSPropertyDescriptorGetKey: Option<&'static NSString>;
1469}
1470
1471extern "C" {
1472    /// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertydescriptorsetkey?language=objc)
1473    #[cfg(feature = "objc2-foundation")]
1474    pub static JSPropertyDescriptorSetKey: Option<&'static NSString>;
1475}