#include <Script.h>

Script objects represent a chunk of code, possibly together with local variables. The code may be changed and executed multiple times during the lifetime of an object.
Public Slots | |
| virtual bool | compile (bool for_eval=true) |
| Compile the Code. Return true if the implementation doesn't support compilation. | |
| virtual QVariant | eval () |
| Evaluate the Code, returning QVariant() on an error / exception. | |
| virtual bool | exec () |
| Execute the Code, returning false on an error / exception. | |
| virtual bool | setDouble (double, const char *) |
| virtual bool | setInt (int, const char *) |
| virtual bool | setQObject (const QObject *, const char *) |
Signals | |
| void | codeChanged () |
| This is emitted whenever the code to be executed by exec() and eval() is changed. | |
| void | error (const QString &message, const QString &scriptName, int lineNumber) |
| signal an error condition / exception | |
| void | print (const QString &output) |
| output generated by the code | |
Public Member Functions | |
| virtual void | addCode (const QString &code) |
| Append to the code that will be executed when calling exec() or eval(). | |
| const QString | code () const |
| Return the code that will be executed when calling exec() or eval(). | |
| const QObject * | context () const |
| Return the context in which the code is to be executed. | |
| const bool | emitErrors () const |
| Return whether errors / exceptions are to be emitted or silently ignored. | |
| const QString | name () const |
| Like QObject::name, but with unicode support. | |
| Script (ScriptingEnv *env, const QString &code, QObject *context=0, const QString &name="<input>") | |
| virtual void | setCode (const QString &code) |
| Set the code that will be executed when calling exec() or eval(). | |
| virtual void | setContext (QObject *context) |
| Set the context in which the code is to be executed. | |
| void | setEmitErrors (bool yes) |
| Set whether errors / exceptions are to be emitted or silently ignored. | |
| void | setName (const QString &name) |
| Like QObject::setName, but with unicode support. | |
| ~Script () | |
Protected Types | |
| enum | compileStatus { notCompiled, isCompiled, compileErr } |
Protected Member Functions | |
| void | emit_error (const QString &message, int lineNumber) |
Protected Attributes | |
| QString | Code |
| enum Script::compileStatus | compiled |
| QObject * | Context |
| bool | EmitErrors |
| ScriptingEnv * | Env |
| QString | Name |
enum Script::compileStatus [protected] |
| Script::Script | ( | ScriptingEnv * | env, | |
| const QString & | code, | |||
| QObject * | context = 0, |
|||
| const QString & | name = "<input>" | |||
| ) | [inline] |
References context(), Context, EmitErrors, Env, and ScriptingEnv::incref().
| Script::~Script | ( | ) | [inline] |
References ScriptingEnv::decref(), and Env.
| virtual void Script::addCode | ( | const QString & | code | ) | [inline, virtual] |
Append to the code that will be executed when calling exec() or eval().
References Code, codeChanged(), compiled, and notCompiled.
| const QString Script::code | ( | ) | const [inline] |
| void Script::codeChanged | ( | ) | [signal] |
| bool Script::compile | ( | bool | for_eval = true |
) | [virtual, slot] |
Compile the Code. Return true if the implementation doesn't support compilation.
Reimplemented in muParserScript, and PythonScript.
References emit_error().
Referenced by Table::calculate(), MatrixModel::calculate(), and Matrix::canCalculate().
| const QObject* Script::context | ( | ) | const [inline] |
| void Script::emit_error | ( | const QString & | message, | |
| int | lineNumber | |||
| ) | [inline, protected] |
References EmitErrors, error(), and Name.
Referenced by compile(), PythonScript::compile(), muParserScript::compile(), muParserScript::defineVariable(), eval(), PythonScript::eval(), muParserScript::eval(), exec(), PythonScript::exec(), muParserScript::exec(), and muParserScript::setDouble().
| const bool Script::emitErrors | ( | ) | const [inline] |
| void Script::error | ( | const QString & | message, | |
| const QString & | scriptName, | |||
| int | lineNumber | |||
| ) | [signal] |
| QVariant Script::eval | ( | ) | [virtual, slot] |
Evaluate the Code, returning QVariant() on an error / exception.
Reimplemented in muParserScript, and PythonScript.
References emit_error().
Referenced by Table::calculate(), MatrixModel::calculate(), Matrix::canCalculate(), Table::cellEdited(), and ScriptEdit::evaluate().
| bool Script::exec | ( | ) | [virtual, slot] |
Execute the Code, returning false on an error / exception.
Reimplemented in muParserScript, and PythonScript.
References emit_error().
Referenced by ScriptEdit::execute(), and ScriptEdit::executeAll().
| const QString Script::name | ( | ) | const [inline] |
| void Script::print | ( | const QString & | output | ) | [signal] |
| virtual void Script::setCode | ( | const QString & | code | ) | [inline, virtual] |
Set the code that will be executed when calling exec() or eval().
References Code, codeChanged(), compiled, and notCompiled.
Referenced by ScriptEdit::evaluate(), ScriptEdit::execute(), and ScriptEdit::executeAll().
| virtual void Script::setContext | ( | QObject * | context | ) | [inline, virtual] |
Set the context in which the code is to be executed.
Reimplemented in PythonScript.
References compiled, Context, and notCompiled.
Referenced by ScriptEdit::setContext(), and PythonScript::setContext().
| virtual bool Script::setDouble | ( | double | , | |
| const char * | ||||
| ) | [inline, virtual, slot] |
Reimplemented in muParserScript, and PythonScript.
Referenced by Table::calculate(), MatrixModel::calculate(), and Matrix::canCalculate().
| void Script::setEmitErrors | ( | bool | yes | ) | [inline] |
| virtual bool Script::setInt | ( | int | , | |
| const char * | ||||
| ) | [inline, virtual, slot] |
| void Script::setName | ( | const QString & | name | ) | [inline] |
Like QObject::setName, but with unicode support.
References compiled, Name, and notCompiled.
Referenced by ScriptEdit::evaluate(), ScriptEdit::execute(), and ScriptEdit::executeAll().
| virtual bool Script::setQObject | ( | const QObject * | , | |
| const char * | ||||
| ) | [inline, virtual, slot] |
QString Script::Code [protected] |
Referenced by addCode(), code(), PythonScript::compile(), muParserScript::compile(), and setCode().
enum Script::compileStatus Script::compiled [protected] |
QObject* Script::Context [protected] |
bool Script::EmitErrors [protected] |
Referenced by emit_error(), emitErrors(), Script(), and setEmitErrors().
ScriptingEnv* Script::Env [protected] |
Referenced by PythonScript::env(), Script(), and ~Script().
QString Script::Name [protected] |
Referenced by PythonScript::compile(), emit_error(), name(), and setName().
1.5.6