SciDAVis  1.D4
Public Slots | Public Member Functions | Private Member Functions | Private Attributes
PythonScript Class Reference

#include <PythonScript.h>

Inheritance diagram for PythonScript:
Script

List of all members.

Public Slots

bool compile (bool for_eval=true)
 Compile the Code. Return true if the implementation doesn't support compilation.
QVariant eval ()
 Evaluate the Code, returning QVariant() on an error / exception.
bool exec ()
 Execute the Code, returning false on an error / exception.
void setContext (QObject *context)
 Set the context in which the code is to be executed.
bool setDouble (double val, const char *name)
bool setInt (int val, const char *name)
bool setQObject (QObject *val, const char *name)
- Public Slots inherited from Script
virtual bool setQObject (const QObject *, const char *)

Public Member Functions

 PythonScript (PythonScripting *env, const QString &code, QObject *context=0, const QString &name="<input>")
void write (const QString &text)
 ~PythonScript ()
- Public Member Functions inherited from Script
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.
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()
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 ()

Private Member Functions

void beginStdoutRedirect ()
void endStdoutRedirect ()
PythonScriptingenv ()

Private Attributes

bool isFunction
PyObjectlocalDict
PyObjectPyCode
PyObjectstderrSave
PyObjectstdoutSave

Additional Inherited Members

- Signals inherited from Script
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
- Protected Types inherited from Script
enum  compileStatus { notCompiled, isCompiled, compileErr }
- Protected Member Functions inherited from Script
void emit_error (const QString &message, int lineNumber)
- Protected Attributes inherited from Script
QString Code
enum Script::compileStatus compiled
QObject * Context
bool EmitErrors
ScriptingEnvEnv
QString Name

Constructor & Destructor Documentation

PythonScript::PythonScript ( PythonScripting env,
const QString &  code,
QObject *  context = 0,
const QString &  name = "<input>" 
)
PythonScript::~PythonScript ( )

References localDict, and PyCode.


Member Function Documentation

void PythonScript::beginStdoutRedirect ( )
private

References env(), PythonScripting::setQObject(), stderrSave, and stdoutSave.

Referenced by eval(), and exec().

bool PythonScript::compile ( bool  for_eval = true)
virtualslot

Compile the Code. Return true if the implementation doesn't support compilation.

Reimplemented from Script.

References Script::Code, Script::compiled, Script::compileErr, Script::Context, Script::emit_error(), env(), Script::isCompiled, localDict, Script::Name, and PyCode.

Referenced by eval(), and exec().

void PythonScript::endStdoutRedirect ( )
private

References env(), stderrSave, and stdoutSave.

Referenced by eval(), and exec().

PythonScripting* PythonScript::env ( )
inlineprivate
QVariant PythonScript::eval ( )
virtualslot

Evaluate the Code, returning QVariant() on an error / exception.

Reimplemented from Script.

References beginStdoutRedirect(), compile(), Script::compiled, Script::emit_error(), endStdoutRedirect(), env(), Script::isCompiled, isFunction, localDict, Script::notCompiled, and PyCode.

bool PythonScript::exec ( )
virtualslot

Execute the Code, returning false on an error / exception.

Reimplemented from Script.

References beginStdoutRedirect(), compile(), Script::compiled, Script::emit_error(), endStdoutRedirect(), env(), Script::isCompiled, isFunction, localDict, Script::notCompiled, and PyCode.

void PythonScript::setContext ( QObject *  context)
virtualslot

Set the context in which the code is to be executed.

Reimplemented from Script.

References Script::Context, and setQObject().

bool PythonScript::setDouble ( double  val,
const char *  name 
)
virtualslot
bool PythonScript::setInt ( int  val,
const char *  name 
)
virtualslot
bool PythonScript::setQObject ( QObject *  val,
const char *  name 
)
slot
void PythonScript::write ( const QString &  text)
inline

References Script::print().


Member Data Documentation

bool PythonScript::isFunction
private

Referenced by eval(), and exec().

PyObject * PythonScript::localDict
private
PyObject* PythonScript::PyCode
private
PyObject * PythonScript::stderrSave
private
PyObject * PythonScript::stdoutSave
private

The documentation for this class was generated from the following files: