Class JavaScriptCore


  • public final class JavaScriptCore
    extends java.lang.Object
    • Method Detail

      • JSEvaluateScript

        public static JSValueRef JSEvaluateScript​(JSContextRef ctx,
                                                  JSStringRef script,
                                                  JSObjectRef thisObject,
                                                  JSStringRef sourceURL,
                                                  int startingLineNumber,
                                                  org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] JSEvaluateScript Evaluates a string of JavaScript.
        Parameters:
        ctx - The execution context to use.
        script - A JSString containing the script to evaluate.
        thisObject - The object to use as "this," or NULL to use the global object as "this."
        sourceURL - A JSString containing a URL for the script's source file. This is used by debuggers and when reporting exceptions. Pass NULL if you do not care to include source file information.
        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.
        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 evaluating script, or NULL if an exception is thrown.
      • JSCheckScriptSyntax

        public static boolean JSCheckScriptSyntax​(JSContextRef ctx,
                                                  JSStringRef script,
                                                  JSStringRef sourceURL,
                                                  int startingLineNumber,
                                                  org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] JSCheckScriptSyntax Checks for syntax errors in a string of JavaScript.
        Parameters:
        ctx - The execution context to use.
        script - A JSString containing the script to check for syntax errors.
        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.
        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.
        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:
        true if the script is syntactically correct, otherwise false.
      • JSGarbageCollect

        public static void JSGarbageCollect​(JSContextRef ctx)
        [@function] JSGarbageCollect Performs a JavaScript garbage collection. JavaScript values that are on the machine stack, in a register, protected by JSValueProtect, set as the global object of an execution context, or reachable from any such value will not be collected. During JavaScript execution, you are not required to call this function; the JavaScript engine will garbage collect as needed. JavaScript values created within a context group are automatically destroyed when the last reference to the context group is released.
        Parameters:
        ctx - The execution context to use.
      • JSValueGetType

        public static int JSValueGetType​(JSContextRef ctx,
                                         JSValueRef value)
        [@function] Returns a JavaScript value's type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue whose type you want to obtain.
        Returns:
        A value of type JSType that identifies value's type.
      • JSValueIsUndefined

        public static boolean JSValueIsUndefined​(JSContextRef ctx,
                                                 JSValueRef value)
        [@function] Tests whether a JavaScript value's type is the undefined type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value's type is the undefined type, otherwise false.
      • JSValueIsNull

        public static boolean JSValueIsNull​(JSContextRef ctx,
                                            JSValueRef value)
        [@function] Tests whether a JavaScript value's type is the null type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value's type is the null type, otherwise false.
      • JSValueIsBoolean

        public static boolean JSValueIsBoolean​(JSContextRef ctx,
                                               JSValueRef value)
        [@function] Tests whether a JavaScript value's type is the boolean type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value's type is the boolean type, otherwise false.
      • JSValueIsNumber

        public static boolean JSValueIsNumber​(JSContextRef ctx,
                                              JSValueRef value)
        [@function] Tests whether a JavaScript value's type is the number type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value's type is the number type, otherwise false.
      • JSValueIsString

        public static boolean JSValueIsString​(JSContextRef ctx,
                                              JSValueRef value)
        [@function] Tests whether a JavaScript value's type is the string type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value's type is the string type, otherwise false.
      • JSValueIsObject

        public static boolean JSValueIsObject​(JSContextRef ctx,
                                              JSValueRef value)
        [@function] Tests whether a JavaScript value's type is the object type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value's type is the object type, otherwise false.
      • JSValueIsObjectOfClass

        public static boolean JSValueIsObjectOfClass​(JSContextRef ctx,
                                                     JSValueRef value,
                                                     JSClassRef jsClass)
        [@function] Tests whether a JavaScript value is an object with a given class in its class chain.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        jsClass - The JSClass to test against.
        Returns:
        true if value is an object and has jsClass in its class chain, otherwise false.
      • JSValueIsArray

        public static boolean JSValueIsArray​(JSContextRef ctx,
                                             JSValueRef value)
        [@function] Tests whether a JavaScript value is an array.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value is an array, otherwise false.
      • JSValueIsDate

        public static boolean JSValueIsDate​(JSContextRef ctx,
                                            JSValueRef value)
        [@function] Tests whether a JavaScript value is a date.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value is a date, otherwise false.
      • JSValueGetTypedArrayType

        public static int JSValueGetTypedArrayType​(JSContextRef ctx,
                                                   JSValueRef value,
                                                   org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Returns a JavaScript value's Typed Array type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue whose Typed Array type to return.
        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 value of type JSTypedArrayType that identifies value's Typed Array type, or kJSTypedArrayTypeNone if the value is not a Typed Array object.
      • JSValueIsEqual

        public static boolean JSValueIsEqual​(JSContextRef ctx,
                                             JSValueRef a,
                                             JSValueRef b,
                                             org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Tests whether two JavaScript values are equal, as compared by the JS == operator.
        Parameters:
        ctx - The execution context to use.
        a - The first value to test.
        b - The second value to test.
        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 two values are equal, false if they are not equal or an exception is thrown.
      • JSValueIsStrictEqual

        public static boolean JSValueIsStrictEqual​(JSContextRef ctx,
                                                   JSValueRef a,
                                                   JSValueRef b)
        [@function] Tests whether two JavaScript values are strict equal, as compared by the JS === operator.
        Parameters:
        ctx - The execution context to use.
        a - The first value to test.
        b - The second value to test.
        Returns:
        true if the two values are strict equal, otherwise false.
      • JSValueIsInstanceOfConstructor

        public static boolean JSValueIsInstanceOfConstructor​(JSContextRef ctx,
                                                             JSValueRef value,
                                                             JSObjectRef constructor,
                                                             org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        constructor - The constructor to test against.
        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 value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false.
      • JSValueMakeUndefined

        public static JSValueRef JSValueMakeUndefined​(JSContextRef ctx)
        [@function] Creates a JavaScript value of the undefined type.
        Parameters:
        ctx - The execution context to use.
        Returns:
        The unique undefined value.
      • JSValueMakeNull

        public static JSValueRef JSValueMakeNull​(JSContextRef ctx)
        [@function] Creates a JavaScript value of the null type.
        Parameters:
        ctx - The execution context to use.
        Returns:
        The unique null value.
      • JSValueMakeBoolean

        public static JSValueRef JSValueMakeBoolean​(JSContextRef ctx,
                                                    boolean boolean_)
        [@function] Creates a JavaScript value of the boolean type.
        Parameters:
        ctx - The execution context to use.
        boolean - The bool to assign to the newly created JSValue.
        Returns:
        A JSValue of the boolean type, representing the value of boolean.
      • JSValueMakeNumber

        public static JSValueRef JSValueMakeNumber​(JSContextRef ctx,
                                                   double number)
        [@function] Creates a JavaScript value of the number type.
        Parameters:
        ctx - The execution context to use.
        number - The double to assign to the newly created JSValue.
        Returns:
        A JSValue of the number type, representing the value of number.
      • JSValueMakeString

        public static JSValueRef JSValueMakeString​(JSContextRef ctx,
                                                   JSStringRef string)
        [@function] Creates a JavaScript value of the string type.
        Parameters:
        ctx - The execution context to use.
        string - The JSString to assign to the newly created JSValue. The newly created JSValue retains string, and releases it upon garbage collection.
        Returns:
        A JSValue of the string type, representing the value of string.
      • JSValueMakeFromJSONString

        public static JSValueRef JSValueMakeFromJSONString​(JSContextRef ctx,
                                                           JSStringRef string)
        [@function] Creates a JavaScript value from a JSON formatted string.
        Parameters:
        ctx - The execution context to use.
        string - The JSString containing the JSON string to be parsed.
        Returns:
        A JSValue containing the parsed value, or NULL if the input is invalid.
      • JSValueCreateJSONString

        public static JSStringRef JSValueCreateJSONString​(JSContextRef ctx,
                                                          JSValueRef value,
                                                          int indent,
                                                          org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript string containing the JSON serialized representation of a JS value.
        Parameters:
        ctx - The execution context to use.
        value - The value to serialize.
        indent - The number of spaces to indent when nesting. If 0, the resulting JSON will not contains newlines. The size of the indent is clamped to 10 spaces.
        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 JSString with the result of serialization, or NULL if an exception is thrown.
      • JSValueToBoolean

        public static boolean JSValueToBoolean​(JSContextRef ctx,
                                               JSValueRef value)
        [@function] Converts a JavaScript value to boolean and returns the resulting boolean.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to convert.
        Returns:
        The boolean result of conversion.
      • JSValueToNumber

        public static double JSValueToNumber​(JSContextRef ctx,
                                             JSValueRef value,
                                             org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Converts a JavaScript value to number and returns the resulting number.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to convert.
        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 numeric result of conversion, or NaN if an exception is thrown.
      • JSValueToStringCopy

        public static JSStringRef JSValueToStringCopy​(JSContextRef ctx,
                                                      JSValueRef value,
                                                      org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Converts a JavaScript value to string and copies the result into a JavaScript string.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to convert.
        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 JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule.
      • JSValueToObject

        public static JSObjectRef JSValueToObject​(JSContextRef ctx,
                                                  JSValueRef value,
                                                  org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Converts a JavaScript value to object and returns the resulting object.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to convert.
        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 result of conversion, or NULL if an exception is thrown.
      • JSValueProtect

        public static void JSValueProtect​(JSContextRef ctx,
                                          JSValueRef value)
        Garbage collection [@function] Protects a JavaScript value from garbage collection. Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it. A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to protect.
      • JSValueUnprotect

        public static void JSValueUnprotect​(JSContextRef ctx,
                                            JSValueRef value)
        [@function] Unprotects a JavaScript value from garbage collection. A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to unprotect.
      • JSClassCreate

        public static JSClassRef JSClassCreate​(JSClassDefinition definition)
        [@function] Creates a JavaScript class suitable for use with JSObjectMake.
        Parameters:
        definition - A JSClassDefinition that defines the class.
        Returns:
        A JSClass with the given definition. Ownership follows the Create Rule.
      • JSClassRetain

        public static JSClassRef JSClassRetain​(JSClassRef jsClass)
        [@function] Retains a JavaScript class.
        Parameters:
        jsClass - The JSClass to retain.
        Returns:
        A JSClass that is the same as jsClass.
      • JSClassRelease

        public static void JSClassRelease​(JSClassRef jsClass)
        [@function] Releases a JavaScript class.
        Parameters:
        jsClass - The JSClass to release.
      • JSObjectMake

        public static JSObjectRef JSObjectMake​(JSContextRef ctx,
                                               JSClassRef jsClass,
                                               org.moe.natj.general.ptr.VoidPtr data)
        [@function] Creates a JavaScript object. 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.
        Parameters:
        ctx - The execution context to use.
        jsClass - The JSClass to assign to the object. Pass NULL to use the default object class.
        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.
      • JSObjectMakeFunctionWithCallback

        public static JSObjectRef JSObjectMakeFunctionWithCallback​(JSContextRef ctx,
                                                                   JSStringRef name,
                                                                   JavaScriptCore.Function_JSObjectMakeFunctionWithCallback callAsFunction)
        [@function] Convenience method for creating a JavaScript function with a given callback as its implementation.
        Parameters:
        ctx - The execution context to use.
        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.
        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.
      • JSObjectMakeConstructor

        public static JSObjectRef JSObjectMakeConstructor​(JSContextRef ctx,
                                                          JSClassRef jsClass,
                                                          JavaScriptCore.Function_JSObjectMakeConstructor callAsConstructor)
        [@function] Convenience method for creating a JavaScript constructor. The default object constructor takes no arguments and constructs an object of class jsClass with no private data.
        Parameters:
        ctx - The execution context to use.
        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.
        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.
      • JSObjectMakeArray

        public static JSObjectRef JSObjectMakeArray​(JSContextRef ctx,
                                                    long argumentCount,
                                                    org.moe.natj.general.ptr.ConstPtr<JSValueRef> arguments,
                                                    org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript Array object. 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.
        Parameters:
        ctx - The execution context to use.
        argumentCount - An integer count of the number of arguments in arguments.
        arguments - A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0.
        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.
      • JSObjectMakeDate

        public static JSObjectRef JSObjectMakeDate​(JSContextRef ctx,
                                                   long argumentCount,
                                                   org.moe.natj.general.ptr.ConstPtr<JSValueRef> arguments,
                                                   org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript Date object, as if by invoking the built-in Date constructor.
        Parameters:
        ctx - The execution context to use.
        argumentCount - An integer count of the number of arguments in arguments.
        arguments - A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0.
        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.
      • JSObjectMakeError

        public static JSObjectRef JSObjectMakeError​(JSContextRef ctx,
                                                    long argumentCount,
                                                    org.moe.natj.general.ptr.ConstPtr<JSValueRef> arguments,
                                                    org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript Error object, as if by invoking the built-in Error constructor.
        Parameters:
        ctx - The execution context to use.
        argumentCount - An integer count of the number of arguments in arguments.
        arguments - A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0.
        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.
      • JSObjectMakeRegExp

        public static JSObjectRef JSObjectMakeRegExp​(JSContextRef ctx,
                                                     long argumentCount,
                                                     org.moe.natj.general.ptr.ConstPtr<JSValueRef> arguments,
                                                     org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor.
        Parameters:
        ctx - The execution context to use.
        argumentCount - An integer count of the number of arguments in arguments.
        arguments - A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0.
        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.
      • JSObjectMakeFunction

        public static JSObjectRef JSObjectMakeFunction​(JSContextRef ctx,
                                                       JSStringRef name,
                                                       int parameterCount,
                                                       org.moe.natj.general.ptr.ConstPtr<JSStringRef> parameterNames,
                                                       JSStringRef body,
                                                       JSStringRef sourceURL,
                                                       int startingLineNumber,
                                                       org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a function with a given script as its body. Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
        Parameters:
        ctx - The execution context to use.
        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.
        parameterCount - An integer count of the number of parameter names in parameterNames.
        parameterNames - A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0.
        body - A JSString containing the script to use as the function's body.
        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.
        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.
        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.
      • JSObjectGetPrototype

        public static JSValueRef JSObjectGetPrototype​(JSContextRef ctx,
                                                      JSObjectRef object)
        [@function] Gets an object's prototype.
        Parameters:
        ctx - The execution context to use.
        object - A JSObject whose prototype you want to get.
        Returns:
        A JSValue that is the object's prototype.
      • JSObjectSetPrototype

        public static void JSObjectSetPrototype​(JSContextRef ctx,
                                                JSObjectRef object,
                                                JSValueRef value)
        [@function] Sets an object's prototype.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose prototype you want to set.
        value - A JSValue to set as the object's prototype.
      • JSObjectHasProperty

        public static boolean JSObjectHasProperty​(JSContextRef ctx,
                                                  JSObjectRef object,
                                                  JSStringRef propertyName)
        [@function] Tests whether an object has a given property.
        Parameters:
        object - The JSObject to test.
        propertyName - A JSString containing the property's name.
        Returns:
        true if the object has a property whose name matches propertyName, otherwise false.
      • JSObjectGetProperty

        public static JSValueRef JSObjectGetProperty​(JSContextRef ctx,
                                                     JSObjectRef object,
                                                     JSStringRef propertyName,
                                                     org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Gets a property from an object.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose property you want to get.
        propertyName - A JSString containing the property's name.
        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.
      • JSObjectSetProperty

        public static void JSObjectSetProperty​(JSContextRef ctx,
                                               JSObjectRef object,
                                               JSStringRef propertyName,
                                               JSValueRef value,
                                               int attributes,
                                               org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Sets a property on an object.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose property you want to set.
        propertyName - A JSString containing the property's name.
        value - A JSValueRef to use as the property's value.
        attributes - A logically ORed set of JSPropertyAttributes to give to the property.
        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.
      • JSObjectDeleteProperty

        public static boolean JSObjectDeleteProperty​(JSContextRef ctx,
                                                     JSObjectRef object,
                                                     JSStringRef propertyName,
                                                     org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Deletes a property from an object.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose property you want to delete.
        propertyName - A JSString containing the property's name.
        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).
      • JSObjectGetPropertyAtIndex

        public static JSValueRef JSObjectGetPropertyAtIndex​(JSContextRef ctx,
                                                            JSObjectRef object,
                                                            int propertyIndex,
                                                            org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Gets a property from an object by numeric index. Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose property you want to get.
        propertyIndex - An integer value that is the property's name.
        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.
      • JSObjectSetPropertyAtIndex

        public static void JSObjectSetPropertyAtIndex​(JSContextRef ctx,
                                                      JSObjectRef object,
                                                      int propertyIndex,
                                                      JSValueRef value,
                                                      org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Sets a property on an object by numeric index. Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose property you want to set.
        propertyIndex - The property's name as a number.
        value - A JSValue to use as the property's value.
        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.
      • JSObjectGetPrivate

        public static org.moe.natj.general.ptr.VoidPtr JSObjectGetPrivate​(JSObjectRef object)
        [@function] Gets an object's private data.
        Parameters:
        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.
      • JSObjectSetPrivate

        public static boolean JSObjectSetPrivate​(JSObjectRef object,
                                                 org.moe.natj.general.ptr.VoidPtr data)
        [@function] Sets a pointer to private data on an object. The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.
        Parameters:
        object - The JSObject whose private data you want to set.
        data - A void* to set as the object's private data.
        Returns:
        true if object can store private data, otherwise false.
      • JSObjectIsFunction

        public static boolean JSObjectIsFunction​(JSContextRef ctx,
                                                 JSObjectRef object)
        [@function] Tests whether an object can be called as a function.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject to test.
        Returns:
        true if the object can be called as a function, otherwise false.
      • JSObjectCallAsFunction

        public static JSValueRef JSObjectCallAsFunction​(JSContextRef ctx,
                                                        JSObjectRef object,
                                                        JSObjectRef thisObject,
                                                        long argumentCount,
                                                        org.moe.natj.general.ptr.ConstPtr<JSValueRef> arguments,
                                                        org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Calls an object as a function.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject to call as a function.
        thisObject - The object to use as "this," or NULL to use the global object as "this."
        argumentCount - An integer count of the number of arguments in arguments.
        arguments - A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0.
        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.
      • JSObjectIsConstructor

        public static boolean JSObjectIsConstructor​(JSContextRef ctx,
                                                    JSObjectRef object)
        [@function] Tests whether an object can be called as a constructor.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject to test.
        Returns:
        true if the object can be called as a constructor, otherwise false.
      • JSObjectCallAsConstructor

        public static JSObjectRef JSObjectCallAsConstructor​(JSContextRef ctx,
                                                            JSObjectRef object,
                                                            long argumentCount,
                                                            org.moe.natj.general.ptr.ConstPtr<JSValueRef> arguments,
                                                            org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Calls an object as a constructor.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject to call as a constructor.
        argumentCount - An integer count of the number of arguments in arguments.
        arguments - A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0.
        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.
      • JSObjectCopyPropertyNames

        public static JSPropertyNameArrayRef JSObjectCopyPropertyNames​(JSContextRef ctx,
                                                                       JSObjectRef object)
        [@function] Gets the names of an object's enumerable properties.
        Parameters:
        ctx - The execution context to use.
        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.
      • JSPropertyNameArrayRetain

        public static JSPropertyNameArrayRef JSPropertyNameArrayRetain​(JSPropertyNameArrayRef array)
        [@function] Retains a JavaScript property name array.
        Parameters:
        array - The JSPropertyNameArray to retain.
        Returns:
        A JSPropertyNameArray that is the same as array.
      • JSPropertyNameArrayRelease

        public static void JSPropertyNameArrayRelease​(JSPropertyNameArrayRef array)
        [@function] Releases a JavaScript property name array.
        Parameters:
        array - The JSPropetyNameArray to release.
      • JSPropertyNameArrayGetCount

        public static long JSPropertyNameArrayGetCount​(JSPropertyNameArrayRef array)
        [@function] Gets a count of the number of items in a JavaScript property name array.
        Parameters:
        array - The array from which to retrieve the count.
        Returns:
        An integer count of the number of names in array.
      • JSPropertyNameArrayGetNameAtIndex

        public static JSStringRef JSPropertyNameArrayGetNameAtIndex​(JSPropertyNameArrayRef array,
                                                                    long index)
        [@function] Gets a property name at a given index in a JavaScript property name array.
        Parameters:
        array - The array from which to retrieve the property name.
        index - The index of the property name to retrieve.
        Returns:
        A JSStringRef containing the property name.
      • JSPropertyNameAccumulatorAddName

        public static void JSPropertyNameAccumulatorAddName​(JSPropertyNameAccumulatorRef accumulator,
                                                            JSStringRef propertyName)
        [@function] Adds a property name to a JavaScript property name accumulator.
        Parameters:
        accumulator - The accumulator object to which to add the property name.
        propertyName - The property name to add.
      • JSContextGroupCreate

        public static JSContextGroupRef JSContextGroupCreate()
        [@function] Creates a JavaScript context group. A JSContextGroup associates JavaScript contexts with one another. Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging JavaScript objects between contexts in different groups will produce undefined behavior. When objects from the same context group are used in multiple threads, explicit synchronization is required. A JSContextGroup may need to run deferred tasks on a run loop, such as garbage collection or resolving WebAssembly compilations. By default, calling JSContextGroupCreate will use the run loop of the thread it was called on. Currently, there is no API to change a JSContextGroup's run loop once it has been created.
        Returns:
        The created JSContextGroup.
      • JSContextGroupRetain

        public static JSContextGroupRef JSContextGroupRetain​(JSContextGroupRef group)
        [@function] Retains a JavaScript context group.
        Parameters:
        group - The JSContextGroup to retain.
        Returns:
        A JSContextGroup that is the same as group.
      • JSContextGroupRelease

        public static void JSContextGroupRelease​(JSContextGroupRef group)
        [@function] Releases a JavaScript context group.
        Parameters:
        group - The JSContextGroup to release.
      • JSGlobalContextCreate

        public static JSGlobalContextRef JSGlobalContextCreate​(JSClassRef globalObjectClass)
        [@function] Creates a global JavaScript execution context. JSGlobalContextCreate allocates a global object and populates it with all the built-in JavaScript objects, such as Object, Function, String, and Array. In WebKit version 4.0 and later, the context is created in a unique context group. Therefore, scripts may execute in it concurrently with scripts executing in other contexts. However, you may not use values created in the context in other contexts.
        Parameters:
        globalObjectClass - The class to use when creating the global object. Pass NULL to use the default object class.
        Returns:
        A JSGlobalContext with a global object of class globalObjectClass.
      • JSGlobalContextCreateInGroup

        public static JSGlobalContextRef JSGlobalContextCreateInGroup​(JSContextGroupRef group,
                                                                      JSClassRef globalObjectClass)
        [@function] Creates a global JavaScript execution context in the context group provided. JSGlobalContextCreateInGroup allocates a global object and populates it with all the built-in JavaScript objects, such as Object, Function, String, and Array.
        Parameters:
        globalObjectClass - The class to use when creating the global object. Pass NULL to use the default object class.
        group - The context group to use. The created global context retains the group. Pass NULL to create a unique group for the context.
        Returns:
        A JSGlobalContext with a global object of class globalObjectClass and a context group equal to group.
      • JSGlobalContextRetain

        public static JSGlobalContextRef JSGlobalContextRetain​(JSGlobalContextRef ctx)
        [@function] Retains a global JavaScript execution context.
        Parameters:
        ctx - The JSGlobalContext to retain.
        Returns:
        A JSGlobalContext that is the same as ctx.
      • JSGlobalContextRelease

        public static void JSGlobalContextRelease​(JSGlobalContextRef ctx)
        [@function] Releases a global JavaScript execution context.
        Parameters:
        ctx - The JSGlobalContext to release.
      • JSContextGetGlobalObject

        public static JSObjectRef JSContextGetGlobalObject​(JSContextRef ctx)
        [@function] Gets the global object of a JavaScript execution context.
        Parameters:
        ctx - The JSContext whose global object you want to get.
        Returns:
        ctx's global object.
      • JSContextGetGroup

        public static JSContextGroupRef JSContextGetGroup​(JSContextRef ctx)
        [@function] Gets the context group to which a JavaScript execution context belongs.
        Parameters:
        ctx - The JSContext whose group you want to get.
        Returns:
        ctx's group.
      • JSContextGetGlobalContext

        public static JSGlobalContextRef JSContextGetGlobalContext​(JSContextRef ctx)
        [@function] Gets the global context of a JavaScript execution context.
        Parameters:
        ctx - The JSContext whose global context you want to get.
        Returns:
        ctx's global context.
      • JSGlobalContextCopyName

        public static JSStringRef JSGlobalContextCopyName​(JSGlobalContextRef ctx)
        [@function] Gets a copy of the name of a context. A JSGlobalContext's name is exposed for remote debugging to make it easier to identify the context you would like to attach to.
        Parameters:
        ctx - The JSGlobalContext whose name you want to get.
        Returns:
        The name for ctx.
      • JSGlobalContextSetName

        public static void JSGlobalContextSetName​(JSGlobalContextRef ctx,
                                                  JSStringRef name)
        [@function] Sets the remote debugging name for a context.
        Parameters:
        ctx - The JSGlobalContext that you want to name.
        name - The remote debugging name to set on ctx.
      • JSStringCreateWithCharacters

        public static JSStringRef JSStringCreateWithCharacters​(org.moe.natj.general.ptr.ConstCharPtr chars,
                                                               long numChars)
        [@function] Creates a JavaScript string from a buffer of Unicode characters.
        Parameters:
        chars - The buffer of Unicode characters to copy into the new JSString.
        numChars - The number of characters to copy from the buffer pointed to by chars.
        Returns:
        A JSString containing chars. Ownership follows the Create Rule.
      • JSStringCreateWithUTF8CString

        public static JSStringRef JSStringCreateWithUTF8CString​(java.lang.String string)
        [@function] Creates a JavaScript string from a null-terminated UTF8 string.
        Parameters:
        string - The null-terminated UTF8 string to copy into the new JSString.
        Returns:
        A JSString containing string. Ownership follows the Create Rule.
      • JSStringRetain

        public static JSStringRef JSStringRetain​(JSStringRef string)
        [@function] Retains a JavaScript string.
        Parameters:
        string - The JSString to retain.
        Returns:
        A JSString that is the same as string.
      • JSStringRelease

        public static void JSStringRelease​(JSStringRef string)
        [@function] Releases a JavaScript string.
        Parameters:
        string - The JSString to release.
      • JSStringGetLength

        public static long JSStringGetLength​(JSStringRef string)
        [@function] Returns the number of Unicode characters in a JavaScript string.
        Parameters:
        string - The JSString whose length (in Unicode characters) you want to know.
        Returns:
        The number of Unicode characters stored in string.
      • JSStringGetCharactersPtr

        public static org.moe.natj.general.ptr.ConstCharPtr JSStringGetCharactersPtr​(JSStringRef string)
        [@function] Returns a pointer to the Unicode character buffer that serves as the backing store for a JavaScript string.
        Parameters:
        string - The JSString whose backing store you want to access.
        Returns:
        A pointer to the Unicode character buffer that serves as string's backing store, which will be deallocated when string is deallocated.
      • JSStringGetMaximumUTF8CStringSize

        public static long JSStringGetMaximumUTF8CStringSize​(JSStringRef string)
        [@function] Returns the maximum number of bytes a JavaScript string will take up if converted into a null-terminated UTF8 string.
        Parameters:
        string - The JSString whose maximum converted size (in bytes) you want to know.
        Returns:
        The maximum number of bytes that could be required to convert string into a null-terminated UTF8 string. The number of bytes that the conversion actually ends up requiring could be less than this, but never more.
      • JSStringGetUTF8CString

        public static long JSStringGetUTF8CString​(JSStringRef string,
                                                  org.moe.natj.general.ptr.BytePtr buffer,
                                                  long bufferSize)
        [@function] Converts a JavaScript string into a null-terminated UTF8 string, and copies the result into an external byte buffer.
        Parameters:
        string - The source JSString.
        buffer - The destination byte buffer into which to copy a null-terminated UTF8 representation of string. On return, buffer contains a UTF8 string representation of string. If bufferSize is too small, buffer will contain only partial results. If buffer is not at least bufferSize bytes in size, behavior is undefined.
        bufferSize - The size of the external buffer in bytes.
        Returns:
        The number of bytes written into buffer (including the null-terminator byte).
      • JSStringIsEqual

        public static boolean JSStringIsEqual​(JSStringRef a,
                                              JSStringRef b)
        [@function] Tests whether two JavaScript strings match.
        Parameters:
        a - The first JSString to test.
        b - The second JSString to test.
        Returns:
        true if the two strings match, otherwise false.
      • JSStringIsEqualToUTF8CString

        public static boolean JSStringIsEqualToUTF8CString​(JSStringRef a,
                                                           java.lang.String b)
        [@function] Tests whether a JavaScript string matches a null-terminated UTF8 string.
        Parameters:
        a - The JSString to test.
        b - The null-terminated UTF8 string to test.
        Returns:
        true if the two strings match, otherwise false.
      • JSObjectMakeTypedArray

        public static JSObjectRef JSObjectMakeTypedArray​(JSContextRef ctx,
                                                         int arrayType,
                                                         long length,
                                                         org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript Typed Array object with the given number of elements.
        Parameters:
        ctx - The execution context to use.
        arrayType - A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
        length - The number of elements to be in the new Typed Array.
        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 JSObjectRef that is a Typed Array with all elements set to zero or NULL if there was an error.
      • JSObjectMakeTypedArrayWithBytesNoCopy

        public static JSObjectRef JSObjectMakeTypedArrayWithBytesNoCopy​(JSContextRef ctx,
                                                                        int arrayType,
                                                                        org.moe.natj.general.ptr.VoidPtr bytes,
                                                                        long byteLength,
                                                                        JavaScriptCore.Function_JSObjectMakeTypedArrayWithBytesNoCopy bytesDeallocator,
                                                                        org.moe.natj.general.ptr.VoidPtr deallocatorContext,
                                                                        org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript Typed Array object from an existing pointer. If an exception is thrown during this function the bytesDeallocator will always be called.
        Parameters:
        ctx - The execution context to use.
        arrayType - A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
        bytes - A pointer to the byte buffer to be used as the backing store of the Typed Array object.
        byteLength - The number of bytes pointed to by the parameter bytes.
        bytesDeallocator - The allocator to use to deallocate the external buffer when the JSTypedArrayData object is deallocated.
        deallocatorContext - A pointer to pass back to the deallocator.
        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 JSObjectRef Typed Array whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
      • JSObjectMakeTypedArrayWithArrayBuffer

        public static JSObjectRef JSObjectMakeTypedArrayWithArrayBuffer​(JSContextRef ctx,
                                                                        int arrayType,
                                                                        JSObjectRef buffer,
                                                                        org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object.
        Parameters:
        ctx - The execution context to use.
        arrayType - A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
        buffer - An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object.
        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 JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
      • JSObjectMakeTypedArrayWithArrayBufferAndOffset

        public static JSObjectRef JSObjectMakeTypedArrayWithArrayBufferAndOffset​(JSContextRef ctx,
                                                                                 int arrayType,
                                                                                 JSObjectRef buffer,
                                                                                 long byteOffset,
                                                                                 long length,
                                                                                 org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript Typed Array object from an existing JavaScript Array Buffer object with the given offset and length.
        Parameters:
        ctx - The execution context to use.
        arrayType - A value identifying the type of array to create. If arrayType is kJSTypedArrayTypeNone or kJSTypedArrayTypeArrayBuffer then NULL will be returned.
        buffer - An Array Buffer object that should be used as the backing store for the created JavaScript Typed Array object.
        byteOffset - The byte offset for the created Typed Array. byteOffset should aligned with the element size of arrayType.
        length - The number of elements to include in the Typed Array.
        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 JSObjectRef that is a Typed Array or NULL if there was an error. The backing store of the Typed Array will be buffer.
      • JSObjectGetTypedArrayBytesPtr

        public static org.moe.natj.general.ptr.VoidPtr JSObjectGetTypedArrayBytesPtr​(JSContextRef ctx,
                                                                                     JSObjectRef object,
                                                                                     org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Returns a temporary pointer to the backing store of a JavaScript Typed Array object. The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
        Parameters:
        ctx - The execution context to use.
        object - The Typed Array object whose backing store pointer to return.
        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 pointer to the raw data buffer that serves as object's backing store or NULL if object is not a Typed Array object.
      • JSObjectGetTypedArrayLength

        public static long JSObjectGetTypedArrayLength​(JSContextRef ctx,
                                                       JSObjectRef object,
                                                       org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Returns the length of a JavaScript Typed Array object.
        Parameters:
        ctx - The execution context to use.
        object - The Typed Array object whose length to return.
        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 length of the Typed Array object or 0 if the object is not a Typed Array object.
      • JSObjectGetTypedArrayByteLength

        public static long JSObjectGetTypedArrayByteLength​(JSContextRef ctx,
                                                           JSObjectRef object,
                                                           org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Returns the byte length of a JavaScript Typed Array object.
        Parameters:
        ctx - The execution context to use.
        object - The Typed Array object whose byte length to return.
        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 byte length of the Typed Array object or 0 if the object is not a Typed Array object.
      • JSObjectGetTypedArrayByteOffset

        public static long JSObjectGetTypedArrayByteOffset​(JSContextRef ctx,
                                                           JSObjectRef object,
                                                           org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Returns the byte offset of a JavaScript Typed Array object.
        Parameters:
        ctx - The execution context to use.
        object - The Typed Array object whose byte offset to return.
        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 byte offset of the Typed Array object or 0 if the object is not a Typed Array object.
      • JSObjectGetTypedArrayBuffer

        public static JSObjectRef JSObjectGetTypedArrayBuffer​(JSContextRef ctx,
                                                              JSObjectRef object,
                                                              org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Returns the JavaScript Array Buffer object that is used as the backing of a JavaScript Typed Array object.
        Parameters:
        ctx - The execution context to use.
        object - The JSObjectRef whose Typed Array type data pointer to obtain.
        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 JSObjectRef with a JSTypedArrayType of kJSTypedArrayTypeArrayBuffer or NULL if object is not a Typed Array.
      • JSObjectMakeArrayBufferWithBytesNoCopy

        public static JSObjectRef JSObjectMakeArrayBufferWithBytesNoCopy​(JSContextRef ctx,
                                                                         org.moe.natj.general.ptr.VoidPtr bytes,
                                                                         long byteLength,
                                                                         JavaScriptCore.Function_JSObjectMakeArrayBufferWithBytesNoCopy bytesDeallocator,
                                                                         org.moe.natj.general.ptr.VoidPtr deallocatorContext,
                                                                         org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript Array Buffer object from an existing pointer. If an exception is thrown during this function the bytesDeallocator will always be called.
        Parameters:
        ctx - The execution context to use.
        bytes - A pointer to the byte buffer to be used as the backing store of the Typed Array object.
        byteLength - The number of bytes pointed to by the parameter bytes.
        bytesDeallocator - The allocator to use to deallocate the external buffer when the Typed Array data object is deallocated.
        deallocatorContext - A pointer to pass back to the deallocator.
        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 JSObjectRef Array Buffer whose backing store is the same as the one pointed to by bytes or NULL if there was an error.
      • JSObjectGetArrayBufferBytesPtr

        public static org.moe.natj.general.ptr.VoidPtr JSObjectGetArrayBufferBytesPtr​(JSContextRef ctx,
                                                                                      JSObjectRef object,
                                                                                      org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Returns a pointer to the data buffer that serves as the backing store for a JavaScript Typed Array object. The pointer returned by this function is temporary and is not guaranteed to remain valid across JavaScriptCore API calls.
        Parameters:
        object - The Array Buffer object whose internal backing store pointer to return.
        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 pointer to the raw data buffer that serves as object's backing store or NULL if object is not an Array Buffer object.
      • JSObjectGetArrayBufferByteLength

        public static long JSObjectGetArrayBufferByteLength​(JSContextRef ctx,
                                                            JSObjectRef object,
                                                            org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Returns the number of bytes in a JavaScript data object.
        Parameters:
        ctx - The execution context to use.
        object - The JS Arary Buffer object whose length in bytes to return.
        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 number of bytes stored in the data object.
      • JSStringCreateWithCFString

        public static JSStringRef JSStringCreateWithCFString​(CFStringRef string)
        [@function] Creates a JavaScript string from a CFString. This function is optimized to take advantage of cases when CFStringGetCharactersPtr returns a valid pointer.
        Parameters:
        string - The CFString to copy into the new JSString.
        Returns:
        A JSString containing string. Ownership follows the Create Rule.
      • JSStringCopyCFString

        public static CFStringRef JSStringCopyCFString​(CFAllocatorRef alloc,
                                                       JSStringRef string)
        [@function] Creates a CFString from a JavaScript string.
        Parameters:
        alloc - The alloc parameter to pass to CFStringCreate.
        string - The JSString to copy into the new CFString.
        Returns:
        A CFString containing string. Ownership follows the Create Rule.
      • kJSClassDefinitionEmpty

        public static JSClassDefinition kJSClassDefinitionEmpty()
        [@const] kJSClassDefinitionEmpty 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;
      • JSPropertyDescriptorWritableKey

        public static java.lang.String JSPropertyDescriptorWritableKey()
        [@group] Property Descriptor Constants These keys may assist in creating a property descriptor for use with the defineProperty method on JSValue. Property descriptors must fit one of three descriptions: Data Descriptor: - A descriptor containing one or both of the keys value and writable, and optionally containing one or both of the keys enumerable and configurable. A data descriptor may not contain either the get or set key. A data descriptor may be used to create or modify the attributes of a data property on an object (replacing any existing accessor property). Accessor Descriptor: - A descriptor containing one or both of the keys get and set, and optionally containing one or both of the keys enumerable and configurable. An accessor descriptor may not contain either the value or writable key. An accessor descriptor may be used to create or modify the attributes of an accessor property on an object (replacing any existing data property). Generic Descriptor: - A descriptor containing one or both of the keys enumerable and configurable. A generic descriptor may not contain any of the keys value, writable, get, or set. A generic descriptor may be used to modify the attributes of an existing data or accessor property, or to create a new data property. [@const]
      • JSPropertyDescriptorEnumerableKey

        public static java.lang.String JSPropertyDescriptorEnumerableKey()
        [@const]
      • JSPropertyDescriptorConfigurableKey

        public static java.lang.String JSPropertyDescriptorConfigurableKey()
        [@const]
      • JSPropertyDescriptorValueKey

        public static java.lang.String JSPropertyDescriptorValueKey()
        [@const]
      • JSPropertyDescriptorGetKey

        public static java.lang.String JSPropertyDescriptorGetKey()
        [@const]
      • JSPropertyDescriptorSetKey

        public static java.lang.String JSPropertyDescriptorSetKey()
        [@const]
      • JSValueIsSymbol

        public static boolean JSValueIsSymbol​(JSContextRef ctx,
                                              JSValueRef value)
        [@function] Tests whether a JavaScript value's type is the symbol type.
        Parameters:
        ctx - The execution context to use.
        value - The JSValue to test.
        Returns:
        true if value's type is the symbol type, otherwise false.
      • JSValueMakeSymbol

        public static JSValueRef JSValueMakeSymbol​(JSContextRef ctx,
                                                   JSStringRef description)
        [@function] Creates a JavaScript value of the symbol type.
        Parameters:
        ctx - The execution context to use.
        description - A description of the newly created symbol value.
        Returns:
        A unique JSValue of the symbol type, whose description matches the one provided.
      • JSObjectMakeDeferredPromise

        public static JSObjectRef JSObjectMakeDeferredPromise​(JSContextRef ctx,
                                                              org.moe.natj.general.ptr.Ptr<JSObjectRef> resolve,
                                                              org.moe.natj.general.ptr.Ptr<JSObjectRef> reject,
                                                              org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Creates a JavaScript promise object by invoking the provided executor.
        Parameters:
        ctx - The execution context to use.
        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.
        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.
        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.
      • JSObjectHasPropertyForKey

        public static boolean JSObjectHasPropertyForKey​(JSContextRef ctx,
                                                        JSObjectRef object,
                                                        JSValueRef propertyKey,
                                                        org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Tests whether an object has a given property using a JSValueRef as the property key. This function is the same as performing "propertyKey in object" from JavaScript.
        Parameters:
        object - The JSObject to test.
        propertyKey - A JSValueRef containing the property key to use when looking up the property.
        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.
      • JSObjectGetPropertyForKey

        public static JSValueRef JSObjectGetPropertyForKey​(JSContextRef ctx,
                                                           JSObjectRef object,
                                                           JSValueRef propertyKey,
                                                           org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Gets a property from an object using a JSValueRef as the property key. This function is the same as performing "object[propertyKey]" from JavaScript.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose property you want to get.
        propertyKey - A JSValueRef containing the property key to use when looking up the property.
        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.
      • JSObjectSetPropertyForKey

        public static void JSObjectSetPropertyForKey​(JSContextRef ctx,
                                                     JSObjectRef object,
                                                     JSValueRef propertyKey,
                                                     JSValueRef value,
                                                     int attributes,
                                                     org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Sets a property on an object using a JSValueRef as the property key. This function is the same as performing "object[propertyKey] = value" from JavaScript.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose property you want to set.
        propertyKey - A JSValueRef containing the property key to use when looking up the property.
        value - A JSValueRef to use as the property's value.
        attributes - A logically ORed set of JSPropertyAttributes to give to the property.
        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.
      • JSObjectDeletePropertyForKey

        public static boolean JSObjectDeletePropertyForKey​(JSContextRef ctx,
                                                           JSObjectRef object,
                                                           JSValueRef propertyKey,
                                                           org.moe.natj.general.ptr.Ptr<JSValueRef> exception)
        [@function] Deletes a property from an object using a JSValueRef as the property key. This function is the same as performing "delete object[propertyKey]" from JavaScript.
        Parameters:
        ctx - The execution context to use.
        object - The JSObject whose property you want to delete.
        propertyKey - A JSValueRef containing the property key to use when looking up the property.
        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).