# class JsFunction | Javascript Function. More...
Full name | `TelEngine::JsFunction`
Definition | `#include <libs/yscript/yatescript.h>`
Inherits | TelEngine::JsObject [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- JsFunction (Mutex* mtx = 0)
- JsFunction (Mutex* mtx, const char* name, ObjList* args = 0, long int lbl = 0, ScriptCode* code = 0)
- virtual bool runDefined (ObjList& stack, const ExpOperation& oper, GenObject* context, JsObject* thisObj = 0)
- inline const ExpFunction* getFunc () const
- inline const String& firstName () const
- inline void firstName (const char* name)
- inline const String* formalName (unsigned int index) const
- inline long int label () const
- virtual JsObject* copy (Mutex* mtx) const

#### Protected Methods

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

## Detailed Description

Javascript Function class, implements user defined functions

JsFunction (Mutex* mtx = 0) | ### JsFunction

Constructor

Parameters:

mtx | Pointer to the mutex that serializes this object

JsFunction (Mutex* mtx, const char* name, ObjList* args = 0, long int lbl = 0, ScriptCode* code = 0) | ### JsFunction

Constructor with function name

Parameters:

mtx | Pointer to the mutex that serializes this object
name | Name of the function
args | Optional list of formal parameter names, will be emptied
lbl | Number of the entry point label
code | The script code to be used while running the function

bool runDefined (ObjList& stack, const ExpOperation& oper, GenObject* context, JsObject* thisObj = 0) | ### runDefined

[virtual]

Try to evaluate a single user defined method

Parameters:

stack | Evaluation stack in use, parameters are popped off this stack and results are pushed back on stack
oper | Function to evaluate
context | Pointer to arbitrary object passed from evaluation methods
thisObj | Object that should act as "this" for the function call

Returns: True if evaluation succeeded

inline const ExpFunction* getFunc () | ### getFunc

[const]

Retrieve the ExpFunction matching this Javascript function

Returns: Pointer to ExpFunction representation

inline const String& firstName () | ### firstName

[const]

Retrieve the first name assigned to this function

Returns: The name of the property towhich this function was first assigned

inline void firstName (const char* name) | ### firstName

Set the name of this function if still empty

Parameters:

name | Name to set as first assigned name

inline const String* formalName (unsigned int index) | ### formalName

[const]

Retrieve the name of the N-th formal argument

Parameters:

index | Index of the formal argument

Returns: Pointer to formal argument name, NULL if index too large

inline long int label () | ### label

[const]

Retrieve the entry label of the code for this function

Returns: Number of the entry point label, zero if no code defined

JsObject* copy (Mutex* mtx) | ### copy

[const virtual]

Deep copy method

Parameters:

mtx | Pointer to the mutex that serializes the copied array

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

Reimplemented from JsObject.

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

[protected virtual]

Try to evaluate a single native method

Parameters:

stack | Evaluation stack in use, parameters are popped off this stack and results are pushed back on stack
oper | Function to evaluate
context | Pointer to arbitrary object passed from evaluation methods

Returns: True if evaluation succeeded

Reimplemented from JsObject.

Generated by: paulc on bussard on Mon Feb 10 13:15:47 2014, using kdoc 2.0a54.