//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjspropertyattributenone?language=objc)
pub const kJSPropertyAttributeNone: c_uint = 0;
/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjspropertyattributereadonly?language=objc)
pub const kJSPropertyAttributeReadOnly: c_uint = 1 << 1;
/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjspropertyattributedontenum?language=objc)
pub const kJSPropertyAttributeDontEnum: c_uint = 1 << 2;
/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjspropertyattributedontdelete?language=objc)
pub const kJSPropertyAttributeDontDelete: c_uint = 1 << 3;
/// A set of JSPropertyAttributes. Combine multiple attributes by logically ORing them together.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jspropertyattributes?language=objc)
pub type JSPropertyAttributes = c_uint;
/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjsclassattributenone?language=objc)
pub const kJSClassAttributeNone: c_uint = 0;
/// [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjsclassattributenoautomaticprototype?language=objc)
pub const kJSClassAttributeNoAutomaticPrototype: c_uint = 1 << 1;
/// A set of JSClassAttributes. Combine multiple attributes by logically ORing them together.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsclassattributes?language=objc)
pub type JSClassAttributes = c_uint;
/// The callback invoked when an object is first created.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject being created.
///
/// If you named your function Initialize, you would declare it like this:
///
/// void Initialize(JSContextRef ctx, JSObjectRef object);
///
/// Unlike the other object callbacks, the initialize callback is called on the least
/// derived class (the parent class) first, and the most derived class last.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectinitializecallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectInitializeCallback =
Option<unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef)>;
/// The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
///
/// Parameter `object`: The JSObject being finalized.
///
/// If you named your function Finalize, you would declare it like this:
///
/// void Finalize(JSObjectRef object);
///
/// The finalize callback is called on the most derived class first, and the least
/// derived class (the parent class) last.
///
/// You must not call any function that may cause a garbage collection or an allocation
/// of a garbage collected object from within a JSObjectFinalizeCallback. This includes
/// all functions that have a JSContextRef parameter.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectfinalizecallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectFinalizeCallback = Option<unsafe extern "C-unwind" fn(JSObjectRef)>;
/// The callback invoked when determining whether an object has a property.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject to search for the property.
///
/// Parameter `propertyName`: A JSString containing the name of the property look up.
///
/// Returns: true if object has the property, otherwise false.
///
/// If you named your function HasProperty, you would declare it like this:
///
/// bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
///
/// 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.
///
/// 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.
///
/// If this callback is NULL, the getProperty callback will be used to service hasProperty requests.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjecthaspropertycallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectHasPropertyCallback =
Option<unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSStringRef) -> bool>;
/// The callback invoked when getting a property's value.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject to search for the property.
///
/// Parameter `propertyName`: A JSString containing the name of the property to get.
///
/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
///
/// Returns: The property's value if object has the property, otherwise NULL.
///
/// If you named your function GetProperty, you would declare it like this:
///
/// JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectgetpropertycallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectGetPropertyCallback = Option<
unsafe extern "C-unwind" fn(
JSContextRef,
JSObjectRef,
JSStringRef,
*mut JSValueRef,
) -> JSValueRef,
>;
/// The callback invoked when setting a property's value.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject on which to set the property's value.
///
/// Parameter `propertyName`: A JSString containing the name of the property to set.
///
/// Parameter `value`: A JSValue to use as the property's value.
///
/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
///
/// Returns: true if the property was set, otherwise false.
///
/// If you named your function SetProperty, you would declare it like this:
///
/// bool SetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
///
/// 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).
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectsetpropertycallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectSetPropertyCallback = Option<
unsafe extern "C-unwind" fn(
JSContextRef,
JSObjectRef,
JSStringRef,
JSValueRef,
*mut JSValueRef,
) -> bool,
>;
/// The callback invoked when deleting a property.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject in which to delete the property.
///
/// Parameter `propertyName`: A JSString containing the name of the property to delete.
///
/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
///
/// Returns: true if propertyName was successfully deleted, otherwise false.
///
/// If you named your function DeleteProperty, you would declare it like this:
///
/// bool DeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
///
/// 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).
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectdeletepropertycallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectDeletePropertyCallback = Option<
unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSStringRef, *mut JSValueRef) -> bool,
>;
/// The callback invoked when collecting the names of an object's properties.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property names are being collected.
///
/// Parameter `propertyNames`: A JavaScript property name accumulator in which to accumulate the names of object's properties.
///
/// If you named your function GetPropertyNames, you would declare it like this:
///
/// void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
///
/// Property name accumulators are used by JSObjectCopyPropertyNames and JavaScript for...in loops.
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectgetpropertynamescallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectGetPropertyNamesCallback =
Option<unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSPropertyNameAccumulatorRef)>;
/// The callback invoked when an object is called as a function.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `function`: A JSObject that is the function being called.
///
/// Parameter `thisObject`: A JSObject that is the 'this' variable in the function's scope.
///
/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
///
/// Parameter `arguments`: A JSValue array of the arguments passed to the function.
///
/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
///
/// Returns: A JSValue that is the function's return value.
///
/// If you named your function CallAsFunction, you would declare it like this:
///
/// JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
///
/// If your callback were invoked by the JavaScript expression 'myObject.myFunction()', function would be set to myFunction, and thisObject would be set to myObject.
///
/// If this callback is NULL, calling your object as a function will throw an exception.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectcallasfunctioncallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectCallAsFunctionCallback = Option<
unsafe extern "C-unwind" fn(
JSContextRef,
JSObjectRef,
JSObjectRef,
usize,
*mut JSValueRef,
*mut JSValueRef,
) -> JSValueRef,
>;
/// The callback invoked when an object is used as a constructor in a 'new' expression.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `constructor`: A JSObject that is the constructor being called.
///
/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
///
/// Parameter `arguments`: A JSValue array of the arguments passed to the function.
///
/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
///
/// Returns: A JSObject that is the constructor's return value.
///
/// If you named your function CallAsConstructor, you would declare it like this:
///
/// JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
///
/// If your callback were invoked by the JavaScript expression 'new myConstructor()', constructor would be set to myConstructor.
///
/// If this callback is NULL, using your object as a constructor in a 'new' expression will throw an exception.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectcallasconstructorcallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectCallAsConstructorCallback = Option<
unsafe extern "C-unwind" fn(
JSContextRef,
JSObjectRef,
usize,
*mut JSValueRef,
*mut JSValueRef,
) -> JSObjectRef,
>;
/// hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `constructor`: The JSObject that is the target of the 'instanceof' expression.
///
/// Parameter `possibleInstance`: The JSValue being tested to determine if it is an instance of constructor.
///
/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
///
/// Returns: true if possibleInstance is an instance of constructor, otherwise false.
///
/// If you named your function HasInstance, you would declare it like this:
///
/// bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
///
/// 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.
///
/// If this callback is NULL, 'instanceof' expressions that target your object will return false.
///
/// Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback as well.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjecthasinstancecallback?language=objc)
#[cfg(feature = "JSBase")]
pub type JSObjectHasInstanceCallback = Option<
unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSValueRef, *mut JSValueRef) -> bool,
>;
/// The callback invoked when converting an object to a particular JavaScript type.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject to convert.
///
/// Parameter `type`: A JSType specifying the JavaScript type to convert to.
///
/// Parameter `exception`: A pointer to a JSValueRef in which to return an exception, if any.
///
/// Returns: The objects's converted value, or NULL if the object was not converted.
///
/// If you named your function ConvertToType, you would declare it like this:
///
/// JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);
///
/// If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class).
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsobjectconverttotypecallback?language=objc)
#[cfg(all(feature = "JSBase", feature = "JSValueRef"))]
pub type JSObjectConvertToTypeCallback = Option<
unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, JSType, *mut JSValueRef) -> JSValueRef,
>;
/// This structure describes a statically declared value property.
/// Field: name A null-terminated UTF8 string containing the property's name.
/// Field: getProperty A JSObjectGetPropertyCallback to invoke when getting the property's value.
/// Field: setProperty A JSObjectSetPropertyCallback to invoke when setting the property's value. May be NULL if the ReadOnly attribute is set.
/// Field: attributes A logically ORed set of JSPropertyAttributes to give to the property.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsstaticvalue?language=objc)
#[cfg(feature = "JSBase")]
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct JSStaticValue {
pub name: *const c_char,
pub getProperty: JSObjectGetPropertyCallback,
pub setProperty: JSObjectSetPropertyCallback,
pub attributes: JSPropertyAttributes,
}
#[cfg(all(feature = "JSBase", feature = "objc2"))]
unsafe impl Encode for JSStaticValue {
const ENCODING: Encoding = Encoding::Struct(
"?",
&[
<*const c_char>::ENCODING,
<JSObjectGetPropertyCallback>::ENCODING,
Encoding::Pointer(&Encoding::Unknown),
<JSPropertyAttributes>::ENCODING,
],
);
}
#[cfg(all(feature = "JSBase", feature = "objc2"))]
unsafe impl RefEncode for JSStaticValue {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// This structure describes a statically declared function property.
/// Field: name A null-terminated UTF8 string containing the property's name.
/// Field: callAsFunction A JSObjectCallAsFunctionCallback to invoke when the property is called as a function.
/// Field: attributes A logically ORed set of JSPropertyAttributes to give to the property.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsstaticfunction?language=objc)
#[cfg(feature = "JSBase")]
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct JSStaticFunction {
pub name: *const c_char,
pub callAsFunction: JSObjectCallAsFunctionCallback,
pub attributes: JSPropertyAttributes,
}
#[cfg(all(feature = "JSBase", feature = "objc2"))]
unsafe impl Encode for JSStaticFunction {
const ENCODING: Encoding = Encoding::Struct(
"?",
&[
<*const c_char>::ENCODING,
<JSObjectCallAsFunctionCallback>::ENCODING,
<JSPropertyAttributes>::ENCODING,
],
);
}
#[cfg(all(feature = "JSBase", feature = "objc2"))]
unsafe impl RefEncode for JSStaticFunction {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// 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.
/// Field: version The version number of this structure. The current version is 0.
/// Field: attributes A logically ORed set of JSClassAttributes to give to the class.
/// Field: className A null-terminated UTF8 string containing the class's name.
/// Field: parentClass A JSClass to set as the class's parent class. Pass NULL use the default object class.
/// 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.
/// 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.
/// Field: initialize The callback invoked when an object is first created. Use this callback to initialize the object.
/// 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.
/// 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.
/// Field: getProperty The callback invoked when getting a property's value.
/// Field: setProperty The callback invoked when setting a property's value.
/// Field: deleteProperty The callback invoked when deleting a property.
/// Field: getPropertyNames The callback invoked when collecting the names of an object's properties.
/// Field: callAsFunction The callback invoked when an object is called as a function.
/// Field: hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
/// Field: callAsConstructor The callback invoked when an object is used as a constructor in a 'new' expression.
/// Field: convertToType The callback invoked when converting an object to a particular JavaScript type.
///
/// 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.
///
/// If you named your getter function "GetX" and your setter function "SetX", you would declare a JSStaticValue array containing "X" like this:
///
/// JSStaticValue StaticValueArray[] = {
/// { "X", GetX, SetX, kJSPropertyAttributeNone },
/// { 0, 0, 0, 0 }
/// };
///
/// 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.
///
/// A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute.
///
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/jsclassdefinition?language=objc)
#[cfg(all(feature = "JSBase", feature = "JSValueRef"))]
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct JSClassDefinition {
pub version: c_int,
pub attributes: JSClassAttributes,
pub className: *const c_char,
pub parentClass: JSClassRef,
pub staticValues: *const JSStaticValue,
pub staticFunctions: *const JSStaticFunction,
pub initialize: JSObjectInitializeCallback,
pub finalize: JSObjectFinalizeCallback,
pub hasProperty: JSObjectHasPropertyCallback,
pub getProperty: JSObjectGetPropertyCallback,
pub setProperty: JSObjectSetPropertyCallback,
pub deleteProperty: JSObjectDeletePropertyCallback,
pub getPropertyNames: JSObjectGetPropertyNamesCallback,
pub callAsFunction: JSObjectCallAsFunctionCallback,
pub callAsConstructor: JSObjectCallAsConstructorCallback,
pub hasInstance: JSObjectHasInstanceCallback,
pub convertToType: JSObjectConvertToTypeCallback,
}
#[cfg(all(feature = "JSBase", feature = "JSValueRef", feature = "objc2"))]
unsafe impl Encode for JSClassDefinition {
const ENCODING: Encoding = Encoding::Struct(
"?",
&[
<c_int>::ENCODING,
<JSClassAttributes>::ENCODING,
<*const c_char>::ENCODING,
<JSClassRef>::ENCODING,
<*const JSStaticValue>::ENCODING,
<*const JSStaticFunction>::ENCODING,
<JSObjectInitializeCallback>::ENCODING,
<JSObjectFinalizeCallback>::ENCODING,
Encoding::Pointer(&Encoding::Unknown),
<JSObjectGetPropertyCallback>::ENCODING,
Encoding::Pointer(&Encoding::Unknown),
Encoding::Pointer(&Encoding::Unknown),
<JSObjectGetPropertyNamesCallback>::ENCODING,
<JSObjectCallAsFunctionCallback>::ENCODING,
<JSObjectCallAsConstructorCallback>::ENCODING,
Encoding::Pointer(&Encoding::Unknown),
<JSObjectConvertToTypeCallback>::ENCODING,
],
);
}
#[cfg(all(feature = "JSBase", feature = "JSValueRef", feature = "objc2"))]
unsafe impl RefEncode for JSClassDefinition {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
/// A JSClassDefinition structure of the current version, filled with NULL pointers and having no attributes.
///
/// Use this constant as a convenience when creating class definitions. For example, to create a class definition with only a finalize method:
///
/// JSClassDefinition definition = kJSClassDefinitionEmpty;
/// definition.finalize = Finalize;
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/javascriptcore/kjsclassdefinitionempty?language=objc)
#[cfg(all(feature = "JSBase", feature = "JSValueRef"))]
pub static kJSClassDefinitionEmpty: JSClassDefinition;
}
extern "C-unwind" {
/// Creates a JavaScript class suitable for use with JSObjectMake.
///
/// Parameter `definition`: A JSClassDefinition that defines the class.
///
/// Returns: A JSClass with the given definition. Ownership follows the Create Rule.
///
/// # Safety
///
/// `definition` must be a valid pointer.
#[cfg(all(feature = "JSBase", feature = "JSValueRef"))]
pub fn JSClassCreate(definition: *const JSClassDefinition) -> JSClassRef;
}
extern "C-unwind" {
/// Retains a JavaScript class.
///
/// Parameter `jsClass`: The JSClass to retain.
///
/// Returns: A JSClass that is the same as jsClass.
///
/// # Safety
///
/// `js_class` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSClassRetain(js_class: JSClassRef) -> JSClassRef;
}
extern "C-unwind" {
/// Releases a JavaScript class.
///
/// Parameter `jsClass`: The JSClass to release.
///
/// # Safety
///
/// `js_class` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSClassRelease(js_class: JSClassRef);
}
extern "C-unwind" {
/// Creates a JavaScript object.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `jsClass`: The JSClass to assign to the object. Pass NULL to use the default object class.
///
/// Parameter `data`: A void* to set as the object's private data. Pass NULL to specify no private data.
///
/// Returns: A JSObject with the given class and private data.
///
/// 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.
///
/// 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.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `js_class` must be a valid pointer.
/// - `data` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectMake(ctx: JSContextRef, js_class: JSClassRef, data: *mut c_void) -> JSObjectRef;
}
extern "C-unwind" {
/// Convenience method for creating a JavaScript function with a given callback as its implementation.
///
/// Parameter `ctx`: The execution context to use.
///
/// 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.
///
/// Parameter `callAsFunction`: The JSObjectCallAsFunctionCallback to invoke when the function is called.
///
/// Returns: A JSObject that is a function. The object's prototype will be the default function prototype.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `name` must be a valid pointer.
/// - `call_as_function` must be implemented correctly.
#[cfg(feature = "JSBase")]
pub fn JSObjectMakeFunctionWithCallback(
ctx: JSContextRef,
name: JSStringRef,
call_as_function: JSObjectCallAsFunctionCallback,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Convenience method for creating a JavaScript constructor.
///
/// Parameter `ctx`: The execution context to use.
///
/// 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.
///
/// Parameter `callAsConstructor`: A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a 'new' expression. Pass NULL to use the default object constructor.
///
/// Returns: A JSObject that is a constructor. The object's prototype will be the default object prototype.
///
/// 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.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `js_class` must be a valid pointer.
/// - `call_as_constructor` must be implemented correctly.
#[cfg(feature = "JSBase")]
pub fn JSObjectMakeConstructor(
ctx: JSContextRef,
js_class: JSClassRef,
call_as_constructor: JSObjectCallAsConstructorCallback,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Creates a JavaScript Array object.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
///
/// Parameter `arguments`: A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0.
///
/// 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.
///
/// Returns: A JSObject that is an Array.
///
/// The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument
/// is supplied, this function returns an array with one element.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `arguments` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectMakeArray(
ctx: JSContextRef,
argument_count: usize,
arguments: *mut JSValueRef,
exception: *mut JSValueRef,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Creates a JavaScript Date object, as if by invoking the built-in Date constructor.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
///
/// Parameter `arguments`: A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0.
///
/// 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.
///
/// Returns: A JSObject that is a Date.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `arguments` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectMakeDate(
ctx: JSContextRef,
argument_count: usize,
arguments: *mut JSValueRef,
exception: *mut JSValueRef,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Creates a JavaScript Error object, as if by invoking the built-in Error constructor.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
///
/// Parameter `arguments`: A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0.
///
/// 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.
///
/// Returns: A JSObject that is an Error.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `arguments` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectMakeError(
ctx: JSContextRef,
argument_count: usize,
arguments: *mut JSValueRef,
exception: *mut JSValueRef,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
///
/// Parameter `arguments`: A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0.
///
/// 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.
///
/// Returns: A JSObject that is a RegExp.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `arguments` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectMakeRegExp(
ctx: JSContextRef,
argument_count: usize,
arguments: *mut JSValueRef,
exception: *mut JSValueRef,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Creates a JavaScript promise object by invoking the provided executor.
///
/// Parameter `ctx`: The execution context to use.
///
/// 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.
///
/// 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.
///
/// 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.
///
/// Returns: A JSObject that is a promise or NULL if an exception occurred.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `resolve` must be a valid pointer.
/// - `reject` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectMakeDeferredPromise(
ctx: JSContextRef,
resolve: *mut JSObjectRef,
reject: *mut JSObjectRef,
exception: *mut JSValueRef,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Creates a function with a given script as its body.
///
/// Parameter `ctx`: The execution context to use.
///
/// 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.
///
/// Parameter `parameterCount`: An integer count of the number of parameter names in parameterNames.
///
/// Parameter `parameterNames`: A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0.
///
/// Parameter `body`: A JSString containing the script to use as the function's body.
///
/// 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.
///
/// 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.
///
/// 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.
///
/// 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.
///
/// Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `name` must be a valid pointer.
/// - `parameter_names` must be a valid pointer.
/// - `body` must be a valid pointer.
/// - `source_url` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectMakeFunction(
ctx: JSContextRef,
name: JSStringRef,
parameter_count: c_uint,
parameter_names: *mut JSStringRef,
body: JSStringRef,
source_url: JSStringRef,
starting_line_number: c_int,
exception: *mut JSValueRef,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Gets an object's prototype.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: A JSObject whose prototype you want to get.
///
/// Returns: A JSValue that is the object's prototype.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectGetPrototype(ctx: JSContextRef, object: JSObjectRef) -> JSValueRef;
}
extern "C-unwind" {
/// Sets an object's prototype.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose prototype you want to set.
///
/// Parameter `value`: A JSValue to set as the object's prototype.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `value` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectSetPrototype(ctx: JSContextRef, object: JSObjectRef, value: JSValueRef);
}
extern "C-unwind" {
/// Tests whether an object has a given property.
///
/// Parameter `object`: The JSObject to test.
///
/// Parameter `propertyName`: A JSString containing the property's name.
///
/// Returns: true if the object has a property whose name matches propertyName, otherwise false.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `property_name` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectHasProperty(
ctx: JSContextRef,
object: JSObjectRef,
property_name: JSStringRef,
) -> bool;
}
extern "C-unwind" {
/// Gets a property from an object.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property you want to get.
///
/// Parameter `propertyName`: A JSString containing the property's name.
///
/// 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.
///
/// Returns: The property's value if object has the property, otherwise the undefined value.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `property_name` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectGetProperty(
ctx: JSContextRef,
object: JSObjectRef,
property_name: JSStringRef,
exception: *mut JSValueRef,
) -> JSValueRef;
}
extern "C-unwind" {
/// Sets a property on an object.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property you want to set.
///
/// Parameter `propertyName`: A JSString containing the property's name.
///
/// Parameter `value`: A JSValueRef to use as the property's value.
///
/// Parameter `attributes`: A logically ORed set of JSPropertyAttributes to give to the property.
///
/// 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.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `property_name` must be a valid pointer.
/// - `value` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectSetProperty(
ctx: JSContextRef,
object: JSObjectRef,
property_name: JSStringRef,
value: JSValueRef,
attributes: JSPropertyAttributes,
exception: *mut JSValueRef,
);
}
extern "C-unwind" {
/// Deletes a property from an object.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property you want to delete.
///
/// Parameter `propertyName`: A JSString containing the property's name.
///
/// 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.
///
/// Returns: true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `property_name` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectDeleteProperty(
ctx: JSContextRef,
object: JSObjectRef,
property_name: JSStringRef,
exception: *mut JSValueRef,
) -> bool;
}
extern "C-unwind" {
/// Tests whether an object has a given property using a JSValueRef as the property key.
///
/// Parameter `object`: The JSObject to test.
///
/// Parameter `propertyKey`: A JSValueRef containing the property key to use when looking up the property.
///
/// 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.
///
/// Returns: true if the object has a property whose name matches propertyKey, otherwise false.
///
/// This function is the same as performing "propertyKey in object" from JavaScript.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `property_key` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectHasPropertyForKey(
ctx: JSContextRef,
object: JSObjectRef,
property_key: JSValueRef,
exception: *mut JSValueRef,
) -> bool;
}
extern "C-unwind" {
/// Gets a property from an object using a JSValueRef as the property key.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property you want to get.
///
/// Parameter `propertyKey`: A JSValueRef containing the property key to use when looking up the property.
///
/// 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.
///
/// Returns: The property's value if object has the property key, otherwise the undefined value.
///
/// This function is the same as performing "object[propertyKey]" from JavaScript.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `property_key` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectGetPropertyForKey(
ctx: JSContextRef,
object: JSObjectRef,
property_key: JSValueRef,
exception: *mut JSValueRef,
) -> JSValueRef;
}
extern "C-unwind" {
/// Sets a property on an object using a JSValueRef as the property key.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property you want to set.
///
/// Parameter `propertyKey`: A JSValueRef containing the property key to use when looking up the property.
///
/// Parameter `value`: A JSValueRef to use as the property's value.
///
/// Parameter `attributes`: A logically ORed set of JSPropertyAttributes to give to the property.
///
/// 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.
///
/// This function is the same as performing "object[propertyKey] = value" from JavaScript.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `property_key` must be a valid pointer.
/// - `value` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectSetPropertyForKey(
ctx: JSContextRef,
object: JSObjectRef,
property_key: JSValueRef,
value: JSValueRef,
attributes: JSPropertyAttributes,
exception: *mut JSValueRef,
);
}
extern "C-unwind" {
/// Deletes a property from an object using a JSValueRef as the property key.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property you want to delete.
///
/// Parameter `propertyKey`: A JSValueRef containing the property key to use when looking up the property.
///
/// 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.
///
/// Returns: true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
///
/// This function is the same as performing "delete object[propertyKey]" from JavaScript.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `property_key` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectDeletePropertyForKey(
ctx: JSContextRef,
object: JSObjectRef,
property_key: JSValueRef,
exception: *mut JSValueRef,
) -> bool;
}
extern "C-unwind" {
/// Gets a property from an object by numeric index.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property you want to get.
///
/// Parameter `propertyIndex`: An integer value that is the property's name.
///
/// 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.
///
/// Returns: The property's value if object has the property, otherwise the undefined value.
///
/// Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectGetPropertyAtIndex(
ctx: JSContextRef,
object: JSObjectRef,
property_index: c_uint,
exception: *mut JSValueRef,
) -> JSValueRef;
}
extern "C-unwind" {
/// Sets a property on an object by numeric index.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject whose property you want to set.
///
/// Parameter `propertyIndex`: The property's name as a number.
///
/// Parameter `value`: A JSValue to use as the property's value.
///
/// 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.
///
/// Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `value` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectSetPropertyAtIndex(
ctx: JSContextRef,
object: JSObjectRef,
property_index: c_uint,
value: JSValueRef,
exception: *mut JSValueRef,
);
}
extern "C-unwind" {
/// Gets an object's private data.
///
/// Parameter `object`: A JSObject whose private data you want to get.
///
/// Returns: A void* that is the object's private data, if the object has private data, otherwise NULL.
///
/// # Safety
///
/// `object` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectGetPrivate(object: JSObjectRef) -> *mut c_void;
}
extern "C-unwind" {
/// Sets a pointer to private data on an object.
///
/// Parameter `object`: The JSObject whose private data you want to set.
///
/// Parameter `data`: A void* to set as the object's private data.
///
/// Returns: true if object can store private data, otherwise false.
///
/// The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.
///
/// # Safety
///
/// - `object` must be a valid pointer.
/// - `data` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectSetPrivate(object: JSObjectRef, data: *mut c_void) -> bool;
}
extern "C-unwind" {
/// Tests whether an object can be called as a function.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject to test.
///
/// Returns: true if the object can be called as a function, otherwise false.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectIsFunction(ctx: JSContextRef, object: JSObjectRef) -> bool;
}
extern "C-unwind" {
/// Calls an object as a function.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject to call as a function.
///
/// Parameter `thisObject`: The object to use as "this," or NULL to use the global object as "this."
///
/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
///
/// Parameter `arguments`: A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0.
///
/// 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.
///
/// Returns: The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `this_object` must be a valid pointer.
/// - `arguments` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectCallAsFunction(
ctx: JSContextRef,
object: JSObjectRef,
this_object: JSObjectRef,
argument_count: usize,
arguments: *mut JSValueRef,
exception: *mut JSValueRef,
) -> JSValueRef;
}
extern "C-unwind" {
/// Tests whether an object can be called as a constructor.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject to test.
///
/// Returns: true if the object can be called as a constructor, otherwise false.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectIsConstructor(ctx: JSContextRef, object: JSObjectRef) -> bool;
}
extern "C-unwind" {
/// Calls an object as a constructor.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The JSObject to call as a constructor.
///
/// Parameter `argumentCount`: An integer count of the number of arguments in arguments.
///
/// Parameter `arguments`: A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0.
///
/// 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.
///
/// Returns: The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
/// - `arguments` must be a valid pointer.
/// - `exception` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectCallAsConstructor(
ctx: JSContextRef,
object: JSObjectRef,
argument_count: usize,
arguments: *mut JSValueRef,
exception: *mut JSValueRef,
) -> JSObjectRef;
}
extern "C-unwind" {
/// Gets the names of an object's enumerable properties.
///
/// Parameter `ctx`: The execution context to use.
///
/// Parameter `object`: The object whose property names you want to get.
///
/// Returns: A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule.
///
/// # Safety
///
/// - `ctx` must be a valid pointer.
/// - `object` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSObjectCopyPropertyNames(
ctx: JSContextRef,
object: JSObjectRef,
) -> JSPropertyNameArrayRef;
}
extern "C-unwind" {
/// Retains a JavaScript property name array.
///
/// Parameter `array`: The JSPropertyNameArray to retain.
///
/// Returns: A JSPropertyNameArray that is the same as array.
///
/// # Safety
///
/// `array` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSPropertyNameArrayRetain(array: JSPropertyNameArrayRef) -> JSPropertyNameArrayRef;
}
extern "C-unwind" {
/// Releases a JavaScript property name array.
///
/// Parameter `array`: The JSPropetyNameArray to release.
///
/// # Safety
///
/// `array` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSPropertyNameArrayRelease(array: JSPropertyNameArrayRef);
}
extern "C-unwind" {
/// Gets a count of the number of items in a JavaScript property name array.
///
/// Parameter `array`: The array from which to retrieve the count.
///
/// Returns: An integer count of the number of names in array.
///
/// # Safety
///
/// `array` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSPropertyNameArrayGetCount(array: JSPropertyNameArrayRef) -> usize;
}
extern "C-unwind" {
/// Gets a property name at a given index in a JavaScript property name array.
///
/// Parameter `array`: The array from which to retrieve the property name.
///
/// Parameter `index`: The index of the property name to retrieve.
///
/// Returns: A JSStringRef containing the property name.
///
/// # Safety
///
/// `array` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSPropertyNameArrayGetNameAtIndex(
array: JSPropertyNameArrayRef,
index: usize,
) -> JSStringRef;
}
extern "C-unwind" {
/// Adds a property name to a JavaScript property name accumulator.
///
/// Parameter `accumulator`: The accumulator object to which to add the property name.
///
/// Parameter `propertyName`: The property name to add.
///
/// # Safety
///
/// - `accumulator` must be a valid pointer.
/// - `property_name` must be a valid pointer.
#[cfg(feature = "JSBase")]
pub fn JSPropertyNameAccumulatorAddName(
accumulator: JSPropertyNameAccumulatorRef,
property_name: JSStringRef,
);
}