Go to the documentation of this file.00001 #ifndef _PYTHONQTMETHODINFO_H
00002 #define _PYTHONQTMETHODINFO_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00043
00044
00045 #include "PythonQtSystem.h"
00046
00047 #include <QByteArray>
00048 #include <QHash>
00049 #include <QList>
00050 #include <QMetaMethod>
00051
00052 class PythonQtClassInfo;
00053 struct _object;
00054 typedef struct _object PyObject;
00055
00057 class PYTHONQT_EXPORT PythonQtMethodInfo
00058 {
00059 public:
00060 enum ParameterType {
00061 Unknown = -1,
00062 Variant = -2
00063 };
00064
00066 struct ParameterInfo {
00067 QByteArray name;
00068 PyObject* enumWrapper;
00069 int typeId;
00070 char pointerCount;
00071 bool isConst;
00072 };
00073
00074 PythonQtMethodInfo() {};
00075 ~PythonQtMethodInfo() {};
00076 PythonQtMethodInfo(const QMetaMethod& meta, PythonQtClassInfo* classInfo);
00077 PythonQtMethodInfo(const QByteArray& typeName, const QList<QByteArray>& args);
00078 PythonQtMethodInfo(const PythonQtMethodInfo& other) {
00079 _parameters = other._parameters;
00080 }
00081
00084 static const PythonQtMethodInfo* getCachedMethodInfo(const QMetaMethod& method, PythonQtClassInfo* classInfo);
00085
00087 static const PythonQtMethodInfo* getCachedMethodInfoFromArgumentList(int numArgs, const char** args);
00088
00090 static void cleanupCachedMethodInfos();
00091
00093 int parameterCount() const { return _parameters.size(); };
00094
00096 static int nameToType(const char* name);
00097
00099 const QList<ParameterInfo>& parameters() const { return _parameters; }
00100
00102 static void addParameterTypeAlias(const QByteArray& alias, const QByteArray& name);
00103
00104 protected:
00105 static void fillParameterInfo(ParameterInfo& type, const QByteArray& name, PythonQtClassInfo* classInfo);
00106
00107 static QHash<QByteArray, int> _parameterTypeDict;
00108 static QHash<QByteArray, QByteArray> _parameterNameAliases;
00109
00111 static QHash<QByteArray, PythonQtMethodInfo*> _cachedSignatures;
00112
00113 QList<ParameterInfo> _parameters;
00114 };
00115
00117 class PythonQtSlotInfo : public PythonQtMethodInfo
00118 {
00119 public:
00120 enum Type {
00121 MemberSlot, InstanceDecorator, ClassDecorator
00122 };
00123
00124 PythonQtSlotInfo(const PythonQtSlotInfo& info):PythonQtMethodInfo() {
00125 _meta = info._meta;
00126 _parameters = info._parameters;
00127 _slotIndex = info._slotIndex;
00128 _next = NULL;
00129 _decorator = info._decorator;
00130 _type = info._type;
00131 _upcastingOffset = 0;
00132 }
00133
00134 PythonQtSlotInfo(PythonQtClassInfo* classInfo, const QMetaMethod& meta, int slotIndex, QObject* decorator = NULL, Type type = MemberSlot ):PythonQtMethodInfo()
00135 {
00136 const PythonQtMethodInfo* info = getCachedMethodInfo(meta, classInfo);
00137 _meta = meta;
00138 _parameters = info->parameters();
00139 _slotIndex = slotIndex;
00140 _next = NULL;
00141 _decorator = decorator;
00142 _type = type;
00143 _upcastingOffset = 0;
00144 }
00145
00146
00147 public:
00148
00149 void deleteOverloadsAndThis();
00150
00151 const QMetaMethod* metaMethod() const { return &_meta; }
00152
00153 void setUpcastingOffset(int upcastingOffset) { _upcastingOffset = upcastingOffset; }
00154
00155 int upcastingOffset() const { return _upcastingOffset; }
00156
00158 int slotIndex() const { return _slotIndex; }
00159
00161 PythonQtSlotInfo* nextInfo() const { return _next; }
00162
00164 void setNextInfo(PythonQtSlotInfo* next) { _next = next; }
00165
00167 bool isInstanceDecorator() { return _decorator!=NULL && _type == InstanceDecorator; }
00168
00170 bool isClassDecorator() { return _decorator!=NULL && _type == ClassDecorator; }
00171
00172 QObject* decorator() { return _decorator; }
00173
00175 QString fullSignature();
00176
00178 QByteArray slotName();
00179
00180 private:
00181 int _slotIndex;
00182 PythonQtSlotInfo* _next;
00183 QObject* _decorator;
00184 Type _type;
00185 QMetaMethod _meta;
00186 int _upcastingOffset;
00187 };
00188
00189
00190 #endif