Yate
JsArray Class Reference

Javascript Array. More...

#include <yatescript.h>

Inheritance diagram for JsArray:
JsObject ScriptContext RefObject ExpExtender GenObject

Public Member Functions

 JsArray (GenObject *context, unsigned int line, ScriptMutex *mtx=0)
 
 JsArray (ScriptMutex *mtx, const char *name, unsigned int line, bool frozen=false)
 
int32_t length () const
 
void setLength (int32_t len)
 
void push (ExpOperation *item)
 
virtual JsObjectcopy (ScriptMutex *mtx, const ExpOperation &oper) const
 
virtual bool runAssign (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
virtual bool runField (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
virtual void initConstructor (JsFunction *construct)
 
virtual JsObjectrunConstructor (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
- Public Member Functions inherited from JsObject
 JsObject (const char *name="Object", ScriptMutex *mtx=0, bool frozen=false)
 
 JsObject (ScriptMutex *mtx, const char *name, unsigned int line, bool frozen=0)
 
 JsObject (GenObject *context, unsigned int line, ScriptMutex *mtx=0, bool frozen=false)
 
virtual ~JsObject ()
 
virtual ScriptMutexmutex ()
 
JsObjectclone (const ExpOperation &oper) const
 
void setPrototype (GenObject *context, const String &objName)
 
virtual void fillFieldNames (ObjList &names)
 
virtual const HashListgetHashListParams () const
 
virtual bool hasField (ObjList &stack, const String &name, GenObject *context) const
 
virtual NamedStringgetField (ObjList &stack, const String &name, GenObject *context) const
 
virtual bool runFunction (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
virtual ExpOperationpopValue (ObjList &stack, GenObject *context=0)
 
virtual void clearField (const String &name)
 
bool setIntField (const char *name, int64_t val)
 
bool setBoolField (const char *name, bool val)
 
bool setStringField (const char *name, const char *val)
 
bool setObjField (const char *name, JsObject *obj)
 
bool getIntField (const String &name, int64_t &val)
 
bool getBoolField (const String &name, bool &val)
 
bool getStringField (const String &name, String &val)
 
bool getObjField (const String &name, JsObject *&obj)
 
bool frozen () const
 
void freeze ()
 
void lineNo (unsigned int line)
 
unsigned int lineNo () const
 
int extractArgs (ObjList &stack, const ExpOperation &oper, GenObject *context, ObjList &arguments)
 
- Public Member Functions inherited from ScriptContext
 ScriptContext (const char *name=0)
 
NamedListparams ()
 
const NamedListparams () const
 
virtual NamedListnativeParams () const
 
virtual const StringtoString () const
 
virtual void * getObject (const String &name) const
 
virtual RefObjectrefObj ()
 
virtual bool copyFields (ObjList &stack, const ScriptContext &original, GenObject *context)
 
virtual void addFields (const NamedList &list, const char *skipPrefix="__")
 
bool runMatchingField (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
virtual void createdObj (GenObject *obj)
 
virtual void deletedObj (GenObject *obj)
 
virtual void trackObjs (unsigned int track=0)
 
virtual ObjListcountAllocations ()
 
- Public Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual const StringtraceId () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- Public Member Functions inherited from ExpExtender
virtual ~ExpExtender ()
 

Protected Member Functions

virtual JsObjectclone (const char *name, const ExpOperation &oper) const
 
bool runNative (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
- Protected Member Functions inherited from JsObject
ScriptMutexmutex () const
 
void setMutex (ScriptMutex *mtx)
 
- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
virtual void destroyed ()
 

Friends

class JsObject
 

Additional Inherited Members

- Public Types inherited from JsObject
enum  DumpFlags {
  DumpFunc = 0x01 , DumpProp = 0x02 , DumpRecursive = 0x10 , DumpType = 0x20 ,
  DumpProto = 0x40 , DumpPropObjType = 0x80 , DumpFuncOnly = DumpRecursive | DumpProto | DumpFunc , DumpPropOnly = DumpRecursive | DumpPropObjType | DumpProp
}
 
- Static Public Member Functions inherited from JsObject
static void addObject (NamedList &params, const char *name, JsObject *obj)
 
static void addConstructor (NamedList &params, const char *name, JsObject *obj)
 
static int extractArgs (JsObject *obj, ObjList &stack, const ExpOperation &oper, GenObject *context, ObjList &arguments)
 
static JsObjectbuildCallContext (ScriptMutex *mtx, JsObject *thisObj=0)
 
static void initialize (ScriptContext *context)
 
static void setLineForObj (JsObject *obj, unsigned int lineNo, bool recursive)
 
static const StringprotoName ()
 
static void deepCopyParams (NamedList &dst, const NamedList &src, ScriptMutex *mtx)
 
static void dumpRecursive (const GenObject *obj, String &buf, unsigned int flags=0xffffffff)
 
static void printRecursive (const GenObject *obj, unsigned int flags=0xffffffff)
 
static ExpOperationtoJSON (const ExpOperation *oper, int spaces)
 
- Static Public Member Functions inherited from ScriptContext
static void fillFieldNames (ObjList &names, const NamedList &list, bool checkDupl=true, const char *skip=0)
 
static void fillFieldNames (ObjList &names, const HashList &list)
 
- Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
 
static bool efficientIncDec ()
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 
- Static Protected Member Functions inherited from JsObject
static void toJSON (const NamedString *ns, String &buf, int spaces, int indent=0)
 
static String strEscape (const char *str)
 

Detailed Description

Javascript Array.

Javascript Array class, implements arrays of items

Constructor & Destructor Documentation

◆ JsArray() [1/2]

JsArray ( GenObject * context,
unsigned int line,
ScriptMutex * mtx = 0 )

Constructor for an empty array with prototype

Parameters
contextScript context from which Array prototype is obtained
lineCode line where this object was created
mtxPointer to the mutex that serializes this object

Referenced by clone(), and runNative().

◆ JsArray() [2/2]

JsArray ( ScriptMutex * mtx,
const char * name,
unsigned int line,
bool frozen = false )
inline

Constructor for an empty array

Parameters
mtxPointer to the mutex that serializes this object
nameFull name of the object
lineCode line where this object was created
frozenTrue if the object is to be frozen from creation

References JsObject::frozen().

Member Function Documentation

◆ clone()

virtual JsObject * clone ( const char * name,
const ExpOperation & oper ) const
inlineprotectedvirtual

Clone and rename method

Parameters
nameName of the cloned object
operExpOperation that requested the cloning
Returns
New object instance

Reimplemented from JsObject.

References JsArray(), ExpOperation::lineNumber(), and JsObject::mutex().

◆ copy()

virtual JsObject * copy ( ScriptMutex * mtx,
const ExpOperation & oper ) const
virtual

Deep copy method

Parameters
mtxPointer to the mutex that serializes the copied array
operExpOperation that required the copy operation
Returns
New object instance, does not keep references to old array

Reimplemented from JsObject.

◆ initConstructor()

virtual void initConstructor ( JsFunction * construct)
virtual

Array constructor initialization

Parameters
constructThe Array function

Reimplemented from JsObject.

◆ length()

int32_t length ( ) const
inline

Retrieve the length of the array

Returns
Number of numerically indexed objects in array

◆ push()

void push ( ExpOperation * item)

Add an item at the end of the array

Parameters
itemItem to add to array

◆ runAssign()

virtual bool runAssign ( ObjList & stack,
const ExpOperation & oper,
GenObject * context )
virtual

Try to assign a value to a single field if object is not frozen and update array length. Reimplemented from JsObject

Parameters
stackEvaluation stack in use
operField to assign to, contains the field name and new value
contextPointer to arbitrary object passed from evaluation methods
Returns
True if assignment succeeded

Reimplemented from JsObject.

◆ runConstructor()

virtual JsObject * runConstructor ( ObjList & stack,
const ExpOperation & oper,
GenObject * context )
virtual

Array object constructor, it's run on the prototype

Parameters
stackEvaluation stack in use
operConstructor function to evaluate
contextPointer to arbitrary object passed from evaluation methods
Returns
New created and populated Javascript Array object

Reimplemented from JsObject.

◆ runField()

virtual bool runField ( ObjList & stack,
const ExpOperation & oper,
GenObject * context )
virtual

Try to evaluate a single field

Parameters
stackEvaluation stack in use, field value must be pushed on it
operField to evaluate
contextPointer to arbitrary object passed from evaluation methods
Returns
True if evaluation succeeded

Reimplemented from JsObject.

◆ runNative()

bool runNative ( ObjList & stack,
const ExpOperation & oper,
GenObject * context )
protectedvirtual

Try to evaluate a single native method

Parameters
stackEvaluation stack in use, parameters are popped off this stack and results are pushed back on stack
operFunction to evaluate
contextPointer to arbitrary object passed from evaluation methods
Returns
True if evaluation succeeded

Reimplemented from JsObject.

References JsArray().

◆ setLength()

void setLength ( int32_t len)
inline

Set the internal length to a specific value

Parameters
lenLength of array to set

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