##// END OF EJS Templates
updated to upstream state in MeVisLab repository...
florianlink -
r157:78da86ccde11
parent child
Show More
@@ -80,7 +80,7 void PythonQt::init(int flags, const QByteArray& pythonQtModuleName)
80
80
81 PythonQt_init_QtCoreBuiltin(NULL);
81 PythonQt_init_QtCoreBuiltin(NULL);
82 PythonQt_init_QtGuiBuiltin(NULL);
82 PythonQt_init_QtGuiBuiltin(NULL);
83
83
84 PythonQtRegisterToolClassesTemplateConverter(QByteArray);
84 PythonQtRegisterToolClassesTemplateConverter(QByteArray);
85 PythonQtRegisterToolClassesTemplateConverter(QDate);
85 PythonQtRegisterToolClassesTemplateConverter(QDate);
86 PythonQtRegisterToolClassesTemplateConverter(QTime);
86 PythonQtRegisterToolClassesTemplateConverter(QTime);
@@ -157,7 +157,7 PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName)
157 }
157 }
158 Py_Initialize();
158 Py_Initialize();
159 }
159 }
160
160
161 // add our own python object types for qt object slots
161 // add our own python object types for qt object slots
162 if (PyType_Ready(&PythonQtSlotFunction_Type) < 0) {
162 if (PyType_Ready(&PythonQtSlotFunction_Type) < 0) {
163 std::cerr << "could not initialize PythonQtSlotFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
163 std::cerr << "could not initialize PythonQtSlotFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
@@ -245,6 +245,14 void PythonQtPrivate::registerClass(const QMetaObject* metaobject, const char* p
245 PythonQtClassInfo* parentInfo = lookupClassInfoAndCreateIfNotPresent(m->superClass()->className());
245 PythonQtClassInfo* parentInfo = lookupClassInfoAndCreateIfNotPresent(m->superClass()->className());
246 info->addParentClass(PythonQtClassInfo::ParentClassInfo(parentInfo));
246 info->addParentClass(PythonQtClassInfo::ParentClassInfo(parentInfo));
247 }
247 }
248 } else if (first && module) {
249 // There is a wrapper already, but if we got a module, we want to place the wrapper into that module as well,
250 // since it might have been placed into "private" earlier on.
251 // If the wrapper was already added to module before, it is just readded, which does no harm.
252 PyObject* classWrapper = info->pythonQtClassWrapper();
253 // AddObject steals a reference, so we need to INCREF
254 Py_INCREF(classWrapper);
255 PyModule_AddObject(module, info->className(), classWrapper);
248 }
256 }
249 if (first) {
257 if (first) {
250 first = false;
258 first = false;
@@ -913,6 +921,7 PythonQtPrivate::PythonQtPrivate()
913 _noLongerWrappedCB = NULL;
921 _noLongerWrappedCB = NULL;
914 _wrappedCB = NULL;
922 _wrappedCB = NULL;
915 _currentClassInfoForClassWrapperCreation = NULL;
923 _currentClassInfoForClassWrapperCreation = NULL;
924 _profilingCB = NULL;
916 }
925 }
917
926
918 void PythonQtPrivate::setupSharedLibrarySuffixes()
927 void PythonQtPrivate::setupSharedLibrarySuffixes()
@@ -922,6 +931,14 void PythonQtPrivate::setupSharedLibrarySuffixes()
922 imp.setNewRef(PyImport_ImportModule("imp"));
931 imp.setNewRef(PyImport_ImportModule("imp"));
923 int cExtensionCode = imp.getVariable("C_EXTENSION").toInt();
932 int cExtensionCode = imp.getVariable("C_EXTENSION").toInt();
924 QVariant result = imp.call("get_suffixes");
933 QVariant result = imp.call("get_suffixes");
934 #ifdef __linux
935 #ifdef _DEBUG
936 // First look for shared libraries with the '_d' suffix in debug mode on Linux.
937 // This is a workaround, because python does not append the '_d' suffix on Linux
938 // and would always load the release library otherwise.
939 _sharedLibrarySuffixes << "_d.so";
940 #endif
941 #endif
925 foreach (QVariant entry, result.toList()) {
942 foreach (QVariant entry, result.toList()) {
926 QVariantList suffixEntry = entry.toList();
943 QVariantList suffixEntry = entry.toList();
927 if (suffixEntry.count()==3) {
944 if (suffixEntry.count()==3) {
@@ -1066,6 +1083,10 void PythonQt::setQObjectNoLongerWrappedCallback(PythonQtQObjectNoLongerWrappedC
1066 _p->_noLongerWrappedCB = cb;
1083 _p->_noLongerWrappedCB = cb;
1067 }
1084 }
1068
1085
1086 void PythonQt::setProfilingCallback(ProfilingCB* cb)
1087 {
1088 _p->_profilingCB = cb;
1089 }
1069
1090
1070
1091
1071 static PyMethodDef PythonQtMethods[] = {
1092 static PyMethodDef PythonQtMethods[] = {
@@ -1080,7 +1101,7 void PythonQt::initPythonQtModule(bool redirectStdOut, const QByteArray& pythonQ
1080 }
1101 }
1081 _p->_pythonQtModule = Py_InitModule(name.constData(), PythonQtMethods);
1102 _p->_pythonQtModule = Py_InitModule(name.constData(), PythonQtMethods);
1082 _p->_pythonQtModuleName = name;
1103 _p->_pythonQtModuleName = name;
1083
1104
1084 if (redirectStdOut) {
1105 if (redirectStdOut) {
1085 PythonQtObjectPtr sys;
1106 PythonQtObjectPtr sys;
1086 PythonQtObjectPtr out;
1107 PythonQtObjectPtr out;
@@ -1194,6 +1215,13 PyObject* PythonQt::helpCalled(PythonQtClassInfo* info)
1194 }
1215 }
1195 }
1216 }
1196
1217
1218 void PythonQt::clearNotFoundCachedMembers()
1219 {
1220 foreach(PythonQtClassInfo* info, _p->_knownClassInfos) {
1221 info->clearNotFoundCachedMembers();
1222 }
1223 }
1224
1197 void PythonQtPrivate::removeWrapperPointer(void* obj)
1225 void PythonQtPrivate::removeWrapperPointer(void* obj)
1198 {
1226 {
1199 _wrappedObjects.remove(obj);
1227 _wrappedObjects.remove(obj);
@@ -75,7 +75,7 template<class T> void PythonQtSetInstanceWrapperOnShell(void* object, PythonQtI
75
75
76 //! returns the offset that needs to be added to upcast an object of type T1 to T2
76 //! returns the offset that needs to be added to upcast an object of type T1 to T2
77 template<class T1, class T2> int PythonQtUpcastingOffset() {
77 template<class T1, class T2> int PythonQtUpcastingOffset() {
78 return (((char*)(static_cast<T2*>(reinterpret_cast<T1*>(0x100)))) - ((char*)reinterpret_cast<T1*>(0x100)));
78 return (((char*)(static_cast<T2*>(reinterpret_cast<T1*>(0x100)))) - ((char*)reinterpret_cast<T1*>(0x100)));
79 }
79 }
80
80
81 //! callback to create a QObject lazily
81 //! callback to create a QObject lazily
@@ -143,10 +143,20 public:
143
143
144 };
144 };
145
145
146 //! enum for profiling callback
147 enum ProfilingCallbackState {
148 Enter = 1,
149 Leave = 2
150 };
151
152 //! callback for profiling. className and methodName are only passed when state == Enter, otherwise
153 //! they are NULL.
154 typedef void ProfilingCB(ProfilingCallbackState state, const char* className, const char* methodName);
155
146 //---------------------------------------------------------------------------
156 //---------------------------------------------------------------------------
147 //! \name Singleton Initialization
157 //! \name Singleton Initialization
148 //@{
158 //@{
149
159
150 //! initialize the python qt binding (flags are a or combination of PythonQt::InitFlags), if \c pythonQtModuleName is given
160 //! initialize the python qt binding (flags are a or combination of PythonQt::InitFlags), if \c pythonQtModuleName is given
151 //! it defines the name of the python module that PythonQt will add, otherwise "PythonQt" is used.
161 //! it defines the name of the python module that PythonQt will add, otherwise "PythonQt" is used.
152 //! This can be used to e.g. pass in PySide or PyQt4 to make it more compatible.
162 //! This can be used to e.g. pass in PySide or PyQt4 to make it more compatible.
@@ -159,7 +169,7 public:
159 static PythonQt* self() { return _self; }
169 static PythonQt* self() { return _self; }
160
170
161 //@}
171 //@}
162
172
163 //! defines the object types for introspection
173 //! defines the object types for introspection
164 enum ObjectType {
174 enum ObjectType {
165 Class,
175 Class,
@@ -186,13 +196,13 public:
186 //! to a module later on.
196 //! to a module later on.
187 //! The user needs to make sure that the \c name is unique in the python module dictionary.
197 //! The user needs to make sure that the \c name is unique in the python module dictionary.
188 PythonQtObjectPtr createModuleFromFile(const QString& name, const QString& filename);
198 PythonQtObjectPtr createModuleFromFile(const QString& name, const QString& filename);
189
199
190 //! creates the new module \c name and evaluates the given script in the context of that module.
200 //! creates the new module \c name and evaluates the given script in the context of that module.
191 //! If the \c script is empty, the module contains no initial code. You can use evalScript/evalCode to add code
201 //! If the \c script is empty, the module contains no initial code. You can use evalScript/evalCode to add code
192 //! to a module later on.
202 //! to a module later on.
193 //! The user needs to make sure that the \c name is unique in the python module dictionary.
203 //! The user needs to make sure that the \c name is unique in the python module dictionary.
194 PythonQtObjectPtr createModuleFromScript(const QString& name, const QString& script = QString());
204 PythonQtObjectPtr createModuleFromScript(const QString& name, const QString& script = QString());
195
205
196 //! create a uniquely named module, you can use evalFile or evalScript to populate the module with
206 //! create a uniquely named module, you can use evalFile or evalScript to populate the module with
197 //! script code
207 //! script code
198 PythonQtObjectPtr createUniqueModule();
208 PythonQtObjectPtr createUniqueModule();
@@ -213,20 +223,20 public:
213 void setModuleImportPath(PyObject* module, const QStringList& paths);
223 void setModuleImportPath(PyObject* module, const QStringList& paths);
214
224
215 //@}
225 //@}
216
226
217 //---------------------------------------------------------------------------
227 //---------------------------------------------------------------------------
218 //! \name Registering Classes
228 //! \name Registering Classes
219 //@{
229 //@{
220
230
221 //! registers a QObject derived class to PythonQt (this is implicitly called by addObject as well)
231 //! registers a QObject derived class to PythonQt (this is implicitly called by addObject as well)
222 /* Since Qt4 does not offer a way to detect if a given classname is derived from QObject and thus has a QMetaObject,
232 /* Since Qt4 does not offer a way to detect if a given classname is derived from QObject and thus has a QMetaObject,
223 you MUST register all your QObject derived classes here when you want them to be detected in signal and slot calls */
233 you MUST register all your QObject derived classes here when you want them to be detected in signal and slot calls */
224 void registerClass(const QMetaObject* metaobject, const char* package = NULL, PythonQtQObjectCreatorFunctionCB* wrapperCreator = NULL, PythonQtShellSetInstanceWrapperCB* shell = NULL);
234 void registerClass(const QMetaObject* metaobject, const char* package = NULL, PythonQtQObjectCreatorFunctionCB* wrapperCreator = NULL, PythonQtShellSetInstanceWrapperCB* shell = NULL);
225
235
226 //! add a wrapper object for the given QMetaType typeName, also does an addClassDecorators() to add constructors for variants
236 //! add a wrapper object for the given QMetaType typeName, also does an addClassDecorators() to add constructors for variants
227 //! (ownership of wrapper is passed to PythonQt)
237 //! (ownership of wrapper is passed to PythonQt)
228 /*! Make sure that you have done a qRegisterMetaType first, if typeName is a user type!
238 /*! Make sure that you have done a qRegisterMetaType first, if typeName is a user type!
229
239
230 This will add a wrapper object that is used to make calls to the given classname \c typeName.
240 This will add a wrapper object that is used to make calls to the given classname \c typeName.
231 All slots that take a pointer to typeName as the first argument will be callable from Python on
241 All slots that take a pointer to typeName as the first argument will be callable from Python on
232 a variant object that contains such a type.
242 a variant object that contains such a type.
@@ -251,7 +261,7 public:
251 //---------------------------------------------------------------------------
261 //---------------------------------------------------------------------------
252 //! \name Script Parsing and Evaluation
262 //! \name Script Parsing and Evaluation
253 //@{
263 //@{
254
264
255 //! parses the given file and returns the python code object, this can then be used to call evalCode()
265 //! parses the given file and returns the python code object, this can then be used to call evalCode()
256 PythonQtObjectPtr parseFile(const QString& filename);
266 PythonQtObjectPtr parseFile(const QString& filename);
257
267
@@ -287,7 +297,7 public:
287
297
288 //---------------------------------------------------------------------------
298 //---------------------------------------------------------------------------
289 //! \name Variable access
299 //! \name Variable access
290 //@{
300 //@{
291
301
292 //! add the given \c qObject to the python \c object as a variable with \c name (it can be removed via clearVariable)
302 //! add the given \c qObject to the python \c object as a variable with \c name (it can be removed via clearVariable)
293 void addObject(PyObject* object, const QString& name, QObject* qObject);
303 void addObject(PyObject* object, const QString& name, QObject* qObject);
@@ -312,7 +322,7 public:
312
322
313 //---------------------------------------------------------------------------
323 //---------------------------------------------------------------------------
314 //! \name Calling Python Objects
324 //! \name Calling Python Objects
315 //@{
325 //@{
316
326
317 //! call the given python \c callable in the scope of object, returns the result converted to a QVariant
327 //! call the given python \c callable in the scope of object, returns the result converted to a QVariant
318 QVariant call(PyObject* object, const QString& callable, const QVariantList& args = QVariantList());
328 QVariant call(PyObject* object, const QString& callable, const QVariantList& args = QVariantList());
@@ -385,10 +395,10 public:
385 //---------------------------------------------------------------------------
395 //---------------------------------------------------------------------------
386 //! \name Custom Importer
396 //! \name Custom Importer
387 //@{
397 //@{
388
398
389 //! replace the internal import implementation and use the supplied interface to load files (both py and pyc files)
399 //! replace the internal import implementation and use the supplied interface to load files (both py and pyc files)
390 //! (this method should be called directly after initialization of init() and before calling overwriteSysPath().
400 //! (this method should be called directly after initialization of init() and before calling overwriteSysPath().
391 //! On the first call to this method, it will install a generic PythonQt importer in Pythons "path_hooks".
401 //! On the first call to this method, it will install a generic PythonQt importer in Pythons "path_hooks".
392 //! This is not reversible, so even setting setImporter(NULL) afterwards will
402 //! This is not reversible, so even setting setImporter(NULL) afterwards will
393 //! keep the custom PythonQt importer with a QFile default import interface.
403 //! keep the custom PythonQt importer with a QFile default import interface.
394 //! Subsequent python import calls will make use of the passed importInterface
404 //! Subsequent python import calls will make use of the passed importInterface
@@ -427,6 +437,10 public:
427 //! The error is currently just output to the python stderr, future version might implement better trace printing
437 //! The error is currently just output to the python stderr, future version might implement better trace printing
428 bool handleError();
438 bool handleError();
429
439
440 //! clear all NotFound entries on all class infos, to ensure that
441 //! newly loaded wrappers can add methods even when the object was wrapped by PythonQt before the wrapper was loaded
442 void clearNotFoundCachedMembers();
443
430 //! set a callback that is called when a QObject with parent == NULL is wrapped by pythonqt
444 //! set a callback that is called when a QObject with parent == NULL is wrapped by pythonqt
431 void setQObjectWrappedCallback(PythonQtQObjectWrappedCB* cb);
445 void setQObjectWrappedCallback(PythonQtQObjectWrappedCB* cb);
432 //! set a callback that is called when a QObject with parent == NULL is no longer wrapped by pythonqt
446 //! set a callback that is called when a QObject with parent == NULL is no longer wrapped by pythonqt
@@ -437,11 +451,14 public:
437
451
438 //! called by internal help methods
452 //! called by internal help methods
439 PyObject* helpCalled(PythonQtClassInfo* info);
453 PyObject* helpCalled(PythonQtClassInfo* info);
440
454
441 //! returns the found object or NULL
455 //! returns the found object or NULL
442 //! @return new reference
456 //! @return new reference
443 PythonQtObjectPtr lookupObject(PyObject* module, const QString& name);
457 PythonQtObjectPtr lookupObject(PyObject* module, const QString& name);
444
458
459 //! sets a callback that is called before and after function calls for profiling
460 void setProfilingCallback(ProfilingCB* cb);
461
445 //@}
462 //@}
446
463
447 signals:
464 signals:
@@ -507,7 +524,7 public:
507
524
508 //! add a handler for polymorphic downcasting
525 //! add a handler for polymorphic downcasting
509 void addPolymorphicHandler(const char* typeName, PythonQtPolymorphicHandlerCB* cb);
526 void addPolymorphicHandler(const char* typeName, PythonQtPolymorphicHandlerCB* cb);
510
527
511 //! lookup existing classinfo and return new if not yet present
528 //! lookup existing classinfo and return new if not yet present
512 PythonQtClassInfo* lookupClassInfoAndCreateIfNotPresent(const char* typeName);
529 PythonQtClassInfo* lookupClassInfoAndCreateIfNotPresent(const char* typeName);
513
530
@@ -528,13 +545,13 public:
528 //! add a wrapper object for the given QMetaType typeName, also does an addClassDecorators() to add constructors for variants
545 //! add a wrapper object for the given QMetaType typeName, also does an addClassDecorators() to add constructors for variants
529 //! (ownership of wrapper is passed to PythonQt)
546 //! (ownership of wrapper is passed to PythonQt)
530 /*! Make sure that you have done a qRegisterMetaType first, if typeName is a user type!
547 /*! Make sure that you have done a qRegisterMetaType first, if typeName is a user type!
531
548
532 This will add a wrapper object that is used to make calls to the given classname \c typeName.
549 This will add a wrapper object that is used to make calls to the given classname \c typeName.
533 All slots that take a pointer to typeName as the first argument will be callable from Python on
550 All slots that take a pointer to typeName as the first argument will be callable from Python on
534 a variant object that contains such a type.
551 a variant object that contains such a type.
535 */
552 */
536 void registerCPPClass(const char* typeName, const char* parentTypeName = NULL, const char* package = NULL, PythonQtQObjectCreatorFunctionCB* wrapperCreator = NULL, PythonQtShellSetInstanceWrapperCB* shell = NULL, PyObject* module = NULL, int typeSlots = 0);
553 void registerCPPClass(const char* typeName, const char* parentTypeName = NULL, const char* package = NULL, PythonQtQObjectCreatorFunctionCB* wrapperCreator = NULL, PythonQtShellSetInstanceWrapperCB* shell = NULL, PyObject* module = NULL, int typeSlots = 0);
537
554
538 //! as an alternative to registerClass, you can tell PythonQt the names of QObject derived classes
555 //! as an alternative to registerClass, you can tell PythonQt the names of QObject derived classes
539 //! and it will register the classes when it first sees a pointer to such a derived class
556 //! and it will register the classes when it first sees a pointer to such a derived class
540 void registerQObjectClassNames(const QStringList& names);
557 void registerQObjectClassNames(const QStringList& names);
@@ -571,10 +588,13 public:
571
588
572 //! called by virtual overloads when a python return value can not be converted to the required Qt type
589 //! called by virtual overloads when a python return value can not be converted to the required Qt type
573 void handleVirtualOverloadReturnError(const char* signature, const PythonQtMethodInfo* methodInfo, PyObject* result);
590 void handleVirtualOverloadReturnError(const char* signature, const PythonQtMethodInfo* methodInfo, PyObject* result);
574
591
575 //! get access to the PythonQt module
592 //! get access to the PythonQt module
576 PythonQtObjectPtr pythonQtModule() const { return _pythonQtModule; }
593 PythonQtObjectPtr pythonQtModule() const { return _pythonQtModule; }
577
594
595 //! returns the profiling callback, which may be NULL
596 PythonQt::ProfilingCB* profilingCB() const { return _profilingCB; }
597
578 private:
598 private:
579 //! Setup the shared library suffixes by getting them from the "imp" module.
599 //! Setup the shared library suffixes by getting them from the "imp" module.
580 void setupSharedLibrarySuffixes();
600 void setupSharedLibrarySuffixes();
@@ -605,13 +625,13 private:
605
625
606 //! the name of the PythonQt python module
626 //! the name of the PythonQt python module
607 QByteArray _pythonQtModuleName;
627 QByteArray _pythonQtModuleName;
608
628
609 //! the importer interface (if set)
629 //! the importer interface (if set)
610 PythonQtImportFileInterface* _importInterface;
630 PythonQtImportFileInterface* _importInterface;
611
631
612 //! the default importer
632 //! the default importer
613 PythonQtQFileImporter* _defaultImporter;
633 PythonQtQFileImporter* _defaultImporter;
614
634
615 PythonQtQObjectNoLongerWrappedCB* _noLongerWrappedCB;
635 PythonQtQObjectNoLongerWrappedCB* _noLongerWrappedCB;
616 PythonQtQObjectWrappedCB* _wrappedCB;
636 PythonQtQObjectWrappedCB* _wrappedCB;
617
637
@@ -625,6 +645,8 private:
625
645
626 PythonQtClassInfo* _currentClassInfoForClassWrapperCreation;
646 PythonQtClassInfo* _currentClassInfoForClassWrapperCreation;
627
647
648 PythonQt::ProfilingCB* _profilingCB;
649
628 int _initFlags;
650 int _initFlags;
629 int _PythonQtObjectPtr_metaId;
651 int _PythonQtObjectPtr_metaId;
630
652
@@ -847,3 +847,22 PyObject* PythonQtClassInfo::findEnumWrapper(const char* name) {
847 return NULL;
847 return NULL;
848 }
848 }
849
849
850 void PythonQtClassInfo::setDecoratorProvider( PythonQtQObjectCreatorFunctionCB* cb )
851 {
852 _decoratorProviderCB = cb;
853 _decoratorProvider = NULL;
854 _enumsCreated = false;
855 }
856
857 void PythonQtClassInfo::clearNotFoundCachedMembers()
858 {
859 // remove all not found entries, since a new decorator means new slots,
860 // which might have been cached as "NotFound" already.
861 QMutableHashIterator<QByteArray, PythonQtMemberInfo> it(_cachedMembers);
862 while (it.hasNext()) {
863 it.next();
864 if (it.value()._type == PythonQtMemberInfo::NotFound) {
865 it.remove();
866 }
867 }
868 }
@@ -166,7 +166,7 public:
166 int metaTypeId() { return _metaTypeId; }
166 int metaTypeId() { return _metaTypeId; }
167
167
168 //! set an additional decorator provider that offers additional decorator slots for this class
168 //! set an additional decorator provider that offers additional decorator slots for this class
169 void setDecoratorProvider(PythonQtQObjectCreatorFunctionCB* cb) { _decoratorProviderCB = cb; _decoratorProvider = NULL; }
169 void setDecoratorProvider(PythonQtQObjectCreatorFunctionCB* cb);
170
170
171 //! get the decorator qobject instance
171 //! get the decorator qobject instance
172 QObject* decorator();
172 QObject* decorator();
@@ -201,7 +201,10 public:
201
201
202 //! returns if the localScope has an enum of that type name or if the enum contains a :: scope, if that class contails the enum
202 //! returns if the localScope has an enum of that type name or if the enum contains a :: scope, if that class contails the enum
203 static PyObject* findEnumWrapper(const QByteArray& name, PythonQtClassInfo* localScope, bool* isLocalEnum = NULL);
203 static PyObject* findEnumWrapper(const QByteArray& name, PythonQtClassInfo* localScope, bool* isLocalEnum = NULL);
204
204
205 //! clear all members that where cached as "NotFound"
206 void clearNotFoundCachedMembers();
207
205 private:
208 private:
206 void createEnumWrappers();
209 void createEnumWrappers();
207 void createEnumWrappers(const QMetaObject* meta);
210 void createEnumWrappers(const QMetaObject* meta);
@@ -225,7 +228,7 private:
225
228
226 PythonQtSlotInfo* findDecoratorSlots(const char* memberName, int memberNameLen, PythonQtSlotInfo* tail, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset);
229 PythonQtSlotInfo* findDecoratorSlots(const char* memberName, int memberNameLen, PythonQtSlotInfo* tail, bool &found, QHash<QByteArray, PythonQtMemberInfo>& memberCache, int upcastingOffset);
227 int findCharOffset(const char* sigStart, char someChar);
230 int findCharOffset(const char* sigStart, char someChar);
228
231
229 QHash<QByteArray, PythonQtMemberInfo> _cachedMembers;
232 QHash<QByteArray, PythonQtMemberInfo> _cachedMembers;
230
233
231 PythonQtSlotInfo* _constructors;
234 PythonQtSlotInfo* _constructors;
@@ -266,6 +266,31 static PyObject *PythonQtClassWrapper_help(PythonQtClassWrapper* type)
266 return PythonQt::self()->helpCalled(type->classInfo());
266 return PythonQt::self()->helpCalled(type->classInfo());
267 }
267 }
268
268
269 PyObject *PythonQtClassWrapper_delete(PythonQtClassWrapper *type, PyObject *args)
270 {
271 Q_UNUSED(type);
272
273 Py_ssize_t argc = PyTuple_Size(args);
274 if (argc>0) {
275 PyObject* self = PyTuple_GET_ITEM(args, 0);
276 if (PyObject_TypeCheck(self, &PythonQtInstanceWrapper_Type)) {
277 return PythonQtInstanceWrapper_delete((PythonQtInstanceWrapper*)self);
278 }
279 }
280 return NULL;
281 }
282
283 PyObject *PythonQtClassWrapper_inherits(PythonQtClassWrapper *type, PyObject *args)
284 {
285 Q_UNUSED(type);
286 PythonQtInstanceWrapper* wrapper = NULL;
287 char *name = NULL;
288 if (!PyArg_ParseTuple(args, "O!s:PythonQtClassWrapper.inherits",&PythonQtInstanceWrapper_Type, &wrapper, &name)) {
289 return NULL;
290 }
291 return PythonQtConv::GetPyBool(wrapper->classInfo()->inherits(name));
292 }
293
269 PyObject *PythonQtClassWrapper__init__(PythonQtClassWrapper *type, PyObject *args)
294 PyObject *PythonQtClassWrapper__init__(PythonQtClassWrapper *type, PyObject *args)
270 {
295 {
271 Py_ssize_t argc = PyTuple_Size(args);
296 Py_ssize_t argc = PyTuple_Size(args);
@@ -295,16 +320,23 PyObject *PythonQtClassWrapper__init__(PythonQtClassWrapper *type, PyObject *arg
295 return NULL;
320 return NULL;
296 }
321 }
297
322
323
298 static PyMethodDef PythonQtClassWrapper_methods[] = {
324 static PyMethodDef PythonQtClassWrapper_methods[] = {
299 {"__init__", (PyCFunction)PythonQtClassWrapper__init__, METH_VARARGS,
325 {"__init__", (PyCFunction)PythonQtClassWrapper__init__, METH_VARARGS,
300 "Return the classname of the object"
326 "Init function"
301 },
327 },
302 {"className", (PyCFunction)PythonQtClassWrapper_classname, METH_NOARGS,
328 {"className", (PyCFunction)PythonQtClassWrapper_classname, METH_NOARGS,
303 "Return the classname of the object"
329 "Return the classname of the object"
304 },
330 },
331 {"inherits", (PyCFunction)PythonQtClassWrapper_inherits, METH_VARARGS,
332 "Returns if the class inherits or is of given type name"
333 },
305 {"help", (PyCFunction)PythonQtClassWrapper_help, METH_NOARGS,
334 {"help", (PyCFunction)PythonQtClassWrapper_help, METH_NOARGS,
306 "Shows the help of available methods for this class"
335 "Shows the help of available methods for this class"
307 },
336 },
337 {"delete", (PyCFunction)PythonQtClassWrapper_delete, METH_VARARGS,
338 "Deletes the given C++ object"
339 },
308 {NULL, NULL, 0 , NULL} /* Sentinel */
340 {NULL, NULL, 0 , NULL} /* Sentinel */
309 };
341 };
310
342
@@ -313,7 +345,7 static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name)
313 {
345 {
314 const char *attributeName;
346 const char *attributeName;
315 PythonQtClassWrapper *wrapper = (PythonQtClassWrapper *)obj;
347 PythonQtClassWrapper *wrapper = (PythonQtClassWrapper *)obj;
316
348
317 if ((attributeName = PyString_AsString(name)) == NULL) {
349 if ((attributeName = PyString_AsString(name)) == NULL) {
318 return NULL;
350 return NULL;
319 }
351 }
@@ -328,7 +360,7 static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name)
328 return dict;
360 return dict;
329 }
361 }
330 dict = PyDict_Copy(dict);
362 dict = PyDict_Copy(dict);
331
363
332 QStringList l = wrapper->classInfo()->memberList(false);
364 QStringList l = wrapper->classInfo()->memberList(false);
333 foreach (QString name, l) {
365 foreach (QString name, l) {
334 PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data());
366 PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data());
@@ -344,7 +376,7 static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name)
344 PyDict_SetItemString(dict, "__init__", func);
376 PyDict_SetItemString(dict, "__init__", func);
345 Py_DECREF(func);
377 Py_DECREF(func);
346 }
378 }
347 for (int i = 1;i<3;i++) {
379 for (int i = 1; PythonQtClassWrapper_methods[i].ml_name != NULL; i++) {
348 PyObject* func = PyCFunction_New(&PythonQtClassWrapper_methods[i], obj);
380 PyObject* func = PyCFunction_New(&PythonQtClassWrapper_methods[i], obj);
349 PyDict_SetItemString(dict, PythonQtClassWrapper_methods[i].ml_name, func);
381 PyDict_SetItemString(dict, PythonQtClassWrapper_methods[i].ml_name, func);
350 Py_DECREF(func);
382 Py_DECREF(func);
@@ -396,7 +428,7 static PyObject * PythonQtClassWrapper_repr(PyObject * obj)
396 {
428 {
397 PythonQtClassWrapper* wrapper = (PythonQtClassWrapper*)obj;
429 PythonQtClassWrapper* wrapper = (PythonQtClassWrapper*)obj;
398 if (wrapper->classInfo()->isCPPWrapper()) {
430 if (wrapper->classInfo()->isCPPWrapper()) {
399 const QMetaObject* meta = wrapper->classInfo()->metaObject();
431 const QMetaObject* meta = wrapper->classInfo()->metaObject();
400 if (!meta) {
432 if (!meta) {
401 QObject* decorator = wrapper->classInfo()->decorator();
433 QObject* decorator = wrapper->classInfo()->decorator();
402 if (decorator) {
434 if (decorator) {
@@ -47,7 +47,7
47
47
48 PythonQtValueStorage<qint64, 128> PythonQtConv::global_valueStorage;
48 PythonQtValueStorage<qint64, 128> PythonQtConv::global_valueStorage;
49 PythonQtValueStorage<void*, 128> PythonQtConv::global_ptrStorage;
49 PythonQtValueStorage<void*, 128> PythonQtConv::global_ptrStorage;
50 PythonQtValueStorage<QVariant, 32> PythonQtConv::global_variantStorage;
50 PythonQtValueStorageWithCleanup<QVariant, 128> PythonQtConv::global_variantStorage;
51
51
52 QHash<int, PythonQtConvertMetaTypeToPythonCB*> PythonQtConv::_metaTypeToPythonConverters;
52 QHash<int, PythonQtConvertMetaTypeToPythonCB*> PythonQtConv::_metaTypeToPythonConverters;
53 QHash<int, PythonQtConvertPythonToMetaTypeCB*> PythonQtConv::_pythonToMetaTypeConverters;
53 QHash<int, PythonQtConvertPythonToMetaTypeCB*> PythonQtConv::_pythonToMetaTypeConverters;
@@ -144,7 +144,7 public:
144
144
145 static PythonQtValueStorage<qint64, 128> global_valueStorage;
145 static PythonQtValueStorage<qint64, 128> global_valueStorage;
146 static PythonQtValueStorage<void*, 128> global_ptrStorage;
146 static PythonQtValueStorage<void*, 128> global_ptrStorage;
147 static PythonQtValueStorage<QVariant, 32> global_variantStorage;
147 static PythonQtValueStorageWithCleanup<QVariant, 128> global_variantStorage;
148
148
149 protected:
149 protected:
150 static QHash<int, PythonQtConvertMetaTypeToPythonCB*> _metaTypeToPythonConverters;
150 static QHash<int, PythonQtConvertMetaTypeToPythonCB*> _metaTypeToPythonConverters;
@@ -58,4 +58,4 public:
58
58
59 };
59 };
60
60
61 #endif No newline at end of file
61 #endif
@@ -46,7 +46,7
46 #include <QString>
46 #include <QString>
47 #include <QByteArray>
47 #include <QByteArray>
48
48
49 //! Defines an abstract interface to file access for the Python import statement.
49 //! Defines an abstract interface to file access for the Python import statement.
50 //! see PythonQt::setImporter()
50 //! see PythonQt::setImporter()
51 class PythonQtImportFileInterface {
51 class PythonQtImportFileInterface {
52
52
@@ -67,6 +67,9 public:
67 //! get the last modified data of a file
67 //! get the last modified data of a file
68 virtual QDateTime lastModifiedDate(const QString& filename) = 0;
68 virtual QDateTime lastModifiedDate(const QString& filename) = 0;
69
69
70 //! indicates that *.py files which are newer than their corresponding *.pyc files
71 //! are ignored
72 virtual bool ignoreUpdatedPythonSourceFiles() { return false; }
70 };
73 };
71
74
72 #endif No newline at end of file
75 #endif
@@ -114,6 +114,7 PythonQtImport::ModuleInfo PythonQtImport::getModuleInfo(PythonQtImporter* self,
114 info.fullPath = test;
114 info.fullPath = test;
115 info.moduleName = subname;
115 info.moduleName = subname;
116 info.type = MI_SHAREDLIBRARY;
116 info.type = MI_SHAREDLIBRARY;
117 return info;
117 }
118 }
118 }
119 }
119 return info;
120 return info;
@@ -263,7 +264,7 PythonQtImporter_load_module(PyObject *obj, PyObject *args)
263 } else {
264 } else {
264 PythonQtObjectPtr imp;
265 PythonQtObjectPtr imp;
265 imp.setNewRef(PyImport_ImportModule("imp"));
266 imp.setNewRef(PyImport_ImportModule("imp"));
266
267
267 // Create a PyList with the current path as its single element,
268 // Create a PyList with the current path as its single element,
268 // which is required for find_module (it won't accept a tuple...)
269 // which is required for find_module (it won't accept a tuple...)
269 PythonQtObjectPtr pathList;
270 PythonQtObjectPtr pathList;
@@ -276,12 +277,21 PythonQtImporter_load_module(PyObject *obj, PyObject *args)
276 args.append(QVariant::fromValue(pathList));
277 args.append(QVariant::fromValue(pathList));
277 QVariant result = imp.call("find_module", args);
278 QVariant result = imp.call("find_module", args);
278 if (result.isValid()) {
279 if (result.isValid()) {
279 // This will return a tuple with (file, pathname, description)
280 // This will return a tuple with (file, pathname, description=(suffix,mode,type))
280 QVariantList list = result.toList();
281 QVariantList list = result.toList();
281 if (list.count()==3) {
282 if (list.count()==3) {
282 // We prepend the full module name (including package prefix)
283 // We prepend the full module name (including package prefix)
283 list.prepend(fullname);
284 list.prepend(fullname);
284 // And call "load_module" with (fullname, file, pathname, description)
285 #ifdef __linux
286 #ifdef _DEBUG
287 // imp_find_module() does not respect the debug suffix '_d' on Linux,
288 // so it does not return the correct file path and we correct it now
289 // find_module opened a file to the release library, but that file handle is
290 // ignored on Linux and Windows, maybe on MacOS also.
291 list[2] = info.fullPath;
292 #endif
293 #endif
294 // And call "load_module" with (fullname, file, pathname, description=(suffix,mode,type))
285 PythonQtObjectPtr module = imp.call("load_module", list);
295 PythonQtObjectPtr module = imp.call("load_module", list);
286 mod = module.object();
296 mod = module.object();
287 if (mod) {
297 if (mod) {
@@ -559,12 +569,16 PythonQtImport::unmarshalCode(const QString& path, const QByteArray& data, time_
559 return Py_None;
569 return Py_None;
560 }
570 }
561
571
562 if (mtime != 0 && !(getLong((unsigned char *)buf + 4) == mtime)) {
572 if (mtime != 0) {
563 if (Py_VerboseFlag)
573 time_t timeDiff = getLong((unsigned char *)buf + 4) - mtime;
564 PySys_WriteStderr("# %s has bad mtime\n",
574 if (timeDiff<0) { timeDiff = -timeDiff; }
565 path.toLatin1().constData());
575 if (timeDiff > 1) {
566 Py_INCREF(Py_None);
576 if (Py_VerboseFlag)
567 return Py_None;
577 PySys_WriteStderr("# %s has bad mtime\n",
578 path.toLatin1().constData());
579 Py_INCREF(Py_None);
580 return Py_None;
581 }
568 }
582 }
569
583
570 code = PyMarshal_ReadObjectFromString(buf + 8, size - 8);
584 code = PyMarshal_ReadObjectFromString(buf + 8, size - 8);
@@ -645,7 +659,10 PythonQtImport::getMTimeOfSource(const QString& path)
645 path2.truncate(path.length()-1);
659 path2.truncate(path.length()-1);
646
660
647 if (PythonQt::importInterface()->exists(path2)) {
661 if (PythonQt::importInterface()->exists(path2)) {
648 mtime = PythonQt::importInterface()->lastModifiedDate(path2).toTime_t();
662 QDateTime t = PythonQt::importInterface()->lastModifiedDate(path2);
663 if (t.isValid()) {
664 mtime = t.toTime_t();
665 }
649 }
666 }
650
667
651 return mtime;
668 return mtime;
@@ -675,7 +692,12 PythonQtImport::getModuleCode(PythonQtImporter *self, const char* fullname, QStr
675 int ispackage = zso->type & IS_PACKAGE;
692 int ispackage = zso->type & IS_PACKAGE;
676 int isbytecode = zso->type & IS_BYTECODE;
693 int isbytecode = zso->type & IS_BYTECODE;
677
694
678 if (isbytecode) {
695 // if ignoreUpdatedPythonSourceFiles() returns true, then mtime stays 0
696 // and unmarshalCode() in getCodeFromData() will always read an existing *.pyc file,
697 // even if a newer *.py file exists. This is a release optimization where
698 // typically only *.pyc files are delivered without *.py files and reading file
699 // modification time is slow.
700 if (isbytecode && !PythonQt::importInterface()->ignoreUpdatedPythonSourceFiles()) {
679 mtime = getMTimeOfSource(test);
701 mtime = getMTimeOfSource(test);
680 }
702 }
681 code = getCodeFromData(test, isbytecode, ispackage, mtime);
703 code = getCodeFromData(test, isbytecode, ispackage, mtime);
@@ -713,7 +735,14 PyObject* PythonQtImport::getCodeFromPyc(const QString& file)
713 QString pyc = replaceExtension(file, pycStr);
735 QString pyc = replaceExtension(file, pycStr);
714 if (PythonQt::importInterface()->exists(pyc)) {
736 if (PythonQt::importInterface()->exists(pyc)) {
715 time_t mtime = 0;
737 time_t mtime = 0;
716 mtime = getMTimeOfSource(pyc);
738 // if ignoreUpdatedPythonSourceFiles() returns true, then mtime stays 0
739 // and unmarshalCode() in getCodeFromData() will always read an existing *.pyc file,
740 // even if a newer *.py file exists. This is a release optimization where
741 // typically only *.pyc files are delivered without *.py files and reading file
742 // modification time is slow.
743 if (!PythonQt::importInterface()->ignoreUpdatedPythonSourceFiles()) {
744 mtime = getMTimeOfSource(pyc);
745 }
717 code = getCodeFromData(pyc, true, false, mtime);
746 code = getCodeFromData(pyc, true, false, mtime);
718 if (code != Py_None && code != NULL) {
747 if (code != Py_None && code != NULL) {
719 return code;
748 return code;
@@ -288,12 +288,21 static PyObject *PythonQtInstanceWrapper_classname(PythonQtInstanceWrapper* obj)
288 return PyString_FromString(obj->ob_type->tp_name);
288 return PyString_FromString(obj->ob_type->tp_name);
289 }
289 }
290
290
291 PyObject *PythonQtInstanceWrapper_inherits(PythonQtInstanceWrapper* obj, PyObject *args)
292 {
293 char *name = NULL;
294 if (!PyArg_ParseTuple(args, "s:PythonQtInstanceWrapper.inherits",&name)) {
295 return NULL;
296 }
297 return PythonQtConv::GetPyBool(obj->classInfo()->inherits(name));
298 }
299
291 static PyObject *PythonQtInstanceWrapper_help(PythonQtInstanceWrapper* obj)
300 static PyObject *PythonQtInstanceWrapper_help(PythonQtInstanceWrapper* obj)
292 {
301 {
293 return PythonQt::self()->helpCalled(obj->classInfo());
302 return PythonQt::self()->helpCalled(obj->classInfo());
294 }
303 }
295
304
296 static PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self)
305 PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self)
297 {
306 {
298 PythonQtInstanceWrapper_deleteObject(self, true);
307 PythonQtInstanceWrapper_deleteObject(self, true);
299 Py_INCREF(Py_None);
308 Py_INCREF(Py_None);
@@ -305,6 +314,9 static PyMethodDef PythonQtInstanceWrapper_methods[] = {
305 {"className", (PyCFunction)PythonQtInstanceWrapper_classname, METH_NOARGS,
314 {"className", (PyCFunction)PythonQtInstanceWrapper_classname, METH_NOARGS,
306 "Return the classname of the object"
315 "Return the classname of the object"
307 },
316 },
317 {"inherits", (PyCFunction)PythonQtInstanceWrapper_inherits, METH_VARARGS,
318 "Returns if the class inherits or is of given type name"
319 },
308 {"help", (PyCFunction)PythonQtInstanceWrapper_help, METH_NOARGS,
320 {"help", (PyCFunction)PythonQtInstanceWrapper_help, METH_NOARGS,
309 "Shows the help of available methods for this class"
321 "Shows the help of available methods for this class"
310 },
322 },
@@ -371,7 +383,23 static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name)
371 case PythonQtMemberInfo::Property:
383 case PythonQtMemberInfo::Property:
372 if (wrapper->_obj) {
384 if (wrapper->_obj) {
373 if (member._property.userType() != QVariant::Invalid) {
385 if (member._property.userType() != QVariant::Invalid) {
374 return PythonQtConv::QVariantToPyObject(member._property.read(wrapper->_obj));
386
387 PythonQt::ProfilingCB* profilingCB = PythonQt::priv()->profilingCB();
388 if (profilingCB) {
389 QString methodName = "getProperty(";
390 methodName += attributeName;
391 methodName += ")";
392 profilingCB(PythonQt::Enter, wrapper->_obj->metaObject()->className(), methodName.toLatin1());
393 }
394
395 PyObject* value = PythonQtConv::QVariantToPyObject(member._property.read(wrapper->_obj));
396
397 if (profilingCB) {
398 profilingCB(PythonQt::Leave, NULL, NULL);
399 }
400
401 return value;
402
375 } else {
403 } else {
376 Py_INCREF(Py_None);
404 Py_INCREF(Py_None);
377 return Py_None;
405 return Py_None;
@@ -475,7 +503,19 static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec
475 }
503 }
476 bool success = false;
504 bool success = false;
477 if (v.isValid()) {
505 if (v.isValid()) {
506 PythonQt::ProfilingCB* profilingCB = PythonQt::priv()->profilingCB();
507 if (profilingCB) {
508 QString methodName = "setProperty(";
509 methodName += attributeName;
510 methodName += ")";
511 profilingCB(PythonQt::Enter, wrapper->_obj->metaObject()->className(), methodName.toLatin1());
512 }
513
478 success = prop.write(wrapper->_obj, v);
514 success = prop.write(wrapper->_obj, v);
515
516 if (profilingCB) {
517 profilingCB(PythonQt::Leave, NULL, NULL);
518 }
479 }
519 }
480 if (success) {
520 if (success) {
481 return 0;
521 return 0;
@@ -605,17 +645,17 static PyObject * PythonQtInstanceWrapper_repr(PyObject * obj)
605 if (str.startsWith(typeName)) {
645 if (str.startsWith(typeName)) {
606 return PyString_FromFormat("%s", str.toLatin1().constData());
646 return PyString_FromFormat("%s", str.toLatin1().constData());
607 } else {
647 } else {
608 return PyString_FromFormat("%s(%s, %p)", typeName, str.toLatin1().constData(), wrapper->_wrappedPtr);
648 return PyString_FromFormat("%s (%s, at: %p)", typeName, str.toLatin1().constData(), wrapper->_wrappedPtr ? wrapper->_wrappedPtr : qobj);
609 }
649 }
610 }
650 }
611 if (wrapper->_wrappedPtr) {
651 if (wrapper->_wrappedPtr) {
612 if (wrapper->_obj) {
652 if (wrapper->_obj) {
613 return PyString_FromFormat("%s (C++ Object %p wrapped by %s %p))", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj);
653 return PyString_FromFormat("%s (C++ object at: %p wrapped by %s at: %p)", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj);
614 } else {
654 } else {
615 return PyString_FromFormat("%s (C++ Object %p)", typeName, wrapper->_wrappedPtr);
655 return PyString_FromFormat("%s (C++ object at: %p)", typeName, wrapper->_wrappedPtr);
616 }
656 }
617 } else {
657 } else {
618 return PyString_FromFormat("%s (%s %p)", typeName, wrapper->classInfo()->className(), qobj);
658 return PyString_FromFormat("%s (%s at: %p)", typeName, wrapper->classInfo()->className(), qobj);
619 }
659 }
620 }
660 }
621
661
@@ -90,9 +90,11 typedef struct PythonQtInstanceWrapperStruct {
90
90
91 //! stores if the object is a shell instance
91 //! stores if the object is a shell instance
92 bool _isShellInstance;
92 bool _isShellInstance;
93
93
94 } PythonQtInstanceWrapper;
94 } PythonQtInstanceWrapper;
95
95
96 int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * self, PyObject * args, PyObject * kwds);
96 int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * self, PyObject * args, PyObject * kwds);
97
97
98 #endif No newline at end of file
98 PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self);
99
100 #endif
@@ -192,7 +192,6 int PythonQtMethodInfo::nameToType(const char* name)
192 _parameterTypeDict.insert("qreal", QMetaType::Double);
192 _parameterTypeDict.insert("qreal", QMetaType::Double);
193 _parameterTypeDict.insert("QChar", QMetaType::QChar);
193 _parameterTypeDict.insert("QChar", QMetaType::QChar);
194 _parameterTypeDict.insert("QByteArray", QMetaType::QByteArray);
194 _parameterTypeDict.insert("QByteArray", QMetaType::QByteArray);
195 _parameterTypeDict.insert("Q3CString", QMetaType::QByteArray);
196 _parameterTypeDict.insert("QString", QMetaType::QString);
195 _parameterTypeDict.insert("QString", QMetaType::QString);
197 _parameterTypeDict.insert("", QMetaType::Void);
196 _parameterTypeDict.insert("", QMetaType::Void);
198 _parameterTypeDict.insert("void", QMetaType::Void);
197 _parameterTypeDict.insert("void", QMetaType::Void);
@@ -203,7 +202,6 int PythonQtMethodInfo::nameToType(const char* name)
203 _parameterTypeDict.insert("qulonglong", QMetaType::ULongLong);
202 _parameterTypeDict.insert("qulonglong", QMetaType::ULongLong);
204 _parameterTypeDict.insert("qint64", QMetaType::LongLong);
203 _parameterTypeDict.insert("qint64", QMetaType::LongLong);
205 _parameterTypeDict.insert("quint64", QMetaType::ULongLong);
204 _parameterTypeDict.insert("quint64", QMetaType::ULongLong);
206 _parameterTypeDict.insert("QIconSet", QMetaType::QIcon);
207 _parameterTypeDict.insert("QVariantMap", QMetaType::QVariantMap);
205 _parameterTypeDict.insert("QVariantMap", QMetaType::QVariantMap);
208 _parameterTypeDict.insert("QVariantList", QMetaType::QVariantList);
206 _parameterTypeDict.insert("QVariantList", QMetaType::QVariantList);
209 _parameterTypeDict.insert("QMap<QString,QVariant>", QMetaType::QVariantMap);
207 _parameterTypeDict.insert("QMap<QString,QVariant>", QMetaType::QVariantMap);
@@ -216,15 +214,14 int PythonQtMethodInfo::nameToType(const char* name)
216 _parameterTypeDict.insert("QUrl", QMetaType::QUrl);
214 _parameterTypeDict.insert("QUrl", QMetaType::QUrl);
217 _parameterTypeDict.insert("QLocale", QMetaType::QLocale);
215 _parameterTypeDict.insert("QLocale", QMetaType::QLocale);
218 _parameterTypeDict.insert("QRect", QMetaType::QRect);
216 _parameterTypeDict.insert("QRect", QMetaType::QRect);
219 _parameterTypeDict.insert("QRectf", QMetaType::QRectF);
217 _parameterTypeDict.insert("QRectF", QMetaType::QRectF);
220 _parameterTypeDict.insert("QSize", QMetaType::QSize);
218 _parameterTypeDict.insert("QSize", QMetaType::QSize);
221 _parameterTypeDict.insert("QSizef", QMetaType::QSizeF);
219 _parameterTypeDict.insert("QSizeF", QMetaType::QSizeF);
222 _parameterTypeDict.insert("QLine", QMetaType::QLine);
220 _parameterTypeDict.insert("QLine", QMetaType::QLine);
223 _parameterTypeDict.insert("QLinef", QMetaType::QLineF);
221 _parameterTypeDict.insert("QLineF", QMetaType::QLineF);
224 _parameterTypeDict.insert("QPoint", QMetaType::QPoint);
222 _parameterTypeDict.insert("QPoint", QMetaType::QPoint);
225 _parameterTypeDict.insert("QPointf", QMetaType::QPointF);
223 _parameterTypeDict.insert("QPointF", QMetaType::QPointF);
226 _parameterTypeDict.insert("QRegExp", QMetaType::QRegExp);
224 _parameterTypeDict.insert("QRegExp", QMetaType::QRegExp);
227 // _parameterTypeDict.insert("QColorGroup", QMetaType::QColorGroup);
228 _parameterTypeDict.insert("QFont", QMetaType::QFont);
225 _parameterTypeDict.insert("QFont", QMetaType::QFont);
229 _parameterTypeDict.insert("QPixmap", QMetaType::QPixmap);
226 _parameterTypeDict.insert("QPixmap", QMetaType::QPixmap);
230 _parameterTypeDict.insert("QBrush", QMetaType::QBrush);
227 _parameterTypeDict.insert("QBrush", QMetaType::QBrush);
@@ -232,7 +229,7 int PythonQtMethodInfo::nameToType(const char* name)
232 _parameterTypeDict.insert("QCursor", QMetaType::QCursor);
229 _parameterTypeDict.insert("QCursor", QMetaType::QCursor);
233 _parameterTypeDict.insert("QPalette", QMetaType::QPalette);
230 _parameterTypeDict.insert("QPalette", QMetaType::QPalette);
234 _parameterTypeDict.insert("QIcon", QMetaType::QIcon);
231 _parameterTypeDict.insert("QIcon", QMetaType::QIcon);
235 _parameterTypeDict.insert("QImage", QMetaType::QPolygon);
232 _parameterTypeDict.insert("QImage", QMetaType::QImage);
236 _parameterTypeDict.insert("QRegion", QMetaType::QRegion);
233 _parameterTypeDict.insert("QRegion", QMetaType::QRegion);
237 _parameterTypeDict.insert("QBitmap", QMetaType::QBitmap);
234 _parameterTypeDict.insert("QBitmap", QMetaType::QBitmap);
238 _parameterTypeDict.insert("QSizePolicy", QMetaType::QSizePolicy);
235 _parameterTypeDict.insert("QSizePolicy", QMetaType::QSizePolicy);
@@ -89,13 +89,6 public:
89 _chunks.clear();
89 _chunks.clear();
90 }
90 }
91
91
92 //! reset the storage to 0 (without freeing memory, thus caching old entries for reuse)
93 void reset() {
94 _chunkIdx = 0;
95 _chunkOffset = 0;
96 _currentChunk = _chunks.at(0);
97 }
98
99 //! get the current position to be restored with setPos
92 //! get the current position to be restored with setPos
100 void getPos(PythonQtValueStoragePosition & pos) {
93 void getPos(PythonQtValueStoragePosition & pos) {
101 pos.chunkIdx = _chunkIdx;
94 pos.chunkIdx = _chunkIdx;
@@ -129,7 +122,7 public:
129 return newEntry;
122 return newEntry;
130 };
123 };
131
124
132 private:
125 protected:
133 QList<T*> _chunks;
126 QList<T*> _chunks;
134
127
135 int _chunkIdx;
128 int _chunkIdx;
@@ -138,5 +131,45 private:
138
131
139 };
132 };
140
133
134 //! a helper class that stores basic C++ value types in chunks and clears the unused values on setPos() usage.
135 template <typename T, int chunkEntries> class PythonQtValueStorageWithCleanup : public PythonQtValueStorage<T, chunkEntries>
136 {
137 public:
138 void setPos(const PythonQtValueStoragePosition& pos) {
139 if (_chunkIdx > pos.chunkIdx) {
140 T* firstChunk = _chunks.at(pos.chunkIdx);
141 // clear region in first chunk
142 for (int i = pos.chunkOffset; i < chunkEntries; i++) {
143 firstChunk[i] = T();
144 }
145 for (int chunk = pos.chunkIdx + 1; chunk < _chunkIdx; chunk++) {
146 // clear the full chunks between the first and last chunk
147 T* fullChunk = _chunks.at(chunk);
148 for (int i = 0; i < chunkEntries; i++) {
149 fullChunk[i] = T();
150 }
151 }
152 // clear region in last chunk
153 T* lastChunk = _chunks.at(_chunkIdx);
154 for (int i = 0; i < _chunkOffset; i++) {
155 lastChunk[i] = T();
156 }
157 } else if (_chunkIdx == pos.chunkIdx) {
158 // clear the region in the last chunk only
159 T* lastChunk = _chunks.at(_chunkIdx);
160 for (int i = pos.chunkOffset; i<_chunkOffset; i++) {
161 lastChunk[i] = T();
162 }
163 }
164
165 PythonQtValueStorage<T, chunkEntries>::setPos(pos);
166 }
167
168 private:
169 using PythonQtValueStorage<T, chunkEntries>::_chunks;
170 using PythonQtValueStorage<T, chunkEntries>::_chunkIdx;
171 using PythonQtValueStorage<T, chunkEntries>::_chunkOffset;
172 using PythonQtValueStorage<T, chunkEntries>::_currentChunk;
173 };
141
174
142 #endif
175 #endif
@@ -57,21 +57,21 public:
57 setObject(p.object());
57 setObject(p.object());
58 }
58 }
59
59
60 //! If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count.
60 //! If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count.
61 PythonQtObjectPtr(const QVariant& variant):_object(NULL) {
61 PythonQtObjectPtr(const QVariant& variant):_object(NULL) {
62 fromVariant(variant);
62 fromVariant(variant);
63 }
63 }
64
64
65 PythonQtObjectPtr(PyObject* o) {
65 PythonQtObjectPtr(PyObject* o) {
66 _object = o;
66 _object = o;
67 if (o) Py_INCREF(_object);
67 if (o) Py_INCREF(_object);
68 }
68 }
69
69
70 ~PythonQtObjectPtr() { if (_object) Py_DECREF(_object); }
70 ~PythonQtObjectPtr() { if (_object) { Py_DECREF(_object); } }
71
71
72 //! If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count.
72 //! If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count.
73 bool fromVariant(const QVariant& variant);
73 bool fromVariant(const QVariant& variant);
74
74
75 PythonQtObjectPtr &operator=(const PythonQtObjectPtr &p) {
75 PythonQtObjectPtr &operator=(const PythonQtObjectPtr &p) {
76 setObject(p.object());
76 setObject(p.object());
77 return *this;
77 return *this;
@@ -82,13 +82,13 public:
82 return *this;
82 return *this;
83 }
83 }
84
84
85
85
86 PythonQtObjectPtr &operator=(const QVariant& variant) {
86 PythonQtObjectPtr &operator=(const QVariant& variant) {
87 fromVariant(variant);
87 fromVariant(variant);
88 return *this;
88 return *this;
89 }
89 }
90
90
91
91
92 bool operator==( const PythonQtObjectPtr &p ) const {
92 bool operator==( const PythonQtObjectPtr &p ) const {
93 return object() == p.object();
93 return object() == p.object();
94 }
94 }
@@ -116,7 +116,7 public:
116 //! sets the object and passes the ownership (stealing the reference, in Python slang)
116 //! sets the object and passes the ownership (stealing the reference, in Python slang)
117 void setNewRef(PyObject* o) {
117 void setNewRef(PyObject* o) {
118 if (o != _object) {
118 if (o != _object) {
119 if (_object) Py_DECREF(_object);
119 if (_object) { Py_DECREF(_object); }
120 _object = o;
120 _object = o;
121 }
121 }
122 }
122 }
@@ -157,9 +157,9 protected:
157
157
158 void setObject(PyObject* o) {
158 void setObject(PyObject* o) {
159 if (o != _object) {
159 if (o != _object) {
160 if (_object) Py_DECREF(_object);
160 if (_object) { Py_DECREF(_object); }
161 _object = o;
161 _object = o;
162 if (_object) Py_INCREF(_object);
162 if (_object) { Py_INCREF(_object); }
163 }
163 }
164 }
164 }
165
165
@@ -171,4 +171,4 private:
171 // register it to the meta type system
171 // register it to the meta type system
172 Q_DECLARE_METATYPE(PythonQtObjectPtr)
172 Q_DECLARE_METATYPE(PythonQtObjectPtr)
173
173
174 #endif No newline at end of file
174 #endif
@@ -56,9 +56,11 void PythonQtSignalTarget::call(void **arguments) const {
56
56
57 PyObject* PythonQtSignalTarget::call(PyObject* callable, const PythonQtMethodInfo* methodInfos, void **arguments, bool skipFirstArgumentOfMethodInfo)
57 PyObject* PythonQtSignalTarget::call(PyObject* callable, const PythonQtMethodInfo* methodInfos, void **arguments, bool skipFirstArgumentOfMethodInfo)
58 {
58 {
59 Q_UNUSED(skipFirstArgumentOfMethodInfo)
60
59 // Note: we check if the callable is a PyFunctionObject and has a fixed number of arguments
61 // Note: we check if the callable is a PyFunctionObject and has a fixed number of arguments
60 // if that is the case, we only pass these arguments to python and skip the additional arguments from the signal
62 // if that is the case, we only pass these arguments to python and skip the additional arguments from the signal
61
63
62 int numPythonArgs = -1;
64 int numPythonArgs = -1;
63 if (PyFunction_Check(callable)) {
65 if (PyFunction_Check(callable)) {
64 PyObject* o = callable;
66 PyObject* o = callable;
@@ -135,7 +137,7 PyObject* PythonQtSignalTarget::call(PyObject* callable, const PythonQtMethodInf
135 PythonQtSignalReceiver::PythonQtSignalReceiver(QObject* obj):PythonQtSignalReceiverBase(obj)
137 PythonQtSignalReceiver::PythonQtSignalReceiver(QObject* obj):PythonQtSignalReceiverBase(obj)
136 {
138 {
137 _obj = obj;
139 _obj = obj;
138
140
139 // fetch the class info for object, since we will need to for correct enum resolution in
141 // fetch the class info for object, since we will need to for correct enum resolution in
140 // signals
142 // signals
141 _objClassInfo = PythonQt::priv()->getClassInfo(obj->metaObject());
143 _objClassInfo = PythonQt::priv()->getClassInfo(obj->metaObject());
@@ -50,7 +50,7 class PythonQtMethodInfo;
50 class PythonQtClassInfo;
50 class PythonQtClassInfo;
51
51
52 //! stores information about a signal target
52 //! stores information about a signal target
53 /*! copy construction and assignment works fine with the C++ standard behaviour and are thus not implemented
53 /*! copy construction and assignment works fine with the C++ standard behavior and are thus not implemented
54 */
54 */
55 class PYTHONQT_EXPORT PythonQtSignalTarget {
55 class PYTHONQT_EXPORT PythonQtSignalTarget {
56 public:
56 public:
@@ -53,7 +53,7
53 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObject* args, bool strict, PythonQtSlotInfo* info, void* firstArgument, PyObject** pythonReturnValue, void** directReturnValuePointer)
53 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObject* args, bool strict, PythonQtSlotInfo* info, void* firstArgument, PyObject** pythonReturnValue, void** directReturnValuePointer)
54 {
54 {
55 static unsigned int recursiveEntry = 0;
55 static unsigned int recursiveEntry = 0;
56
56
57 if (directReturnValuePointer) {
57 if (directReturnValuePointer) {
58 *directReturnValuePointer = NULL;
58 *directReturnValuePointer = NULL;
59 }
59 }
@@ -65,19 +65,19 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
65 PythonQtConv::global_valueStorage.getPos(globalValueStoragePos);
65 PythonQtConv::global_valueStorage.getPos(globalValueStoragePos);
66 PythonQtConv::global_ptrStorage.getPos(globalPtrStoragePos);
66 PythonQtConv::global_ptrStorage.getPos(globalPtrStoragePos);
67 PythonQtConv::global_variantStorage.getPos(globalVariantStoragePos);
67 PythonQtConv::global_variantStorage.getPos(globalVariantStoragePos);
68
68
69 recursiveEntry++;
69 recursiveEntry++;
70
70
71 // the arguments that are passed to qt_metacall
71 // the arguments that are passed to qt_metacall
72 void* argList[PYTHONQT_MAX_ARGS];
72 void* argList[PYTHONQT_MAX_ARGS];
73 PyObject* result = NULL;
73 PyObject* result = NULL;
74 int argc = info->parameterCount();
74 int argc = info->parameterCount();
75 const QList<PythonQtSlotInfo::ParameterInfo>& params = info->parameters();
75 const QList<PythonQtSlotInfo::ParameterInfo>& params = info->parameters();
76
76
77 const PythonQtSlotInfo::ParameterInfo& returnValueParam = params.at(0);
77 const PythonQtSlotInfo::ParameterInfo& returnValueParam = params.at(0);
78 // set return argument to NULL
78 // set return argument to NULL
79 argList[0] = NULL;
79 argList[0] = NULL;
80
80
81 bool ok = true;
81 bool ok = true;
82 bool skipFirst = false;
82 bool skipFirst = false;
83 if (info->isInstanceDecorator()) {
83 if (info->isInstanceDecorator()) {
@@ -114,7 +114,7 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
114 }
114 }
115 }
115 }
116 }
116 }
117
117
118 if (ok) {
118 if (ok) {
119 // parameters are ok, now create the qt return value which is assigned to by metacall
119 // parameters are ok, now create the qt return value which is assigned to by metacall
120 if (returnValueParam.typeId != QMetaType::Void) {
120 if (returnValueParam.typeId != QMetaType::Void) {
@@ -133,8 +133,8 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
133 if (result) {
133 if (result) {
134 argList[0] = ((PythonQtInstanceWrapper*)result)->_wrappedPtr;
134 argList[0] = ((PythonQtInstanceWrapper*)result)->_wrappedPtr;
135 }
135 }
136 Py_DECREF(emptyTuple);
136 Py_DECREF(emptyTuple);
137 }
137 }
138 }
138 }
139 } else {
139 } else {
140 // we can use our pointer directly!
140 // we can use our pointer directly!
@@ -142,9 +142,26 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
142 }
142 }
143 }
143 }
144
144
145
146 PythonQt::ProfilingCB* profilingCB = PythonQt::priv()->profilingCB();
147 if (profilingCB) {
148 const char* className = NULL;
149 if (info->decorator()) {
150 className = info->decorator()->metaObject()->className();
151 } else {
152 className = objectToCall->metaObject()->className();
153 }
154
155 profilingCB(PythonQt::Enter, className, info->metaMethod()->signature());
156 }
157
145 // invoke the slot via metacall
158 // invoke the slot via metacall
146 (info->decorator()?info->decorator():objectToCall)->qt_metacall(QMetaObject::InvokeMetaMethod, info->slotIndex(), argList);
159 (info->decorator()?info->decorator():objectToCall)->qt_metacall(QMetaObject::InvokeMetaMethod, info->slotIndex(), argList);
147
160
161 if (profilingCB) {
162 profilingCB(PythonQt::Leave, NULL, NULL);
163 }
164
148 // handle the return value (which in most cases still needs to be converted to a Python object)
165 // handle the return value (which in most cases still needs to be converted to a Python object)
149 if (argList[0] || returnValueParam.typeId == QMetaType::Void) {
166 if (argList[0] || returnValueParam.typeId == QMetaType::Void) {
150 if (directReturnValuePointer) {
167 if (directReturnValuePointer) {
@@ -162,12 +179,12 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
162 }
179 }
163 }
180 }
164 recursiveEntry--;
181 recursiveEntry--;
165
182
166 // reset the parameter storage position to the stored pos to "pop" the parameter stack
183 // reset the parameter storage position to the stored pos to "pop" the parameter stack
167 PythonQtConv::global_valueStorage.setPos(globalValueStoragePos);
184 PythonQtConv::global_valueStorage.setPos(globalValueStoragePos);
168 PythonQtConv::global_ptrStorage.setPos(globalPtrStoragePos);
185 PythonQtConv::global_ptrStorage.setPos(globalPtrStoragePos);
169 PythonQtConv::global_variantStorage.setPos(globalVariantStoragePos);
186 PythonQtConv::global_variantStorage.setPos(globalVariantStoragePos);
170
187
171 *pythonReturnValue = result;
188 *pythonReturnValue = result;
172 // NOTE: it is important to only return here, otherwise the stack will not be popped!!!
189 // NOTE: it is important to only return here, otherwise the stack will not be popped!!!
173 return result || (directReturnValuePointer && *directReturnValuePointer);
190 return result || (directReturnValuePointer && *directReturnValuePointer);
@@ -286,7 +303,7 PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* o
286 PyErr_SetString(PyExc_ValueError, e.toLatin1().data());
303 PyErr_SetString(PyExc_ValueError, e.toLatin1().data());
287 }
304 }
288 }
305 }
289
306
290 return r;
307 return r;
291 }
308 }
292
309
@@ -53,7 +53,7 bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, P
53 } else {
53 } else {
54 signalTmp = "2" + signal;
54 signalTmp = "2" + signal;
55 }
55 }
56
56
57 if (sender) {
57 if (sender) {
58 return PythonQt::self()->addSignalHandler(sender, signalTmp, callable);
58 return PythonQt::self()->addSignalHandler(sender, signalTmp, callable);
59 } else {
59 } else {
@@ -112,7 +112,7 bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal
112 } else {
112 } else {
113 signalTmp = "2" + signal;
113 signalTmp = "2" + signal;
114 }
114 }
115
115
116 QByteArray slotTmp;
116 QByteArray slotTmp;
117 first = slot.at(0);
117 first = slot.at(0);
118 if (first>='0' && first<='9') {
118 if (first>='0' && first<='9') {
@@ -120,21 +120,12 bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal
120 } else {
120 } else {
121 slotTmp = "1" + slot;
121 slotTmp = "1" + slot;
122 }
122 }
123
123
124 r = QObject::disconnect(sender, signalTmp, receiver, slotTmp);
124 r = QObject::disconnect(sender, signalTmp, receiver, slotTmp);
125 }
125 }
126 return r;
126 return r;
127 }
127 }
128
128
129 #undef emit
130 void PythonQtStdDecorators::emit(QObject* sender, const QByteArray& signal, PyObject* arg1 ,PyObject* arg2 ,
131 PyObject* arg3 ,PyObject* arg4 ,PyObject* arg5 ,PyObject* arg6 ,PyObject* arg7 )
132 {
133 // TODO xxx
134 // use normal PythonQtSlot calling code, add "allowSignal" to member lookup?!
135 }
136 #define emit
137
138 QObject* PythonQtStdDecorators::parent(QObject* o) {
129 QObject* PythonQtStdDecorators::parent(QObject* o) {
139 return o->parent();
130 return o->parent();
140 }
131 }
@@ -244,7 +235,7 QObject* PythonQtStdDecorators::findChild(QObject* parent, const char* typeName,
244 if (!name.isNull() && obj->objectName() != name)
235 if (!name.isNull() && obj->objectName() != name)
245 continue;
236 continue;
246
237
247 if ((typeName && obj->inherits(typeName)) ||
238 if ((typeName && obj->inherits(typeName)) ||
248 (meta && meta->cast(obj)))
239 (meta && meta->cast(obj)))
249 return obj;
240 return obj;
250 }
241 }
@@ -274,7 +265,7 int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, c
274 if (!name.isNull() && obj->objectName() != name)
265 if (!name.isNull() && obj->objectName() != name)
275 continue;
266 continue;
276
267
277 if ((typeName && obj->inherits(typeName)) ||
268 if ((typeName && obj->inherits(typeName)) ||
278 (meta && meta->cast(obj))) {
269 (meta && meta->cast(obj))) {
279 list += obj;
270 list += obj;
280 }
271 }
@@ -301,7 +292,7 int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, c
301 if (regExp.indexIn(obj->objectName()) == -1)
292 if (regExp.indexIn(obj->objectName()) == -1)
302 continue;
293 continue;
303
294
304 if ((typeName && obj->inherits(typeName)) ||
295 if ((typeName && obj->inherits(typeName)) ||
305 (meta && meta->cast(obj))) {
296 (meta && meta->cast(obj))) {
306 list += obj;
297 list += obj;
307 }
298 }
@@ -62,11 +62,6 public slots:
62 bool disconnect(QObject* sender, const QByteArray& signal, PyObject* callable);
62 bool disconnect(QObject* sender, const QByteArray& signal, PyObject* callable);
63 bool disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot);
63 bool disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot);
64
64
65 #undef emit
66 void emit(QObject* sender, const QByteArray& signal, PyObject* arg1 = NULL,PyObject* arg2 = NULL,
67 PyObject* arg3 = NULL,PyObject* arg4 = NULL,PyObject* arg5 = NULL,PyObject* arg6 = NULL,PyObject* arg7 = NULL);
68 #define emit
69
70 QObject* parent(QObject* o);
65 QObject* parent(QObject* o);
71 void setParent(QObject* o, QObject* parent);
66 void setParent(QObject* o, QObject* parent);
72
67
@@ -74,19 +69,19 public slots:
74 QObject* findChild(QObject* parent, PyObject* type, const QString& name = QString());
69 QObject* findChild(QObject* parent, PyObject* type, const QString& name = QString());
75 QList<QObject*> findChildren(QObject* parent, PyObject* type, const QString& name= QString());
70 QList<QObject*> findChildren(QObject* parent, PyObject* type, const QString& name= QString());
76 QList<QObject*> findChildren(QObject* parent, PyObject* type, const QRegExp& regExp);
71 QList<QObject*> findChildren(QObject* parent, PyObject* type, const QRegExp& regExp);
77
72
78 bool setProperty(QObject* o, const char* name, const QVariant& value);
73 bool setProperty(QObject* o, const char* name, const QVariant& value);
79 QVariant property(QObject* o, const char* name);
74 QVariant property(QObject* o, const char* name);
80
75
81 double static_Qt_qAbs(double a) { return qAbs(a); }
76 double static_Qt_qAbs(double a) { return qAbs(a); }
82 double static_Qt_qBound(double a,double b,double c) { return qBound(a,b,c); }
77 double static_Qt_qBound(double a,double b,double c) { return qBound(a,b,c); }
83 void static_Qt_qDebug(const QByteArray& msg) { qDebug(msg.constData()); }
78 void static_Qt_qDebug(const QByteArray& msg) { qDebug("%s", msg.constData()); }
84 // TODO: multi arg qDebug...
79 // TODO: multi arg qDebug...
85 void static_Qt_qWarning(const QByteArray& msg) { qWarning(msg.constData()); }
80 void static_Qt_qWarning(const QByteArray& msg) { qWarning("%s", msg.constData()); }
86 // TODO: multi arg qWarning...
81 // TODO: multi arg qWarning...
87 void static_Qt_qCritical(const QByteArray& msg) { qCritical(msg.constData()); }
82 void static_Qt_qCritical(const QByteArray& msg) { qCritical("%s", msg.constData()); }
88 // TODO: multi arg qCritical...
83 // TODO: multi arg qCritical...
89 void static_Qt_qFatal(const QByteArray& msg) { qFatal(msg.constData()); }
84 void static_Qt_qFatal(const QByteArray& msg) { qFatal("%s", msg.constData()); }
90 // TODO: multi arg qFatal...
85 // TODO: multi arg qFatal...
91 bool static_Qt_qFuzzyCompare(double a, double b) { return qFuzzyCompare(a, b); }
86 bool static_Qt_qFuzzyCompare(double a, double b) { return qFuzzyCompare(a, b); }
92 double static_Qt_qMax(double a, double b) { return qMax(a, b); }
87 double static_Qt_qMax(double a, double b) { return qMax(a, b); }
@@ -98,7 +93,7 public slots:
98 void static_Qt_qsrand(uint a) { qsrand(a); }
93 void static_Qt_qsrand(uint a) { qsrand(a); }
99
94
100 QString tr(QObject* obj, const QByteArray& text, const QByteArray& ambig = QByteArray(), int n = -1);
95 QString tr(QObject* obj, const QByteArray& text, const QByteArray& ambig = QByteArray(), int n = -1);
101
96
102 QByteArray static_Qt_SIGNAL(const QByteArray& s) { return QByteArray("2") + s; }
97 QByteArray static_Qt_SIGNAL(const QByteArray& s) { return QByteArray("2") + s; }
103 QByteArray static_Qt_SLOT(const QByteArray& s) { return QByteArray("1") + s; }
98 QByteArray static_Qt_SLOT(const QByteArray& s) { return QByteArray("1") + s; }
104
99
General Comments 0
You need to be logged in to leave comments. Login now