class KJScript

ECMAScript interpreter. More...

Definition#include <kjs.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods


Detailed Description

 KJScript ()

KJScript

Create a new ECMAScript interpreter. You can later ask it to interprete code by passing it via evaluate.

 ~KJScript ()

~KJScript

Destructor

void  init ()

init

Force a "context switch". You usually do not need to do that, evaluate() does it too.

KJS::ImpglobalObject ()

globalObject

[const]

Returns a pointer to the Global object.

KJScriptcurrent ()

current

[static]

Don't use. May disappear.

void  setCurrent ( KJScript *newCurr )

setCurrent

[static]

Don't use. May disappear.

int  recursion ()

recursion

[const]

Current level of recursive calls to this interpreter. 0 initially.

bool  evaluate (const char *code)

evaluate

Asks the interpreter to evaluate a piece of code. If called more than once the state (global variables, functions etc.) will be preserved between each call.

Parameters:
codeis a string containing the code to be executed.

Returns: True if the code was evaluated successfully, false if an error occured.

bool  evaluate (const KJS::KJSO &thisV, const QChar *code, unsigned int length)

evaluate

Same as above. Only differing in the arguments accepted.

Parameters:
codeis a pointer to an Unicode string containing the code to be executed.
lengthnumber of characters.

bool  evaluate (const KJS::UString &code)

evaluate

Added for convenience in case you have the code in available in internal representation already.

Parameters:
codeis an Unicode string containing the code to be executed.

bool  call (const KJS::UString &func, const KJS::List &args)

call

Call the specified function directly, optionally passing args as a list of arguments. Return value and treatment of errors is analog to the evaluate() calls.

bool  call (const KJS::KJSO &scope, const KJS::UString &func, const KJS::List &args)

call

bool  call (const KJS::KJSO &func, const KJS::KJSO &thisV, const KJS::List &args, const KJS::List &extraScope )

call

void  clear ()

clear

Clear the interpreter's memory. Otherwise, function declarations and global variables will be remembered after each invokation of KJScript::evaluate.

KJS::ImpreturnValue ()

returnValue

[const]

Returns: Return value from the last call to evaluate(). Null if there hasn't been any.

int  errorType ()

errorType

[const]

Returns: Return code from last call to evaluate(). 0 on success.

int  errorLine ()

errorLine

[const]

Returns: Return line of last error. -1 if last call didn't have an error.

const char * errorMsg ()

errorMsg

[const]

Returns: Error message from last call to evaluate(). Empty string if no error occured.

bool  checkSyntax (const KJS::UString &code)

checkSyntax

Check the syntax of a piece of code. Return true if the code could be parsed without errors, false otherwise. errorLine() will tell you approximately where the syntax error happened.

void  enableDebug ()

enableDebug

Adds a debug() function to the set of pre-defined properties. debug(arg) tries to convert 'arg' to a string and prints the result to stderr. If you want to debug self defined Host Objects this way you should provide them with a toString() method that returns a string.


Generated by: dfaure on kde.faure.org on Thu Jan 17 22:18:54 2002, using kdoc 2.0a53.