34 #include <QStringList> 36 #include <QStringList> 82 virtual bool compile(
bool for_eval=
true);
84 virtual QVariant
eval();
89 virtual bool setQObject(
const QObject*,
const char*) {
return false; }
90 virtual bool setInt(
int,
const char*) {
return false; }
91 virtual bool setDouble(
double,
const char*) {
return false; }
97 void error(
const QString & message,
const QString & scriptName,
int lineNumber);
99 void print(
const QString & output);
109 {
if(EmitErrors) emit
error(message, Name, lineNumber); }
121 static QStringList languages();
123 static int numLanguages();
void incref()
Increase the reference count. This should only be called by scripted and Script to avoid memory leaks...
Definition: ScriptingEnv.cpp:59
QString Code
Definition: Script.h:103
virtual bool exec()
Execute the Code, returning false on an error / exception.
Definition: Script.cpp:91
ScriptingEnv * Env
Definition: Script.h:102
virtual void setContext(QObject *context)
Set the context in which the code is to be executed.
Definition: Script.h:73
ScriptingEnv * scriptingEnv()
Definition: Script.h:158
Type type() const
Definition: Script.h:141
An interpreter for evaluating scripting code. Abstract.
Definition: ScriptingEnv.h:50
QObject * Context
Definition: Script.h:104
const QString code() const
Return the code that will be executed when calling exec() or eval()
Definition: Script.h:61
virtual QVariant eval()
Evaluate the Code, returning QVariant() on an error / exception.
Definition: Script.cpp:85
void emit_error(const QString &message, int lineNumber)
Definition: Script.h:108
keeps a static list of available interpreters and instantiates them on demand
Definition: Script.h:113
ScriptingEnvConstructor constructor
Definition: Script.h:129
ScriptingEnv * scriptingEnv() const
Definition: Script.h:140
void setName(const QString &name)
Like QObject::setName, but with unicode support.
Definition: Script.h:75
const QString name() const
Like QObject::name, but with unicode support.
Definition: Script.h:65
virtual void setCode(const QString &code)
Set the code that will be executed when calling exec() or eval()
Definition: Script.h:71
bool EmitErrors
Definition: Script.h:106
notify an object that it should update its scripting environment (see class scripted) ...
Definition: Script.h:136
virtual bool setInt(int, const char *)
Definition: Script.h:90
const char * name
Definition: Script.h:128
A chunk of scripting code. Abstract.
Definition: Script.h:50
ScriptingChangeEvent(ScriptingEnv *e)
Definition: Script.h:139
QObject * context() const
Return the context in which the code is to be executed.
Definition: Script.h:63
QtiPlot's main window.
Definition: ApplicationWindow.h:133
Script(ScriptingEnv *env, const QString &code, QObject *context=0, const QString &name="<input>")
Definition: Script.h:55
void decref()
Decrease the reference count. This should only be called by scripted and Script to avoid segfaults...
Definition: ScriptingEnv.cpp:64
#define SCRIPTING_CHANGE_EVENT
Definition: customevents.h:37
enum Script::compileStatus compiled
compileStatus
Definition: Script.h:105
ScriptingEnv * env
Definition: Script.h:143
virtual bool setDouble(double, const char *)
Definition: Script.h:91
void print(const QString &output)
output generated by the code
Interface for maintaining a reference to the current ScriptingEnv.
Definition: Script.h:152
~Script()
Definition: Script.h:58
virtual void addCode(const QString &code)
Append to the code that will be executed when calling exec() or eval()
Definition: Script.h:69
ScriptingEnv * scriptingEnv()
Definition: Script.h:78
void codeChanged()
This is emitted whenever the code to be executed by exec() and eval() is changed. ...
void setEmitErrors(bool yes)
Set whether errors / exceptions are to be emitted or silently ignored.
Definition: Script.h:77
void error(const QString &message, const QString &scriptName, int lineNumber)
signal an error condition / exception
virtual bool setQObject(const QObject *, const char *)
Definition: Script.h:89
virtual bool compile(bool for_eval=true)
Compile the Code. Return true if the implementation doesn't support compilation.
Definition: Script.cpp:77
QString Name
Definition: Script.h:103
bool emitErrors() const
Return whether errors / exceptions are to be emitted or silently ignored.
Definition: Script.h:67