PythonQt
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
PythonQtMethodInfo Class Reference

stores information about a specific signal/slot/method More...

#include <PythonQtMethodInfo.h>

Inheritance diagram for PythonQtMethodInfo:
PythonQtSlotInfo

Classes

struct  ParameterInfo
 stores various informations about a parameter/type name More...
 

Public Types

enum  ParameterType { Unknown = -1 , Variant = -2 }
 

Public Member Functions

 PythonQtMethodInfo ()
 
 ~PythonQtMethodInfo ()
 
 PythonQtMethodInfo (const QMetaMethod &meta, PythonQtClassInfo *classInfo)
 
 PythonQtMethodInfo (const QByteArray &typeName, const QList< QByteArray > &args)
 
 PythonQtMethodInfo (const PythonQtMethodInfo &other)
 
int parameterCount () const
 returns the number of parameters including the return value More...
 
const QList< ParameterInfo > & parameters () const
 get the parameter infos More...
 
bool shouldAllowThreads () const
 

Static Public Member Functions

static const PythonQtMethodInfogetCachedMethodInfo (const QMetaMethod &method, PythonQtClassInfo *classInfo)
 
static const PythonQtMethodInfogetCachedMethodInfoFromArgumentList (int numArgs, const char **args)
 get the cached method info using the passed in list of return value and arguments, return value needs to be passed as first arg More...
 
static void cleanupCachedMethodInfos ()
 cleanup the cache More...
 
static int nameToType (const char *name)
 returns the id for the given type (using an internal dictionary) More...
 
static void addParameterTypeAlias (const QByteArray &alias, const QByteArray &name)
 add an alias for a typename, e.g. QObjectList and QList<QObject*>. More...
 
static void fillParameterInfo (ParameterInfo &type, const QByteArray &name, PythonQtClassInfo *classInfo=nullptr)
 fill the parameter info for the given type name More...
 
static const ParameterInfogetParameterInfoForMetaType (int type)
 returns a parameter info for the given metatype (and creates and caches one if it is not yet present) More...
 
static int getInnerTemplateMetaType (const QByteArray &typeName)
 returns the inner type id of a simple template of the form SomeObject<InnerType> More...
 
static QByteArray getInnerTemplateTypeName (const QByteArray &typeName)
 returns the inner type name of a simple template of the form SomeObject<InnerType> More...
 
static QByteArray getInnerListTypeName (const QByteArray &typeName)
 returns the inner type name of a simple template or the typename without appended "List". More...
 

Protected Member Functions

void setupAllowThreads ()
 

Protected Attributes

QList< ParameterInfo_parameters
 
bool _shouldAllowThreads
 

Static Protected Attributes

static QHash< QByteArray, int > _parameterTypeDict
 
static QHash< QByteArray, QByteArray > _parameterNameAliases
 
static QHash< QByteArray, PythonQtMethodInfo * > _cachedSignatures
 stores the cached signatures of methods to speedup mapping from Qt to Python types More...
 
static QHash< int, ParameterInfo_cachedParameterInfos
 

Detailed Description

stores information about a specific signal/slot/method

Definition at line 58 of file PythonQtMethodInfo.h.

Member Enumeration Documentation

◆ ParameterType

Enumerator
Unknown 
Variant 

Definition at line 61 of file PythonQtMethodInfo.h.

61  {
62  Unknown = -1,
63  Variant = -2
64  };

Constructor & Destructor Documentation

◆ PythonQtMethodInfo() [1/4]

PythonQtMethodInfo::PythonQtMethodInfo ( )
inline

Definition at line 82 of file PythonQtMethodInfo.h.

82  {
83  _shouldAllowThreads = true;
84  };

◆ ~PythonQtMethodInfo()

PythonQtMethodInfo::~PythonQtMethodInfo ( )
inline

Definition at line 85 of file PythonQtMethodInfo.h.

85 {};

◆ PythonQtMethodInfo() [2/4]

PythonQtMethodInfo::PythonQtMethodInfo ( const QMetaMethod &  meta,
PythonQtClassInfo classInfo 
)

◆ PythonQtMethodInfo() [3/4]

PythonQtMethodInfo::PythonQtMethodInfo ( const QByteArray &  typeName,
const QList< QByteArray > &  args 
)

◆ PythonQtMethodInfo() [4/4]

PythonQtMethodInfo::PythonQtMethodInfo ( const PythonQtMethodInfo other)
inline

Definition at line 88 of file PythonQtMethodInfo.h.

88  {
89  _parameters = other._parameters;
91  }
QList< ParameterInfo > _parameters

References _parameters, and _shouldAllowThreads.

Member Function Documentation

◆ addParameterTypeAlias()

static void PythonQtMethodInfo::addParameterTypeAlias ( const QByteArray &  alias,
const QByteArray &  name 
)
static

add an alias for a typename, e.g. QObjectList and QList<QObject*>.

