scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ScriptingEnv Class Referenceabstract

An interpreter for evaluating scripting code. Abstract. More...

#include <ScriptingEnv.h>

Inheritance diagram for ScriptingEnv:
[legend]
Collaboration diagram for ScriptingEnv:
[legend]

Public Slots

virtual bool setQObject (QObject *, const char *)
 
virtual bool setInt (int, const char *)
 
virtual bool setDouble (double, const char *)
 
virtual void clear ()
 Clear the global environment. What exactly happens depends on the implementation. More...
 
virtual void stopExecution ()
 If the implementation supports asynchronuos execution, deactivate it. More...
 
virtual void startExecution ()
 If the implementation supports asynchronuos execution, activate it. More...
 
void incref ()
 Increase the reference count. This should only be called by scripted and Script to avoid memory leaks. More...
 
void decref ()
 Decrease the reference count. This should only be called by scripted and Script to avoid segfaults. More...
 

Signals

void error (const QString &message, const QString &scriptName, int lineNumber)
 signal an error condition / exception More...
 
void print (const QString &output)
 output that is not handled by a Script More...
 

Public Member Functions

 ScriptingEnv (ApplicationWindow *parent, const char *langName)
 
virtual bool initialize ()
 Part of the initialization is deferred from the constructor until after the signals have been connected. More...
 
bool initialized () const
 initialization of the interpreter may fail; or there could be other errors setting up the environment More...
 
virtual bool isRunning () const
 whether asynchronuous execution is enabled (if supported by the implementation) More...
 
virtual ScriptnewScript (const QString &, QObject *, const QString &)=0
 Instantiate the Script subclass matching the ScriptEnv subclass. More...
 
virtual QString stackTraceString ()
 If an exception / error occured, return a nicely formated stack backtrace. More...
 
virtual const QStringList mathFunctions () const
 Return a list of supported mathematical functions. These should be imported into the global namespace. More...
 
virtual const QString mathFunctionDoc (const QString &) const
 Return a documentation string for the given mathematical function. More...
 
virtual const QStringList fileExtensions () const
 Return a list of file extensions commonly used for this language. More...
 
const QString fileFilter () const
 Construct a filter expression from fileExtension(), suitable for QFileDialog. More...
 
virtual void redirectStdIO ()
 

Protected Attributes

bool d_initialized
 whether the interpreter has been successfully initialized More...
 
ApplicationWindowd_parent
 the context in which we are running More...
 

Private Attributes

int d_refcount
 the reference counter More...
 

Detailed Description

An interpreter for evaluating scripting code. Abstract.

ScriptingEnv objects represent a running interpreter, possibly with global variables, and are responsible for generating Script objects (which do the actual evaluation of code).

Definition at line 52 of file ScriptingEnv.h.

Constructor & Destructor Documentation

◆ ScriptingEnv()

ScriptingEnv::ScriptingEnv ( ApplicationWindow parent,
const char *  langName 
)

File : ScriptingEnv.cpp

Project : SciDAVis

Copyright : (C) 2006 by Knut Franke Email (use @ for *) : knut.franke*gmx.de Description : Implementations of generic scripting classes

  • This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *
    • This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
    • You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA *

Definition at line 43 of file ScriptingEnv.cpp.

44 : QObject(0), d_parent(parent)
45 {
46  setObjectName(langName);
47  d_initialized=false;
48  d_refcount=0;
49 }

References d_initialized, and d_refcount.

Member Function Documentation

◆ clear

virtual void ScriptingEnv::clear ( )
inlinevirtualslot

Clear the global environment. What exactly happens depends on the implementation.

Definition at line 91 of file ScriptingEnv.h.

91 {}

◆ decref

void ScriptingEnv::decref ( )
slot

Decrease the reference count. This should only be called by scripted and Script to avoid segfaults.

Definition at line 65 of file ScriptingEnv.cpp.

66 {
67  d_refcount--;
68  if (d_refcount==0)
69  delete this;
70 }

References d_refcount.

Referenced by scripted::scriptingChangeEvent(), PythonScripting::toString(), Script::~Script(), and scripted::~scripted().

Here is the caller graph for this function:

◆ error

void ScriptingEnv::error ( const QString &  message,
const QString &  scriptName,
int  lineNumber 
)
signal

signal an error condition / exception

◆ fileExtensions()

virtual const QStringList ScriptingEnv::fileExtensions ( ) const
inlinevirtual

Return a list of file extensions commonly used for this language.

Reimplemented in PythonScripting.

Definition at line 76 of file ScriptingEnv.h.

76 { return QStringList(); };

Referenced by fileFilter().

Here is the caller graph for this function:

◆ fileFilter()

const QString ScriptingEnv::fileFilter ( ) const

Construct a filter expression from fileExtension(), suitable for QFileDialog.

Definition at line 51 of file ScriptingEnv.cpp.

52 {
53  QStringList extensions = fileExtensions();
54  if (extensions.isEmpty())
55  return "";
56  else
57  return tr("%1 Source (*.%2);;").arg(objectName()).arg(extensions.join(" *."));
58 }

References fileExtensions().

Referenced by ScriptEdit::exportASCII(), and ScriptEdit::importASCII().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ incref

void ScriptingEnv::incref ( )
slot

Increase the reference count. This should only be called by scripted and Script to avoid memory leaks.

Definition at line 60 of file ScriptingEnv.cpp.

61 {
62  d_refcount++;
63 }

References d_refcount.

Referenced by Script::Script(), scripted::scripted(), and scripted::scriptingChangeEvent().

Here is the caller graph for this function:

◆ initialize()

virtual bool ScriptingEnv::initialize ( )
inlinevirtual

