Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
JSObjectRef.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006-2019 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com)
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef JSObjectRef_h
28#define JSObjectRef_h
29
33
34#ifndef __cplusplus
35#include <stdbool.h>
36#endif
37#include <stddef.h> /* for size_t */
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43/*!
44@enum JSPropertyAttribute
45@constant kJSPropertyAttributeNone Specifies that a property has no special attributes.
46@constant kJSPropertyAttributeReadOnly Specifies that a property is read-only.
47@constant kJSPropertyAttributeDontEnum Specifies that a property should not be enumerated by JSPropertyEnumerators and JavaScript for...in loops.
48@constant kJSPropertyAttributeDontDelete Specifies that the delete operation should fail on a property.
49*/
50enum {
55};
56
57/*!
58@typedef JSPropertyAttributes
59@abstract A set of JSPropertyAttributes. Combine multiple attributes by logically ORing them together.
60*/
61typedef unsigned JSPropertyAttributes;
62
63/*!
64@enum JSClassAttribute
65@constant kJSClassAttributeNone Specifies that a class has no special attributes.
66@constant kJSClassAttributeNoAutomaticPrototype Specifies that a class should not automatically generate a shared prototype for its instance objects. Use kJSClassAttributeNoAutomaticPrototype in combination with JSObjectSetPrototype to manage prototypes manually.
67*/
68enum {
71};
72
73/*!
74@typedef JSClassAttributes
75@abstract A set of JSClassAttributes. Combine multiple attributes by logically ORing them together.
76*/
77typedef unsigned JSClassAttributes;
78
79/*!
80@typedef JSObjectInitializeCallback
81@abstract The callback invoked when an object is first created.
82@param ctx The execution context to use.
83@param object The JSObject being created.
84@discussion If you named your function Initialize, you would declare it like this:
85
86void Initialize(JSContextRef ctx, JSObjectRef object);
87
88Unlike the other object callbacks, the initialize callback is called on the least
89derived class (the parent class) first, and the most derived class last.
90*/
91typedef void
93
94/* Extension of the above callback with the class that the method is being invoked for. */
95typedef void
97
98/*!
99@typedef JSObjectFinalizeCallback
100@abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
101@param object The JSObject being finalized.
102@discussion If you named your function Finalize, you would declare it like this:
103
104void Finalize(JSObjectRef object);
105
106The finalize callback is called on the most derived class first, and the least
107derived class (the parent class) last.
108
109You must not call any function that may cause a garbage collection or an allocation
110of a garbage collected object from within a JSObjectFinalizeCallback. This includes
111all functions that have a JSContextRef parameter.
112*/
113typedef void
115
116/* Extension of the above callback with the class that the method is being invoked for. */
117typedef void
119
120/*!
121@typedef JSObjectHasPropertyCallback
122@abstract The callback invoked when determining whether an object has a property.
123@param ctx The execution context to use.
124@param object The JSObject to search for the property.
125@param propertyName A JSString containing the name of the property look up.
126@result true if object has the property, otherwise false.
127@discussion If you named your function HasProperty, you would declare it like this:
128
129bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
130
131If 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.
132
133This 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.
134
135If this callback is NULL, the getProperty callback will be used to service hasProperty requests.
136*/
137typedef bool
139
140/* Extension of the above callback with the class that the method is being invoked for. */
141typedef bool
142(*JSObjectHasPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName);
143
144/*!
145@typedef JSObjectGetPropertyCallback
146@abstract The callback invoked when getting a property's value.
147@param ctx The execution context to use.
148@param object The JSObject to search for the property.
149@param propertyName A JSString containing the name of the property to get.
150@param exception A pointer to a JSValueRef in which to return an exception, if any.
151@result The property's value if object has the property, otherwise NULL.
152@discussion If you named your function GetProperty, you would declare it like this:
153
154JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
155
156If 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.
157*/
159(*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
160
161/* Extension of the above callback with the class that the method is being invoked for. */
163(*JSObjectGetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
164
165/*!
166@typedef JSObjectSetPropertyCallback
167@abstract The callback invoked when setting a property's value.
168@param ctx The execution context to use.
169@param object The JSObject on which to set the property's value.
170@param propertyName A JSString containing the name of the property to set.
171@param value A JSValue to use as the property's value.
172@param exception A pointer to a JSValueRef in which to return an exception, if any.
173@result true if the property was set, otherwise false.
174@discussion If you named your function SetProperty, you would declare it like this:
175
176bool SetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
177
178If 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).
179*/
180typedef bool
181(*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
182
183/* Extension of the above callback with the class that the method is being invoked for. */
184typedef bool
185(*JSObjectSetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
186
187/*!
188@typedef JSObjectDeletePropertyCallback
189@abstract The callback invoked when deleting a property.
190@param ctx The execution context to use.
191@param object The JSObject in which to delete the property.
192@param propertyName A JSString containing the name of the property to delete.
193@param exception A pointer to a JSValueRef in which to return an exception, if any.
194@result true if propertyName was successfully deleted, otherwise false.
195@discussion If you named your function DeleteProperty, you would declare it like this:
196
197bool DeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
198
199If 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).
200*/
201typedef bool
202(*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
203
204/* Extension of the above callback with the class that the method is being invoked for. */
205typedef bool
206(*JSObjectDeletePropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
207
208/*!
209@typedef JSObjectGetPropertyNamesCallback
210@abstract The callback invoked when collecting the names of an object's properties.
211@param ctx The execution context to use.
212@param object The JSObject whose property names are being collected.
213@param propertyNames A JavaScript property name accumulator in which to accumulate the names of object's properties.
214@discussion If you named your function GetPropertyNames, you would declare it like this:
215
216void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
217
218Property name accumulators are used by JSObjectCopyPropertyNames and JavaScript for...in loops.
219
220Use 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.
221*/
222typedef void
224
225/* Extension of the above callback with the class that the method is being invoked for. */
226typedef void
228
229/*!
230@typedef JSObjectCallAsFunctionCallback
231@abstract The callback invoked when an object is called as a function.
232@param ctx The execution context to use.
233@param function A JSObject that is the function being called.
234@param thisObject A JSObject that is the 'this' variable in the function's scope.
235@param argumentCount An integer count of the number of arguments in arguments.
236@param arguments A JSValue array of the arguments passed to the function.
237@param exception A pointer to a JSValueRef in which to return an exception, if any.
238@result A JSValue that is the function's return value.
239@discussion If you named your function CallAsFunction, you would declare it like this:
240
241JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
242
243If your callback were invoked by the JavaScript expression 'myObject.myFunction()', function would be set to myFunction, and thisObject would be set to myObject.
244
245If this callback is NULL, calling your object as a function will throw an exception.
246*/
248(*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
249
250/* Extension of the above callback with the class and class name of the object being called as a function.
251@discussion If this is a JSStaticFunctionEx, className will actually be the name of the function.
252*/
254(*JSObjectCallAsFunctionCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSStringRef className, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
255
256/*!
257@typedef JSObjectCallAsConstructorCallback
258@abstract The callback invoked when an object is used as a constructor in a 'new' expression.
259@param ctx The execution context to use.
260@param constructor A JSObject that is the constructor being called.
261@param argumentCount An integer count of the number of arguments in arguments.
262@param arguments A JSValue array of the arguments passed to the function.
263@param exception A pointer to a JSValueRef in which to return an exception, if any.
264@result A JSObject that is the constructor's return value.
265@discussion If you named your function CallAsConstructor, you would declare it like this:
266
267JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
268
269If your callback were invoked by the JavaScript expression 'new myConstructor()', constructor would be set to myConstructor.
270
271If this callback is NULL, using your object as a constructor in a 'new' expression will throw an exception.
272*/
274(*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
275
276/* Extension of the above callback with the class that the method is being invoked for. */
278(*JSObjectCallAsConstructorCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
279
280/*!
281@typedef JSObjectHasInstanceCallback
282@abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
283@param ctx The execution context to use.
284@param constructor The JSObject that is the target of the 'instanceof' expression.
285@param possibleInstance The JSValue being tested to determine if it is an instance of constructor.
286@param exception A pointer to a JSValueRef in which to return an exception, if any.
287@result true if possibleInstance is an instance of constructor, otherwise false.
288@discussion If you named your function HasInstance, you would declare it like this:
289
290bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
291
292If your callback were invoked by the JavaScript expression 'someValue instanceof myObject', constructor would be set to myObject and possibleInstance would be set to someValue.
293
294If this callback is NULL, 'instanceof' expressions that target your object will return false.
295
296Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback as well.
297*/
298typedef bool
299(*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
300
301/* Extension of the above callback with the class that the method is being invoked for. */
302typedef bool
303(*JSObjectHasInstanceCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
304
305/*!
306@typedef JSObjectConvertToTypeCallback
307@abstract The callback invoked when converting an object to a particular JavaScript type.
308@param ctx The execution context to use.
309@param object The JSObject to convert.
310@param type A JSType specifying the JavaScript type to convert to.
311@param exception A pointer to a JSValueRef in which to return an exception, if any.
312@result The objects's converted value, or NULL if the object was not converted.
313@discussion If you named your function ConvertToType, you would declare it like this:
314
315JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);
316
317If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class).
318
319This 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.
320*/
323
324/* Extension of the above callback with the class that the method is being invoked for. */
326(*JSObjectConvertToTypeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSType type, JSValueRef* exception);
327
328/*!
329@struct JSStaticValue
330@abstract This structure describes a statically declared value property.
331@field name A null-terminated UTF8 string containing the property's name.
332@field getProperty A JSObjectGetPropertyCallback to invoke when getting the property's value.
333@field setProperty A JSObjectSetPropertyCallback to invoke when setting the property's value. May be NULL if the ReadOnly attribute is set.
334@field attributes A logically ORed set of JSPropertyAttributes to give to the property.
335*/
336typedef struct {
337 const char* name;
342
343/* Extension of the above structure for use with class version 1000 */
344typedef struct {
345 const char* name;
350
351/*!
352@struct JSStaticFunction
353@abstract This structure describes a statically declared function property.
354@field name A null-terminated UTF8 string containing the property's name.
355@field callAsFunction A JSObjectCallAsFunctionCallback to invoke when the property is called as a function.
356@field attributes A logically ORed set of JSPropertyAttributes to give to the property.
357*/
358typedef struct {
359 const char* name;
363
364/* Extension of the above structure for use with class version 1000 */
365typedef struct {
366 const char* name;
370
371/*!
372@struct JSClassDefinition
373@abstract 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.
374@field version The version number of this structure. The current version is 0.
375@field attributes A logically ORed set of JSClassAttributes to give to the class.
376@field className A null-terminated UTF8 string containing the class's name.
377@field parentClass A JSClass to set as the class's parent class. Pass NULL use the default object class.
378@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.
379@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.
380@field initialize The callback invoked when an object is first created. Use this callback to initialize the object.
381@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.
382@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.
383@field getProperty The callback invoked when getting a property's value.
384@field setProperty The callback invoked when setting a property's value.
385@field deleteProperty The callback invoked when deleting a property.
386@field getPropertyNames The callback invoked when collecting the names of an object's properties.
387@field callAsFunction The callback invoked when an object is called as a function.
388@field hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
389@field callAsConstructor The callback invoked when an object is used as a constructor in a 'new' expression.
390@field convertToType The callback invoked when converting an object to a particular JavaScript type.
391@discussion 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.
392
393If you named your getter function "GetX" and your setter function "SetX", you would declare a JSStaticValue array containing "X" like this:
394
395JSStaticValue StaticValueArray[] = {
396 { "X", GetX, SetX, kJSPropertyAttributeNone },
397 { 0, 0, 0, 0 }
398};
399
400Standard 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.
401
402A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute.
403*/
404typedef struct {
405 int version; /* default version is 0, use version 1000 for callbacks with extended class information */
407
408 const char* className;
410
411 union {
412 /* version 0 */
413 struct {
427 };
428
429 /* version 1000 */
430 struct {
444 };
445 };
446
447 void* privateData; /* version 1000 only */
449
450/*!
451@const kJSClassDefinitionEmpty
452@abstract A JSClassDefinition structure of the current version, filled with NULL pointers and having no attributes.
453@discussion Use this constant as a convenience when creating class definitions. For example, to create a class definition with only a finalize method:
454
455JSClassDefinition definition = kJSClassDefinitionEmpty;
456definition.finalize = Finalize;
457*/
459
460/*!
461@function
462@abstract Creates a JavaScript class suitable for use with JSObjectMake.
463@param definition A JSClassDefinition that defines the class.
464@result A JSClass with the given definition. Ownership follows the Create Rule.
465*/
467
468/*!
469@function
470@abstract Retains a JavaScript class.
471@param jsClass The JSClass to retain.
472@result A JSClass that is the same as jsClass.
473*/
475
476/*!
477@function
478@abstract Releases a JavaScript class.
479@param jsClass The JSClass to release.
480*/
482
483/*!
484@function
485@abstract Retrieves the private data from a class reference, only possible with classes created with version 1000 (extended callbacks).
486@param jsClass The class to get the data from
487@result The private data on the class, or NULL, if not set
488@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes always NULL will always be returned.
489*/
491
492/*!
493@function
494@abstract Sets the private data on a class, only possible with classes created with version 1000 (extended callbacks).
495@param jsClass The class to set the data on
496@param data A void* to set as the private data for the class
497@result true if the data has been set on the class, false if the class has not been created with version 1000 (extended callbacks)
498@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes the function always fails. The set pointer is not touched by the engine.
499*/
500JS_EXPORT bool JSClassSetPrivate(JSClassRef jsClass, void* data);
501
502/*!
503@function
504@abstract Creates a JavaScript object.
505@param ctx The execution context to use.
506@param jsClass The JSClass to assign to the object. Pass NULL to use the default object class.
507@param data A void* to set as the object's private data. Pass NULL to specify no private data.
508@result A JSObject with the given class and private data.
509@discussion 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.
510
511data 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.
512*/
514
515/*!
516@function
517@abstract Convenience method for creating a JavaScript function with a given callback as its implementation.
518@param ctx The execution context to use.
519@param 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.
520@param callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called.
521@result A JSObject that is a function. The object's prototype will be the default function prototype.
522*/
524
525/*!
526@function
527@abstract Convenience method for creating a JavaScript constructor.
528@param ctx The execution context to use.
529@param 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.
530@param callAsConstructor A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a 'new' expression. Pass NULL to use the default object constructor.
531@result A JSObject that is a constructor. The object's prototype will be the default object prototype.
532@discussion The default object constructor takes no arguments and constructs an object of class jsClass with no private data.
533*/
535
536/*!
537 @function
538 @abstract Creates a JavaScript Array object.
539 @param ctx The execution context to use.
540 @param argumentCount An integer count of the number of arguments in arguments.
541 @param arguments A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0.
542 @param 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.
543 @result A JSObject that is an Array.
544 @discussion The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument
545 is supplied, this function returns an array with one element.
546 */
547JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
548
549/*!
550 @function
551 @abstract Creates a JavaScript Date object, as if by invoking the built-in Date constructor.
552 @param ctx The execution context to use.
553 @param argumentCount An integer count of the number of arguments in arguments.
554 @param arguments A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0.
555 @param 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.
556 @result A JSObject that is a Date.
557 */
558JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
559
560/*!
561 @function
562 @abstract Creates a JavaScript Error object, as if by invoking the built-in Error constructor.
563 @param ctx The execution context to use.
564 @param argumentCount An integer count of the number of arguments in arguments.
565 @param arguments A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0.
566 @param 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.
567 @result A JSObject that is a Error.
568 */
569JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
570
571/*!
572 @function
573 @abstract Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor.
574 @param ctx The execution context to use.
575 @param argumentCount An integer count of the number of arguments in arguments.
576 @param arguments A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0.
577 @param 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.
578 @result A JSObject that is a RegExp.
579 */
580JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) JSC_API_AVAILABLE(macos(10.6), ios(7.0));
581
582/*!
583 @function
584 @abstract Creates a JavaScript promise object by invoking the provided executor.
585 @param ctx The execution context to use.
586 @param 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.
587 @param 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.
588 @param 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 @result A JSObject that is a promise or NULL if an exception occurred.
590 */
592
593/*!
594@function
595@abstract Creates a function with a given script as its body.
596@param ctx The execution context to use.
597@param 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.
598@param parameterCount An integer count of the number of parameter names in parameterNames.
599@param parameterNames A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0.
600@param body A JSString containing the script to use as the function's body.
601@param 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.
602@param 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.
603@param 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.
604@result 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.
605@discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
606*/
607JS_EXPORT JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
608
609/*!
610@function
611@abstract Gets an object's prototype.
612@param ctx The execution context to use.
613@param object A JSObject whose prototype you want to get.
614@result A JSValue that is the object's prototype.
615*/
617
618/*!
619@function
620@abstract Sets an object's prototype.
621@param ctx The execution context to use.
622@param object The JSObject whose prototype you want to set.
623@param value A JSValue to set as the object's prototype.
624*/
626
627/*!
628@function
629@abstract Tests whether an object has a given property.
630@param object The JSObject to test.
631@param propertyName A JSString containing the property's name.
632@result true if the object has a property whose name matches propertyName, otherwise false.
633*/
635
636/*!
637@function
638@abstract Gets a property from an object.
639@param ctx The execution context to use.
640@param object The JSObject whose property you want to get.
641@param propertyName A JSString containing the property's name.
642@param 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.
643@result The property's value if object has the property, otherwise the undefined value.
644*/
646
647/*!
648@function
649@abstract Sets a property on an object.
650@param ctx The execution context to use.
651@param object The JSObject whose property you want to set.
652@param propertyName A JSString containing the property's name.
653@param value A JSValueRef to use as the property's value.
654@param attributes A logically ORed set of JSPropertyAttributes to give to the property.
655@param 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.
656*/
657JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception);
658
659/*!
660@function
661@abstract Deletes a property from an object.
662@param ctx The execution context to use.
663@param object The JSObject whose property you want to delete.
664@param propertyName A JSString containing the property's name.
665@param 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.
666@result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
667*/
669
670/*!
671 @function
672 @abstract Tests whether an object has a given property using a JSValueRef as the property key.
673 @param object The JSObject to test.
674 @param propertyKey A JSValueRef containing the property key to use when looking up the property.
675 @param 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 @result true if the object has a property whose name matches propertyKey, otherwise false.
677 @discussion This function is the same as performing "propertyKey in object" from JavaScript.
678 */
679JS_EXPORT bool JSObjectHasPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
680
681/*!
682 @function
683 @abstract Gets a property from an object using a JSValueRef as the property key.
684 @param ctx The execution context to use.
685 @param object The JSObject whose property you want to get.
686 @param propertyKey A JSValueRef containing the property key to use when looking up the property.
687 @param 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.
688 @result The property's value if object has the property key, otherwise the undefined value.
689 @discussion This function is the same as performing "object[propertyKey]" from JavaScript.
690 */
692
693/*!
694 @function
695 @abstract Sets a property on an object using a JSValueRef as the property key.
696 @param ctx The execution context to use.
697 @param object The JSObject whose property you want to set.
698 @param propertyKey A JSValueRef containing the property key to use when looking up the property.
699 @param value A JSValueRef to use as the property's value.
700 @param attributes A logically ORed set of JSPropertyAttributes to give to the property.
701 @param 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.
702 @discussion This function is the same as performing "object[propertyKey] = value" from JavaScript.
703 */
704JS_EXPORT void JSObjectSetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
705
706/*!
707 @function
708 @abstract Deletes a property from an object using a JSValueRef as the property key.
709 @param ctx The execution context to use.
710 @param object The JSObject whose property you want to delete.
711 @param propertyKey A JSValueRef containing the property key to use when looking up the property.
712 @param 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.
713 @result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
714 @discussion This function is the same as performing "delete object[propertyKey]" from JavaScript.
715 */
716JS_EXPORT bool JSObjectDeletePropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef* exception) JSC_API_AVAILABLE(macos(10.15), ios(13.0));
717
718/*!
719@function
720@abstract Gets a property from an object by numeric index.
721@param ctx The execution context to use.
722@param object The JSObject whose property you want to get.
723@param propertyIndex An integer value that is the property's name.
724@param 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.
725@result The property's value if object has the property, otherwise the undefined value.
726@discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties.
727*/
728JS_EXPORT JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception);
729
730/*!
731@function
732@abstract Sets a property on an object by numeric index.
733@param ctx The execution context to use.
734@param object The JSObject whose property you want to set.
735@param propertyIndex The property's name as a number.
736@param value A JSValue to use as the property's value.
737@param 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.
738@discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties.
739*/
740JS_EXPORT void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception);
741
742/*!
743@function
744@abstract Gets an object's private data.
745@param object A JSObject whose private data you want to get.
746@result A void* that is the object's private data, if the object has private data, otherwise NULL.
747*/
749
750/*!
751@function
752@abstract Sets a pointer to private data on an object.
753@param object The JSObject whose private data you want to set.
754@param data A void* to set as the object's private data.
755@result true if object can store private data, otherwise false.
756@discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.
757*/
758JS_EXPORT bool JSObjectSetPrivate(JSObjectRef object, void* data);
759
760/*!
761@function
762@abstract Tests whether an object can be called as a function.
763@param ctx The execution context to use.
764@param object The JSObject to test.
765@result true if the object can be called as a function, otherwise false.
766*/
768
769/*!
770@function
771@abstract Calls an object as a function.
772@param ctx The execution context to use.
773@param object The JSObject to call as a function.
774@param thisObject The object to use as "this," or NULL to use the global object as "this."
775@param argumentCount An integer count of the number of arguments in arguments.
776@param arguments A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0.
777@param 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.
778@result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.
779*/
780JS_EXPORT JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
781
782/*!
783@function
784@abstract Tests whether an object can be called as a constructor.
785@param ctx The execution context to use.
786@param object The JSObject to test.
787@result true if the object can be called as a constructor, otherwise false.
788*/
790
791/*!
792@function
793@abstract Calls an object as a constructor.
794@param ctx The execution context to use.
795@param object The JSObject to call as a constructor.
796@param argumentCount An integer count of the number of arguments in arguments.
797@param arguments A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0.
798@param 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.
799@result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.
800*/
801JS_EXPORT JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
802
803/*!
804@function
805@abstract Gets the names of an object's enumerable properties.
806@param ctx The execution context to use.
807@param object The object whose property names you want to get.
808@result A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule.
809*/
811
812/*!
813@function
814@abstract Retains a JavaScript property name array.
815@param array The JSPropertyNameArray to retain.
816@result A JSPropertyNameArray that is the same as array.
817*/
819
820/*!
821@function
822@abstract Releases a JavaScript property name array.
823@param array The JSPropetyNameArray to release.
824*/
826
827/*!
828@function
829@abstract Gets a count of the number of items in a JavaScript property name array.
830@param array The array from which to retrieve the count.
831@result An integer count of the number of names in array.
832*/
834
835/*!
836@function
837@abstract Gets a property name at a given index in a JavaScript property name array.
838@param array The array from which to retrieve the property name.
839@param index The index of the property name to retrieve.
840@result A JSStringRef containing the property name.
841*/
843
844/*!
845@function
846@abstract Adds a property name to a JavaScript property name accumulator.
847@param accumulator The accumulator object to which to add the property name.
848@param propertyName The property name to add.
849*/
851
852#ifdef __cplusplus
853}
854#endif
855
856#endif /* JSObjectRef_h */
struct OpaqueJSClass * JSClassRef
Definition JSBase.h:52
struct OpaqueJSString * JSStringRef
Definition JSBase.h:49
struct OpaqueJSValue * JSObjectRef
Definition JSBase.h:69
const struct OpaqueJSValue * JSValueRef
Definition JSBase.h:66
struct OpaqueJSPropertyNameArray * JSPropertyNameArrayRef
Definition JSBase.h:55
struct OpaqueJSPropertyNameAccumulator * JSPropertyNameAccumulatorRef
Definition JSBase.h:58
#define JS_EXPORT
Definition JSBase.h:93
const struct OpaqueJSContext * JSContextRef
Definition JSBase.h:43
JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array)
Retains a JavaScript property name array.
@ kJSPropertyAttributeReadOnly
Definition JSObjectRef.h:52
@ kJSPropertyAttributeNone
Definition JSObjectRef.h:51
@ kJSPropertyAttributeDontDelete
Definition JSObjectRef.h:54
@ kJSPropertyAttributeDontEnum
Definition JSObjectRef.h:53
const JSClassDefinition kJSClassDefinitionEmpty
A JSClassDefinition structure of the current version, filled with NULL pointers and having no attribu...
JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception)
Gets a property from an object.
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
Convenience method for creating a JavaScript constructor.
bool(* JSObjectHasPropertyCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName)
Definition JSObjectRef.h:142
bool(* JSObjectDeletePropertyCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception)
Definition JSObjectRef.h:206
bool JSClassSetPrivate(JSClassRef jsClass, void *data)
Sets the private data on a class, only possible with classes created with version 1000 (extended call...
bool(* JSObjectSetPropertyCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef *exception)
Definition JSObjectRef.h:185
JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object)
Gets an object's prototype.
void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array)
Releases a JavaScript property name array.
bool(* JSObjectHasInstanceCallback)(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef *exception)
hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
Definition JSObjectRef.h:299
void * JSClassGetPrivate(JSClassRef jsClass)
Retrieves the private data from a class reference, only possible with classes created with version 10...
void(* JSObjectFinalizeCallbackEx)(JSClassRef jsClass, JSObjectRef object)
Definition JSObjectRef.h:118
JSObjectRef(* JSObjectCallAsConstructorCallback)(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
The callback invoked when an object is used as a constructor in a 'new' expression.
Definition JSObjectRef.h:274
JSValueRef JSObjectGetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef *exception) JSC_API_AVAILABLE(macos(10.15)
Gets a property from an object using a JSValueRef as the property key.
JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
Calls an object as a function.
JSValueRef(* JSObjectConvertToTypeCallback)(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef *exception)
The callback invoked when converting an object to a particular JavaScript type.
Definition JSObjectRef.h:322
JSObjectRef ios(7.0))
JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) JSC_API_AVAILABLE(macos(10.6)
Creates a JavaScript Array object.
void * JSObjectGetPrivate(JSObjectRef object)
Gets an object's private data.
bool JSObjectDeletePropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef *exception) JSC_API_AVAILABLE(macos(10.15)
Deletes a property from an object using a JSValueRef as the property key.
JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef *exception)
Creates a function with a given script as its body.
JSValueRef(* JSObjectGetPropertyCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception)
Definition JSObjectRef.h:163
void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef *exception)
Sets a property on an object.
void(* JSObjectInitializeCallback)(JSContextRef ctx, JSObjectRef object)
The callback invoked when an object is first created.
Definition JSObjectRef.h:92
bool(* JSObjectHasPropertyCallback)(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
The callback invoked when determining whether an object has a property.
Definition JSObjectRef.h:138
void JSObjectSetPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef value, JSPropertyAttributes attributes, JSValueRef *exception) JSC_API_AVAILABLE(macos(10.15)
Sets a property on an object using a JSValueRef as the property key.
size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array)
Gets a count of the number of items in a JavaScript property name array.
void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef *exception)
Sets a property on an object by numeric index.
unsigned JSPropertyAttributes
A set of JSPropertyAttributes. Combine multiple attributes by logically ORing them together.
Definition JSObjectRef.h:61
JSObjectRef(* JSObjectCallAsConstructorCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
Definition JSObjectRef.h:278
bool JSObjectHasPropertyForKey(JSContextRef ctx, JSObjectRef object, JSValueRef propertyKey, JSValueRef *exception) JSC_API_AVAILABLE(macos(10.15)
Tests whether an object has a given property using a JSValueRef as the property key.
JSValueRef(* JSObjectConvertToTypeCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSType type, JSValueRef *exception)
Definition JSObjectRef.h:326
void(* JSObjectGetPropertyNamesCallback)(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames)
The callback invoked when collecting the names of an object's properties.
Definition JSObjectRef.h:223
JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) JSC_API_AVAILABLE(macos(10.6)
Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor.
bool(* JSObjectDeletePropertyCallback)(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception)
The callback invoked when deleting a property.
Definition JSObjectRef.h:202
JSClassRef JSClassCreate(const JSClassDefinition *definition)
Creates a JavaScript class suitable for use with JSObjectMake.
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void *data)
Creates a JavaScript object.
bool JSObjectIsConstructor(JSContextRef ctx, JSObjectRef object)
Tests whether an object can be called as a constructor.
void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef accumulator, JSStringRef propertyName)
Adds a property name to a JavaScript property name accumulator.
JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index)
Gets a property name at a given index in a JavaScript property name array.
void JSClassRelease(JSClassRef jsClass)
Releases a JavaScript class.
bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception)
Deletes a property from an object.
void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value)
Sets an object's prototype.
void(* JSObjectFinalizeCallback)(JSObjectRef object)
The callback invoked when an object is finalized (prepared for garbage collection)....
Definition JSObjectRef.h:114
JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
Calls an object as a constructor.
bool(* JSObjectSetPropertyCallback)(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef *exception)
The callback invoked when setting a property's value.
Definition JSObjectRef.h:181
bool JSObjectIsFunction(JSContextRef ctx, JSObjectRef object)
Tests whether an object can be called as a function.
JSValueRef(* JSObjectGetPropertyCallback)(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception)
The callback invoked when getting a property's value.
Definition JSObjectRef.h:159
void(* JSObjectGetPropertyNamesCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames)
Definition JSObjectRef.h:227
JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object)
Gets the names of an object's enumerable properties.
JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef *exception)
Gets a property from an object by numeric index.
JSValueRef(* JSObjectCallAsFunctionCallback)(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
The callback invoked when an object is called as a function.
Definition JSObjectRef.h:248
unsigned JSClassAttributes
A set of JSClassAttributes. Combine multiple attributes by logically ORing them together.
Definition JSObjectRef.h:77
JSObjectRef JSObjectMakeDeferredPromise(JSContextRef ctx, JSObjectRef *resolve, JSObjectRef *reject, JSValueRef *exception) JSC_API_AVAILABLE(macos(10.15)
Creates a JavaScript promise object by invoking the provided executor.
@ kJSClassAttributeNone
Definition JSObjectRef.h:69
@ kJSClassAttributeNoAutomaticPrototype
Definition JSObjectRef.h:70
void(* JSObjectInitializeCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef object)
Definition JSObjectRef.h:96
bool JSObjectSetPrivate(JSObjectRef object, void *data)
Sets a pointer to private data on an object.
JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) JSC_API_AVAILABLE(macos(10.6)
Creates a JavaScript Error object, as if by invoking the built-in Error constructor.
JSClassRef JSClassRetain(JSClassRef jsClass)
Retains a JavaScript class.
JSValueRef(* JSObjectCallAsFunctionCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSStringRef className, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
Definition JSObjectRef.h:254
bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
Tests whether an object has a given property.
bool(* JSObjectHasInstanceCallbackEx)(JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef *exception)
Definition JSObjectRef.h:303
JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) JSC_API_AVAILABLE(macos(10.6)
Creates a JavaScript Date object, as if by invoking the built-in Date constructor.
JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
Convenience method for creating a JavaScript function with a given callback as its implementation.
JSType
A constant identifying the type of a JSValue.
Definition JSValueRef.h:47
#define JSC_API_AVAILABLE(...)
Definition WebKitAvailability.h:77
This structure contains properties and callbacks that define a type of object. All fields other than ...
Definition JSObjectRef.h:404
const JSStaticValue * staticValues
Definition JSObjectRef.h:414
JSObjectDeletePropertyCallback deleteProperty
Definition JSObjectRef.h:421
JSObjectDeletePropertyCallbackEx deletePropertyEx
Definition JSObjectRef.h:438
JSObjectSetPropertyCallback setProperty
Definition JSObjectRef.h:420
JSObjectCallAsFunctionCallbackEx callAsFunctionEx
Definition JSObjectRef.h:440
JSObjectHasPropertyCallbackEx hasPropertyEx
Definition JSObjectRef.h:435
JSObjectFinalizeCallbackEx finalizeEx
Definition JSObjectRef.h:434
JSObjectCallAsFunctionCallback callAsFunction
Definition JSObjectRef.h:423
JSObjectInitializeCallbackEx initializeEx
Definition JSObjectRef.h:433
JSObjectHasInstanceCallback hasInstance
Definition JSObjectRef.h:425
int version
Definition JSObjectRef.h:405
const JSStaticFunction * staticFunctions
Definition JSObjectRef.h:415
JSObjectHasPropertyCallback hasProperty
Definition JSObjectRef.h:418
JSObjectConvertToTypeCallbackEx convertToTypeEx
Definition JSObjectRef.h:443
JSObjectGetPropertyNamesCallbackEx getPropertyNamesEx
Definition JSObjectRef.h:439
JSObjectCallAsConstructorCallback callAsConstructor
Definition JSObjectRef.h:424
JSObjectInitializeCallback initialize
Definition JSObjectRef.h:416
JSClassRef parentClass
Definition JSObjectRef.h:409
JSObjectSetPropertyCallbackEx setPropertyEx
Definition JSObjectRef.h:437
JSObjectCallAsConstructorCallbackEx callAsConstructorEx
Definition JSObjectRef.h:441
JSObjectFinalizeCallback finalize
Definition JSObjectRef.h:417
const JSStaticValueEx * staticValuesEx
Definition JSObjectRef.h:431
JSClassAttributes attributes
Definition JSObjectRef.h:406
JSObjectHasInstanceCallbackEx hasInstanceEx
Definition JSObjectRef.h:442
JSObjectGetPropertyCallbackEx getPropertyEx
Definition JSObjectRef.h:436
const JSStaticFunctionEx * staticFunctionsEx
Definition JSObjectRef.h:432
JSObjectGetPropertyNamesCallback getPropertyNames
Definition JSObjectRef.h:422
JSObjectConvertToTypeCallback convertToType
Definition JSObjectRef.h:426
const char * className
Definition JSObjectRef.h:408
void * privateData
Definition JSObjectRef.h:447
JSObjectGetPropertyCallback getProperty
Definition JSObjectRef.h:419
Definition JSObjectRef.h:365
const char * name
Definition JSObjectRef.h:366
JSObjectCallAsFunctionCallbackEx callAsFunctionEx
Definition JSObjectRef.h:367
JSPropertyAttributes attributes
Definition JSObjectRef.h:368
This structure describes a statically declared function property.
Definition JSObjectRef.h:358
JSPropertyAttributes attributes
Definition JSObjectRef.h:361
JSObjectCallAsFunctionCallback callAsFunction
Definition JSObjectRef.h:360
const char * name
Definition JSObjectRef.h:359
Definition JSObjectRef.h:344
JSObjectSetPropertyCallbackEx setPropertyEx
Definition JSObjectRef.h:347
JSObjectGetPropertyCallbackEx getPropertyEx
Definition JSObjectRef.h:346
JSPropertyAttributes attributes
Definition JSObjectRef.h:348
const char * name
Definition JSObjectRef.h:345
This structure describes a statically declared value property.
Definition JSObjectRef.h:336
JSObjectSetPropertyCallback setProperty
Definition JSObjectRef.h:339
const char * name
Definition JSObjectRef.h:337
JSPropertyAttributes attributes
Definition JSObjectRef.h:340
JSObjectGetPropertyCallback getProperty
Definition JSObjectRef.h:338