class JsObject

Javascript Object. More...

Full nameTelEngine::JsObject
Definition#include <libs/yscript/yatescript.h>
InheritsTelEngine::ScriptContext [public ]
Inherited byJsArray, JsFunction, JsRegExp
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods

Protected Methods


Detailed Description

Javascript Object class, base for all JS objects

 JsObject (const char* name = "Object", Mutex* mtx = 0, bool frozen = false)

JsObject

Constructor

Parameters:
nameName of the object
mtxPointer to the mutex that serializes this object
frozenTrue if the object is to be frozen from creation

 JsObject (Mutex* mtx, const char* name, bool frozen = false)

JsObject

Constructor for an empty object

Parameters:
mtxPointer to the mutex that serializes this object
nameFull name of the object
frozenTrue if the object is to be frozen from creation

 JsObject (GenObject* context, Mutex* mtx = 0, bool frozen = false)

JsObject

Constructor for an empty object with prototype

Parameters:
contextScript context from which Object prototype is obtainend
mtxPointer to the mutex that serializes this object
frozenTrue if the object is to be frozen from creation

 ~JsObject ()

~JsObject

[virtual]

Destructor

Mutex*  mutex ()

mutex

[virtual]

Retrieve the Mutex object used to serialize object access

Returns: Pointer to the mutex of the context this object belongs to

Reimplemented from ScriptContext.

JsObject*  clone (const char* name)

clone

[const virtual]

Clone and rename method

Parameters:
nameName of the cloned object

Returns: New object instance

inline JsObject*  clone ()

clone

[const]

Clone method

Returns: New object instance

void  setPrototype (GenObject* context, const String& objName)

setPrototype

Set the object prototype

Parameters:
contextPointer to arbitrary object passed from evaluation methods
objNameName of the object prototype to set the this object

JsObject*  copy (Mutex* mtx)

copy

[const virtual]

Deep copy method

Parameters:
mtxPointer to the mutex that serializes the copied object

Returns: New object instance, does not keep references to old object

void  fillFieldNames (ObjList& names)

fillFieldNames

[virtual]

Fill a list with the unique names of all fields

Parameters:
namesList to which key names must be added

Reimplemented from ScriptContext.

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

hasField

[const virtual]

Check if a certain field is assigned in the object or its prototype

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 ScriptContext.

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

getField

[const virtual]

Get a pointer to a field in the object or its prototype

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 ScriptContext.

void  initConstructor (JsFunction* construct)

initConstructor

[virtual]

Native constructor initialization, called by addConstructor on the prototype

Parameters:
constructFunction that has this object as prototype

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

runConstructor

[virtual]

Native 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 object

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

runFunction

[virtual]

Try to evaluate a single 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 ScriptContext.

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

runField

[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 ScriptContext.

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

runAssign

[virtual]

Try to assign a value to a single field if object is not frozen

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 ScriptContext.

ExpOperation*  popValue (ObjList& stack, GenObject* context = 0)

popValue

[virtual]

Pops and evaluate the value of an operand off an evaluation stack, does not pop a barrier

Parameters:
stackEvaluation stack to remove the operand from
contextPointer to arbitrary object to be passed to called methods

Returns: Value removed from stack, NULL if stack underflow or field not evaluable

inline bool  frozen ()

frozen

[const]

Retrieve the object frozen status (cannot modify attributes or methods)

Returns: True if the object is frozen

inline void  freeze ()

freeze

Freeze the Javascript object preventing external changes to it

void  addObject (NamedList& params, const char* name, JsObject* obj)

addObject

[static]

Helper static method that adds an object to a parent

Parameters:
paramsList of parameters where to add the object
nameName of the new parameter
objPointer to the object to add

void  addConstructor (NamedList& params, const char* name, JsObject* obj)

addConstructor

[static]

Helper static method that adds a constructor to a parent

Parameters:
paramsList of parameters where to add the constructor
nameName of the new parameter
objPointer to the prototype object to add

int  extractArgs (JsObject* obj, ObjList& stack, const ExpOperation& oper, GenObject* context, ObjList& arguments)

extractArgs

[static]

Helper static method that pops arguments off a stack to a list in proper order

Parameters:
objPointer to the object to use when popping each argument
stackEvaluation stack in use, parameters are popped off this stack
operFunction that is being evaluated
contextPointer to arbitrary object passed from evaluation methods
argumentsList where the arguments are added in proper order

Returns: Number of arguments popped off stack

inline int  extractArgs (ObjList& stack, const ExpOperation& oper, GenObject* context, ObjList& arguments)

extractArgs

Helper method that pops arguments off a stack to a list in proper order

Parameters:
stackEvaluation stack in use, parameters are popped off this stack
operFunction that is being evaluated
contextPointer to arbitrary object passed from evaluation methods
argumentsList where the arguments are added in proper order

Returns: Number of arguments popped off stack

JsObject*  buildCallContext (Mutex* mtx, JsObject* thisObj = 0)

buildCallContext

[static]

Create an empty function call context

Parameters:
mtxPointer to the mutex that serializes this object
thisObjOptional object that will be set as "this"

Returns: New empty object usable as call context

void  initialize (ScriptContext* context)

initialize

[static]

Initialize the standard global objects in a context

Parameters:
contextScript context to initialize

inline const String&  protoName ()

protoName

[static]

Get the name of the internal property used to track prototypes

Returns: The "__proto__" constant string

void  deepCopyParams (NamedList& dst, const NamedList& src, Mutex* mtx)

deepCopyParams

[static]

Static helper method that deep copies all parameters

Parameters:
dstDestination parameters
srcSource parameters
mtxMutex to be used to synchronize all new objects

void  dumpRecursive (const GenObject* obj, String& buf)

dumpRecursive

[static]

Helper method to return the hierarchical structure of an object

Parameters:
objObject to dump structure
bufString to which the structure is added

void  printRecursive (const GenObject* obj)

printRecursive

[static]

Helper method to display the hierarchical structure of an object

Parameters:
objObject to display

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

runNative

[protected virtual]

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

inline Mutex*  mutex ()

mutex

[protected const]

Retrieve the Mutex object used to serialize object access

Returns: Pointer to the mutex of the context this object belongs to

Reimplemented from ScriptContext.


Generated by: paulc on bussard on Thu Jul 24 18:41:02 2014, using kdoc 2.0a54.