◆ cleanupCachedMethodInfos()

static void PythonQtMethodInfo::cleanupCachedMethodInfos ( )
static

cleanup the cache

◆ fillParameterInfo()

static void PythonQtMethodInfo::fillParameterInfo ( ParameterInfo type,
const QByteArray &  name,
PythonQtClassInfo classInfo = nullptr 
)
static

fill the parameter info for the given type name

◆ getCachedMethodInfo()

static const PythonQtMethodInfo* PythonQtMethodInfo::getCachedMethodInfo ( const QMetaMethod &  method,
PythonQtClassInfo classInfo 
)
static

returns the method info of the signature, uses a cache internally to speed up multiple requests for the same method, classInfo is passed to allow local enum resolution (if NULL is passed, no local enums are recognized)

◆ getCachedMethodInfoFromArgumentList()

static const PythonQtMethodInfo* PythonQtMethodInfo::getCachedMethodInfoFromArgumentList ( int  numArgs,
const char **  args 
)
static

get the cached method info using the passed in list of return value and arguments, return value needs to be passed as first arg

◆ getInnerListTypeName()

static QByteArray PythonQtMethodInfo::getInnerListTypeName ( const QByteArray &  typeName)
static

returns the inner type name of a simple template or the typename without appended "List".

Referenced by PythonQtConvertListOfKnownClassToPythonList(), and PythonQtConvertPythonListToListOfKnownClass().

◆ getInnerTemplateMetaType()

static int PythonQtMethodInfo::getInnerTemplateMetaType ( const QByteArray &  typeName)
static

◆ getInnerTemplateTypeName()

static QByteArray PythonQtMethodInfo::getInnerTemplateTypeName ( const QByteArray &  typeName)
static

returns the inner type name of a simple template of the form SomeObject<InnerType>

Referenced by PythonQtConvertIntegerMapToPython(), PythonQtConvertPairToPython(), PythonQtConvertPythonToIntegerMap(), and PythonQtConvertPythonToPair().

◆ getParameterInfoForMetaType()

static const ParameterInfo& PythonQtMethodInfo::getParameterInfoForMetaType ( int  type)
static

returns a parameter info for the given metatype (and creates and caches one if it is not yet present)

◆ nameToType()

static int PythonQtMethodInfo::nameToType ( const char *  name)
static

returns the id for the given type (using an internal dictionary)

◆ parameterCount()

int PythonQtMethodInfo::parameterCount ( ) const
inline

returns the number of parameters including the return value

Definition at line 104 of file PythonQtMethodInfo.h.

104 { return _parameters.size(); };

◆ parameters()

const QList<ParameterInfo>& PythonQtMethodInfo::parameters ( ) const
inline

get the parameter infos

Definition at line 110 of file PythonQtMethodInfo.h.

110 { return _parameters; }

Referenced by PythonQtSlotInfo::PythonQtSlotInfo().

◆ setupAllowThreads()

void PythonQtMethodInfo::setupAllowThreads ( )
protected

◆ shouldAllowThreads()

bool PythonQtMethodInfo::shouldAllowThreads ( ) const
inline

returns if the GIL should be released when calling this method. This is the default, but it will return false if any of the parameters is a PythonQtObjectPtr or PyObject*.

Definition at line 133 of file PythonQtMethodInfo.h.

133 { return _shouldAllowThreads; }

Referenced by PythonQtSlotInfo::PythonQtSlotInfo().

Member Data Documentation

◆ _cachedParameterInfos

QHash<int, ParameterInfo> PythonQtMethodInfo::_cachedParameterInfos
staticprotected

Definition at line 144 of file PythonQtMethodInfo.h.

◆ _cachedSignatures

QHash<QByteArray, PythonQtMethodInfo*> PythonQtMethodInfo::_cachedSignatures
staticprotected

stores the cached signatures of methods to speedup mapping from Qt to Python types

Definition at line 142 of file PythonQtMethodInfo.h.

◆ _parameterNameAliases

QHash<QByteArray, QByteArray> PythonQtMethodInfo::_parameterNameAliases
staticprotected

Definition at line 139 of file PythonQtMethodInfo.h.

◆ _parameters

QList<ParameterInfo> PythonQtMethodInfo::_parameters
protected

Definition at line 146 of file PythonQtMethodInfo.h.

Referenced by PythonQtMethodInfo(), and PythonQtSlotInfo::PythonQtSlotInfo().

◆ _parameterTypeDict

QHash<QByteArray, int> PythonQtMethodInfo::_parameterTypeDict
staticprotected

Definition at line 138 of file PythonQtMethodInfo.h.

◆ _shouldAllowThreads

bool PythonQtMethodInfo::_shouldAllowThreads
protected

Definition at line 147 of file PythonQtMethodInfo.h.

Referenced by PythonQtMethodInfo(), and PythonQtSlotInfo::PythonQtSlotInfo().


The documentation for this class was generated from the following file: