objc2_javascript_core/generated/JSObjectRef.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/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjspropertyattributenone?language=objc)
10pub const kJSPropertyAttributeNone: c_uint = 0;
11/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjspropertyattributereadonly?language=objc)
12pub const kJSPropertyAttributeReadOnly: c_uint = 1 << 1;
13/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjspropertyattributedontenum?language=objc)
14pub const kJSPropertyAttributeDontEnum: c_uint = 1 << 2;
15/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjspropertyattributedontdelete?language=objc)
16pub const kJSPropertyAttributeDontDelete: c_uint = 1 << 3;
17
18/// A set of JSPropertyAttributes. Combine multiple attributes by logically ORing them together.
19///
20/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertyattributes?language=objc)
21pub type JSPropertyAttributes = c_uint;
22
23/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjsclassattributenone?language=objc)
24pub const kJSClassAttributeNone: c_uint = 0;
25/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjsclassattributenoautomaticprototype?language=objc)
26pub const kJSClassAttributeNoAutomaticPrototype: c_uint = 1 << 1;
27
28/// A set of JSClassAttributes. Combine multiple attributes by logically ORing them together.
29///
30/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsclassattributes?language=objc)
31pub type JSClassAttributes = c_uint;
32
33/// The callback invoked when an object is first created.
34///
35/// Parameter `ctx`: The execution context to use.
36///
37/// Parameter `object`: The JSObject being created.
38///
39/// If you named your function Initialize, you would declare it like this:
40///
41/// void Initialize(JSContextRef ctx, JSObjectRef object);
42///
43/// Unlike the other object callbacks, the initialize callback is called on the least
44/// derived class (the parent class) first, and the most derived class last.
45///
46/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectinitializecallback?language=objc)
47#[cfg(feature = "JSBase")]
48pub type JSObjectInitializeCallback =
49 Option<unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef)>;
50
51/// The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
52///
53/// Parameter `object`: The JSObject being finalized.
54///
55/// If you named your function Finalize, you would declare it like this:
56///
57/// void Finalize(JSObjectRef object);
58///
59/// The finalize callback is called on the most derived class first, and the least
60/// derived class (the parent class) last.
61///
62/// You must not call any function that may cause a garbage collection or an allocation
63/// of a garbage collected object from within a JSObjectFinalizeCallback. This includes
64/// all functions that have a JSContextRef parameter.
65///
66/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectfinalizecallback?language=objc)
67#[cfg(feature = "JSBase")]
68pub type JSObjectFinalizeCallback = Option<unsafe extern "C-unwind" fn(JSObjectRef)>;
69
70/// The callback invoked when determining whether an object has a property.
71///
72/// Parameter `ctx`: The execution context to use.
73///
74/// Parameter `object`: The JSObject to search for the property.
75///
76/// Parameter `propertyName`: A JSString containing the name of the property look up.
77///
78/// Returns: true if object has the property, otherwise false.
79///
80/// If you named your function HasProperty, you would declare it like this:
81///
82/// bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
83///
84/// If this function returns false, the hasProperty request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain.
85///
86/// This callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value would be expensive.
87///
88/// If this callback is NULL, the getProperty callback will be used to service hasProperty requests.
89///
90/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjecthaspropertycallback?language=objc)
91#[cfg(feature = "JSBase")]
92pub type JSObjectHasPropertyCallback =
93 Option<unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSStringRef) -> bool>;
94
95/// The callback invoked when getting a property's value.
96///
97/// Parameter `ctx`: The execution context to use.
98///
99/// Parameter `object`: The JSObject to search for the property.
100///
101/// Parameter `propertyName`: A JSString containing the name of the property to get.
102///
103/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
104///
105/// Returns: The property's value if object has the property, otherwise NULL.
106///
107/// If you named your function GetProperty, you would declare it like this:
108///
109/// JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
110///
111/// If this function returns NULL, the get request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain.
112///
113/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectgetpropertycallback?language=objc)
114#[cfg(feature = "JSBase")]
115pub type JSObjectGetPropertyCallback = Option<
116 unsafe extern "C-unwind" fn(
117 JSContextRef,
118 JSObjectRef,
119 JSStringRef,
120 *mut JSValueRef,
121 ) -> JSValueRef,
122>;
123
124/// The callback invoked when setting a property's value.
125///
126/// Parameter `ctx`: The execution context to use.
127///
128/// Parameter `object`: The JSObject on which to set the property's value.
129///
130/// Parameter `propertyName`: A JSString containing the name of the property to set.
131///
132/// Parameter `value`: A JSValue to use as the property's value.
133///
134/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
135///
136/// Returns: true if the property was set, otherwise false.
137///
138/// If you named your function SetProperty, you would declare it like this:
139///
140/// bool SetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
141///
142/// If this function returns false, the set request forwards to object's statically declared properties, then its parent class chain (which includes the default object class).
143///
144/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectsetpropertycallback?language=objc)
145#[cfg(feature = "JSBase")]
146pub type JSObjectSetPropertyCallback = Option<
147 unsafe extern "C-unwind" fn(
148 JSContextRef,
149 JSObjectRef,
150 JSStringRef,
151 JSValueRef,
152 *mut JSValueRef,
153 ) -> bool,
154>;
155
156/// The callback invoked when deleting a property.
157///
158/// Parameter `ctx`: The execution context to use.
159///
160/// Parameter `object`: The JSObject in which to delete the property.
161///
162/// Parameter `propertyName`: A JSString containing the name of the property to delete.
163///
164/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
165///
166/// Returns: true if propertyName was successfully deleted, otherwise false.
167///
168/// If you named your function DeleteProperty, you would declare it like this:
169///
170/// bool DeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
171///
172/// If this function returns false, the delete request forwards to object's statically declared properties, then its parent class chain (which includes the default object class).
173///
174/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectdeletepropertycallback?language=objc)
175#[cfg(feature = "JSBase")]
176pub type JSObjectDeletePropertyCallback = Option<
177 unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSStringRef, *mut JSValueRef) -> bool,
178>;
179
180/// The callback invoked when collecting the names of an object's properties.
181///
182/// Parameter `ctx`: The execution context to use.
183///
184/// Parameter `object`: The JSObject whose property names are being collected.
185///
186/// Parameter `propertyNames`: A JavaScript property name accumulator in which to accumulate the names of object's properties.
187///
188/// If you named your function GetPropertyNames, you would declare it like this:
189///
190/// void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
191///
192/// Property name accumulators are used by JSObjectCopyPropertyNames and JavaScript for...in loops.
193///
194/// Use JSPropertyNameAccumulatorAddName to add property names to accumulator. A class's getPropertyNames callback only needs to provide the names of properties that the class vends through a custom getProperty or setProperty callback. Other properties, including statically declared properties, properties vended by other classes, and properties belonging to object's prototype, are added independently.
195///
196/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectgetpropertynamescallback?language=objc)
197#[cfg(feature = "JSBase")]
198pub type JSObjectGetPropertyNamesCallback =
199 Option<unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSPropertyNameAccumulatorRef)>;
200
201/// The callback invoked when an object is called as a function.
202///
203/// Parameter `ctx`: The execution context to use.
204///
205/// Parameter `function`: A JSObject that is the function being called.
206///
207/// Parameter `thisObject`: A JSObject that is the 'this' variable in the function's scope.
208///
209/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
210///
211/// Parameter `arguments`: A JSValue array of the arguments passed to the function.
212///
213/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
214///
215/// Returns: A JSValue that is the function's return value.
216///
217/// If you named your function CallAsFunction, you would declare it like this:
218///
219/// JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
220///
221/// If your callback were invoked by the JavaScript expression 'myObject.myFunction()', function would be set to myFunction, and thisObject would be set to myObject.
222///
223/// If this callback is NULL, calling your object as a function will throw an exception.
224///
225/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectcallasfunctioncallback?language=objc)
226#[cfg(feature = "JSBase")]
227pub type JSObjectCallAsFunctionCallback = Option<
228 unsafe extern "C-unwind" fn(
229 JSContextRef,
230 JSObjectRef,
231 JSObjectRef,
232 usize,
233 *mut JSValueRef,
234 *mut JSValueRef,
235 ) -> JSValueRef,
236>;
237
238/// The callback invoked when an object is used as a constructor in a 'new' expression.
239///
240/// Parameter `ctx`: The execution context to use.
241///
242/// Parameter `constructor`: A JSObject that is the constructor being called.
243///
244/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
245///
246/// Parameter `arguments`: A JSValue array of the arguments passed to the function.
247///
248/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
249///
250/// Returns: A JSObject that is the constructor's return value.
251///
252/// If you named your function CallAsConstructor, you would declare it like this:
253///
254/// JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
255///
256/// If your callback were invoked by the JavaScript expression 'new myConstructor()', constructor would be set to myConstructor.
257///
258/// If this callback is NULL, using your object as a constructor in a 'new' expression will throw an exception.
259///
260/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectcallasconstructorcallback?language=objc)
261#[cfg(feature = "JSBase")]
262pub type JSObjectCallAsConstructorCallback = Option<
263 unsafe extern "C-unwind" fn(
264 JSContextRef,
265 JSObjectRef,
266 usize,
267 *mut JSValueRef,
268 *mut JSValueRef,
269 ) -> JSObjectRef,
270>;
271
272/// hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
273///
274/// Parameter `ctx`: The execution context to use.
275///
276/// Parameter `constructor`: The JSObject that is the target of the 'instanceof' expression.
277///
278/// Parameter `possibleInstance`: The JSValue being tested to determine if it is an instance of constructor.
279///
280/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
281///
282/// Returns: true if possibleInstance is an instance of constructor, otherwise false.
283///
284/// If you named your function HasInstance, you would declare it like this:
285///
286/// bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
287///
288/// If your callback were invoked by the JavaScript expression 'someValue instanceof myObject', constructor would be set to myObject and possibleInstance would be set to someValue.
289///
290/// If this callback is NULL, 'instanceof' expressions that target your object will return false.
291///
292/// Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback as well.
293///
294/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjecthasinstancecallback?language=objc)
295#[cfg(feature = "JSBase")]
296pub type JSObjectHasInstanceCallback = Option<
297 unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSValueRef, *mut JSValueRef) -> bool,
298>;
299
300/// The callback invoked when converting an object to a particular JavaScript type.
301///
302/// Parameter `ctx`: The execution context to use.
303///
304/// Parameter `object`: The JSObject to convert.
305///
306/// Parameter `type`: A JSType specifying the JavaScript type to convert to.
307///
308/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
309///
310/// Returns: The objects's converted value, or NULL if the object was not converted.
311///
312/// If you named your function ConvertToType, you would declare it like this:
313///
314/// JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);
315///
316/// If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class).
317///
318/// This function is only invoked when converting an object to number or string. An object converted to boolean is 'true.' An object converted to object is itself.
319///
320/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectconverttotypecallback?language=objc)
321#[cfg(all(feature = "JSBase", feature = "JSValueRef"))]
322pub type JSObjectConvertToTypeCallback = Option<
323 unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSType, *mut JSValueRef) -> JSValueRef,
324>;
325
326/// This structure describes a statically declared value property.
327/// Field: name A null-terminated UTF8 string containing the property's name.
328/// Field: getProperty A JSObjectGetPropertyCallback to invoke when getting the property's value.
329/// Field: setProperty A JSObjectSetPropertyCallback to invoke when setting the property's value. May be NULL if the ReadOnly attribute is set.
330/// Field: attributes A logically ORed set of JSPropertyAttributes to give to the property.
331///
332/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsstaticvalue?language=objc)
333#[cfg(feature = "JSBase")]
334#[repr(C)]
335#[derive(Clone, Copy, Debug, PartialEq)]
336pub struct JSStaticValue {
337 pub name: *const c_char,
338 pub getProperty: JSObjectGetPropertyCallback,
339 pub setProperty: JSObjectSetPropertyCallback,
340 pub attributes: JSPropertyAttributes,
341}
342
343#[cfg(all(feature = "JSBase", feature = "objc2"))]
344unsafe impl Encode for JSStaticValue {
345 const ENCODING: Encoding = Encoding::Struct(
346 "?",
347 &[
348 <*const c_char>::ENCODING,
349 <JSObjectGetPropertyCallback>::ENCODING,
350 Encoding::Pointer(&Encoding::Unknown),
351 <JSPropertyAttributes>::ENCODING,
352 ],
353 );
354}
355
356#[cfg(all(feature = "JSBase", feature = "objc2"))]
357unsafe impl RefEncode for JSStaticValue {
358 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
359}
360
361/// This structure describes a statically declared function property.
362/// Field: name A null-terminated UTF8 string containing the property's name.
363/// Field: callAsFunction A JSObjectCallAsFunctionCallback to invoke when the property is called as a function.
364/// Field: attributes A logically ORed set of JSPropertyAttributes to give to the property.
365///
366/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsstaticfunction?language=objc)
367#[cfg(feature = "JSBase")]
368#[repr(C)]
369#[derive(Clone, Copy, Debug, PartialEq)]
370pub struct JSStaticFunction {
371 pub name: *const c_char,
372 pub callAsFunction: JSObjectCallAsFunctionCallback,
373 pub attributes: JSPropertyAttributes,
374}
375
376#[cfg(all(feature = "JSBase", feature = "objc2"))]
377unsafe impl Encode for JSStaticFunction {
378 const ENCODING: Encoding = Encoding::Struct(
379 "?",
380 &[
381 <*const c_char>::ENCODING,
382 <JSObjectCallAsFunctionCallback>::ENCODING,
383 <JSPropertyAttributes>::ENCODING,
384 ],
385 );
386}
387
388#[cfg(all(feature = "JSBase", feature = "objc2"))]
389unsafe impl RefEncode for JSStaticFunction {
390 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
391}
392
393/// This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL.
394/// Field: version The version number of this structure. The current version is 0.
395/// Field: attributes A logically ORed set of JSClassAttributes to give to the class.
396/// Field: className A null-terminated UTF8 string containing the class's name.
397/// Field: parentClass A JSClass to set as the class's parent class. Pass NULL use the default object class.
398/// Field: staticValues A JSStaticValue array containing the class's statically declared value properties. Pass NULL to specify no statically declared value properties. The array must be terminated by a JSStaticValue whose name field is NULL.
399/// Field: staticFunctions A JSStaticFunction array containing the class's statically declared function properties. Pass NULL to specify no statically declared function properties. The array must be terminated by a JSStaticFunction whose name field is NULL.
400/// Field: initialize The callback invoked when an object is first created. Use this callback to initialize the object.
401/// Field: finalize The callback invoked when an object is finalized (prepared for garbage collection). Use this callback to release resources allocated for the object, and perform other cleanup.
402/// Field: hasProperty The callback invoked when determining whether an object has a property. If this field is NULL, getProperty is called instead. The hasProperty callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value is expensive.
403/// Field: getProperty The callback invoked when getting a property's value.
404/// Field: setProperty The callback invoked when setting a property's value.
405/// Field: deleteProperty The callback invoked when deleting a property.
406/// Field: getPropertyNames The callback invoked when collecting the names of an object's properties.
407/// Field: callAsFunction The callback invoked when an object is called as a function.
408/// Field: hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
409/// Field: callAsConstructor The callback invoked when an object is used as a constructor in a 'new' expression.
410/// Field: convertToType The callback invoked when converting an object to a particular JavaScript type.
411///
412/// The staticValues and staticFunctions arrays are the simplest and most efficient means for vending custom properties. Statically declared properties autmatically service requests like getProperty, setProperty, and getPropertyNames. Property access callbacks are required only to implement unusual properties, like array indexes, whose names are not known at compile-time.
413///
414/// If you named your getter function "GetX" and your setter function "SetX", you would declare a JSStaticValue array containing "X" like this:
415///
416/// JSStaticValue StaticValueArray[] = {
417/// { "X", GetX, SetX, kJSPropertyAttributeNone },
418/// { 0, 0, 0, 0 }
419/// };
420///
421/// Standard JavaScript practice calls for storing function objects in prototypes, so they can be shared. The default JSClass created by JSClassCreate follows this idiom, instantiating objects with a shared, automatically generating prototype containing the class's function objects. The kJSClassAttributeNoAutomaticPrototype attribute specifies that a JSClass should not automatically generate such a prototype. The resulting JSClass instantiates objects with the default object prototype, and gives each instance object its own copy of the class's function objects.
422///
423/// A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute.
424///
425/// It is not possible to use JS subclassing with objects created from a class definition that sets callAsConstructor by default. Subclassing is supported via the JSObjectMakeConstructor function, however.
426///
427/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsclassdefinition?language=objc)
428#[cfg(all(feature = "JSBase", feature = "JSValueRef"))]
429#[repr(C)]
430#[derive(Clone, Copy, Debug, PartialEq)]
431pub struct JSClassDefinition {
432 pub version: c_int,
433 pub attributes: JSClassAttributes,
434 pub className: *const c_char,
435 pub parentClass: JSClassRef,
436 pub staticValues: *const JSStaticValue,
437 pub staticFunctions: *const JSStaticFunction,
438 pub initialize: JSObjectInitializeCallback,
439 pub finalize: JSObjectFinalizeCallback,
440 pub hasProperty: JSObjectHasPropertyCallback,
441 pub getProperty: JSObjectGetPropertyCallback,
442 pub setProperty: JSObjectSetPropertyCallback,
443 pub deleteProperty: JSObjectDeletePropertyCallback,
444 pub getPropertyNames: JSObjectGetPropertyNamesCallback,
445 pub callAsFunction: JSObjectCallAsFunctionCallback,
446 pub callAsConstructor: JSObjectCallAsConstructorCallback,
447 pub hasInstance: JSObjectHasInstanceCallback,
448 pub convertToType: JSObjectConvertToTypeCallback,
449}
450
451#[cfg(all(feature = "JSBase", feature = "JSValueRef", feature = "objc2"))]
452unsafe impl Encode for JSClassDefinition {
453 const ENCODING: Encoding = Encoding::Struct(
454 "?",
455 &[
456 <c_int>::ENCODING,
457 <JSClassAttributes>::ENCODING,
458 <*const c_char>::ENCODING,
459 <JSClassRef>::ENCODING,
460 <*const JSStaticValue>::ENCODING,
461 <*const JSStaticFunction>::ENCODING,
462 <JSObjectInitializeCallback>::ENCODING,
463 <JSObjectFinalizeCallback>::ENCODING,
464 Encoding::Pointer(&Encoding::Unknown),
465 <JSObjectGetPropertyCallback>::ENCODING,
466 Encoding::Pointer(&Encoding::Unknown),
467 Encoding::Pointer(&Encoding::Unknown),
468 <JSObjectGetPropertyNamesCallback>::ENCODING,
469 <JSObjectCallAsFunctionCallback>::ENCODING,
470 <JSObjectCallAsConstructorCallback>::ENCODING,
471 Encoding::Pointer(&Encoding::Unknown),
472 <JSObjectConvertToTypeCallback>::ENCODING,
473 ],
474 );
475}
476
477#[cfg(all(feature = "JSBase", feature = "JSValueRef", feature = "objc2"))]
478unsafe impl RefEncode for JSClassDefinition {
479 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
480}
481
482extern "C" {
483 /// A JSClassDefinition structure of the current version, filled with NULL pointers and having no attributes.
484 ///
485 /// Use this constant as a convenience when creating class definitions. For example, to create a class definition with only a finalize method:
486 ///
487 /// JSClassDefinition definition = kJSClassDefinitionEmpty;
488 /// definition.finalize = Finalize;
489 ///
490 /// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjsclassdefinitionempty?language=objc)
491 #[cfg(all(feature = "JSBase", feature = "JSValueRef"))]
492 pub static kJSClassDefinitionEmpty: JSClassDefinition;
493}
494
495extern "C-unwind" {
496 /// Creates a JavaScript class suitable for use with JSObjectMake.
497 ///
498 /// Parameter `definition`: A JSClassDefinition that defines the class.
499 ///
500 /// Returns: A JSClass with the given definition. Ownership follows the Create Rule.
501 #[cfg(all(feature = "JSBase", feature = "JSValueRef"))]
502 pub fn JSClassCreate(definition: *const JSClassDefinition) -> JSClassRef;
503}
504
505extern "C-unwind" {
506 /// Retains a JavaScript class.
507 ///
508 /// Parameter `jsClass`: The JSClass to retain.
509 ///
510 /// Returns: A JSClass that is the same as jsClass.
511 #[cfg(feature = "JSBase")]
512 pub fn JSClassRetain(js_class: JSClassRef) -> JSClassRef;
513}
514
515extern "C-unwind" {
516 /// Releases a JavaScript class.
517 ///
518 /// Parameter `jsClass`: The JSClass to release.
519 #[cfg(feature = "JSBase")]
520 pub fn JSClassRelease(js_class: JSClassRef);
521}
522
523extern "C-unwind" {
524 /// Creates a JavaScript object.
525 ///
526 /// Parameter `ctx`: The execution context to use.
527 ///
528 /// Parameter `jsClass`: The JSClass to assign to the object. Pass NULL to use the default object class.
529 ///
530 /// Parameter `data`: A void* to set as the object's private data. Pass NULL to specify no private data.
531 ///
532 /// Returns: A JSObject with the given class and private data.
533 ///
534 /// The default object class does not allocate storage for private data, so you must provide a non-NULL jsClass to JSObjectMake if you want your object to be able to store private data.
535 ///
536 /// data is set on the created object before the intialize methods in its class chain are called. This enables the initialize methods to retrieve and manipulate data through JSObjectGetPrivate.
537 #[cfg(feature = "JSBase")]
538 pub fn JSObjectMake(ctx: JSContextRef, js_class: JSClassRef, data: *mut c_void) -> JSObjectRef;
539}
540
541extern "C-unwind" {
542 /// Convenience method for creating a JavaScript function with a given callback as its implementation.
543 ///
544 /// Parameter `ctx`: The execution context to use.
545 ///
546 /// Parameter `name`: A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
547 ///
548 /// Parameter `callAsFunction`: The JSObjectCallAsFunctionCallback to invoke when the function is called.
549 ///
550 /// Returns: A JSObject that is a function. The object's prototype will be the default function prototype.
551 #[cfg(feature = "JSBase")]
552 pub fn JSObjectMakeFunctionWithCallback(
553 ctx: JSContextRef,
554 name: JSStringRef,
555 call_as_function: JSObjectCallAsFunctionCallback,
556 ) -> JSObjectRef;
557}
558
559extern "C-unwind" {
560 /// Convenience method for creating a JavaScript constructor.
561 ///
562 /// Parameter `ctx`: The execution context to use.
563 ///
564 /// Parameter `jsClass`: A JSClass that is the class your constructor will assign to the objects its constructs. jsClass will be used to set the constructor's .prototype property, and to evaluate 'instanceof' expressions. Pass NULL to use the default object class.
565 ///
566 /// Parameter `callAsConstructor`: A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a 'new' expression. Pass NULL to use the default object constructor.
567 ///
568 /// Returns: A JSObject that is a constructor. The object's prototype will be the default object prototype.
569 ///
570 /// The default object constructor takes no arguments and constructs an object of class jsClass with no private data. If the constructor is inherited via JS subclassing and the value returned from callAsConstructor was created with jsClass, then the returned object will have it's prototype overridden to the derived class's prototype.
571 #[cfg(feature = "JSBase")]
572 pub fn JSObjectMakeConstructor(
573 ctx: JSContextRef,
574 js_class: JSClassRef,
575 call_as_constructor: JSObjectCallAsConstructorCallback,
576 ) -> JSObjectRef;
577}
578
579extern "C-unwind" {
580 /// Creates a JavaScript Array object.
581 ///
582 /// Parameter `ctx`: The execution context to use.
583 ///
584 /// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
585 ///
586 /// Parameter `arguments`: A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0.
587 ///
588 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
589 ///
590 /// Returns: A JSObject that is an Array.
591 ///
592 /// The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument
593 /// is supplied, this function returns an array with one element.
594 #[cfg(feature = "JSBase")]
595 pub fn JSObjectMakeArray(
596 ctx: JSContextRef,
597 argument_count: usize,
598 arguments: *mut JSValueRef,
599 exception: *mut JSValueRef,
600 ) -> JSObjectRef;
601}
602
603extern "C-unwind" {
604 /// Creates a JavaScript Date object, as if by invoking the built-in Date constructor.
605 ///
606 /// Parameter `ctx`: The execution context to use.
607 ///
608 /// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
609 ///
610 /// Parameter `arguments`: A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0.
611 ///
612 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
613 ///
614 /// Returns: A JSObject that is a Date.
615 #[cfg(feature = "JSBase")]
616 pub fn JSObjectMakeDate(
617 ctx: JSContextRef,
618 argument_count: usize,
619 arguments: *mut JSValueRef,
620 exception: *mut JSValueRef,
621 ) -> JSObjectRef;
622}
623
624extern "C-unwind" {
625 /// Creates a JavaScript Error object, as if by invoking the built-in Error constructor.
626 ///
627 /// Parameter `ctx`: The execution context to use.
628 ///
629 /// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
630 ///
631 /// Parameter `arguments`: A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0.
632 ///
633 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
634 ///
635 /// Returns: A JSObject that is an Error.
636 #[cfg(feature = "JSBase")]
637 pub fn JSObjectMakeError(
638 ctx: JSContextRef,
639 argument_count: usize,
640 arguments: *mut JSValueRef,
641 exception: *mut JSValueRef,
642 ) -> JSObjectRef;
643}
644
645extern "C-unwind" {
646 /// Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor.
647 ///
648 /// Parameter `ctx`: The execution context to use.
649 ///
650 /// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
651 ///
652 /// Parameter `arguments`: A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0.
653 ///
654 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
655 ///
656 /// Returns: A JSObject that is a RegExp.
657 #[cfg(feature = "JSBase")]
658 pub fn JSObjectMakeRegExp(
659 ctx: JSContextRef,
660 argument_count: usize,
661 arguments: *mut JSValueRef,
662 exception: *mut JSValueRef,
663 ) -> JSObjectRef;
664}
665
666extern "C-unwind" {
667 /// Creates a JavaScript promise object by invoking the provided executor.
668 ///
669 /// Parameter `ctx`: The execution context to use.
670 ///
671 /// Parameter `resolve`: A pointer to a JSObjectRef in which to store the resolve function for the new promise. Pass NULL if you do not care to store the resolve callback.
672 ///
673 /// Parameter `reject`: A pointer to a JSObjectRef in which to store the reject function for the new promise. Pass NULL if you do not care to store the reject callback.
674 ///
675 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
676 ///
677 /// Returns: A JSObject that is a promise or NULL if an exception occurred.
678 #[cfg(feature = "JSBase")]
679 pub fn JSObjectMakeDeferredPromise(
680 ctx: JSContextRef,
681 resolve: *mut JSObjectRef,
682 reject: *mut JSObjectRef,
683 exception: *mut JSValueRef,
684 ) -> JSObjectRef;
685}
686
687extern "C-unwind" {
688 /// Creates a function with a given script as its body.
689 ///
690 /// Parameter `ctx`: The execution context to use.
691 ///
692 /// Parameter `name`: A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
693 ///
694 /// Parameter `parameterCount`: An integer count of the number of parameter names in parameterNames.
695 ///
696 /// Parameter `parameterNames`: A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0.
697 ///
698 /// Parameter `body`: A JSString containing the script to use as the function's body.
699 ///
700 /// Parameter `sourceURL`: A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
701 ///
702 /// Parameter `startingLineNumber`: An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
703 ///
704 /// Parameter `exception`: A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
705 ///
706 /// Returns: A JSObject that is a function, or NULL if either body or parameterNames contains a syntax error. The object's prototype will be the default function prototype.
707 ///
708 /// Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
709 #[cfg(feature = "JSBase")]
710 pub fn JSObjectMakeFunction(
711 ctx: JSContextRef,
712 name: JSStringRef,
713 parameter_count: c_uint,
714 parameter_names: *mut JSStringRef,
715 body: JSStringRef,
716 source_url: JSStringRef,
717 starting_line_number: c_int,
718 exception: *mut JSValueRef,
719 ) -> JSObjectRef;
720}
721
722extern "C-unwind" {
723 /// Gets an object's prototype.
724 ///
725 /// Parameter `ctx`: The execution context to use.
726 ///
727 /// Parameter `object`: A JSObject whose prototype you want to get.
728 ///
729 /// Returns: A JSValue that is the object's prototype.
730 #[cfg(feature = "JSBase")]
731 pub fn JSObjectGetPrototype(ctx: JSContextRef, object: JSObjectRef) -> JSValueRef;
732}
733
734extern "C-unwind" {
735 /// Sets an object's prototype.
736 ///
737 /// Parameter `ctx`: The execution context to use.
738 ///
739 /// Parameter `object`: The JSObject whose prototype you want to set.
740 ///
741 /// Parameter `value`: A JSValue to set as the object's prototype.
742 #[cfg(feature = "JSBase")]
743 pub fn JSObjectSetPrototype(ctx: JSContextRef, object: JSObjectRef, value: JSValueRef);
744}
745
746extern "C-unwind" {
747 /// Tests whether an object has a given property.
748 ///
749 /// Parameter `object`: The JSObject to test.
750 ///
751 /// Parameter `propertyName`: A JSString containing the property's name.
752 ///
753 /// Returns: true if the object has a property whose name matches propertyName, otherwise false.
754 #[cfg(feature = "JSBase")]
755 pub fn JSObjectHasProperty(
756 ctx: JSContextRef,
757 object: JSObjectRef,
758 property_name: JSStringRef,
759 ) -> bool;
760}
761
762extern "C-unwind" {
763 /// Gets a property from an object.
764 ///
765 /// Parameter `ctx`: The execution context to use.
766 ///
767 /// Parameter `object`: The JSObject whose property you want to get.
768 ///
769 /// Parameter `propertyName`: A JSString containing the property's name.
770 ///
771 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
772 ///
773 /// Returns: The property's value if object has the property, otherwise the undefined value.
774 #[cfg(feature = "JSBase")]
775 pub fn JSObjectGetProperty(
776 ctx: JSContextRef,
777 object: JSObjectRef,
778 property_name: JSStringRef,
779 exception: *mut JSValueRef,
780 ) -> JSValueRef;
781}
782
783extern "C-unwind" {
784 /// Sets a property on an object.
785 ///
786 /// Parameter `ctx`: The execution context to use.
787 ///
788 /// Parameter `object`: The JSObject whose property you want to set.
789 ///
790 /// Parameter `propertyName`: A JSString containing the property's name.
791 ///
792 /// Parameter `value`: A JSValueRef to use as the property's value.
793 ///
794 /// Parameter `attributes`: A logically ORed set of JSPropertyAttributes to give to the property.
795 ///
796 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
797 #[cfg(feature = "JSBase")]
798 pub fn JSObjectSetProperty(
799 ctx: JSContextRef,
800 object: JSObjectRef,
801 property_name: JSStringRef,
802 value: JSValueRef,
803 attributes: JSPropertyAttributes,
804 exception: *mut JSValueRef,
805 );
806}
807
808extern "C-unwind" {
809 /// Deletes a property from an object.
810 ///
811 /// Parameter `ctx`: The execution context to use.
812 ///
813 /// Parameter `object`: The JSObject whose property you want to delete.
814 ///
815 /// Parameter `propertyName`: A JSString containing the property's name.
816 ///
817 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
818 ///
819 /// Returns: true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
820 #[cfg(feature = "JSBase")]
821 pub fn JSObjectDeleteProperty(
822 ctx: JSContextRef,
823 object: JSObjectRef,
824 property_name: JSStringRef,
825 exception: *mut JSValueRef,
826 ) -> bool;
827}
828
829extern "C-unwind" {
830 /// Tests whether an object has a given property using a JSValueRef as the property key.
831 ///
832 /// Parameter `object`: The JSObject to test.
833 ///
834 /// Parameter `propertyKey`: A JSValueRef containing the property key to use when looking up the property.
835 ///
836 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
837 ///
838 /// Returns: true if the object has a property whose name matches propertyKey, otherwise false.
839 ///
840 /// This function is the same as performing "propertyKey in object" from JavaScript.
841 #[cfg(feature = "JSBase")]
842 pub fn JSObjectHasPropertyForKey(
843 ctx: JSContextRef,
844 object: JSObjectRef,
845 property_key: JSValueRef,
846 exception: *mut JSValueRef,
847 ) -> bool;
848}
849
850extern "C-unwind" {
851 /// Gets a property from an object using a JSValueRef as the property key.
852 ///
853 /// Parameter `ctx`: The execution context to use.
854 ///
855 /// Parameter `object`: The JSObject whose property you want to get.
856 ///
857 /// Parameter `propertyKey`: A JSValueRef containing the property key to use when looking up the property.
858 ///
859 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
860 ///
861 /// Returns: The property's value if object has the property key, otherwise the undefined value.
862 ///
863 /// This function is the same as performing "object[propertyKey]" from JavaScript.
864 #[cfg(feature = "JSBase")]
865 pub fn JSObjectGetPropertyForKey(
866 ctx: JSContextRef,
867 object: JSObjectRef,
868 property_key: JSValueRef,
869 exception: *mut JSValueRef,
870 ) -> JSValueRef;
871}
872
873extern "C-unwind" {
874 /// Sets a property on an object using a JSValueRef as the property key.
875 ///
876 /// Parameter `ctx`: The execution context to use.
877 ///
878 /// Parameter `object`: The JSObject whose property you want to set.
879 ///
880 /// Parameter `propertyKey`: A JSValueRef containing the property key to use when looking up the property.
881 ///
882 /// Parameter `value`: A JSValueRef to use as the property's value.
883 ///
884 /// Parameter `attributes`: A logically ORed set of JSPropertyAttributes to give to the property.
885 ///
886 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
887 ///
888 /// This function is the same as performing "object[propertyKey] = value" from JavaScript.
889 #[cfg(feature = "JSBase")]
890 pub fn JSObjectSetPropertyForKey(
891 ctx: JSContextRef,
892 object: JSObjectRef,
893 property_key: JSValueRef,
894 value: JSValueRef,
895 attributes: JSPropertyAttributes,
896 exception: *mut JSValueRef,
897 );
898}
899
900extern "C-unwind" {
901 /// Deletes a property from an object using a JSValueRef as the property key.
902 ///
903 /// Parameter `ctx`: The execution context to use.
904 ///
905 /// Parameter `object`: The JSObject whose property you want to delete.
906 ///
907 /// Parameter `propertyKey`: A JSValueRef containing the property key to use when looking up the property.
908 ///
909 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
910 ///
911 /// Returns: true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
912 ///
913 /// This function is the same as performing "delete object[propertyKey]" from JavaScript.
914 #[cfg(feature = "JSBase")]
915 pub fn JSObjectDeletePropertyForKey(
916 ctx: JSContextRef,
917 object: JSObjectRef,
918 property_key: JSValueRef,
919 exception: *mut JSValueRef,
920 ) -> bool;
921}
922
923extern "C-unwind" {
924 /// Gets a property from an object by numeric index.
925 ///
926 /// Parameter `ctx`: The execution context to use.
927 ///
928 /// Parameter `object`: The JSObject whose property you want to get.
929 ///
930 /// Parameter `propertyIndex`: An integer value that is the property's name.
931 ///
932 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
933 ///
934 /// Returns: The property's value if object has the property, otherwise the undefined value.
935 ///
936 /// Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties.
937 #[cfg(feature = "JSBase")]
938 pub fn JSObjectGetPropertyAtIndex(
939 ctx: JSContextRef,
940 object: JSObjectRef,
941 property_index: c_uint,
942 exception: *mut JSValueRef,
943 ) -> JSValueRef;
944}
945
946extern "C-unwind" {
947 /// Sets a property on an object by numeric index.
948 ///
949 /// Parameter `ctx`: The execution context to use.
950 ///
951 /// Parameter `object`: The JSObject whose property you want to set.
952 ///
953 /// Parameter `propertyIndex`: The property's name as a number.
954 ///
955 /// Parameter `value`: A JSValue to use as the property's value.
956 ///
957 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
958 ///
959 /// Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties.
960 #[cfg(feature = "JSBase")]
961 pub fn JSObjectSetPropertyAtIndex(
962 ctx: JSContextRef,
963 object: JSObjectRef,
964 property_index: c_uint,
965 value: JSValueRef,
966 exception: *mut JSValueRef,
967 );
968}
969
970extern "C-unwind" {
971 /// Gets an object's private data.
972 ///
973 /// Parameter `object`: A JSObject whose private data you want to get.
974 ///
975 /// Returns: A void* that is the object's private data, if the object has private data, otherwise NULL.
976 #[cfg(feature = "JSBase")]
977 pub fn JSObjectGetPrivate(object: JSObjectRef) -> *mut c_void;
978}
979
980extern "C-unwind" {
981 /// Sets a pointer to private data on an object.
982 ///
983 /// Parameter `object`: The JSObject whose private data you want to set.
984 ///
985 /// Parameter `data`: A void* to set as the object's private data.
986 ///
987 /// Returns: true if object can store private data, otherwise false.
988 ///
989 /// The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.
990 #[cfg(feature = "JSBase")]
991 pub fn JSObjectSetPrivate(object: JSObjectRef, data: *mut c_void) -> bool;
992}
993
994extern "C-unwind" {
995 /// Tests whether an object can be called as a function.
996 ///
997 /// Parameter `ctx`: The execution context to use.
998 ///
999 /// Parameter `object`: The JSObject to test.
1000 ///
1001 /// Returns: true if the object can be called as a function, otherwise false.
1002 #[cfg(feature = "JSBase")]
1003 pub fn JSObjectIsFunction(ctx: JSContextRef, object: JSObjectRef) -> bool;
1004}
1005
1006extern "C-unwind" {
1007 /// Calls an object as a function.
1008 ///
1009 /// Parameter `ctx`: The execution context to use.
1010 ///
1011 /// Parameter `object`: The JSObject to call as a function.
1012 ///
1013 /// Parameter `thisObject`: The object to use as "this," or NULL to use the global object as "this."
1014 ///
1015 /// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
1016 ///
1017 /// Parameter `arguments`: A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0.
1018 ///
1019 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
1020 ///
1021 /// Returns: The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.
1022 #[cfg(feature = "JSBase")]
1023 pub fn JSObjectCallAsFunction(
1024 ctx: JSContextRef,
1025 object: JSObjectRef,
1026 this_object: JSObjectRef,
1027 argument_count: usize,
1028 arguments: *mut JSValueRef,
1029 exception: *mut JSValueRef,
1030 ) -> JSValueRef;
1031}
1032
1033extern "C-unwind" {
1034 /// Tests whether an object can be called as a constructor.
1035 ///
1036 /// Parameter `ctx`: The execution context to use.
1037 ///
1038 /// Parameter `object`: The JSObject to test.
1039 ///
1040 /// Returns: true if the object can be called as a constructor, otherwise false.
1041 #[cfg(feature = "JSBase")]
1042 pub fn JSObjectIsConstructor(ctx: JSContextRef, object: JSObjectRef) -> bool;
1043}
1044
1045extern "C-unwind" {
1046 /// Calls an object as a constructor.
1047 ///
1048 /// Parameter `ctx`: The execution context to use.
1049 ///
1050 /// Parameter `object`: The JSObject to call as a constructor.
1051 ///
1052 /// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
1053 ///
1054 /// Parameter `arguments`: A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0.
1055 ///
1056 /// Parameter `exception`: A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
1057 ///
1058 /// Returns: The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.
1059 #[cfg(feature = "JSBase")]
1060 pub fn JSObjectCallAsConstructor(
1061 ctx: JSContextRef,
1062 object: JSObjectRef,
1063 argument_count: usize,
1064 arguments: *mut JSValueRef,
1065 exception: *mut JSValueRef,
1066 ) -> JSObjectRef;
1067}
1068
1069extern "C-unwind" {
1070 /// Gets the names of an object's enumerable properties.
1071 ///
1072 /// Parameter `ctx`: The execution context to use.
1073 ///
1074 /// Parameter `object`: The object whose property names you want to get.
1075 ///
1076 /// Returns: A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule.
1077 #[cfg(feature = "JSBase")]
1078 pub fn JSObjectCopyPropertyNames(
1079 ctx: JSContextRef,
1080 object: JSObjectRef,
1081 ) -> JSPropertyNameArrayRef;
1082}
1083
1084extern "C-unwind" {
1085 /// Retains a JavaScript property name array.
1086 ///
1087 /// Parameter `array`: The JSPropertyNameArray to retain.
1088 ///
1089 /// Returns: A JSPropertyNameArray that is the same as array.
1090 #[cfg(feature = "JSBase")]
1091 pub fn JSPropertyNameArrayRetain(array: JSPropertyNameArrayRef) -> JSPropertyNameArrayRef;
1092}
1093
1094extern "C-unwind" {
1095 /// Releases a JavaScript property name array.
1096 ///
1097 /// Parameter `array`: The JSPropetyNameArray to release.
1098 #[cfg(feature = "JSBase")]
1099 pub fn JSPropertyNameArrayRelease(array: JSPropertyNameArrayRef);
1100}
1101
1102extern "C-unwind" {
1103 /// Gets a count of the number of items in a JavaScript property name array.
1104 ///
1105 /// Parameter `array`: The array from which to retrieve the count.
1106 ///
1107 /// Returns: An integer count of the number of names in array.
1108 #[cfg(feature = "JSBase")]
1109 pub fn JSPropertyNameArrayGetCount(array: JSPropertyNameArrayRef) -> usize;
1110}
1111
1112extern "C-unwind" {
1113 /// Gets a property name at a given index in a JavaScript property name array.
1114 ///
1115 /// Parameter `array`: The array from which to retrieve the property name.
1116 ///
1117 /// Parameter `index`: The index of the property name to retrieve.
1118 ///
1119 /// Returns: A JSStringRef containing the property name.
1120 #[cfg(feature = "JSBase")]
1121 pub fn JSPropertyNameArrayGetNameAtIndex(
1122 array: JSPropertyNameArrayRef,
1123 index: usize,
1124 ) -> JSStringRef;
1125}
1126
1127extern "C-unwind" {
1128 /// Adds a property name to a JavaScript property name accumulator.
1129 ///
1130 /// Parameter `accumulator`: The accumulator object to which to add the property name.
1131 ///
1132 /// Parameter `propertyName`: The property name to add.
1133 #[cfg(feature = "JSBase")]
1134 pub fn JSPropertyNameAccumulatorAddName(
1135 accumulator: JSPropertyNameAccumulatorRef,
1136 property_name: JSStringRef,
1137 );
1138}