| 67 | } |
| 68 | |
| 69 | std::string |
| 70 | Interpreter::interpret( const std::string& command, int* errorCode ) |
| 71 | { |
| 72 | PyEval_AcquireThread( m_threadState ); |
| 73 | *errorCode = 0; |
| 74 | |
| 75 | PyObject* py_result; |
| 76 | PyObject* dum; |
| 77 | std::string res; |
| 78 | py_result = Py_CompileString(command.c_str(), "<stdin>", Py_single_input); |
| 79 | if ( py_result == 0 ) |
| 80 | { |
| 81 | if ( PyErr_Occurred( ) ) |
| 82 | { |
| 83 | *errorCode = 1; |
| 84 | PyErr_Print( ); |
| 85 | res = GetResultString( m_threadState ); |
| 86 | GetResultString( m_threadState ) = ""; |
| 87 | } |
| 88 | |
| 89 | PyEval_ReleaseThread( m_threadState ); |
| 90 | return res; |
| 91 | } |
| 92 | dum = PyEval_EvalCode (py_result, glb, loc); |
| 93 | Py_XDECREF (dum); |
| 94 | Py_XDECREF (py_result); |
| 95 | if ( PyErr_Occurred( ) ) |
| 96 | { |
| 97 | *errorCode = 1; |
| 98 | PyErr_Print( ); |
| 99 | } |
| 100 | |
| 101 | res = GetResultString( m_threadState ); |
| 102 | GetResultString( m_threadState ) = ""; |
| 103 | |
| 104 | PyEval_ReleaseThread( m_threadState ); |
| 105 | return res; |
| 106 | } |
| 107 | |
| 108 | const std::list<std::string>& Interpreter::suggest( const std::string& hint ) |
| 109 | { |