-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
// File : PyConsole_Interp.cxx
-// Author : Nicolas REJNERI
-// Module : SALOME
-//
+// Author : Nicolas REJNERI, Adrien BRUNETON
+
#include "PyConsole_Interp.h"
/*!
The method initialize() calls virtuals methods
- initPython() to initialize global Python interpreter
- //- initState() to initialize embedded interpreter state (OBSOLETE)
- initContext() to initialize interpreter internal context
- initRun() to prepare interpreter for running commands
*/
PyConsole_Interp::~PyConsole_Interp()
{
}
+
+/*! Sets the variable "__IN_SALOME_GUI_CONSOLE" to True.
+* This is not attached to a module (like salome_iapp.IN_SALOME_GUI_CONSOLE)
+* since modules are shared across all interpreters in SALOME.
+*
+* (GIL is already acquired here)
+*/
+int PyConsole_Interp::beforeRun()
+{
+ return PyRun_SimpleString("__builtins__.__IN_SALOME_GUI_CONSOLE=True");
+}
-/*!
- \brief Initialize python interpeter context.
+int PyConsole_Interp::afterRun()
+{
+ return PyRun_SimpleString("__builtins__.__IN_SALOME_GUI_CONSOLE=False");
+}
- The GIL is assumed to be held.
- It is the caller responsability to acquire the GIL.
- It must still be held on initContext() exit.
+QStringList PyConsole_Interp::getLastMatches() const
+{
+ return QStringList();
+}
- \return \c true on success
-*/
-bool PyConsole_Interp::initContext()
+QString PyConsole_Interp::getDocStr() const
+{
+ return QString();
+}
+
+int PyConsole_Interp::runDirCommand(const QString&, const QString& )
+{
+ return 0;
+}
+
+void PyConsole_Interp::clearCompletion()
{
- PyObject *m = PyImport_AddModule("__main__"); // interpreter main module (module context)
- if(!m){
- PyErr_Print();
- return false;
- }
- _context = PyModule_GetDict(m); // get interpreter dictionnary context
- return true;
}