Jerryscript::Array Class Reference

Array objects have properties accessed by index. More...

#include <Types.h>

Inheritance diagram for Jerryscript::Array:
Collaboration diagram for Jerryscript::Array:

Classes

struct  IndexedItem
 Iterator and operator[] access uses this wrapper class so items may be written or read. More...
 
class  Iterator
 

Public Member Functions

 Array (size_t size)
 Create a new, fixed-size array with the given number of elements. More...
 
size_t count () const
 Get number of elements in the array. More...
 
 Object ()
 Default constructor creates a new, empty object. More...
 
 Object (const Value &value)
 
 Object (Value &&value)
 
Iterator support
Iterator begin ()
 begin More...
 
Iterator end ()
 end More...
 
Array element/property access by index
IndexedItem operator[] (unsigned index)
 operator[] uses IndexedItem proxy object so value can be assigned or read More...
 
const Value operator[] (unsigned index) const
 const operator[] returns value directly More...
 
Value getProperty (unsigned index) const
 Get a property value. More...
 
Value setProperty (unsigned index, const Value &value)
 Set a property value. More...
 
- Public Member Functions inherited from Jerryscript::Object
 Object ()
 Default constructor creates a new, empty object. More...
 
 Object (const Value &value)
 
 Object (Value &&value)
 
Array keys () const
 Get list of property names. More...
 
Value runFunction (const String &name, Value &arg)
 Call a specified JavaScript function with exactly one argument. More...
 
Value runFunction (const String &name, std::initializer_list< Value > args={})
 Call a specified JavaScript function with zero or more arguments. More...
 
bool registerFunction (const String &name, jerry_external_handler_t handler)
 Register an external function so it may be called from javascript. More...
 
bool unregisterFunction (const String &name)
 Unregister an external function. More...
 
Callable getFunction (const String &name)
 Retrieve the given property as a function. More...
 
 Value ()
 Construct An empty (unused) value. More...
 
 Value (const OwnedValue &value)
 Construct a Value and take ownership of the given native value. More...
 
 Value (const CopyValue &value)
 Construct a Value using a copy (or reference to) the given native value. More...
 
 Value (const StringValue &value)
 Construct a string Value from the given native value. More...
 
 Value (const Undefined &value)
 
 Value (const Null &value)
 
 Value (const Value &value)
 Copy constructor. More...
 
 Value (Value &&value)
 Move constructor. More...
 
 Value (int value)
 Integer. More...
 
 Value (unsigned value)
 Unsigned integer. More...
 
 Value (double value)
 floating-point More...
 
 Value (bool value)
 Boolean. More...
 
 Value (const String &s)
 Wiring String. More...
 
 Value (const char *s)
 NUL-terminated 'C' string. More...
 
 Value (const FSTR::String &s)
 Flash String. More...
 
NamedItem operator[] (const String &name)
 operator[] uses NamedItem proxy object so value can be assigned or read More...
 
const Value operator[] (const String &name) const
 const operator[] returns Value directly More...
 
Value setProperty (const Value &name, const Value &value)
 Set a property value. More...
 
Value getProperty (const Value &name) const
 Get a property value. More...
 
bool hasProperty (const Value &name) const
 Determine if a property exists. More...
 
bool removeProperty (const Value &name)
 Remove a property. More...
 
- Public Member Functions inherited from Jerryscript::Value
 Value ()
 Construct An empty (unused) value. More...
 
 Value (const OwnedValue &value)
 Construct a Value and take ownership of the given native value. More...
 
 Value (const CopyValue &value)
 Construct a Value using a copy (or reference to) the given native value. More...
 
 Value (const StringValue &value)
 Construct a string Value from the given native value. More...
 
 Value (const Undefined &value)
 
 Value (const Null &value)
 
 Value (const Value &value)
 Copy constructor. More...
 
 Value (Value &&value)
 Move constructor. More...
 
 ~Value ()
 
Valueoperator= (const Value &value)
 Assignment copy operator. More...
 
