Abstract base class for return constructors which create PyObjects from C++ values. More...
#include <PyArgConstructor.h>
Public Member Functions | |
virtual PyObject * | Create () const =0 |
Create PyObject from value returned from QObject method. | |
virtual PyObject * | Create (void *) const =0 |
Create PyObject from parameter passed to Python callback from Qt when signal triggered. | |
virtual | ~PyArgConstructor () |
Virtual destructor. | |
virtual PyArgConstructor * | Clone () const =0 |
Return copy of object. | |
virtual QMetaType::Type | Type () const =0 |
Return type of constructed data. | |
QGenericReturnArgument | Argument () const |
Return QGenericReturnArguments holding a reference to the memory location where the returned value is stored. | |
virtual bool | IsQObjectPtr () const =0 |
Return true if type is a pointer to a QObject-derived object. | |
Protected Member Functions | |
template<typename T > | |
void | SetArg (T &arg) |
Creates return argument of the proper type. |
Abstract base class for return constructors which create PyObjects from C++ values.
There are two cases where data need to converted from Qt-C++ to Python:
In the case of (1) each parameter is directly converted to its Python format; in the case of (2) the return value must first be stored into a memory location passed to the method invocation function, and then be converted into Python format.
virtual bool qpy::PyArgConstructor::IsQObjectPtr | ( | ) | const [pure virtual] |
Return true
if type is a pointer to a QObject-derived object.
This is required to have the QPy run-time add the passed QObject into the Python context. The other option is to have PyArgConstructors::Create receive a reference to a PyContext which introduces a two-way dependency between PyArgConstructor and PyContext; this would also augment PyQArgConstructor requirements with the added responsibility of having to add instances to Python. Note that it is not enough to simply check the PyArgConstructor returned Type(), because in the case of custom registered types derived from QObject the returned type is not QObjectStar.
Implemented in qpy::ObjectStarPyArgConstructor, qpy::VoidPyArgConstructor, qpy::FloatPyArgConstructor, qpy::DoublePyArgConstructor, qpy::StringPyArgConstructor, qpy::IntPyArgConstructor, and qpy::NoPyArgConstructor.