From 6b78afdf59857b9a63851c66adf8afd2aafe7c91 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 6 Oct 2008 09:19:05 +0000 Subject: [PATCH] Merging from the BR_VP5_DEV branch. --- src/Plot2d/resources/plot2d_legend.png | Bin 308 -> 790 bytes src/Plot2d/resources/plot2d_linear.png | Bin 281 -> 789 bytes src/Plot2d/resources/plot2d_linear_y.png | Bin 289 -> 778 bytes src/Plot2d/resources/plot2d_lines.png | Bin 299 -> 408 bytes src/Plot2d/resources/plot2d_log.png | Bin 288 -> 721 bytes src/Plot2d/resources/plot2d_log_y.png | Bin 280 -> 744 bytes src/Plot2d/resources/plot2d_points.png | Bin 272 -> 343 bytes src/Plot2d/resources/plot2d_settings.png | Bin 313 -> 764 bytes src/Plot2d/resources/plot2d_splines.png | Bin 289 -> 432 bytes src/PyInterp/PyInterp.pro | 2 +- src/PyInterp/PyInterp_Dispatcher.cxx | 19 +- src/PyInterp/PyInterp_Dispatcher.h | 5 +- src/PyInterp/PyInterp_base.cxx | 317 ----------------------- src/PyInterp/PyInterp_base.h | 145 ----------- 14 files changed, 21 insertions(+), 467 deletions(-) delete mode 100644 src/PyInterp/PyInterp_base.cxx delete mode 100644 src/PyInterp/PyInterp_base.h diff --git a/src/Plot2d/resources/plot2d_legend.png b/src/Plot2d/resources/plot2d_legend.png index cdcc1e0d858a1fa5dd62c11d6b8df2344f8b873e..81c06277b4f1d65c661c16b6209c9cbd2c700de4 100755 GIT binary patch delta 766 zcmV004R=004l4008;_004mL004C`008P>0026e000+nl3&F}0007vNklLnMt^b)1PCA|5b^EXH->$Z zk_?9=Bp6Ns@rMr|K*GvE%>7(j8^sGRjg3+GFZA?K_y7R}Ht^@qpA7$jF8dEO`2W|h z41fRr1qplH)X?}MdG#vKeND~(FvG>qp5=J~v4r~>ke0Y~iRX!y7MKsx1Q0+BpfD5@ z6Z`+t-2DFwU4PyGk06pD+z-UoK&%hM?odO;Vf@Dsb#VSesG$G>#0WBwpP&Cf$lHJZ z{6Tj81R&l4#9x4zhsYp&0T4joNcr^XlL3%Q0L2fQ0+3;Mplk^!egVbU_&fjs#DYa5 z4BUY#e2Jvy1(g1ZgUpTkhTB(C4Fm`vu$MuJ8sw~hVCTV;m4WxnYeyKFnHdV-oB&(CiRo0C;R23DZO@)smF zHa<9<0e=DrY#<{eqdp4@%LSxla{!1hKn-LdB6cNU$p#>R;IRxe4CEpkB->vg#o`Mj z7vbWA%>f7?cq~J61uTb@L-{1fGC%+^AQfN#A3yX(PBz@+lr{hX1PjCe&z|@(eEs@| z;m41E47&Q@pyRoE+2acf3nK#?8#4ndDjl(bu1eZa+1_-zTmcq^s*GWoYDQv)iI^aDN zDUKpbz9b6>w)U|ai!{m1@J(F-K+R%rnks!1*vj2QM5sOJNPB>8AONH-g{hLePeTj9 zFtA8OC~avPnzj_YGF=Puh=f-@eW#W1EXnD>|B@W(Qr}bqs()W1+y|)!%;?1jF!eF$ zLjVx7=VF!iIPw8d{q^pr`t1e);Dz&Z<(FcWyYBf9!h-D{C9Dl-)$=c{QP4+0BX#fa zllHk!8*QeIy&YITIezj29#vM;*dI3ASHhn1w8`yJrpavoL`c7RwGt8Hg=>q<_O%b& fX~PS@Rh&PK4-&4sC2YQ>00000NkvXXu0mjf?L>v_ diff --git a/src/Plot2d/resources/plot2d_linear.png b/src/Plot2d/resources/plot2d_linear.png index d79f2142684f74bccf2b7a8f4e19a0d834088660..0140fcc9874aa12603941a4600f0555929d097d6 100755 GIT binary patch delta 765 zcmV004R=004l4008;_004mL004C`008P>0026e000+nl3&F}0007uNklgX00f{zj!gi7K`4m+fEzojgQ%cbXaXtH<$vHcx0rd02#Dy-?!JD_ z45|v5iHLx^LsemB>j)sQDKlpTfXrr)S4d}g_+UE2|Ns9OCQrG?kej0jHb6l!hvC8f zDPZ>GDfbz2vgLtl{xB#h7ctzv)daNsC&TPHKNxy@dzAqK2y7ro5@GvqApb9v{S!$X zmHq$!Z>Vp6Ab-nw00a=!z`qRt8U7zY&A$q*PDB#v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dXEB>R8adhN-Ia-e(cXJ!m=b+o3o6QD7-02jIQW^#)aSAp`)9 z<7npZ^?--~6nD)AfNk5}bJjouv>^khg|liLRyq2WcLo}FMSefKyww9KB_|@Jl-x?l z4X}jVyWtr%ml9(vH{F%Z@zCK+ci1`{0^ym%5%g7ubHIPq1+G2}a8cN+(38W`dNIb~ zZB7B<-0Um0*n~XN$a&MtB9ggyzEsuq-oYYQ{{r9>>QznJbl7zd^&y98Uc7U000000 LNkvXXu0mjf*|vR5 diff --git a/src/Plot2d/resources/plot2d_lines.png b/src/Plot2d/resources/plot2d_lines.png index 6baf57344cacc7fd22a5e42fa8c5eff44313ecef..9789452845376333452f55f398bcc3f9e4124bc4 100755 GIT binary patch delta 381 zcmV-@0fPRk0+<7kB!3BTNLh0L01FcU01FcV0GgZ_00004XF*Lt006O$eEU(80000W zV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F}0003FNklgX00a=#4Fm`vsv8IpKn%o%VFO5!I1qCaQhx~$KtveW@L!{9|9_~V z)`ScN2q1!9){5m|xY2eHOap-p5KG`w4-i0jU8oh?0drM35cebTak>&9fN&ZJ)vOQ1 z?odNOY-=QOtcC&v5LN@x3`5ooqV@3^3J^dT2I4V{ffz#p0tm^#hW|)m@Cq0R#}th2l`b*-!(OiOd(uNc!SI<^Ti`BgjBTMn;fp z41ib#i0=UL1t9)Pgn=0P00Ia(Qn-oEUYLf$^#KGBBelyzfB>R;X#)^IR5uVHfT(UD bK!5=N)r@9CMEYK)00000NkvXXu0mjfxl4lC delta 272 zcmV+r0q_2p1FHg%B!BWrL_t(|oW;~l3WG2Z1>l!VaVH3#qtFW!=4f81(6vyQ3l#)+ z!jLZPq-xb@5jq=*n9rAACn7kiwA0`Z(*RIL?obc_{sS^gI1Dt5S%P+&gwqMD&yzB8 zsn1WV=|qAsJFPXeZ5!J^C5%|tV*qeJU%;|HpR?c`W|cy}z<(ty&+|=a1eql)VMSRu z%E%RE5$Dg)>6Y?_0RXE0JT4_OJT|INm=P$_uiT@)Vv5ae6+`d03x@pxz}amxmn^mK znr9P}*-!iyjEDjeeJ#Rp_=bA`$ziJMV$#u^;(b!4FZb54|K{s!E#| Wp0jrXqWb^<00{s|MNUMnLSTZ+;C!n9 diff --git a/src/Plot2d/resources/plot2d_log.png b/src/Plot2d/resources/plot2d_log.png index aecca8c13acab4ff9fe724bdd0532f858b60e84e..fb62cd77242c43e92c8dd638560f0ce535fae6fb 100755 GIT binary patch delta 697 zcmV;q0!ICy0?`GKB!3BTNLh0L01FcU01FcV0GgZ_00004XF*Lt006O$eEU(80000W zV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F}0006gX00f{zj!gi7K`4m+fEzojgQ%cbXaXtH<$vHcx0rd02#Dy-?!JD_ z45|v5iHLx^LsemB>j)sQDKlpTfXrr)S4d}g_+UE2|NsAhd_+(vDCRIcxIYDjfA4M| zgOYL)!|hv54615%3_yo5^!D~D0|XG*!2kdMAld#K$OpOZADXLvqVaz~ee(lZ*aIMd zpa%X0y5~P!BY%XCYT#cC1Ak((NChB(z>)IrKhRY`m)*JD0aWk{tmxlg1ipEr9*tiE zcG;E7MGRlR{$eqkmrvKY;WAb`LI+S$*bS}X$u5XfkKAWi^c11gwz0Wu(fKrZ|O#CNFVz&ii|1acua5K90t f4;2jj0uW#TvY}<(S$VC|00000NkvXXu0mjfHANm` delta 260 zcmV+f0sH>Z1)u_uB!A~gL_t(|oXwNL4Z|=9ML$-?@WF$4j10mk4B{bj$RIv=4|-@x ziIvoqnn>k>FrOC$gqCH&l@>0g-2t2cfSL7IkciL*d_g~ncX^AwueEAQi6&o|b3O(7 zyu}B#O19-%tLB{1TB9RqpSO5jS9rfIC8cx-I?G$!d%EoozkS`b*DkMqOvu1*b(5N%udAK88j8OwH-muv>x@jahvr-D?c?JOW zf6=z(em-aBbs|Eg6aeq;cOAYShx7Eh)*9uU6@a$Z=)S}LTi^rT50BHSofNhJ0000< KMNUMnLSTY(k$$cK diff --git a/src/Plot2d/resources/plot2d_log_y.png b/src/Plot2d/resources/plot2d_log_y.png index 4e1e21147730b76ee0a07b6d9296c2ff63cac672..825d59edbabe2880137e8a8f6537a7124335edef 100755 GIT binary patch delta 720 zcmV;>0x$iT0_X*hB!3BTNLh0L01FcU01FcV0GgZ_00004XF*Lt006O$eEU(80000W zV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F}0007BNklfB<5FN&Nl$mw%zRw->JP;e+Ww1^*Zn z6thtbxOcaY;orYsK)GK)JwJhZK7oXlf%pXwe+392xPgEE{9$--e+pdVzkk0O6qWLT z1|Tc}S)im`#Bl3oBT)V)7(;;v5bpruy8ro1s$3V#sufEWM)1UK;4uU`yz@AiP40Yrbn8bB^lRjoqt^7U)wK;Qgi`2PJj z!?$n0F~SrefZzuH`0;~5S-Au*aq~tk(BMB{0}x*R%b=y*#c<+yHc>Jms7{~zt0fb^8dKi)e00M}Kfyw|NfT(UDKmeg6 z8<00)-u?goH&E;^Fu(p|K;-v-@Z*pVw=@1}*;0AvE`jtULvlT9J@IVHGgX2twZCewOT=<{C!(%SP zisexZzdEAQnV% z^^f7p7f1;LGV}+~Tl40IFoZ`eL(wpGY5-UsR7sdJGBIKp2oOMwuoAnZq~t%jF$*l1 zCjhAhK(j6a1Q6UnMn*<`Ae8{b24t9d0cIdTfB^t!_g5XG@sD@_0000dnrq^j=ybl_nXscH!!xEi-P z5pgj_tQ^2u-Hfi`y)QZEmv&e=fCHeqSyAiI(%CPhl(_F3pmkV@Ch>&U>cv9IQL;A9|QA=x9ymw};5 zm4Tt5nStTwe<1ymfuYoZf#FpG1B2BJ1_tr`N%2SBfNIZrx;TbZ+)DcM|Gz!6DWd~} zp<#d|1B<{_UKS38Rni;+4m?L%6PZ0GS_l*i2i0>5IJijM_z=H1>wo=Uu5^ZB( zJmT=Sg;&5K#NQ0ab_u(5VDb_MCXQFBLX+9%sjvz-Y%oyK%zWS-#K6enZMH;}*T$1e zpCD-C3|y|V3pn&#@dIjg`I^EEG{sy%pjCi!PC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|55H l>1SxRhvl8xq8Qy@>?hexp_V=;#tQ%d002ovPDHLkV1kaXejfk; diff --git a/src/Plot2d/resources/plot2d_splines.png b/src/Plot2d/resources/plot2d_splines.png index c39d4321c35c26f3792db5fbdcc42d7a272e36a1..06a95572db8bb67fe21ae249da802c8da1091026 100755 GIT binary patch delta 406 zcmV;H0crlB0004R=004l4008;_004mL004C`008P>0026e000+nl3&F}0003dNklgX00a=#4Fm`vsv8IpKn%o%VFO5!I1qCaQhx~$KtveW@L!{9|9_~V z)`ScN2p~p~fsBldSS7V$JHWPGTl@pa=3s!ZD{O$&1t9*4O%Ff-VKoq85LmMc6!QS_ z7oc1XR1PHe0^MMM0K)Jx)G&P@4u)cDC?AGF{9q(?C_w-aKqv+xDRPHuRK^l!+)#0A zY=!~^5DS)IfPZ-fS2%&h?n2eT)PI4BF#rS*k_+Ln7z}j*F+dqT_5lJ2Y9LC|2!^IP zqS7aNk^%@ImxBf@t_B2eBXlhc zaiJsWPtp_uzD?Rm=Ifg@87CrWC4Fi1&1eAVNUkXm0R97Hme>qvFlLGR(oJv?$RZKL z_hkUikNYQ9&>;%~Aj}Q`^rn%H%YH#8B^O{5jn6S&PyK57 zt0kwf(1nGI(#L)d?Qd?u=JENF@{{1Oo|M(Fgn9rF`Rv>E(pSSm7o4rP5dfTZo0?MB zWOjZt-%RW<8)Zs3q}wMS`wb^9v0Oyz4j$R51`lB<3+1VYzX00000 LNkvXXu0mjfj^=wX diff --git a/src/PyInterp/PyInterp.pro b/src/PyInterp/PyInterp.pro index 8ee7c1f25..62e78e807 100644 --- a/src/PyInterp/PyInterp.pro +++ b/src/PyInterp/PyInterp.pro @@ -5,7 +5,7 @@ MOC_DIR = ../../moc OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET INCLUDEPATH += ../../include $$(PYTHONINC) -unix:LIBS += -L$$(PYTHONLIB) -lpython2.5 +unix:LIBS += -L$$(PYTHONLIB) -lpython2.5 -L../../$(CONFIG_ID)/lib -lEvent win32:LIBS += /LIBPATH:$$(PYTHONLIB) CONFIG -= debug release debug_and_release diff --git a/src/PyInterp/PyInterp_Dispatcher.cxx b/src/PyInterp/PyInterp_Dispatcher.cxx index e3adb001d..2fbda19ee 100755 --- a/src/PyInterp/PyInterp_Dispatcher.cxx +++ b/src/PyInterp/PyInterp_Dispatcher.cxx @@ -23,10 +23,23 @@ #include "PyInterp_Dispatcher.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!! #include "PyInterp_Interp.h" #include "PyInterp_Watcher.h" +#include #include #include +class PyInterp_ExecuteEvent: public SALOME_Event +{ +public: + PyInterp_Request* myRequest; + PyInterp_ExecuteEvent( PyInterp_Request* r ) + : myRequest( r ) {} + virtual void Execute() + { + myRequest->execute(); + } +}; + using namespace std; PyInterp_Dispatcher* PyInterp_Dispatcher::myInstance = 0; @@ -49,7 +62,7 @@ void PyInterp_Request::process() void PyInterp_Request::safeExecute() { - execute(); + ProcessVoidEvent( new PyInterp_ExecuteEvent( this ) ); } void PyInterp_Request::Destroy( PyInterp_Request* request ) @@ -62,7 +75,7 @@ void PyInterp_Request::Destroy( PyInterp_Request* request ) QEvent* PyInterp_Request::createEvent() const { - return new PyInterp_Event( PyInterp_Event::NOTIFY, (PyInterp_Request*)this ); + return new PyInterp_Event( PyInterp_Event::ES_NOTIFY, (PyInterp_Request*)this ); } void PyInterp_Request::processEvent( QObject* o ) @@ -94,7 +107,7 @@ void PyInterp_LockRequest::safeExecute() { if ( getInterp() ){ PyLockWrapper aLock = getInterp()->GetLockWrapper(); - execute(); + ProcessVoidEvent( new PyInterp_ExecuteEvent( this ) ); } } diff --git a/src/PyInterp/PyInterp_Dispatcher.h b/src/PyInterp/PyInterp_Dispatcher.h index cf46694e4..5040b1032 100755 --- a/src/PyInterp/PyInterp_Dispatcher.h +++ b/src/PyInterp/PyInterp_Dispatcher.h @@ -35,10 +35,12 @@ class QObject; class PyInterp_Interp; class PyInterp_Watcher; class PyInterp_Dispatcher; +class PyInterp_ExecuteEvent; class PYINTERP_EXPORT PyInterp_Request { friend class PyInterp_Dispatcher; + friend class PyInterp_ExecuteEvent; PyInterp_Request(); PyInterp_Request( const PyInterp_Request& ); @@ -102,7 +104,8 @@ class PYINTERP_EXPORT PyInterp_Event : public QEvent PyInterp_Event( const PyInterp_Event& ); public: - enum { NOTIFY = QEvent::User + 5000, OK, ERROR, INCOMPLETE, LAST }; + //Execution state + enum { ES_NOTIFY = QEvent::User + 5000, ES_OK, ES_ERROR, ES_INCOMPLETE, ES_LAST }; PyInterp_Event( int type, PyInterp_Request* request ) : QEvent( (QEvent::Type)type ), myRequest( request ) {} diff --git a/src/PyInterp/PyInterp_base.cxx b/src/PyInterp/PyInterp_base.cxx deleted file mode 100644 index 1ff7cd241..000000000 --- a/src/PyInterp/PyInterp_base.cxx +++ /dev/null @@ -1,317 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// SALOME SALOMEGUI : implementation of desktop and GUI kernel -// -// File : PyInterp_base.cxx -// Author : Christian CAREMOLI, Paul RASCLE, EDF -// Module : SALOME -// $Header$ - - -#include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)! - -#include - -#include -#include - -using namespace std; - -PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): - myThreadState(theThreadState), - mySaveThreadState(0) -{ -#if defined(USE_GILSTATE) - if (myThreadState->interp == PyInterp_base::_interp) { - _savestate = PyGILState_Ensure(); - } else { - PyEval_AcquireThread(myThreadState); - } -#else - PyEval_AcquireThread(myThreadState); -#endif -} - -PyLockWrapper::~PyLockWrapper() -{ -#if defined(USE_GILSTATE) - if (myThreadState->interp == PyInterp_base::_interp) { - PyGILState_Release(_savestate); - } else { - PyEval_ReleaseThread(myThreadState); - } -#else - PyEval_ReleaseThread(myThreadState); -#endif -} - -class PyReleaseLock{ -public: - ~PyReleaseLock(){ - PyEval_ReleaseLock(); - } -}; - - -PyLockWrapper PyInterp_base::GetLockWrapper(){ - return _tstate; -} - - -// main python interpreter (static attributes) - -int PyInterp_base::_argc = 1; -char* PyInterp_base::_argv[] = {""}; - -PyObject *PyInterp_base::builtinmodule = NULL; - -PyThreadState *PyInterp_base::_gtstate = NULL; -PyInterpreterState *PyInterp_base::_interp = NULL; - - -/*! - * basic constructor here : herited classes constructors must call initalize() method - * defined here. - */ -PyInterp_base::PyInterp_base(): _tstate(0), _vout(0), _verr(0), _g(0), _atFirst(true) -{ -} - -PyInterp_base::~PyInterp_base() -{ -} - - -/*! - * Must be called by herited classes constructors. initialize() calls virtuals methods - * initstate & initcontext, not defined here in base class. initstate & initcontext methods - * must be implemented in herited classes, following the Python interpreter policy - * (mono or multi interpreter...). - */ -void PyInterp_base::initialize() -{ - _history.clear(); // start a new list of user's commands - _ith = _history.begin(); - - init_python(); - // Here the global lock is released - - initState(); - - PyLockWrapper aLock= GetLockWrapper(); - - initContext(); - - // used to interpret & compile commands - PyObjWrapper m(PyImport_ImportModule("codeop")); - if(!m){ - PyErr_Print(); - return; - } - - // Create cStringIO to capture stdout and stderr - PycString_IMPORT; - if (PycStringIO) { // CTH11627 : additional check - _vout = PycStringIO->NewOutput(128); - _verr = PycStringIO->NewOutput(128); - } - - // All the initRun outputs are redirected to the standard output (console) - initRun(); -} - -void PyInterp_base::init_python() -{ - _atFirst = false; - if (Py_IsInitialized()) - return; - - // Python is not initialized - Py_SetProgramName(_argv[0]); - Py_Initialize(); // Initialize the interpreter - PySys_SetArgv(_argc, _argv); - PyEval_InitThreads(); // Create (and acquire) the interpreter lock - _interp = PyThreadState_Get()->interp; - _gtstate = PyEval_SaveThread(); // Release global thread state -} - -string PyInterp_base::getbanner() -{ - // Should we take the lock ? - // PyEval_RestoreThread(_tstate); - string aBanner("Python "); - aBanner = aBanner + Py_GetVersion() + " on " + Py_GetPlatform() ; - aBanner = aBanner + "\ntype help to get general information on environment\n"; - //PyEval_SaveThread(); - return aBanner; -} - - -int PyInterp_base::initRun() -{ - PySys_SetObject("stderr",_verr); - PySys_SetObject("stdout",_vout); - - PyObjWrapper verr(PyObject_CallMethod(_verr,"reset","")); - PyObjWrapper vout(PyObject_CallMethod(_vout,"reset","")); - - //PyObject *m = PyImport_GetModuleDict(); - - PySys_SetObject("stdout",PySys_GetObject("__stdout__")); - PySys_SetObject("stderr",PySys_GetObject("__stderr__")); - - return 0; -} - - -/*! - * This function compiles a string (command) and then evaluates it in the dictionnary - * context if possible. - * Returns : - * -1 : fatal error - * 1 : incomplete text - * 0 : complete text executed with success - */ -int compile_command(const char *command,PyObject *context) -{ - PyObject *m = PyImport_AddModule("codeop"); - if(!m){ // Fatal error. No way to go on. - PyErr_Print(); - return -1; - } - PyObjWrapper v(PyObject_CallMethod(m,"compile_command","s",command)); - if(!v){ - // Error encountered. It should be SyntaxError, - //so we don't write out traceback - PyObjWrapper exception, value, tb; - PyErr_Fetch(&exception, &value, &tb); - PyErr_NormalizeException(&exception, &value, &tb); - PyErr_Display(exception, value, NULL); - return -1; - }else if (v == Py_None){ - // Incomplete text we return 1 : we need a complete text to execute - return 1; - }else{ - // Complete and correct text. We evaluate it. - //#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0 - // PyObjWrapper r(PyEval_EvalCode(v,context,context)); - //#else - PyObjWrapper r(PyEval_EvalCode((PyCodeObject *)(void *)v,context,context)); - //#endif - if(!r){ - // Execution error. We return -1 - PyErr_Print(); - return -1; - } - // The command has been successfully executed. Return 0 - return 0; - } -} - - -int PyInterp_base::run(const char *command) -{ - if(_atFirst){ - int ret = 0; - ret = simpleRun("from Help import *"); - if (ret) { - _atFirst = false; - return ret; - } - ret = simpleRun("import salome"); - if (ret) { - _atFirst = false; - return ret; - } - ret = simpleRun("salome.salome_init(0,1)"); - if (ret) { - _atFirst = false; - return ret; - } - _atFirst = false; - } - return simpleRun(command); -} - - -int PyInterp_base::simpleRun(const char *command) -{ - if( !_atFirst && strcmp(command,"") != 0 ) { - _history.push_back(command); - _ith = _history.end(); - } - - // We come from C++ to enter Python world - // We need to acquire the Python global lock - //PyLockWrapper aLock(_tstate); // san - lock is centralized now - - // Reset redirected outputs before treatment - PySys_SetObject("stderr",_verr); - PySys_SetObject("stdout",_vout); - - PyObjWrapper verr(PyObject_CallMethod(_verr,"reset","")); - PyObjWrapper vout(PyObject_CallMethod(_vout,"reset","")); - - int ier = compile_command(command,_g); - - // Outputs are redirected on standards outputs (console) - PySys_SetObject("stdout",PySys_GetObject("__stdout__")); - PySys_SetObject("stderr",PySys_GetObject("__stderr__")); - - return ier; -} - - -const char * PyInterp_base::getPrevious() -{ - if(_ith != _history.begin()){ - _ith--; - return (*_ith).c_str(); - } - else - return BEGIN_HISTORY_PY; -} - - -const char * PyInterp_base::getNext() -{ - if(_ith != _history.end()){ - _ith++; - } - if (_ith == _history.end()) - return TOP_HISTORY_PY; - else - return (*_ith).c_str(); -} - - -string PyInterp_base::getverr(){ - //PyLockWrapper aLock(_tstate); - PyObjWrapper v(PycStringIO->cgetvalue(_verr)); - string aRet(PyString_AsString(v)); - return aRet; -} - - -string PyInterp_base::getvout(){ - //PyLockWrapper aLock(_tstate); - PyObjWrapper v(PycStringIO->cgetvalue(_vout)); - string aRet(PyString_AsString(v)); - return aRet; -} diff --git a/src/PyInterp/PyInterp_base.h b/src/PyInterp/PyInterp_base.h deleted file mode 100644 index a00056e86..000000000 --- a/src/PyInterp/PyInterp_base.h +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// SALOME SALOMEGUI : implementation of desktop and GUI kernel -// -// File : PyInterp_base.h -// Author : Christian CAREMOLI, Paul RASCLE, EDF -// Module : SALOME - -#ifndef _PYINTERP_BASE_H_ -#define _PYINTERP_BASE_H_ - -#include "PyInterp.h" - -#include -#include -#include - -// include order important! -// pthread then python then qt -//#include // must be before Python.h ! - -#include // must be before qt includes ... -#include // Python include needed for versions before 2.4. Included in Python.h now. -#include // Python include needed for versions before 2.4. Included in Python.h now. - -//#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0 -//extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l); -//#endif - -/* For 2.3, use the PyGILState_ calls */ -#if (PY_VERSION_HEX >= 0x02030000) -#define USE_GILSTATE -#endif - -#define TOP_HISTORY_PY "--- top of history ---" -#define BEGIN_HISTORY_PY "--- begin of history ---" - -class PYINTERP_EXPORT PyLockWrapper -{ - PyThreadState* myThreadState; - PyThreadState* mySaveThreadState; -#if defined(USE_GILSTATE) - PyGILState_STATE _savestate ; -#endif - public: - PyLockWrapper(PyThreadState* theThreadState); - ~PyLockWrapper(); -}; - -class PYINTERP_EXPORT PyInterp_base{ - public: - static int _argc; - static char* _argv[]; - static PyObject *builtinmodule; - static PyThreadState *_gtstate; - static PyInterpreterState *_interp; - - PyInterp_base(); - virtual ~PyInterp_base(); - - virtual void initialize(); - virtual void init_python(); - // init_python() made virtual to: - // 1. Remove dependency on KERNEL in light SALOME configuration - // 2. Allow redefinition of this method in SalomeApp_PyInterp class (it should be empty there and rely on KERNEL_PYTHON) - - virtual int run(const char *command); - - PyLockWrapper GetLockWrapper(); - - std::string getbanner(); - std::string getverr(); - std::string getvout(); - - const char * getPrevious(); - const char * getNext(); - - protected: - PyThreadState * _tstate; - PyObject * _vout; - PyObject * _verr; - PyObject * _g; - PyObject * _codeop; - std::list _history; - std::list::iterator _ith; - bool _atFirst; - - int simpleRun(const char* command); - int initRun(); - - virtual bool initState() = 0; - virtual bool initContext() = 0; -}; - - -class PYINTERP_EXPORT PyObjWrapper{ - PyObject* myObject; -public: - PyObjWrapper(PyObject* theObject): myObject(theObject) {} - PyObjWrapper(): myObject(0) {} - operator PyObject*(){ - return myObject; - } - PyObject* operator->(){ - return myObject; - } - PyObject* get(){ - return myObject; - } - bool operator!(){ - return !myObject; - } - bool operator==(PyObject* theObject){ - return myObject == theObject; - } - PyObject** operator&(){ - return &myObject; - } - PyObjWrapper& operator=(PyObjWrapper* theObjWrapper){ - Py_XDECREF(myObject); - myObject = theObjWrapper->myObject; - return *this; - } - virtual ~PyObjWrapper(){ - Py_XDECREF(myObject); - } -}; - -#endif -- 2.39.2