1#ifndef _PYTHONQTCLASSINFO_H
2#define _PYTHONQTCLASSINFO_H
99 , _upcastingOffset(upcastingOffset) {};
164 void*
castTo(
void* ptr,
const char* classname);
256 void updateRefCountingCBs();
258 void createEnumWrappers(
const QObject* decoratorProvider);
259 void createEnumWrappers(
const QMetaObject* meta);
260 PyObject* findEnumWrapper(
const char* name);
263 void clearCachedMembers();
265 void* recursiveCastDownIfPossible(
void* ptr,
const char** resultClassName);
268 bool& found, QHash<QByteArray, PythonQtMemberInfo>& memberCache,
int upcastingOffset);
269 void listDecoratorSlotsFromDecoratorProvider(QStringList& list,
bool metaOnly);
270 PythonQtSlotInfo* recursiveFindDecoratorSlotsFromDecoratorProvider(
const char* memberName,
271 PythonQtSlotInfo* inputInfo,
bool& found, QHash<QByteArray, PythonQtMemberInfo>& memberCache,
int upcastingOffset);
273 void recursiveCollectClassInfos(QList<PythonQtClassInfo*>& classInfoObjects);
274 void recursiveCollectDecoratorObjects(QList<QObject*>& decoratorObjects);
276 bool lookForPropertyAndCache(
const char* memberName);
277 bool lookForMethodAndCache(
const char* memberName);
278 bool lookForEnumAndCache(
const QMetaObject* m,
const char* memberName);
281 QHash<QByteArray, PythonQtMemberInfo>& memberCache,
int upcastingOffset);
282 int findCharOffset(
const char* sigStart,
char someChar);
284 QHash<QByteArray, PythonQtMemberInfo> _cachedMembers;
292 QList<PythonQtSlotInfo*> _decoratorSlots;
294 QList<PythonQtObjectPtr> _enumWrappers;
296 const QMetaObject* _meta;
298 QByteArray _wrappedClassName;
299 QList<ParentClassInfo> _parentClasses;
301 QList<PythonQtPolymorphicHandlerCB*> _polymorphicHandlers;
303 QList<PythonQtClassInfo*> _nestedClasses;
305 QObject* _decoratorProvider;
317 bool _richCompareDetectionDone;
318 bool _searchPolymorphicHandlerOnParent;
319 bool _searchRefCountCB;
321 static QList<PythonQtClassInfo*> _globalNamespaceWrappers;
323 static QSet<QByteArray> _reservedNames;
void PythonQtShellSetInstanceWrapperCB(void *object, PythonQtInstanceWrapper *wrapper)
void * PythonQtPolymorphicHandlerCB(const void *ptr, const char **class_name)
void PythonQtVoidPtrCB(void *object)
QObject * PythonQtQObjectCreatorFunctionCB()
callback to create a QObject lazily
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.
const QMetaObject * metaObject()
get the meta object
bool supportsRichCompare()
void addNestedClass(PythonQtClassInfo *info)
add a nested class, so that it can be shown as outer class member
bool isCPPWrapper()
returns if the class is a CPP wrapper
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())
PythonQtSlotInfo * destructor()
get access to the destructor slot
void setDecoratorProvider(PythonQtQObjectCreatorFunctionCB *cb)
set an additional decorator provider that offers additional decorator slots for this class
const QList< PythonQtClassInfo * > & nestedClasses()
get nested classes
int typeSlots() const
get the type capabilities
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
void addPolymorphicHandler(PythonQtPolymorphicHandlerCB *cb)
add a handler for polymorphic downcasting
void * castTo(void *ptr, const char *classname)
PyObject * getPythonTypeForProperty(const QString &name)
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
PythonQtVoidPtrCB * referenceCountingRefCB()
Returns the ref counting CB, if there is any.
PythonQtSlotInfo * getCopyConstructor()
Get the copy constructor for this class.
PythonQtShellSetInstanceWrapperCB * shellSetInstanceWrapperCB()
get the shell set instance wrapper cb
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
PythonQtClassInfo * getClassInfoForProperty(const QString &name)
Returns the class info for given property, if available.
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
PyObject * pythonQtClassWrapper()
get the associated PythonQtClassWrapper (which handles instance creation of this type)
void * castDownIfPossible(void *ptr, PythonQtClassInfo **resultClassInfo)
cast the pointer down in the class hierarchy if a polymorphic handler allows to do that
PyObject * copyObject(void *cppObject)
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.
void setTypeSlots(int typeSlots)
set the type capabilities
PythonQtSlotInfo * constructors()
get access to the constructor slot (which may be overloaded if there are multiple constructors)
static void clearGlobalNamespaceWrappers()
void setPythonQtClassWrapper(PyObject *obj)
set 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
const QByteArray & className() const
get the classname (either of the QObject or of the wrapped CPP object)
static void addGlobalNamespaceWrapper(PythonQtClassInfo *namespaceWrapper)
Add a wrapper that contains global enums.
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,...
QObject * decorator()
get the decorator qobject instance
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)