Valueoperator= (Value &&value)
 Assignment move operator. More...
 
Valuereset (jerry_value_t value=jerry_value_t(Ecma::VALUE_EMPTY))
 Reset contents of object to new value (default is unassigned) More...
 
jerry_value_t release ()
 Get raw/native value and release ownership. More...
 
Type type () const
 Get value type. More...
 
Object toObject () const
 Create a new object from this value. More...
 
Value toString () const
 Create a new string value from this value. More...
 
size_t readString (unsigned offset, char *buffer, size_t length) const
 Get content from within a string value. More...
 
String subString (unsigned offset, size_t length) const
 Get content from within a string value. More...
 
 operator String () const
 Support intrinsic cast to Wiring String. More...
 
template<typename T >
as () const
 Get value of object with specific type. e.g. value.as<int>(). More...
 
 Value (int value)
 Integer. More...
 
 Value (unsigned value)
 Unsigned integer. More...
 
 Value (double value)
 floating-point More...
 
 Value (bool value)
 Boolean. More...
 
 Value (const String &s)
 Wiring String. More...
 
 Value (const char *s)
 NUL-terminated 'C' string. More...
 
 Value (const FSTR::String &s)
 Flash String. More...
 
const jerry_value_t & get () const
 const get() More...
 
jerry_value_t & get ()
 get() More...
 
bool isCallable () const
 Is this object a function? If so, can cast to Callable type. More...
 
bool isArray () const
 Can this object be accessed as an array? If so, can cast to Array type. More...
 
bool isError () const
 Determine if value represents an error. If so, can cast to Error type. More...
 
bool isEmpty () const
 An empty Value contains nothing, i.e. no javascript type has been assigned. This gets interpreted as 'undefined' if any attempt is made to use it in javascript. More...
 
bool isDefined () const
 Contains a javascript value, but contents undefined. More...
 
bool isBoolean () const
 A true/false value type. More...
 
bool isFalse () const
 Is this a Boolean type set to False? More...
 
bool isTrue () const
 Is this a Boolean type set to True? More...
 
bool isNull () const
 Is this a NULL value? More...
 
bool isString () const
 Is this a String? More...
 
bool isObject () const
 Is this an Object type? If so, can cast to Object class. More...
 
bool isNumber () const
 Does this value contain a Number? More...
 

Additional Inherited Members

- Public Types inherited from Jerryscript::Object
using List = Vector< Object >
 
- Public Types inherited from Jerryscript::Value
using List = Vector< Value >
 

Detailed Description

Array objects have properties accessed by index.

Constructor & Destructor Documentation

◆ Array()

Jerryscript::Array::Array ( size_t  size)
inline

Create a new, fixed-size array with the given number of elements.

Member Function Documentation

◆ begin()

Iterator Jerryscript::Array::begin ( )
inline

begin

◆ count()

size_t Jerryscript::Array::count ( ) const
inline

Get number of elements in the array.

◆ end()

Iterator Jerryscript::Array::end ( )
inline

end

◆ getProperty()

Value Jerryscript::Array::getProperty ( unsigned  index) const
inline

Get a property value.

Parameters
indexIndex of property
Return values
ValueThe property value, or Error

◆ Object() [1/3]

Jerryscript::Object::Object
inline

Default constructor creates a new, empty object.

◆ Object() [2/3]

Jerryscript::Object::Object
inline

◆ Object() [3/3]

Jerryscript::Object::Object
inline

◆ operator[]() [1/2]

IndexedItem Jerryscript::Array::operator[] ( unsigned  index)
inline

operator[] uses IndexedItem proxy object so value can be assigned or read

◆ operator[]() [2/2]

const Value Jerryscript::Array::operator[] ( unsigned  index) const
inline

const operator[] returns value directly

◆ setProperty()

Value Jerryscript::Array::setProperty ( unsigned  index,
const Value value 
)
inline

Set a property value.

Parameters
indexIndex of property
valueValue to set
Return values
Valuetrue on success, otherwise Error

The documentation for this class was generated from the following file: