|
PythonQt
|
a smart pointer that stores a PyObject pointer and that handles reference counting automatically More...
#include <PythonQtObjectPtr.h>
Public Member Functions | |
| PythonQtObjectPtr () | |
| PythonQtObjectPtr (const PythonQtObjectPtr &p) | |
| PythonQtObjectPtr (PythonQtObjectPtr &&p) noexcept | |
| rvalue copy constructor, does not need any incref/decref. | |
| PythonQtObjectPtr (PythonQtSafeObjectPtr &&p) | |
| rvalue copy constructor, does not need any incref/decref. | |
| PythonQtObjectPtr (const QVariant &variant) | |
| If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count. | |
| PythonQtObjectPtr (PyObject *o) | |
| ~PythonQtObjectPtr () | |
| bool | fromVariant (const QVariant &variant) |
| If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count. | |
| QVariant | toVariant () |
| Returns a PythonQtSafeObjectPtr as a QVariant. It does not return a PythonQtObjectPtr, because that would be unsafe regarding the GIL. | |
| QVariant | toLocalVariant () |
| Returns a PythonQtObjectPtr as a QVariant. Only use this when you know that the variant is only used locally and not stored outside of the current GIL scope. | |
| PythonQtObjectPtr & | operator= (const PythonQtObjectPtr &p) |
| PythonQtObjectPtr & | operator= (PythonQtObjectPtr &&p) noexcept |
| rvalue assignment operator that steals the reference from p | |
| PythonQtObjectPtr & | operator= (PythonQtSafeObjectPtr &&p) |
| rvalue assignment operator that steals the reference from p | |
| PythonQtObjectPtr & | operator= (PyObject *o) |
| PythonQtObjectPtr & | operator= (const QVariant &variant) |
| bool | operator== (const PythonQtObjectPtr &p) const |
| bool | operator!= (const PythonQtObjectPtr &p) const |
| bool | operator== (PyObject *p) const |
| bool | operator!= (PyObject *p) const |
| bool | isNull () const |
| PyObject * | operator-> () const |
| PyObject & | operator* () const |
| operator PyObject * () const | |
| void | setNewRef (PyObject *o) |
| sets the object and passes the ownership (stealing the reference, in Python slang) | |
| PyObject * | object () const |
| QVariant | evalScript (const QString &script, int start=Py_file_input) |
| evaluates the given script code in the context of this object and returns the result value | |
| QVariant | evalCode (PyObject *pycode) |
| void | evalFile (const QString &filename) |
| evaluates the given code in the context | |
| void | addObject (const QString &name, QObject *object) |
add the given object to the module as a variable with name (it can be removed via clearVariable) | |
| void | addVariable (const QString &name, const QVariant &v) |
| add the given variable to the module | |
| void | removeVariable (const QString &name) |
| remove the given variable | |
| QVariant | getVariable (const QString &name) |
get the variable with the name of the module, returns an invalid QVariant on error | |
| QVariant | call (const QString &callable, const QVariantList &args=QVariantList(), const QVariantMap &kwargs=QVariantMap()) |
| call the given python object (in the scope of the current object), returns the result converted to a QVariant | |
| QVariant | call (const QVariantList &args=QVariantList(), const QVariantMap &kwargs=QVariantMap()) |
| call the contained python object directly, returns the result converted to a QVariant | |
| PyObject * | takeObject () |
Protected Member Functions | |
| void | setObject (PyObject *o) |
a smart pointer that stores a PyObject pointer and that handles reference counting automatically
Definition at line 56 of file PythonQtObjectPtr.h.
|
inline |
Definition at line 59 of file PythonQtObjectPtr.h.
Referenced by operator!=(), operator=(), operator=(), operator=(), operator=(), operator=(), operator==(), PythonQtObjectPtr(), and PythonQtObjectPtr().
|
inline |
Definition at line 64 of file PythonQtObjectPtr.h.
References object(), PythonQtObjectPtr(), and setObject().
|
inlinenoexcept |
rvalue copy constructor, does not need any incref/decref.
Definition at line 71 of file PythonQtObjectPtr.h.
References PythonQtObjectPtr().
| PythonQtObjectPtr::PythonQtObjectPtr | ( | PythonQtSafeObjectPtr && | p | ) |
rvalue copy constructor, does not need any incref/decref.
|
inline |
If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count.
Definition at line 80 of file PythonQtObjectPtr.h.
References fromVariant().
| PythonQtObjectPtr::PythonQtObjectPtr | ( | PyObject * | o | ) |
| PythonQtObjectPtr::~PythonQtObjectPtr | ( | ) |
| void PythonQtObjectPtr::addObject | ( | const QString & | name, |
| QObject * | object ) |
add the given object to the module as a variable with name (it can be removed via clearVariable)
| void PythonQtObjectPtr::addVariable | ( | const QString & | name, |
| const QVariant & | v ) |
add the given variable to the module
| QVariant PythonQtObjectPtr::call | ( | const QString & | callable, |
| const QVariantList & | args = QVariantList(), | ||
| const QVariantMap & | kwargs = QVariantMap() ) |
call the given python object (in the scope of the current object), returns the result converted to a QVariant
| QVariant PythonQtObjectPtr::call | ( | const QVariantList & | args = QVariantList(), |
| const QVariantMap & | kwargs = QVariantMap() ) |
call the contained python object directly, returns the result converted to a QVariant
| QVariant PythonQtObjectPtr::evalCode | ( | PyObject * | pycode | ) |
evaluates the given code and returns the result value (use Py_Compile etc. to create pycode from string) If pycode is NULL, a python error is printed.
| void PythonQtObjectPtr::evalFile | ( | const QString & | filename | ) |
evaluates the given code in the context
| QVariant PythonQtObjectPtr::evalScript | ( | const QString & | script, |
| int | start = Py_file_input ) |
evaluates the given script code in the context of this object and returns the result value
| bool PythonQtObjectPtr::fromVariant | ( | const QVariant & | variant | ) |
If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count.
Referenced by operator=(), and PythonQtObjectPtr().
| QVariant PythonQtObjectPtr::getVariable | ( | const QString & | name | ) |
get the variable with the name of the module, returns an invalid QVariant on error
|
inline |
|
inline |
Definition at line 149 of file PythonQtObjectPtr.h.
Referenced by isNull(), operator PyObject *(), operator!=(), operator*(), operator->(), operator=(), PythonQtSafeObjectPtr::operator=(), operator==(), operator==(), PythonQtObjectPtr(), and PythonQtSafeObjectPtr::PythonQtSafeObjectPtr().
|
inline |
|
inline |
Definition at line 132 of file PythonQtObjectPtr.h.
References PythonQtObjectPtr().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 99 of file PythonQtObjectPtr.h.
References object(), PythonQtObjectPtr(), and setObject().
|
inline |
Definition at line 124 of file PythonQtObjectPtr.h.
References fromVariant(), and PythonQtObjectPtr().
|
inline |
Definition at line 118 of file PythonQtObjectPtr.h.
References PythonQtObjectPtr(), and setObject().
|
inlinenoexcept |
rvalue assignment operator that steals the reference from p
Definition at line 106 of file PythonQtObjectPtr.h.
References PythonQtObjectPtr(), and setObject().
| PythonQtObjectPtr & PythonQtObjectPtr::operator= | ( | PythonQtSafeObjectPtr && | p | ) |
rvalue assignment operator that steals the reference from p
References PythonQtObjectPtr().
|
inline |
Definition at line 130 of file PythonQtObjectPtr.h.
References object(), and PythonQtObjectPtr().
|
inline |
| void PythonQtObjectPtr::removeVariable | ( | const QString & | name | ) |
remove the given variable
| void PythonQtObjectPtr::setNewRef | ( | PyObject * | o | ) |
sets the object and passes the ownership (stealing the reference, in Python slang)
|
protected |
Referenced by operator=(), operator=(), operator=(), and PythonQtObjectPtr().
|
inline |
takes the object from the pointer, leaving the pointer empty. the caller has to take care about the decref of the taken object!
Definition at line 182 of file PythonQtObjectPtr.h.
| QVariant PythonQtObjectPtr::toLocalVariant | ( | ) |
Returns a PythonQtObjectPtr as a QVariant. Only use this when you know that the variant is only used locally and not stored outside of the current GIL scope.
| QVariant PythonQtObjectPtr::toVariant | ( | ) |
Returns a PythonQtSafeObjectPtr as a QVariant. It does not return a PythonQtObjectPtr, because that would be unsafe regarding the GIL.