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. More... | |
PythonQtObjectPtr (PythonQtSafeObjectPtr &&p) | |
rvalue copy constructor, does not need any incref/decref. More... | |
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. More... | |
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. More... | |
QVariant | toVariant () |
Returns a PythonQtSafeObjectPtr as a QVariant. It does not return a PythonQtObjectPtr, because that would be unsafe regarding the GIL. More... | |
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. More... | |
PythonQtObjectPtr & | operator= (const PythonQtObjectPtr &p) |
PythonQtObjectPtr & | operator= (PythonQtObjectPtr &&p) noexcept |
rvalue assignment operator that steals the reference from p More... | |
PythonQtObjectPtr & | operator= (PythonQtSafeObjectPtr &&p) |
rvalue assignment operator that steals the reference from p More... | |
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) More... | |
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 More... | |
QVariant | evalCode (PyObject *pycode) |
void | evalFile (const QString &filename) |
evaluates the given code in the context More... | |
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) More... | |
void | addVariable (const QString &name, const QVariant &v) |
add the given variable to the module More... | |
void | removeVariable (const QString &name) |
remove the given variable More... | |
QVariant | getVariable (const QString &name) |
get the variable with the name of the module , returns an invalid QVariant on error More... | |
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 More... | |
QVariant | call (const QVariantList &args=QVariantList(), const QVariantMap &kwargs=QVariantMap()) |
call the contained python object directly, returns the result converted to a QVariant More... | |
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.
|
inline |
|
inlinenoexcept |
rvalue copy constructor, does not need any incref/decref.
Definition at line 67 of file PythonQtObjectPtr.h.
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 75 of file PythonQtObjectPtr.h.
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.
QVariant PythonQtObjectPtr::getVariable | ( | const QString & | name | ) |
get the variable with the name
of the module
, returns an invalid QVariant on error
|
inline |
Definition at line 137 of file PythonQtObjectPtr.h.
|
inline |
Definition at line 148 of file PythonQtObjectPtr.h.
Referenced by operator=(), PythonQtSafeObjectPtr::operator=(), operator==(), PythonQtObjectPtr(), and PythonQtSafeObjectPtr::PythonQtSafeObjectPtr().
|
inline |
Definition at line 143 of file PythonQtObjectPtr.h.
|
inline |
Definition at line 125 of file PythonQtObjectPtr.h.
|
inline |
Definition at line 133 of file PythonQtObjectPtr.h.
|
inline |
Definition at line 141 of file PythonQtObjectPtr.h.
|
inline |
Definition at line 139 of file PythonQtObjectPtr.h.
|
inline |
Definition at line 92 of file PythonQtObjectPtr.h.
References object().
|
inline |
Definition at line 115 of file PythonQtObjectPtr.h.
|
inline |
Definition at line 109 of file PythonQtObjectPtr.h.
|
inlinenoexcept |
rvalue assignment operator that steals the reference from p
Definition at line 98 of file PythonQtObjectPtr.h.
PythonQtObjectPtr& PythonQtObjectPtr::operator= | ( | PythonQtSafeObjectPtr && | p | ) |
rvalue assignment operator that steals the reference from p
|
inline |
Definition at line 121 of file PythonQtObjectPtr.h.
References object().
|
inline |
Definition at line 129 of file PythonQtObjectPtr.h.
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 |
|
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.