|
HAL
v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
|
Interface for pybind11. More...
#include </home/runner/work/hal/hal/plugins/gui/include/gui/python/python_context.h>


Public Member Functions | |
| PythonContext (QObject *parent=nullptr) | |
| ~PythonContext () | |
| void | interpretForeground (const QString &input) |
| void | interpretBackground (QObject *caller, const QString &input, bool multiple_expressions=false) |
| void | interpretScript (QObject *caller, const QString &input) |
| void | forwardStdout (const QString &output) |
| void | forwardError (const QString &output) |
| void | scheduleClear () |
| void | scheduleReset () |
| void | setConsole (PythonConsole *console) |
| std::vector< std::tuple< std::string, std::string > > | complete (const QString &text, bool use_console_context) |
| int | checkCompleteStatement (const QString &text) |
| void | initPython () |
| void | closePython () |
| void | updateNetlist () |
| PythonThread * | pythonThread () const |
| void | abortThread () |
| void | abortThreadAndWait () |
| bool | isThreadRunning () const |
Public Member Functions inherited from QObject | |
| virtual const QMetaObject * | metaObject () const const |
| QObject (QObject *parent) | |
| virtual | ~QObject () |
| virtual bool | event (QEvent *e) |
| virtual bool | eventFilter (QObject *watched, QEvent *event) |
| QString | objectName () const const |
| void | setObjectName (const QString &name) |
| bool | isWidgetType () const const |
| bool | isWindowType () const const |
| bool | signalsBlocked () const const |
| bool | blockSignals (bool block) |
| QThread * | thread () const const |
| void | moveToThread (QThread *targetThread) |
| int | startTimer (int interval, Qt::TimerType timerType) |
| int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
| void | killTimer (int id) |
| T | findChild (const QString &name, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
| const QObjectList & | children () const const |
| void | setParent (QObject *parent) |
| void | installEventFilter (QObject *filterObj) |
| void | removeEventFilter (QObject *obj) |
| QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
| bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
| bool | disconnect (const QObject *receiver, const char *method) const const |
| void | dumpObjectTree () |
| void | dumpObjectInfo () |
| void | dumpObjectTree () const const |
| void | dumpObjectInfo () const const |
| bool | setProperty (const char *name, const QVariant &value) |
| QVariant | property (const char *name) const const |
| QList< QByteArray > | dynamicPropertyNames () const const |
| void | destroyed (QObject *obj) |
| void | objectNameChanged (const QString &objectName) |
| QObject * | parent () const const |
| bool | inherits (const char *className) const const |
| void | deleteLater () |
| Q_DISABLE_COPY (Class) | |
| Q_DISABLE_MOVE (Class) | |
| Q_DISABLE_COPY_MOVE (Class) | |
| T | qobject_cast (QObject *object) |
| T | qobject_cast (const QObject *object) |
| T | qFindChild (const QObject *obj, const QString &name) |
| QList< T > | qFindChildren (const QObject *obj, const QString &name) |
| QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
| Q_CLASSINFO (Name, Value) | |
| Q_INTERFACES (...) | |
| Q_PROPERTY (...) | |
| Q_ENUMS (...) | |
| Q_FLAGS (...) | |
| Q_ENUM (...) | |
| Q_FLAG (...) | |
| Q_ENUM_NS (...) | |
| Q_FLAG_NS (...) | |
| Q_OBJECT Q_OBJECT | |
| Q_GADGET Q_GADGET | |
| Q_NAMESPACE Q_NAMESPACE | |
| Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
| Q_SIGNALS Q_SIGNALS | |
| Q_SIGNAL Q_SIGNAL | |
| Q_SLOTS Q_SLOTS | |
| Q_SLOT Q_SLOT | |
| Q_EMIT Q_EMIT | |
| Q_INVOKABLE Q_INVOKABLE | |
| Q_REVISION Q_REVISION | |
| Q_SET_OBJECT_NAME (Object) | |
| QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Static Public Member Functions | |
| static void | initializeContext (py::dict *context) |
| static void | initializeScript (py::dict *context) |
Static Public Member Functions inherited from QObject | |
| QString | tr (const char *sourceText, const char *disambiguation, int n) |
| QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
| QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
| bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
| bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
| bool | disconnect (const QMetaObject::Connection &connection) |
| bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
Additional Inherited Members | |
Public Attributes inherited from QObject | |
| typedef | QObjectList |
Protected Member Functions inherited from QObject | |
| QObject * | sender () const const |
| int | senderSignalIndex () const const |
| int | receivers (const char *signal) const const |
| bool | isSignalConnected (const QMetaMethod &signal) const const |
| virtual void | timerEvent (QTimerEvent *event) |
| virtual void | childEvent (QChildEvent *event) |
| virtual void | customEvent (QEvent *event) |
| virtual void | connectNotify (const QMetaMethod &signal) |
| virtual void | disconnectNotify (const QMetaMethod &signal) |
Properties inherited from QObject | |
| objectName | |
Interface for pybind11.
This class provides an interface for using pybind11. It can call a python interpreter to run python expressions and scripts. Moreover it provides a function to get auto-completion candidates that are available in the context.
Definition at line 89 of file python_context.h.
| hal::PythonContext::PythonContext | ( | QObject * | parent = nullptr | ) |
| hal::PythonContext::~PythonContext | ( | ) |
| void hal::PythonContext::abortThread | ( | ) |
Definition at line 85 of file python_context.cpp.
References hal::PythonThread::interrupt().
Referenced by abortThreadAndWait().
| void hal::PythonContext::abortThreadAndWait | ( | ) |
Definition at line 92 of file python_context.cpp.
References abortThread(), and QThread::wait().
| int hal::PythonContext::checkCompleteStatement | ( | const QString & | text | ) |
Check if given statement is a complete or incomplete statement for compound statement processing.
| [text] | text - The text to check. |
Definition at line 539 of file python_context.cpp.
References _PyParser_Grammar, hal::state, and QString::toStdString().
Referenced by hal::PythonConsole::interpretCommand().
| void hal::PythonContext::closePython | ( | ) |
Close the current context.
Definition at line 189 of file python_context.cpp.
Referenced by ~PythonContext().
| std::vector< std::tuple< std::string, std::string > > hal::PythonContext::complete | ( | const QString & | text, |
| bool | use_console_context | ||
| ) |
Compute a list of auto completion options for a given input.
Each entry is a tuple (name_with_symbols, complete).
E.g. for text="pri" one entry would be ("print", "nt")
| text | - The text to complete |
| use_console_context | - Set true if identifiers in the context of the python console should be considered in the auto completion. |
Definition at line 490 of file python_context.cpp.
References forwardError(), QString::fromStdString(), initializeContext(), log_warning, hal::state, and QString::toStdString().
Referenced by hal::PythonConsole::handleTabKeyPressed().
| void hal::PythonContext::forwardError | ( | const QString & | output | ) |
Forwards error output to the python console.
| output | - The output |
Definition at line 481 of file python_context.cpp.
References hal::PythonConsole::handleError(), log_error, and hal::output.
Referenced by complete(), interpretBackground(), interpretForeground(), and hal::PYBIND11_PLUGIN().
| void hal::PythonContext::forwardStdout | ( | const QString & | output | ) |
Forwards standard output to the python console.
| output | - The output |
Definition at line 469 of file python_context.cpp.
References hal::PythonConsole::handleStdout(), log_info, hal::output, and hal::utils::rtrim().
Referenced by interpretForeground(), interpretScript(), and hal::PYBIND11_PLUGIN().
|
static |
Definition at line 99 of file python_context.cpp.
References hal::utils::get_library_directory(), hal::utils::get_plugin_directories(), hal::gGuiApi, and hal::gNetlistOwner.
Referenced by complete(), and initPython().
|
static |
Definition at line 154 of file python_context.cpp.
References hal::gGuiApi, and hal::gNetlistOwner.
Referenced by hal::PythonThread::run().
| void hal::PythonContext::initPython | ( | ) |
Initializes the context to work with hal.
Definition at line 175 of file python_context.cpp.
References initializeContext().
Referenced by PythonContext().
| void hal::PythonContext::interpretBackground | ( | QObject * | caller, |
| const QString & | input, | ||
| bool | multiple_expressions = false |
||
| ) |
Interprets an input string in python format in new thread.
| caller | - The caller of interpreter, will be notified when finished |
| input | - The input string in python format. |
| multiple_expressions | - Must be set to true if the input contains multiple expressions (i.e. is a compound statement). |
Definition at line 196 of file python_context.cpp.
References forwardError(), hal::input, and log_info.
Referenced by hal::PythonConsole::interpretCommand().
| void hal::PythonContext::interpretForeground | ( | const QString & | input | ) |
Interprets an input string in python format in GUI thread.
| input | - The input string in python format. |
Definition at line 244 of file python_context.cpp.
References forwardError(), forwardStdout(), QString::fromStdString(), hal::input, log_info, and hal::state.
Referenced by hal::PythonConsole::PythonConsole().
Interprets a python script.
| caller | - The caller of interpreter, will be notified when finished |
| input | - The python script as a string. |
Definition at line 291 of file python_context.cpp.
References forwardStdout(), hal::input, log_info, and log_warning.
Referenced by hal::PythonEditor::handleActionRun().
|
inline |
Definition at line 205 of file python_context.h.
| PythonThread * hal::PythonContext::pythonThread | ( | ) | const |
Definition at line 80 of file python_context.cpp.
Referenced by hal::PluginParameterDialog::accept(), hal::FileManager::autosave(), hal::PythonEditor::handleCurrentTabChanged(), and hal::PYBIND11_PLUGIN().
| void hal::PythonContext::scheduleClear | ( | ) |
Clears the python console.
Definition at line 609 of file python_context.cpp.
Referenced by hal::PYBIND11_PLUGIN().
| void hal::PythonContext::scheduleReset | ( | ) |
Resets the python console.
Definition at line 604 of file python_context.cpp.
Referenced by hal::PYBIND11_PLUGIN().
| void hal::PythonContext::setConsole | ( | PythonConsole * | console | ) |
Assign this object the python console to work with.
| console | - The python console to work with. |
Definition at line 71 of file python_context.cpp.
References QObject::connect(), and hal::PythonConsole::inputReceived().
Referenced by hal::PythonConsole::PythonConsole(), and hal::PythonConsole::~PythonConsole().
| void hal::PythonContext::updateNetlist | ( | ) |
Update the current netlist the python context works with.
Definition at line 614 of file python_context.cpp.
References hal::gNetlistOwner, and hal::state.
Referenced by hal::MainWindow::handleFileOpened().