![]() |
Ultralight C++ API 1.4.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 |
| JSArray | ( | ) |
Create empty Array.
| JSArray | ( | JSObjectRef | array_obj | ) |
Create Array from existing JSObjectRef (JavaScriptCore C API)
| ~JSArray | ( | ) |
|
protected |
|
inline |
Get the bound context for this JSArray (it is cached at creation).
| int indexOf | ( | const JSValue & | val, |
| int | start = 0 ) const |
Find the index (location) of a certain value, will return -1 if not found.
| unsigned 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 operator[] | ( | unsigned | idx | ) | const |
Get a property by array index (numbering starts at 0)
| void push | ( | const JSValue & | val | ) |
Push an element to back of Array.
|
inline |
Set the JSContext for this JSArray.
|
friend |
|
protected |
|
protected |