Ultralight C++ API 1.3.0
|
#include <AppCore/JSHelpers.h>
JSArray wrapper that automatically manages lifetime and provides convenient access to indices and Array functions.
Public Member Functions | |
JSArray () | |
Create empty Array. | |
JSArray (const std::initializer_list< JSValue > &values) | |
Create Array from list of JSValues. | |
JSArray (JSObjectRef array_obj) | |
Create Array from existing JSObjectRef (JavaScriptCore C API) | |
JSArray (const JSArray &other) | |
Copy constructor (shallow copy, will point to same instance) | |
~JSArray () | |
JSArray & | operator= (const JSArray &other) |
Assignment (shallow assignment, will point to same instance) | |
unsigned | length () |
Get number of elements in the Array. | |
void | push (const JSValue &val) |
Push an element to back of Array. | |
int | indexOf (const JSValue &val, int start=0) const |
Find the index (location) of a certain value, will return -1 if not found. | |
JSPropertyValue | operator[] (unsigned idx) const |
Get a property by array index (numbering starts at 0) | |
operator JSObjectRef () const | |
Get the underlying JSObjectRef (JavaScriptCore C API) | |
JSContextRef | context () const |
Get the bound context for this JSArray (it is cached at creation). | |
void | set_context (JSContextRef context) |
Set the JSContext for this JSArray. | |
Protected Member Functions | |
JSArray (JSContextRef ctx, JSValueRef val) | |
Protected Attributes | |
JSContextRef | ctx_ |
JSObjectRef | instance_ |
Friends | |
class | JSValue |
ultralight::JSArray::JSArray | ( | ) |
Create empty Array.
ultralight::JSArray::JSArray | ( | const std::initializer_list< JSValue > & | values | ) |
Create Array from list of JSValues.
ultralight::JSArray::JSArray | ( | JSObjectRef | array_obj | ) |
Create Array from existing JSObjectRef (JavaScriptCore C API)
ultralight::JSArray::JSArray | ( | const JSArray & | other | ) |
Copy constructor (shallow copy, will point to same instance)
ultralight::JSArray::~JSArray | ( | ) |
|
protected |
|
inline |
Get the bound context for this JSArray (it is cached at creation).
int ultralight::JSArray::indexOf | ( | const JSValue & | val, |
int | start = 0 |
||
) | const |
Find the index (location) of a certain value, will return -1 if not found.
unsigned ultralight::JSArray::length | ( | ) |
Get number of elements in the Array.
|
inline |
Get the underlying JSObjectRef (JavaScriptCore C API)
Assignment (shallow assignment, will point to same instance)
JSPropertyValue ultralight::JSArray::operator[] | ( | unsigned | idx | ) | const |
Get a property by array index (numbering starts at 0)
void ultralight::JSArray::push | ( | const JSValue & | val | ) |
Push an element to back of Array.
|
inline |
Set the JSContext for this JSArray.
Note: JSArrays created from within a JSCallback have a temporary JSContext that is destroyed when the callback returns. You will need to "move" any JSArrays created within these callbacks to the View's main context (call set_context() with the main context) before using them outside the callback.
|
friend |
|
protected |
|
protected |