KSInterpreter Class Reference
This class offers the API to koscript functionality. More...
#include <koscript.h>
Public Types | |
typedef KSSharedPtr< KSInterpreter > | Ptr |
Public Member Functions | |
KSInterpreter () | |
virtual | ~KSInterpreter () |
QString | runScript (const QString &filename, const QStringList &args) |
bool | runModule (KSContext &context, const QString &name, const QString &filename, const QStringList &args) |
bool | runModule (KSContext &context, const QString &name) |
KSModule::Ptr | module (const QString &name) |
KSContext & | context () |
void | addSearchPath (const QString &p) |
virtual bool | processExtension (KSContext &context, KSParseNode *node) |
KRegExp * | regexp () |
QString | readInput () |
KSValue::Ptr | lastInputLine () const |
KSNamespace * | globalNamespace () |
Protected Attributes | |
KSNamespace * | m_global |
KSContext | m_globalContext |
QMap< QString, KSModule::Ptr > | m_modules |
QStringList | m_searchPaths |
KRegExp | m_regexp |
QStringList | m_args |
int | m_currentArg |
QTextStream * | m_outStream |
QIODevice * | m_outDevice |
KSValue::Ptr | m_lastInputLine |
Detailed Description
This class offers the API to koscript functionality.If you want to execute a koscript on your hard disk or if you want to embed koscript in your application, then you need an instance of this class.
- Author:
- Torben Weis <weis@kde.org>
Definition at line 45 of file koscript.h.
Constructor & Destructor Documentation
|
Creates a new interpreter. It is ok to have many of them at the same time. Definition at line 39 of file koscript.cc. References m_currentArg, m_global, m_globalContext, m_lastInputLine, m_modules, m_outDevice, and m_outStream. |
|
Destroys the interpreter and all associated modules etc.
Definition at line 58 of file koscript.cc. References m_outDevice, and m_outStream. |
Member Function Documentation
|
Reads the script
Definition at line 78 of file koscript.cc. References context(), m_args, m_globalContext, and runModule(). |
|
Runs a module located in the file
The modules name is given by
Definition at line 141 of file koscript.cc. References context(), KSValue::functionValue(), m_global, m_globalContext, m_modules, and module(). Referenced by runModule(), and runScript(). |
|
This function is for convenience. It searches the module in the search paths by appending a ".ks" suffix. Definition at line 92 of file koscript.cc. References m_modules, m_searchPaths, and runModule(). |
|
Definition at line 69 of file koscript.cc. References m_modules. Referenced by runModule(). |
|
The global context is needed for destructors, callbacks etc. This method is internal. DON'T USE. Definition at line 100 of file koscript.h. References m_globalContext. Referenced by runModule(), and runScript(). |
|
Add a search path. KScript will search for modules in this path.
Definition at line 107 of file koscript.h. References m_searchPaths. |
|
KScript can be extended with special syntax. For example "Table1!A1" for use in some spread sheet. If such a node has to be evaluated, then this functions is told to do so.
Definition at line 252 of file koscript.cc. |
|
Internal function for implementing regexp and $0, $1, $2, ...
Definition at line 260 of file koscript.cc. References m_regexp. |
|
Internal function for implementing the <> operator.
Definition at line 265 of file koscript.cc. References m_args, m_currentArg, m_lastInputLine, m_outDevice, and m_outStream. |
|
Internal function used for implementing the $_ operator.
Definition at line 311 of file koscript.cc. References m_lastInputLine. |
|
Internal function that returns the global namespace of this interpreter.
Definition at line 137 of file koscript.h. References m_global. |
Member Data Documentation
|
A pointer to the namespace of the KScript module.
Definition at line 143 of file koscript.h. Referenced by globalNamespace(), KSInterpreter(), and runModule(). |
|
Used by destructors. Since they are invoked by reference counters, they dont get a context. Instead they use this context. Definition at line 148 of file koscript.h. Referenced by context(), KSInterpreter(), runModule(), and runScript(). |
|
Maps the names of successfully loaded modules to their KSModule object. The name is the logical name of the module, that means NOT the filename. Definition at line 154 of file koscript.h. Referenced by KSInterpreter(), module(), and runModule(). |
|
List of all classes where we can search for modules.
Definition at line 158 of file koscript.h. Referenced by addSearchPath(), and runModule(). |
|
Rgeular expression matcher used for constructions like "/(.+) (.+)/".
Definition at line 162 of file koscript.h. Referenced by regexp(). |
|
The last arguments passed to runScript. They are saved here, since the <> operator may be used to read the files named by the arguments. Definition at line 167 of file koscript.h. Referenced by readInput(), and runScript(). |
|
When reading in files with the <> operator, then this variable tells us which file we just opened. So it is used like this: m_args[ m_currentArg ]. The initial value is -1, that means no argument file was opened until now.
Definition at line 175 of file koscript.h. Referenced by KSInterpreter(), and readInput(). |
|
When reading in files with the <> operator, then this stream handles the current input file. If there is no such input file specified in the command line then this stream points to stdin. Definition at line 181 of file koscript.h. Referenced by KSInterpreter(), readInput(), and ~KSInterpreter(). |
|
Used for m_stream.
Definition at line 185 of file koscript.h. Referenced by KSInterpreter(), readInput(), and ~KSInterpreter(). |
|
The last line read by the <> operator is stored here. Definition at line 191 of file koscript.h. Referenced by KSInterpreter(), lastInputLine(), and readInput(). |
The documentation for this class was generated from the following files: