1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : PyInterp_base.h
8 // Author : Christian CAREMOLI, Paul RASCLE, EDF
12 #ifndef _PYINTERP_BASE_H_
13 #define _PYINTERP_BASE_H_
24 extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l);
26 #define TOP_HISTORY_PY "--- top of history ---"
27 #define BEGIN_HISTORY_PY "--- begin of history ---"
31 QSemaphore* mySemaphore;
32 std::string myComment;
34 SemaphoreLock(QSemaphore* theSemaphore, const char* theComment = "");
40 PyThreadState* myThreadState;
41 PyThreadState* mySaveThreadState;
43 PyLockWrapper(PyThreadState* theThreadState);
50 std::string myComment;
52 ThreadLock(QMutex* theMutex, const char* theComment = "");
59 ThreadLock GetPyThreadLock(const char* theComment = "");
64 static PyThreadState *_gtstate;
67 static PyObject *builtinmodule;
68 static PyObject *salome_shared_modules_module;
73 virtual void initialize();
75 int run(const char *command);
77 PyLockWrapper GetLockWrapper();
79 std::string getbanner();
80 std::string getverr();
81 std::string getvout();
83 const char * getPrevious();
84 const char * getNext();
87 PyThreadState * _tstate;
91 std::list<std::string> _history;
92 std::list<std::string>::iterator _ith;
95 int simpleRun(const char* command);
98 virtual void initState() = 0;
99 virtual void initContext() = 0;
106 PyObjWrapper(PyObject* theObject): myObject(theObject) {}
107 PyObjWrapper(): myObject(0) {}
108 operator PyObject*(){
111 PyObject* operator->(){
120 bool operator==(PyObject* theObject){
121 return myObject == theObject;
123 PyObject** operator&(){
126 PyObjWrapper& operator=(PyObjWrapper* theObjWrapper){
127 Py_XDECREF(myObject);
128 myObject = theObjWrapper->myObject;
131 virtual ~PyObjWrapper(){
132 Py_XDECREF(myObject);