class JsParser

Javascript parser. More...

Full nameTelEngine::JsParser
Definition#include <libs/yscript/yatescript.h>
InheritsTelEngine::ScriptParser [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods


Detailed Description

Javascript parser, takes source code and generates preparsed code

inline  JsParser (bool allowLink = true, bool allowTrace = false)

JsParser

Constructor

Parameters:
allowLinkTrue to allow linking of the code, false otherwise.
allowTraceTrue to allow the script to enable performance tracing

bool  parse (const char* text, bool fragment = false, const char* file = 0, int len = -1)

parse

[virtual]

Parse a string as Javascript source code

Parameters:
textSource code text
fragmentTrue if the code is just an included fragment
fileName of the file that is being parsed
lenLength of text, negative if unknown

Returns: True if the text was successfully parsed

Reimplemented from ScriptParser.

ScriptContext*  createContext ()

createContext

[const virtual]

Create a context adequate for Javascript code

Returns: A new Javascript context

Reimplemented from ScriptParser.

ScriptRun*  createRunner (ScriptCode* code, ScriptContext* context = 0, const char* title = 0)

createRunner

[const virtual]

Create a runner adequate for a block of parsed Javascript code

Parameters:
codeParsed code block
contextJavascript context, an empty one will be allocated if NULL
titleAn optional name for the runner

Returns: A new Javascript runner, NULL if code is NULL

Reimplemented from ScriptParser.

inline ScriptRun*  createRunner (ScriptContext* context = 0, const char* title = 0)

createRunner

[const]

Create a runner adequate for the parsed Javascript code

Parameters:
contextJavascript context, an empty one will be allocated if NULL
titleAn optional name for the runner

Returns: A new Javascript runner, NULL if code is not yet parsed

Reimplemented from ScriptParser.

bool  callable (const String& name)

callable

[virtual]

Check if a script has a certain function or method

Parameters:
nameName of the function to check

Returns: True if function exists in code

Reimplemented from ScriptParser.

void  adjustPath (String& script, bool extraInc = false)

adjustPath

[const]

Adjust a file script path to include default if needed

Parameters:
scriptFile path to adjust
extraIncTrue to check the extra include path first

inline const String&  basePath ()

basePath

[const]

Retrieve the base script path

Returns: Base path added to relative script paths

inline const String&  includePath ()

includePath

[const]

Retrieve the extra include script path

Returns: Include path added to relative script paths

inline void  basePath (const char* path, const char* incPath = 0)

basePath

Set the base script path

Parameters:
pathBase path to add to relative script paths
incPathExtra include path to add to relative script paths

inline const String&  parsedFile ()

parsedFile

[const]

Retrieve the last parsed file name

Returns: Name of the successfully parsed file or an empty String

bool  scriptChanged (const char* file)

scriptChanged

[const]

Check if the script or any includes have changed

Parameters:
fileName of the file to check

Returns: True if the script may have changed, false if not changed

inline bool  scriptChanged (const char* file, const String& path, const String& incPath = String::empty())

scriptChanged

[const]

Check if the script or any includes have changed

Parameters:
fileName of the file to check
pathNew base path to check
incPathNew extra include path to check

Returns: True if the script may have changed, false if not changed

inline void  link (bool allowed = true)

link

Set whether the Javascript code should be linked or not

Parameters:
allowedTrue to allow linking, false otherwise

inline void  trace (bool allowed = true)

trace

Set whether the Javascript code can be traced or not

Parameters:
allowedTrue to allow tracing, false otherwise

ScriptRun::Status  eval (const String& text, ExpOperation** result = 0, ScriptContext* context = 0)

eval

[static]

Parse and run a piece of Javascript code

Parameters:
textSource code fragment to execute
resultPointer to an optional pointer to store returned value
contextScript context, an empty one will be allocated if NULL

Returns: Status of the runtime after code execution

ExpOperation*  parseJSON (const char* text, Mutex* mtx = 0)

parseJSON

[static]

Parse a complete block of JSON text

Parameters:
textJSON text to parse
mtxPointer to the mutex that serializes this object

Returns: ExpOperation holding the content of JSON, must be dereferenced after use, NULL if parse error

ExpOperation*  nullClone (const char* name = 0)

nullClone

[static]

Get a "null" object wrapper that will identity match another "null"

Parameters:
nameName of the new wrapper, "null" if empty

Returns: ExpWrapper for the "null" object

JsObject*  nullObject ()

nullObject

[static]

Obtain the "null" object

Returns: Referenced "null" object (0 if ref() fails)

bool  isNull (const ExpOperation& oper)

isNull

[static]

Check if an operation holds a null value

Returns: True if the operation holds a null object

bool  isUndefined (const ExpOperation& oper)

isUndefined

[static]

Check if an operation holds an undefined value

Returns: True if the operation holds an undefined value


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