1 #ifndef _PYTHONQTCLASSINFO_H
2 #define _PYTHONQTCLASSINFO_H
38 #include <QMetaObject>
39 #include <QMetaMethod>
156 void*
castTo(
void* ptr,
const char* classname);
187 _shellSetInstanceWrapperCB = cb;
192 return _shellSetInstanceWrapperCB;
248 void updateRefCountingCBs();
250 void createEnumWrappers(
const QObject* decoratorProvider);
251 void createEnumWrappers(
const QMetaObject* meta);
252 PyObject* findEnumWrapper(
const char* name);
255 void clearCachedMembers();
257 void* recursiveCastDownIfPossible(
void* ptr,
const char** resultClassName);
259 PythonQtSlotInfo* findDecoratorSlotsFromDecoratorProvider(
const char* memberName,
PythonQtSlotInfo* inputInfo,
bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache,
int upcastingOffset);
260 void listDecoratorSlotsFromDecoratorProvider(QStringList& list,
bool metaOnly);
261 PythonQtSlotInfo* recursiveFindDecoratorSlotsFromDecoratorProvider(
const char* memberName,
PythonQtSlotInfo* inputInfo,
bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache,
int upcastingOffset);
263 void recursiveCollectClassInfos(QList<PythonQtClassInfo*>& classInfoObjects);
264 void recursiveCollectDecoratorObjects(QList<QObject*>& decoratorObjects);
266 bool lookForPropertyAndCache(
const char* memberName);
267 bool lookForMethodAndCache(
const char* memberName);
268 bool lookForEnumAndCache(
const QMetaObject* m,
const char* memberName);
270 PythonQtSlotInfo* findDecoratorSlots(
const char* memberName,
PythonQtSlotInfo* tail,
bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache,
int upcastingOffset);
271 int findCharOffset(
const char* sigStart,
char someChar);
273 QHash<QByteArray, PythonQtMemberInfo> _cachedMembers;
281 QList<PythonQtSlotInfo*> _decoratorSlots;
283 QList<PythonQtObjectPtr> _enumWrappers;
285 const QMetaObject* _meta;
287 QByteArray _wrappedClassName;
288 QList<ParentClassInfo> _parentClasses;
290 QList<PythonQtPolymorphicHandlerCB*> _polymorphicHandlers;
292 QList<PythonQtClassInfo*> _nestedClasses;
294 QObject* _decoratorProvider;
306 bool _richCompareDetectionDone;
307 bool _searchPolymorphicHandlerOnParent;
308 bool _searchRefCountCB;
310 static QList<PythonQtClassInfo*> _globalNamespaceWrappers;
312 static QSet<QByteArray> _reservedNames;
QObject * PythonQtQObjectCreatorFunctionCB()
callback to create a QObject lazily
void PythonQtShellSetInstanceWrapperCB(void *object, PythonQtInstanceWrapper *wrapper)
void PythonQtVoidPtrCB(void *object)
void * PythonQtPolymorphicHandlerCB(const void *ptr, const char **class_name)
a class that stores all required information about a Qt object (and an optional associated C++ class ...
void setShellSetInstanceWrapperCB(PythonQtShellSetInstanceWrapperCB *cb)
set the shell set instance wrapper cb
void setReferenceCounting(PythonQtVoidPtrCB *refCB, PythonQtVoidPtrCB *unrefCB)
Sets reference counting callbacks for this class and all its subclasses.
bool supportsRichCompare()
void addNestedClass(PythonQtClassInfo *info)
add a nested class, so that it can be shown as outer class member
PythonQtClassInfo * getClassInfoForProperty(const QString &name)
Returns the class info for given property, if available.
bool isCPPWrapper()
returns if the class is a CPP wrapper
PyObject * copyObject(void *cppObject)
bool inherits(const char *classname)
returns if this class inherits from the given classname
void addDecoratorSlot(PythonQtSlotInfo *info)
add a decorator slot, ownership is passed to classinfo
void clearNotFoundCachedMembers()
clear all members that where cached as "NotFound"
QStringList memberList()
get list of all members (excluding properties, which can be listed with propertyList())
void setDecoratorProvider(PythonQtQObjectCreatorFunctionCB *cb)
set an additional decorator provider that offers additional decorator slots for this class
PythonQtSlotInfo * constructors()
get access to the constructor slot (which may be overloaded if there are multiple constructors)
int typeSlots() const
get the type capabilities
PythonQtShellSetInstanceWrapperCB * shellSetInstanceWrapperCB()
get the shell set instance wrapper cb
int metaTypeId()
get the meta type id of this class (only valid for isCPPWrapper() == true)
void addParentClass(const ParentClassInfo &info)
add the parent class info of a CPP object
QString help()
get help string for the metaobject
PythonQtSlotInfo * destructor()
get access to the destructor slot
void addPolymorphicHandler(PythonQtPolymorphicHandlerCB *cb)
add a handler for polymorphic downcasting
PythonQtVoidPtrCB * referenceCountingRefCB()
Returns the ref counting CB, if there is any.
static QByteArray escapeReservedNames(const QByteArray &name)
bool isQObject()
returns if the QObject
bool inherits(PythonQtClassInfo *info)
returns if this class inherits from the given classinfo
static PyObject * findEnumWrapper(const QByteArray &name, PythonQtClassInfo *localScope, bool *isLocalEnum=nullptr)
returns if the localScope has an enum of that type name or if the enum contains a :: scope,...
QStringList propertyList()
get list of all properties (on QObjects only, otherwise the list is empty)
void setupCPPObject(const QByteArray &classname)
setup as a CPP (non-QObject), taking the classname
void setDestructor(PythonQtSlotInfo *info)
set a destructor, ownership is passed to classinfo
PythonQtMemberInfo member(const char *member)
get the Python method definition for a given slot name (without return type and signature)
void addConstructor(PythonQtSlotInfo *info)
add a constructor, ownership is passed to classinfo
void setMetaObject(const QMetaObject *meta)
set the meta object, this will reset the caching
QByteArray unscopedClassName() const
get the unscoped classname (without ParentClass::) for nested classes
PythonQtVoidPtrCB * referenceCountingUnrefCB()
Returns the unref counting CB, if there is any.
PythonQtSlotInfo * getCopyConstructor()
Get the copy constructor for this class.
void setTypeSlots(int typeSlots)
set the type capabilities
void * castTo(void *ptr, const char *classname)
const QList< PythonQtClassInfo * > & nestedClasses()
get nested classes
void setPythonQtClassWrapper(PyObject *obj)
set the associated PythonQtClassWrapper (which handles instance creation of this type)
PyObject * pythonQtClassWrapper()
get the associated PythonQtClassWrapper (which handles instance creation of this type)
void setupQObject(const QMetaObject *meta)
setup as a QObject, taking the meta object as meta information about the QObject
QObject * decorator()
get the decorator qobject instance
static void addGlobalNamespaceWrapper(PythonQtClassInfo *namespaceWrapper)
Add a wrapper that contains global enums.
const QMetaObject * metaObject()
get the meta object
PyObject * getPythonTypeForProperty(const QString &name)
void * castDownIfPossible(void *ptr, PythonQtClassInfo **resultClassInfo)
cast the pointer down in the class hierarchy if a polymorphic handler allows to do that
const QByteArray & className() const
get the classname (either of the QObject or of the wrapped CPP object)
a smart pointer that stores a PyObject pointer and that handles reference counting automatically
stores information about a slot, including a next pointer to overloaded slots
store information about parent classes
ParentClassInfo(PythonQtClassInfo *parent, int upcastingOffset=0)
PythonQtClassInfo * _parent
~PythonQtDynamicClassInfo()
const QMetaObject * _dynamicMetaObject
PythonQtClassInfo * _classInfo
PythonQtDynamicClassInfo()
PythonQtObjectPtr _enumValue
PythonQtMemberInfo(const QMetaProperty &prop)
PythonQtMemberInfo(const PythonQtObjectPtr &enumValue)
PythonQtMemberInfo(PythonQtSlotInfo *info)