#include <script.h>
Inheritance diagram for ScriptInterp:
Public Member Functions | |
long | getIntValue (const char *text, unsigned prec) |
int | getExpression (long *list, int max, unsigned prec) |
bool | setData (const char *scrname) |
Set data read pointer to a known data source script. | |
char | getPackToken (void) |
Get pack token. | |
void | clrTransactions (void) |
Clear transaction processing group. | |
Symbol * | getVariable (size_t size=0) |
Fetch a variable (symbol) that will be used to store data. | |
void | rewindTemp (void) |
Rewind temporary buffer for prescan results. | |
void | setTemp (const char *value) |
Set prescan value into temporary buffer. | |
virtual Symbol * | getIndirect (char *sym) |
May be used to override processing of indirect content requests. | |
Symbol * | getLocal (const char *name, size_t size=0) |
Search for symbols either thru the virtual global space or thru local space if a local space has been allocated on the heap. | |
bool | attach (const char *scrname) |
Attempt to attach script engine to active session and specify a starting script. | |
void | detach (void) |
Detach the current script image. | |
bool | redirect (const char *scrname) |
Script redirection support. | |
bool | step (const char *trapname=NULL) |
Execute the next pending script statement. | |
bool | isActive (void) |
Test if script interpreter is currently active. | |
char * | getOption (const char *def=NULL) |
Fetch next logical option but do not evaluate. | |
char * | getKeyword (const char *keyword) |
Fetch an embedded attribute keyword argument. | |
int | initKeywords (int size) |
Initialize symbols from the keyword list. | |
char * | getValue (const char *def=NULL) |
Fetch and evaluate next logical option. | |
char * | getString (void) |
Fetch and concatenate a temporary string expression until either a comma or closing parenthesis. | |
char * | getTempBuffer (void) |
Fetch a temp workspace buffer. | |
char * | getContent (char *sym) |
Evaluate the content of an option retrieved with getOption. | |
Line * | getScript (void) |
Return the current script line object so it may be debugged. | |
bool | hasEvents (void) |
Return if the script has generic event handlers. | |
Line * | getPrescan (void) |
Return if the current line requires prescanning. | |
const char * | getMember (void) |
Return the member id of a script command. | |
Name * | getObject (void) |
Return the master script object for resource context. | |
ScriptImage * | getImage (void) |
Return the script image holding this application's context. | |
void | autoloop (bool enable) |
Enable or disable autolooping of statements. | |
int | mapicmp (const char *s1, const char *s2) |
int | mapnicmp (const char *s1, const char *s2, size_t n) |
unsigned | getDecimal (void) |
Get decimal. | |
Static Public Member Functions | |
static long | getRealValue (double val, unsigned prec) |
static double | getDouble (long value, unsigned prec) |
static long | getInteger (long value, unsigned prec) |
static long | getTens (unsigned prec) |
Protected Member Functions | |
ScriptInterp (ScriptCommand *cmd, size_t symsize, size_t pgsize=1024) | |
Derive a new instance of the system script interpreter. | |
~ScriptInterp () | |
void | getTrigger (bool use) |
Get a local and/or global trigger. | |
bool | getOnce (void) |
Fetch unique "once" flag and set. | |
void | Notify (unsigned long mask) |
Notify signal mask for "on" handlers. | |
void | Notify (const char *str) |
Notify signal by symbolic name. | |
unsigned long | getMask (void) |
Fetch the current interpreter mask bits directly. | |
void | setLine (Line *line) |
Set the line handler to a new statement. | |
unsigned long | getScriptMask (const char *id) |
Fetch the script mask identifer. | |
ScriptCommand * | getCommand (void) |
Fetch the active command interpreter subsystem. | |
bool | conditional (void) |
Used to process "conditional" arguments such as for IF/DO/LOOP statements. | |
bool | scrExit (void) |
Some systems can derive alternative "exit" commands which can call this routine after performing other operations. | |
bool | scrGoto (void) |
This is often called to process branching requests. | |
bool | scrIf (void) |
override if support. | |
bool | ifGoto (void) |
If version of goto. | |
bool | scrData (void) |
Method used to encode "data" lines. | |
virtual unsigned | getId (void) |
Used to return channel identifiers in some systems. | |
virtual bool | getGlobalTrap (unsigned id) |
Used to fetch a global trap execution context branch. | |
void | advance (void) |
Advance program to the next script statement. | |
void | error (const char *error) |
Set error variable and advance to either the error handler or next script statement. | |
void | trap (unsigned id) |
Set the execution interpreter to a trap identifier. | |
void | trap (const char *trapname) |
Select trap by symbolic name and execute if found, else advance to next script step (unless exit trap). | |
bool | push (void) |
Attempt to push a value onto the stack. | |
bool | pull (void) |
Attempt to recall a previous stack level. | |
bool | signal (const char *trapname) |
Signals are used during "delayed" execution steps when a signal event has occured aynchronously with the execution of a script controlled state event handler. | |
bool | event (const char *evtname) |
Events reference to named handlers which have been attached to a script. | |
bool | signal (unsigned trapid) |
Signals can be referenced by numeric id as well as by symbolic name. | |
virtual bool | execute (Method method) |
Runtime execution of script handler. | |
virtual void | stop (unsigned long mask) |
Stop request handler. | |
virtual void | exit (void)=0 |
Exit request handler. | |
virtual Name * | getScriptImage (const char *label) |
Runtime branch point for label selection. | |
Name * | getScriptCopy (const char *src) |
Fetch duplicative script image as needed. | |
virtual void | sleepScheduler (timeout_t timeout) |
Patch point for sleep delay notification. | |
virtual void | stepScheduler (const char *trapname) |
Step scheduler callback to force step execution. | |
virtual void | setExclusive (bool enable) |
Set exclusive sync locking for interpreter. | |
Protected Attributes | |
unsigned char | lckcount |
Friends | |
class | ScriptImage |
class | Script::Session |
class | Script::Locks |
class | ScriptModule |
class | ScriptCommand |
void | addFunction (const char *name, unsigned count, Function i) |
void | addConditional (const char *name, Cond test) |
void | addAttribute (const char *name, Meta meta) |
Classes | |
class | Context |
ScriptInterp::ScriptInterp | ( | ScriptCommand * | cmd, | |
size_t | symsize, | |||
size_t | pgsize = 1024 | |||
) | [protected] |
Derive a new instance of the system script interpreter.
symsize | for default symbol sizing. | |
pgsize | for memory fragmentation. |
ScriptInterp::~ScriptInterp | ( | ) | [protected] |
void ScriptInterp::advance | ( | void | ) | [protected] |
Advance program to the next script statement.
bool ScriptInterp::attach | ( | const char * | scrname | ) |
Attempt to attach script engine to active session and specify a starting script.
name | of script entry. |
void ScriptInterp::autoloop | ( | bool | enable | ) | [inline] |
Enable or disable autolooping of statements.
true | to enable autoloop (default). |
void ScriptInterp::clrTransactions | ( | void | ) | [inline] |
Clear transaction processing group.
bool ScriptInterp::conditional | ( | void | ) | [protected] |
Used to process "conditional" arguments such as for IF/DO/LOOP statements.
The index is kept at the next logical argument so a goto can be performed if needed.
void ScriptInterp::detach | ( | void | ) |
Detach the current script image.
If it is the last ref count and the exit flag is set, then delete it.
void ScriptInterp::error | ( | const char * | error | ) | [protected] |
Set error variable and advance to either the error handler or next script statement.
error | message. |
bool ScriptInterp::event | ( | const char * | evtname | ) | [protected] |
Events reference to named handlers which have been attached to a script.
This allows low level applications to invoke an event handler much the way a signal handler occurs.
name | of event handler. |
virtual bool ScriptInterp::execute | ( | Method | method | ) | [inline, protected, virtual] |
Runtime execution of script handler.
This can be called in the current or derived class to invoke extensible methods.
derived | method to call. |
virtual void ScriptInterp::exit | ( | void | ) | [protected, pure virtual] |
Exit request handler.
This is called when no script line exists. No default behavior is known.
ScriptCommand* ScriptInterp::getCommand | ( | void | ) | [inline, protected] |
Fetch the active command interpreter subsystem.
char* ScriptInterp::getContent | ( | char * | sym | ) |
Evaluate the content of an option retrieved with getOption.
option | string. |
unsigned ScriptInterp::getDecimal | ( | void | ) | [inline] |
Get decimal.
static double ScriptInterp::getDouble | ( | long | value, | |
unsigned | prec | |||
) | [static] |
int ScriptInterp::getExpression | ( | long * | list, | |
int | max, | |||
unsigned | prec | |||
) |
virtual bool ScriptInterp::getGlobalTrap | ( | unsigned | id | ) | [inline, protected, virtual] |
Used to fetch a global trap execution context branch.
trap | identifier. |
virtual unsigned ScriptInterp::getId | ( | void | ) | [inline, protected, virtual] |
Used to return channel identifiers in some systems.
ScriptImage* ScriptInterp::getImage | ( | void | ) | [inline] |
Return the script image holding this application's context.
virtual Symbol* ScriptInterp::getIndirect | ( | char * | sym | ) | [inline, virtual] |
May be used to override processing of indirect content requests.
This is used in the Bayonne IVR to fetch content constants based on language and country settings.
indirect | fetch request. |
static long ScriptInterp::getInteger | ( | long | value, | |
unsigned | prec | |||
) | [static] |
long ScriptInterp::getIntValue | ( | const char * | text, | |
unsigned | prec | |||
) |
char* ScriptInterp::getKeyword | ( | const char * | keyword | ) |
Fetch an embedded attribute keyword argument.
This allows embedded tag=value keywords to be extracted.
keyword | to find. |
Symbol* ScriptInterp::getLocal | ( | const char * | name, | |
size_t | size = 0 | |||
) |
Search for symbols either thru the virtual global space or thru local space if a local space has been allocated on the heap.
script | symbol to look for or create. | |
size | of symbol to allocate. |
unsigned long ScriptInterp::getMask | ( | void | ) | [protected] |
Fetch the current interpreter mask bits directly.
const char* ScriptInterp::getMember | ( | void | ) |
Return the member id of a script command.
Name* ScriptInterp::getObject | ( | void | ) | [inline] |
Return the master script object for resource context.
bool ScriptInterp::getOnce | ( | void | ) | [protected] |
Fetch unique "once" flag and set.
char* ScriptInterp::getOption | ( | const char * | def = NULL |
) |
Fetch next logical option but do not evaluate.
The index is advanced.
optional | default. |
char ScriptInterp::getPackToken | ( | void | ) |
Get pack token.
Line* ScriptInterp::getPrescan | ( | void | ) |
Return if the current line requires prescanning.
static long ScriptInterp::getRealValue | ( | double | val, | |
unsigned | prec | |||
) | [static] |
Line* ScriptInterp::getScript | ( | void | ) | [inline] |
Return the current script line object so it may be debugged.
Name* ScriptInterp::getScriptCopy | ( | const char * | src | ) | [protected] |
Fetch duplicative script image as needed.
label | to dup. |
virtual Name* ScriptInterp::getScriptImage | ( | const char * | label | ) | [protected, virtual] |
Runtime branch point for label selection.
label | to locate. | |
script | line associated. |
unsigned long ScriptInterp::getScriptMask | ( | const char * | id | ) | [inline, protected] |
Fetch the script mask identifer.
char* ScriptInterp::getString | ( | void | ) |
Fetch and concatenate a temporary string expression until either a comma or closing parenthesis.
char* ScriptInterp::getTempBuffer | ( | void | ) |
Fetch a temp workspace buffer.
static long ScriptInterp::getTens | ( | unsigned | prec | ) | [static] |
void ScriptInterp::getTrigger | ( | bool | use | ) | [protected] |
Get a local and/or global trigger.
use | or clear. |
char* ScriptInterp::getValue | ( | const char * | def = NULL |
) |
Fetch and evaluate next logical option.
If a symbol ref. then the symbol is also expressed. The index is advanced.
optional | default value. |
Symbol* ScriptInterp::getVariable | ( | size_t | size = 0 |
) |
Fetch a variable (symbol) that will be used to store data.
This advances the index.
optional | size to allocate if new symbol. |
bool ScriptInterp::hasEvents | ( | void | ) | [inline] |
Return if the script has generic event handlers.
..
bool ScriptInterp::ifGoto | ( | void | ) | [protected] |
If version of goto.
int ScriptInterp::initKeywords | ( | int | size | ) |
Initialize symbols from the keyword list.
bool ScriptInterp::isActive | ( | void | ) | [inline] |
Test if script interpreter is currently active.
int ScriptInterp::mapicmp | ( | const char * | s1, | |
const char * | s2 | |||
) | [inline] |
int ScriptInterp::mapnicmp | ( | const char * | s1, | |
const char * | s2, | |||
size_t | n | |||
) | [inline] |
void ScriptInterp::Notify | ( | const char * | str | ) | [inline, protected] |
Notify signal by symbolic name.
mask | name. |
void ScriptInterp::Notify | ( | unsigned long | mask | ) | [inline, protected] |
Notify signal mask for "on" handlers.
mask | value. |
bool ScriptInterp::pull | ( | void | ) | [protected] |
Attempt to recall a previous stack level.
bool ScriptInterp::push | ( | void | ) | [protected] |
Attempt to push a value onto the stack.
bool ScriptInterp::redirect | ( | const char * | scrname | ) |
void ScriptInterp::rewindTemp | ( | void | ) |
Rewind temporary buffer for prescan results.
bool ScriptInterp::scrData | ( | void | ) | [protected] |
Method used to encode "data" lines.
bool ScriptInterp::scrExit | ( | void | ) | [protected] |
Some systems can derive alternative "exit" commands which can call this routine after performing other operations.
bool ScriptInterp::scrGoto | ( | void | ) | [protected] |
This is often called to process branching requests.
bool ScriptInterp::scrIf | ( | void | ) | [protected] |
override if support.
bool ScriptInterp::setData | ( | const char * | scrname | ) |
Set data read pointer to a known data source script.
name | of script. |
virtual void ScriptInterp::setExclusive | ( | bool | enable | ) | [inline, protected, virtual] |
Set exclusive sync locking for interpreter.
turn | exclusive on or off. |
Reimplemented from ScriptSymbol.
void ScriptInterp::setLine | ( | Line * | line | ) | [protected] |
Set the line handler to a new statement.
line | value. |
void ScriptInterp::setTemp | ( | const char * | value | ) |
Set prescan value into temporary buffer.
value | to set into temp. |
bool ScriptInterp::signal | ( | unsigned | trapid | ) | [protected] |
Signals can be referenced by numeric id as well as by symbolic name.
trap | number of handler. |
bool ScriptInterp::signal | ( | const char * | trapname | ) | [protected] |
Signals are used during "delayed" execution steps when a signal event has occured aynchronously with the execution of a script controlled state event handler.
This mechanism can be used in place of calling implicit "Step" traps.
name | of signal identifier. |
virtual void ScriptInterp::sleepScheduler | ( | timeout_t | timeout | ) | [inline, protected, virtual] |
Patch point for sleep delay notification.
sleep | timeout expected. |
bool ScriptInterp::step | ( | const char * | trapname = NULL |
) |
Execute the next pending script statement.
If no statement is selected, then we execute the exit handler instead. We can also force feed a trap identifier.
optional | trap branch point (also checks mask). |
virtual void ScriptInterp::stepScheduler | ( | const char * | trapname | ) | [inline, protected, virtual] |
Step scheduler callback to force step execution.
trap | name to use. |
virtual void ScriptInterp::stop | ( | unsigned long | mask | ) | [inline, protected, virtual] |
Stop request handler.
Used for handling external trap requests during a "Signal". This is needed in some state engines when the current state is being abandoned because of a signaled trap.
signal | mask forcing stop. |
void ScriptInterp::trap | ( | const char * | trapname | ) | [protected] |
Select trap by symbolic name and execute if found, else advance to next script step (unless exit trap).
name | of trap to select. |
void ScriptInterp::trap | ( | unsigned | id | ) | [protected] |
Set the execution interpreter to a trap identifier.
If no trap id exists, then advance to next script statement (unless exit trap).
id | of trap to select numerically. |
void addAttribute | ( | const char * | name, | |
Meta | meta | |||
) | [friend] |
void addConditional | ( | const char * | name, | |
Cond | test | |||
) | [friend] |
void addFunction | ( | const char * | name, | |
unsigned | count, | |||
Function | i | |||
) | [friend] |
friend class Script::Locks [friend] |
friend class Script::Session [friend] |
friend class ScriptCommand [friend] |
friend class ScriptImage [friend] |
friend class ScriptModule [friend] |
unsigned char ScriptInterp::lckcount [protected] |