Part of the initialization is deferred from the constructor until after the signals have been connected.

Reimplemented in PythonScripting.

Definition at line 59 of file ScriptingEnv.h.

59 { return true; };

Referenced by ApplicationWindow::ApplicationWindow(), and ApplicationWindow::setScriptingLang().

Here is the caller graph for this function:

◆ initialized()

bool ScriptingEnv::initialized ( ) const
inline

initialization of the interpreter may fail; or there could be other errors setting up the environment

Definition at line 61 of file ScriptingEnv.h.

61 { return d_initialized; }

References d_initialized.

Referenced by PythonScripting::initialize().

Here is the caller graph for this function:

◆ isRunning()

virtual bool ScriptingEnv::isRunning ( ) const
inlinevirtual

whether asynchronuous execution is enabled (if supported by the implementation)

Reimplemented in PythonScripting, and MuParserScripting.

Definition at line 63 of file ScriptingEnv.h.

63 { return false; }

◆ mathFunctionDoc()

virtual const QString ScriptingEnv::mathFunctionDoc ( const QString &  ) const
inlinevirtual

Return a documentation string for the given mathematical function.

Reimplemented in PythonScripting, and MuParserScripting.

Definition at line 74 of file ScriptingEnv.h.

74 { return {}; }

Referenced by ScriptEdit::contextMenuEvent(), Matrix::updateFunctionDoc(), and Table::updateFunctionDoc().

Here is the caller graph for this function:

◆ mathFunctions()

virtual const QStringList ScriptingEnv::mathFunctions ( ) const
inlinevirtual

Return a list of supported mathematical functions. These should be imported into the global namespace.

Reimplemented in PythonScripting, and MuParserScripting.

Definition at line 72 of file ScriptingEnv.h.

72 { return QStringList(); }

Referenced by ScriptEdit::contextMenuEvent(), Table::init(), Matrix::init(), and ScriptEdit::insertFunction().

Here is the caller graph for this function:

◆ newScript()

virtual Script* ScriptingEnv::newScript ( const QString &  ,
QObject *  ,
const QString &   
)
pure virtual

Instantiate the Script subclass matching the ScriptEnv subclass.

Implemented in PythonScripting, and MuParserScripting.

Referenced by ScriptEdit::customEvent(), Fit::fit(), FunctionCurve::loadData(), Matrix::recalculate(), Table::recalculate(), ScriptEdit::ScriptEdit(), and Matrix::setText().

Here is the caller graph for this function:

◆ print

void ScriptingEnv::print ( const QString &  output)
signal

output that is not handled by a Script

Referenced by PythonScripting::write().

Here is the caller graph for this function:

◆ redirectStdIO()

virtual void ScriptingEnv::redirectStdIO ( )
inlinevirtual

Reimplemented in PythonScripting.

Definition at line 80 of file ScriptingEnv.h.

80 {}

◆ setDouble

virtual bool ScriptingEnv::setDouble ( double  ,
const char *   
)
inlinevirtualslot

Reimplemented in MuParserScripting, and PythonScripting.

Definition at line 88 of file ScriptingEnv.h.

88 { return false; }

◆ setInt

virtual bool ScriptingEnv::setInt ( int  ,
const char *   
)
inlinevirtualslot

Reimplemented in MuParserScripting, and PythonScripting.

Definition at line 87 of file ScriptingEnv.h.

87 { return false; }

◆ setQObject

virtual bool ScriptingEnv::setQObject ( QObject *  ,
const char *   
)
inlinevirtualslot

Reimplemented in PythonScripting, and MuParserScripting.

Definition at line 86 of file ScriptingEnv.h.

86 { return false; }

◆ stackTraceString()

virtual QString ScriptingEnv::stackTraceString ( )
inlinevirtual

If an exception / error occured, return a nicely formated stack backtrace.

Definition at line 69 of file ScriptingEnv.h.

69 { return {}; }

◆ startExecution

virtual void ScriptingEnv::startExecution ( )
inlinevirtualslot

If the implementation supports asynchronuos execution, activate it.

Definition at line 95 of file ScriptingEnv.h.

95 {}

◆ stopExecution

virtual void ScriptingEnv::stopExecution ( )
inlinevirtualslot

If the implementation supports asynchronuos execution, deactivate it.

Definition at line 93 of file ScriptingEnv.h.

93 {}

Member Data Documentation

◆ d_initialized

bool ScriptingEnv::d_initialized
protected

whether the interpreter has been successfully initialized

Definition at line 110 of file ScriptingEnv.h.

Referenced by PythonScripting::initialize(), initialized(), MuParserScripting::MuParserScripting(), PythonScripting::PythonScripting(), and ScriptingEnv().

◆ d_parent

ApplicationWindow* ScriptingEnv::d_parent
protected

the context in which we are running

Definition at line 112 of file ScriptingEnv.h.

Referenced by PythonScripting::initialize(), and PythonScripting::PythonScripting().

◆ d_refcount

int ScriptingEnv::d_refcount
private

the reference counter

Definition at line 116 of file ScriptingEnv.h.

Referenced by decref(), incref(), and ScriptingEnv().


The documentation for this class was generated from the following files:
ScriptingEnv::fileExtensions
virtual const QStringList fileExtensions() const
Return a list of file extensions commonly used for this language.
Definition: ScriptingEnv.h:76
ScriptingEnv::d_parent
ApplicationWindow * d_parent
the context in which we are running
Definition: ScriptingEnv.h:112
ScriptingEnv::d_initialized
bool d_initialized
whether the interpreter has been successfully initialized
Definition: ScriptingEnv.h:110
ScriptingEnv::d_refcount
int d_refcount
the reference counter
Definition: ScriptingEnv.h:116