Yate
Public Member Functions | Static Public Member Functions | List of all members
ScriptContext Class Referenceabstract

Script execution context. More...

#include <yatescript.h>

Inheritance diagram for ScriptContext:
RefObject ExpExtender GenObject JsObject JsArray JsFunction JsRegExp

Public Member Functions

 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 ScriptMutexmutex ()=0
 
virtual bool hasField (ObjList &stack, const String &name, GenObject *context) const
 
virtual NamedStringgetField (ObjList &stack, const String &name, GenObject *context) const
 
virtual void fillFieldNames (ObjList &names)
 
virtual bool runFunction (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
virtual bool runField (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
virtual bool runAssign (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
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 void * getObject (const String &name) const
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
virtual void * getObject (const String &name) const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- Public Member Functions inherited from ExpExtender
virtual ~ExpExtender ()
 
virtual RefObjectrefObj ()
 
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 bool runField (ObjList &stack, const ExpOperation &oper, GenObject *context)
 
virtual bool runAssign (ObjList &stack, const ExpOperation &oper, GenObject *context)
 

Static Public Member Functions

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 ()
 

Additional Inherited Members

- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
virtual void destroyed ()
 

Detailed Description

Script execution context.

A script execution context, holds global variables and objects

Constructor & Destructor Documentation

◆ ScriptContext()

ScriptContext ( const char *  name = 0)
inlineexplicit

Constructor

Parameters
nameName of the context

Member Function Documentation

◆ addFields()

virtual void addFields ( const NamedList list,
const char *  skipPrefix = "__" 
)
virtual

Add string parameters from list

Parameters
listParameters list
skipPrefixSkip parameters whose name start with specified prefix

◆ copyFields()

virtual bool copyFields ( ObjList stack,
const ScriptContext original,
GenObject context 
)
virtual

Copy all fields from another context

Parameters
stackEvaluation stack in use
originalScript context to copy from
contextPointer to context data passed from evaluation methods
Returns
True if all fields were copied

◆ countAllocations()

virtual ObjList * countAllocations ( )
inlinevirtual

Retrieve a list of how many objects were allocated at each line

Returns
The list of counters for allocations, 0 if tracking is not active

◆ createdObj()

virtual void createdObj ( GenObject obj)
inlinevirtual

Notification that an object was created in this context Used for object tracking purposes

Parameters
objThe created object

◆ deletedObj()

virtual void deletedObj ( GenObject obj)
inlinevirtual

Notification that an object was destroyed in this context Used for object tracking purposes

Parameters
objThe destroyed object

◆ fillFieldNames() [1/3]

virtual void fillFieldNames ( ObjList names)
virtual

Fill a list with the unique names of all fields

Parameters
namesList to which key names must be added

Reimplemented in JsObject.

◆ fillFieldNames() [2/3]

static void fillFieldNames ( ObjList names,
const HashList list 
)
static

Fill a list with the unique names from a Hash list

Parameters
namesList to which key names must be added
listHash list whose names are to be added

◆ fillFieldNames() [3/3]

static void fillFieldNames ( ObjList names,
const NamedList list,
bool  checkDupl = true,
const char *  skip = 0 
)
static

Fill a list with the unique names of all fields

Parameters
namesList to which key names must be added
listList of parameters whose names to be added
checkDuplTrue to ignore duplicates from the given list
skipParameters starting with this prefix will not be added

◆ getField()

virtual NamedString * getField ( ObjList stack,
const String name,
GenObject context 
) const
virtual

Get a pointer to a field in the context

Parameters
stackEvaluation stack in use
nameName of the field to retrieve
contextPointer to arbitrary object passed from evaluation methods
Returns
Pointer to field, NULL if not present

Reimplemented from ExpExtender.

Reimplemented in JsObject.

◆ getObject()

virtual void * getObject ( const String name) const
virtual

Get a pointer to a derived class given that class name

Parameters
nameName of the class we are asking for
Returns
Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from RefObject.

◆ hasField()

virtual bool hasField ( ObjList stack,
const String name,
GenObject context 
) const
virtual

Check if a certain field is assigned in context

Parameters
stackEvaluation stack in use
nameName of the field to test
contextPointer to arbitrary object passed from evaluation methods
Returns
True if the field is present

Reimplemented from ExpExtender.

Reimplemented in JsObject.

◆ mutex()

virtual ScriptMutex * mutex ( )
pure virtual

Retrieve the Mutex object used to serialize object access, if any

Returns
Pointer to the mutex or NULL if none applies

Implemented in JsObject.

◆ nativeParams()

virtual NamedList * nativeParams ( ) const
inlinevirtual

Access any native NamedList hold by the context

Returns
Pointer to a native named list

◆ params() [1/2]

NamedList & params ( )
inline

Access to the NamedList operator

Returns
Reference to the internal named list

Referenced by JsObject::clearField(), JsObject::setBoolField(), JsObject::setIntField(), JsObject::setObjField(), and JsObject::setStringField().

◆ params() [2/2]

const NamedList & params ( ) const
inline

Const access to the NamedList operator

Returns
Reference to the internal named list

◆ refObj()

virtual RefObject * refObj ( )
inlinevirtual

Retrieve the reference counted object owning this interface

Returns
Pointer to this script context

Reimplemented from ExpExtender.

◆ runAssign()

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

Try to assign a value to a single field

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

Reimplemented from ExpExtender.

Reimplemented in JsObject, JsArray, and JsRegExp.

◆ runField()

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

Try to evaluate a single field in the context

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

Reimplemented from ExpExtender.

Reimplemented in JsObject, and JsArray.

◆ runFunction()

virtual bool runFunction ( ObjList stack,
const ExpOperation oper,
GenObject context 
)
virtual

Try to evaluate a single function in the context

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

Reimplemented from ExpExtender.

Reimplemented in JsObject.

◆ runMatchingField()

bool runMatchingField ( ObjList stack,
const ExpOperation oper,
GenObject context 
)

Try to evaluate a single field searching for a matching context

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

◆ toString()

virtual const String & toString ( ) const
inlinevirtual

Override GenObject's method to return the internal name of the named list

Returns
A reference to the context name

Reimplemented from GenObject.

Referenced by JsObject::clone().

◆ trackObjs()

virtual void trackObjs ( unsigned int  track = 0)
inlinevirtual

Activate object tracking

Parameters
trackO for not enabled, non-zero for enabling it

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