Salome HOME
According to cotech80 PyConsoleBase->PyConsole and PyConsole->SalomePyConsole
[modules/gui.git] / src / PyConsole / PyConsole_Interp.cxx
index d230e9b12e1e4af677da1399e84e0d4f65f3e363..ca459b5827d8334d8d4c801a3fd546ab8fbeb669 100644 (file)
@@ -1,4 +1,4 @@
-// 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"
 
 /*!
@@ -38,7 +35,6 @@
 
   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
 */
@@ -60,23 +56,38 @@ PyConsole_Interp::PyConsole_Interp(): PyInterp_Interp()
 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;
 }