13#include <frameobject.h>
19struct ScriptEditorDetails {
39int traceLineNumber(PyObject *
obj, PyFrameObject *frame,
int event, PyObject *arg) {
42 if (event != PyTrace_LINE)
44 auto iter = EDITOR_LOOKUP.constFind(frame->f_code->co_filename);
45 if (iter != EDITOR_LOOKUP.constEnd()) {
46 const auto &details = iter.value();
47 int lineLoc = frame->f_lineno + details.lineOffset;
48 details.editor->updateProgressMarkerFromThread(lineLoc,
false);
72 int lineOffset)
const {
74 PyCompilerFlags compileFlags;
75 compileFlags.cf_flags = flags;
77 Py_CompileStringFlags(codeStr.toUtf8().constData(), filename.toUtf8().constData(), Py_file_input, &compileFlags);
83 return PyEval_EvalCode(
CODE_OBJECT(compiledCode), globals, globals);
86 ScriptEditorDetails editor_details{
m_editor, lineOffset};
87 const auto coFileObject = ((PyCodeObject *)compiledCode)->co_filename;
88 const auto posIter = EDITOR_LOOKUP.insert(coFileObject, editor_details);
89 PyEval_SetTrace((Py_tracefunc)&traceLineNumber,
nullptr);
90 const auto result = PyEval_EvalCode(
CODE_OBJECT(compiledCode), globals, globals);
91 PyEval_SetTrace(
nullptr,
nullptr);
92 EDITOR_LOOKUP.erase(posIter);
double obj
the value of the quadratic function
Defines a structure for acquiring/releasing the Python GIL using the RAII pattern.
This class provides an area to write scripts.