SourceForge.net Logo
PythonQt
PythonQtConversion.h
Go to the documentation of this file.
1 #ifndef _PYTHONQTCONVERSION_H
2 #define _PYTHONQTCONVERSION_H
3 
4 /*
5  *
6  * Copyright (C) 2010 MeVis Medical Solutions AG All Rights Reserved.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * Further, this software is distributed without any warranty that it is
19  * free of the rightful claim of any third person regarding infringement
20  * or the like. Any license provided herein, whether implied or
21  * otherwise, applies only to this software file. Patent licenses, if
22  * any, provided herein do not apply to combinations of this program with
23  * other software, or any other product whatsoever.
24  *
25  * You should have received a copy of the GNU Lesser General Public
26  * License along with this library; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28  *
29  * Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
30  * 28359 Bremen, Germany or:
31  *
32  * http://www.mevis.de
33  *
34  */
35 
36 //----------------------------------------------------------------------------------
43 //----------------------------------------------------------------------------------
44 
45 #include "PythonQt.h"
46 #include "PythonQtMisc.h"
47 #include "PythonQtClassInfo.h"
48 #include "PythonQtMethodInfo.h"
49 
50 #include <QList>
51 #include <vector>
52 
53 typedef PyObject* PythonQtConvertMetaTypeToPythonCB(const void* inObject, int metaTypeId);
54 typedef bool PythonQtConvertPythonToMetaTypeCB(PyObject* inObject, void* outObject, int metaTypeId, bool strict);
55 
56 #define PythonQtRegisterListTemplateConverter(type, innertype) \
57 { int typeId = qRegisterMetaType<type<innertype > >(#type"<"#innertype">"); \
58 PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonListToListOfValueType<type<innertype >, innertype>); \
59 PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertListOfValueTypeToPythonList<type<innertype >, innertype>); \
60 }
61 
62 #define PythonQtRegisterListTemplateConverterForKnownClass(type, innertype) \
63 { int typeId = qRegisterMetaType<type<innertype > >(#type"<"#innertype">"); \
64  PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonListToListOfKnownClass<type<innertype >, innertype>); \
65  PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertListOfKnownClassToPythonList<type<innertype >, innertype>); \
66 }
67 
68 #define PythonQtRegisterQPairConverter(type1, type2) \
69 { int typeId = qRegisterMetaType<QPair<type1, type2> >("QPair<"#type1","#type2">"); \
70  PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonToPair<type1, type2>); \
71  PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertPairToPython<type1, type2>); \
72 }
73 
74 #define PythonQtRegisterIntegerMapConverter(type, innertype) \
75 { int typeId = qRegisterMetaType<type<int, innertype > >(#type"<int, "#innertype">"); \
76  PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonToIntegerMap<type<int, innertype >, innertype>); \
77  PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertIntegerMapToPython<type<int, innertype >, innertype>); \
78 }
79 
80 #define PythonQtRegisterListTemplateQPairConverter(listtype, type1, type2) \
81 { \
82  qRegisterMetaType<QPair<type1, type2> >("QPair<"#type1","#type2">"); \
83  int typeId = qRegisterMetaType<listtype<QPair<type1, type2> > >(#listtype"<QPair<"#type1","#type2">>"); \
84  PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonListToListOfPair<listtype<QPair<type1, type2> >, type1, type2>); \
85  PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertListOfPairToPythonList<listtype<QPair<type1, type2> >, type1, type2>); \
86 }
87 
88 #define PythonQtRegisterToolClassesTemplateConverter(innertype) \
89  PythonQtRegisterListTemplateConverter(QList, innertype); \
90  PythonQtRegisterListTemplateConverter(QVector, innertype); \
91  PythonQtRegisterListTemplateConverter(std::vector, innertype);
92 
93 #define PythonQtRegisterToolClassesTemplateConverterForKnownClass(innertype) \
94  PythonQtRegisterListTemplateConverterForKnownClass(QList, innertype); \
95  PythonQtRegisterListTemplateConverterForKnownClass(QVector, innertype); \
96  PythonQtRegisterListTemplateConverterForKnownClass(std::vector, innertype);
97 
100 
101 public:
102 
104  static PyObject* GetPyBool(bool val);
105 
107  static PyObject* ConvertQtValueToPython(const PythonQtMethodInfo::ParameterInfo& info, const void* data);
108 
110  static void* ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& info, PyObject* obj, bool strict, PythonQtClassInfo* classInfo, void* alreadyAllocatedCPPObject = NULL);
111 
113  static void* CreateQtReturnValue(const PythonQtMethodInfo::ParameterInfo& info);
114 
116  static PyObject* QStringToPyObject(const QString& str);
117 
119  static PyObject* QStringListToPyObject(const QStringList& list);
120 
122  static PyObject* QStringListToPyList(const QStringList& list);
123 
125  static QString PyObjGetRepresentation(PyObject* val);
126 
128  static QString PyObjGetString(PyObject* val) { bool ok; QString s = PyObjGetString(val, false, ok); return s; }
130  static QString PyObjGetString(PyObject* val, bool strict, bool &ok);
132  static QByteArray PyObjGetBytes(PyObject* val, bool strict, bool &ok);
134  static int PyObjGetInt(PyObject* val, bool strict, bool &ok);
136  static qint64 PyObjGetLongLong(PyObject* val, bool strict, bool &ok);
138  static quint64 PyObjGetULongLong(PyObject* val, bool strict, bool &ok);
140  static double PyObjGetDouble(PyObject* val, bool strict, bool &ok);
142  static bool PyObjGetBool(PyObject* val, bool strict, bool &ok);
143 
145  static QStringList PyObjToStringList(PyObject* val, bool strict, bool& ok);
146 
149  static QVariant PyObjToQVariant(PyObject* val, int type = -1);
150 
152  static PyObject* QVariantToPyObject(const QVariant& v);
153 
154  static PyObject* QVariantHashToPyObject(const QVariantHash& m);
155  static PyObject* QVariantMapToPyObject(const QVariantMap& m);
156  static PyObject* QVariantListToPyObject(const QVariantList& l);
157 
159  static QString CPPObjectToString(int type, const void* data);
160 
162  static void registerPythonToMetaTypeConverter(int metaTypeId, PythonQtConvertPythonToMetaTypeCB* cb) { _pythonToMetaTypeConverters.insert(metaTypeId, cb); }
163 
165  static void registerMetaTypeToPythonConverter(int metaTypeId, PythonQtConvertMetaTypeToPythonCB* cb) { _metaTypeToPythonConverters.insert(metaTypeId, cb); }
166 
168  static PyObject* convertQtValueToPythonInternal(int type, const void* data);
169 
171  static PyObject* createCopyFromMetaType( int type, const void* object );
172 
174  static void* castWrapperTo(PythonQtInstanceWrapper* wrapper, const QByteArray& className, bool& ok);
175 
176  static bool convertToPythonQtObjectPtr(PyObject* obj, void* /* PythonQtObjectPtr* */ outPtr, int /*metaTypeId*/, bool /*strict*/);
177  static PyObject* convertFromPythonQtObjectPtr(const void* /* PythonQtObjectPtr* */ inObject, int /*metaTypeId*/);
178  static bool convertToQListOfPythonQtObjectPtr(PyObject* obj, void* /* QList<PythonQtObjectPtr>* */ outList, int /*metaTypeId*/, bool /*strict*/);
179  static PyObject* convertFromQListOfPythonQtObjectPtr(const void* /* QList<PythonQtObjectPtr>* */ inObject, int /*metaTypeId*/);
180  static PyObject* convertFromStringRef(const void* inObject, int /*metaTypeId*/);
181 
183  static QByteArray getCPPTypeName(PyObject* type);
184 
186  static bool isStringType(PyTypeObject* type);
187 
188 public:
189 
193 
194 protected:
195  static QHash<int, PythonQtConvertMetaTypeToPythonCB*> _metaTypeToPythonConverters;
196  static QHash<int, PythonQtConvertPythonToMetaTypeCB*> _pythonToMetaTypeConverters;
197 
199  static void* handlePythonToQtAutoConversion(int typeId, PyObject* obj, void* alreadyAllocatedCPPObject);
200 
202  static PyObject* ConvertQListOfPointerTypeToPythonList(QList<void*>* list, const PythonQtMethodInfo::ParameterInfo& info);
204  static bool ConvertPythonListToQListOfPointerType(PyObject* obj, QList<void*>* list, const PythonQtMethodInfo::ParameterInfo& info, bool strict);
205 
207  template <typename Map>
208  static void pythonToMapVariant(PyObject* val, QVariant& result);
210  template <typename Map>
211  static PyObject* mapToPython (const Map& m);
212 
213 };
214 
215 template<class ListType, class T>
216 PyObject* PythonQtConvertListOfValueTypeToPythonList(const void* /*QList<T>* */ inList, int metaTypeId)
217 {
218  ListType* list = (ListType*)inList;
219  static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId)));
220  if (innerType == QVariant::Invalid) {
221  std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
222  }
223  PyObject* result = PyTuple_New(list->size());
224  int i = 0;
225  Q_FOREACH (const T& value, *list) {
226  PyTuple_SET_ITEM(result, i, PythonQtConv::convertQtValueToPythonInternal(innerType, &value));
227  i++;
228  }
229  return result;
230 }
231 
232 template<class ListType, class T>
233 bool PythonQtConvertPythonListToListOfValueType(PyObject* obj, void* /*QList<T>* */ outList, int metaTypeId, bool /*strict*/)
234 {
235  ListType* list = (ListType*)outList;
236  static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId)));
237  if (innerType == QVariant::Invalid) {
238  std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
239  }
240  bool result = false;
241  if (PySequence_Check(obj)) {
242  int count = PySequence_Size(obj);
243  if (count >= 0) {
244  result = true;
245  PyObject* value;
246  for (int i = 0;i<count;i++) {
247  value = PySequence_GetItem(obj,i);
248  // this is quite some overhead, but it avoids having another large switch...
249  QVariant v = PythonQtConv::PyObjToQVariant(value, innerType);
250  Py_XDECREF(value);
251  if (v.isValid()) {
252  list->push_back(qvariant_cast<T>(v));
253  } else {
254  result = false;
255  break;
256  }
257  }
258  }
259  }
260  return result;
261 }
262 
263 //--------------------------------------------------------------------------------------------------------------------
264 
265 template<class ListType, class T>
266 PyObject* PythonQtConvertListOfKnownClassToPythonList(const void* /*QList<T>* */ inList, int metaTypeId)
267 {
268  ListType* list = (ListType*)inList;
270  if (innerType == NULL) {
271  std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type " << innerType->className().constData() << std::endl;
272  }
273  PyObject* result = PyTuple_New(list->size());
274  int i = 0;
275  Q_FOREACH(const T& value, *list) {
276  T* newObject = new T(value);
278  wrap->_ownedByPythonQt = true;
279  PyTuple_SET_ITEM(result, i, (PyObject*)wrap);
280  i++;
281  }
282  return result;
283 }
284 
285 template<class ListType, class T>
286 bool PythonQtConvertPythonListToListOfKnownClass(PyObject* obj, void* /*QList<T>* */ outList, int metaTypeId, bool /*strict*/)
287 {
288  ListType* list = (ListType*)outList;
290  if (innerType == NULL) {
291  std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type " << innerType->className().constData() << std::endl;
292  }
293  bool result = false;
294  if (PySequence_Check(obj)) {
295  int count = PySequence_Size(obj);
296  if (count >= 0) {
297  result = true;
298  PyObject* value;
299  for (int i = 0; i < count; i++) {
300  value = PySequence_GetItem(obj, i);
301  if (PyObject_TypeCheck(value, &PythonQtInstanceWrapper_Type)) {
303  bool ok;
304  T* object = (T*)PythonQtConv::castWrapperTo(wrap, innerType->className(), ok);
305  Py_XDECREF(value);
306  if (ok) {
307  list->push_back(*object);
308  } else {
309  result = false;
310  break;
311  }
312  } else {
313  Py_XDECREF(value);
314  result = false;
315  break;
316  }
317  }
318  }
319  }
320  return result;
321 }
322 
323 //--------------------------------------------------------------------------------------------------------------------
324 
325 template<class T1, class T2>
326 PyObject* PythonQtConvertPairToPython(const void* /*QPair<T1,T2>* */ inPair, int metaTypeId)
327 {
328  QPair<T1, T2>* pair = (QPair<T1, T2>*)inPair;
329  static int innerType1 = -1;
330  static int innerType2 = -1;
331  if (innerType1==-1) {
332  QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(QMetaType::typeName(metaTypeId)));
333  QList<QByteArray> names = innerTypes.split(',');
334  innerType1 = QMetaType::type(names.at(0).trimmed());
335  innerType2 = QMetaType::type(names.at(1).trimmed());
336  }
337  if (innerType1 == QVariant::Invalid || innerType2 == QVariant::Invalid) {
338  std::cerr << "PythonQtConvertPairToPython: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
339  }
340  PyObject* result = PyTuple_New(2);
341  PyTuple_SET_ITEM(result, 0, PythonQtConv::convertQtValueToPythonInternal(innerType1, &pair->first));
342  PyTuple_SET_ITEM(result, 1, PythonQtConv::convertQtValueToPythonInternal(innerType2, &pair->second));
343  return result;
344 }
345 
346 template<class T1, class T2>
347 bool PythonQtConvertPythonToPair(PyObject* obj, void* /*QPair<T1,T2>* */ outPair, int metaTypeId, bool /*strict*/)
348 {
349  QPair<T1, T2>* pair = (QPair<T1, T2>*)outPair;
350  static int innerType1 = -1;
351  static int innerType2 = -1;
352  if (innerType1 == -1) {
353  QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(QMetaType::typeName(metaTypeId)));
354  QList<QByteArray> names = innerTypes.split(',');
355  innerType1 = QMetaType::type(names.at(0).trimmed());
356  innerType2 = QMetaType::type(names.at(1).trimmed());
357  }
358  if (innerType1 == QVariant::Invalid || innerType2 == QVariant::Invalid) {
359  std::cerr << "PythonQtConvertPythonToPair: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
360  }
361  bool result = false;
362  if (PySequence_Check(obj)) {
363  int count = PySequence_Size(obj);
364  if (count == 2) {
365  result = true;
366  PyObject* value;
367 
368  value = PySequence_GetItem(obj, 0);
369  // this is quite some overhead, but it avoids having another large switch...
370  QVariant v = PythonQtConv::PyObjToQVariant(value, innerType1);
371  Py_XDECREF(value);
372  if (v.isValid()) {
373  pair->first = qvariant_cast<T1>(v);
374  } else {
375  return false;
376  }
377 
378  value = PySequence_GetItem(obj, 1);
379  // this is quite some overhead, but it avoids having another large switch...
380  v = PythonQtConv::PyObjToQVariant(value, innerType2);
381  Py_XDECREF(value);
382  if (v.isValid()) {
383  pair->second = qvariant_cast<T2>(v);
384  } else {
385  return false;
386  }
387  }
388  }
389  return result;
390 }
391 
392 //--------------------------------------------------------------------------------------------------------------------
393 
394 template<class ListType, class T1, class T2>
395 PyObject* PythonQtConvertListOfPairToPythonList(const void* /*QList<QPair<T1,T2> >* */ inList, int metaTypeId)
396 {
397  ListType* list = (ListType*)inList;
398  static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId)));
399  if (innerType == QVariant::Invalid) {
400  std::cerr << "PythonQtConvertListOfPairToPythonList: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
401  }
402  PyObject* result = PyTuple_New(list->size());
403  int i = 0;
404  typedef const QPair<T1, T2> Pair;
405  Q_FOREACH(Pair& value, *list) {
406  PyObject* object = PythonQtConvertPairToPython<T1, T2>(&value, innerType);
407  PyTuple_SET_ITEM(result, i, object);
408  i++;
409  }
410  return result;
411 }
412 
413 template<class ListType, class T1, class T2>
414 bool PythonQtConvertPythonListToListOfPair(PyObject* obj, void* /*QList<QPair<T1,T2> >* */ outList, int metaTypeId, bool /*strict*/)
415 {
416  ListType* list = (ListType*)outList;
417  static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId)));
418  if (innerType == QVariant::Invalid) {
419  std::cerr << "PythonQtConvertPythonListToListOfPair: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
420  }
421  bool result = false;
422  if (PySequence_Check(obj)) {
423  int count = PySequence_Size(obj);
424  if (count >= 0) {
425  result = true;
426  PyObject* value;
427  for (int i = 0; i < count; i++) {
428  QPair<T1, T2> pair;
429  value = PySequence_GetItem(obj, i);
430  if (PythonQtConvertPythonToPair<T1,T2>(value, &pair, innerType, false)) {
431  Py_XDECREF(value);
432  list->push_back(pair);
433  } else {
434  Py_XDECREF(value);
435  result = false;
436  break;
437  }
438  }
439  }
440  }
441  return result;
442 }
443 
444 //--------------------------------------------------------------------------------------------------------------------
445 
446 template<class MapType, class T>
447 PyObject* PythonQtConvertIntegerMapToPython(const void* /*QMap<int, T>* */ inMap, int metaTypeId)
448 {
449  MapType* map = (MapType*)inMap;
450  static int innerType = -1;
451  if (innerType == -1) {
452  QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(QMetaType::typeName(metaTypeId)));
453  QList<QByteArray> names = innerTypes.split(',');
454  innerType = QMetaType::type(names.at(1).trimmed());
455  }
456  if (innerType == QVariant::Invalid) {
457  std::cerr << "PythonQtConvertIntegerMapToPython: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
458  }
459 
460  PyObject* result = PyDict_New();
461  typename MapType::const_iterator t = map->constBegin();
462  PyObject* key;
463  PyObject* val;
464  for (; t != map->constEnd(); t++) {
465  key = PyInt_FromLong(t.key());
466  val = PythonQtConv::convertQtValueToPythonInternal(innerType, &t.value());
467  PyDict_SetItem(result, key, val);
468  Py_DECREF(key);
469  Py_DECREF(val);
470  }
471  return result;
472 }
473 
474 template<class MapType, class T>
475 bool PythonQtConvertPythonToIntegerMap(PyObject* val, void* /*QMap<int, T>* */ outMap, int metaTypeId, bool /*strict*/)
476 {
477  MapType* map = (MapType*)outMap;
478  static int innerType = -1;
479  if (innerType == -1) {
480  QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(QMetaType::typeName(metaTypeId)));
481  QList<QByteArray> names = innerTypes.split(',');
482  innerType = QMetaType::type(names.at(1).trimmed());
483  }
484  if (innerType == QVariant::Invalid) {
485  std::cerr << "PythonQtConvertPythonToIntegerMap: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl;
486  }
487  bool result = false;
488  if (PyMapping_Check(val)) {
489  result = true;
490  PyObject* items = PyMapping_Items(val);
491  if (items) {
492  int count = PyList_Size(items);
493  PyObject* value;
494  PyObject* key;
495  PyObject* tuple;
496  for (int i = 0; i < count; i++) {
497  tuple = PyList_GetItem(items, i);
498  key = PyTuple_GetItem(tuple, 0);
499  value = PyTuple_GetItem(tuple, 1);
500 
501  bool ok;
502  int intKey = PythonQtConv::PyObjGetInt(key, false, ok);
503  // this is quite some overhead, but it avoids having another large switch...
504  QVariant v = PythonQtConv::PyObjToQVariant(value, innerType);
505  if (v.isValid() && ok) {
506  map->insert(intKey, qvariant_cast<T>(v));
507  } else {
508  result = false;
509  break;
510  }
511  }
512  Py_DECREF(items);
513  }
514  }
515  return result;
516 }
517 
518 
519 #endif
PyObject * wrapPtr(void *ptr, const QByteArray &name, bool passOwnership=false)
bool PythonQtConvertPythonToIntegerMap(PyObject *val, void *outMap, int metaTypeId, bool)
bool PythonQtConvertPythonListToListOfValueType(PyObject *obj, void *outList, int metaTypeId, bool)
bool PythonQtConvertPythonToMetaTypeCB(PyObject *inObject, void *outObject, int metaTypeId, bool strict)
a Python wrapper object for Qt objects and C++ objects (that are themselves wrapped by wrapper QObjec...
static PythonQtValueStorage< qint64, 128 > global_valueStorage
bool PythonQtConvertPythonToPair(PyObject *obj, void *outPair, int metaTypeId, bool)
const QByteArray & className() const
get the classname (either of the QObject or of the wrapped CPP object)
PyObject * PythonQtConvertPairToPython(const void *inPair, int metaTypeId)
a class that stores all required information about a Qt object (and an optional associated C++ class ...
PyObject * PythonQtConvertListOfPairToPythonList(const void *inList, int metaTypeId)
QByteArray typeName(const QMetaMethod &method)
Definition: PythonQtUtils.h:72
PyObject * PythonQtConvertListOfKnownClassToPythonList(const void *inList, int metaTypeId)
static PythonQtValueStorageWithCleanup< QVariant, 128 > global_variantStorage
static PythonQtPrivate * priv()
get access to internal data (should not be used on the public API, but is used by some C functions) ...
Definition: PythonQt.h:529
a static class that offers methods for type conversion
PyObject * PythonQtConvertMetaTypeToPythonCB(const void *inObject, int metaTypeId)
static QByteArray getInnerTemplateTypeName(const QByteArray &typeName)
returns the inner type name of a simple template of the form SomeObject ...
static void * castWrapperTo(PythonQtInstanceWrapper *wrapper, const QByteArray &className, bool &ok)
cast wrapper to given className if possible
bool PythonQtConvertPythonListToListOfPair(PyObject *obj, void *outList, int metaTypeId, bool)
stores various informations about a parameter/type name
bool _ownedByPythonQt
flag that stores if the object is owned by pythonQt
static QHash< int, PythonQtConvertMetaTypeToPythonCB * > _metaTypeToPythonConverters
static int getInnerTemplateMetaType(const QByteArray &typeName)
returns the inner type id of a simple template of the form SomeObject
#define PYTHONQT_EXPORT
struct _object PyObject
static PythonQtValueStorage< void *, 128 > global_ptrStorage
static int PyObjGetInt(PyObject *val, bool strict, bool &ok)
get int from py object
PyObject * PythonQtConvertIntegerMapToPython(const void *inMap, int metaTypeId)
static void registerPythonToMetaTypeConverter(int metaTypeId, PythonQtConvertPythonToMetaTypeCB *cb)
register a converter callback from python to cpp for given metatype
static QString PyObjGetString(PyObject *val)
get string value from py object
static QVariant PyObjToQVariant(PyObject *val, int type=-1)
static QByteArray getInnerListTypeName(const QByteArray &typeName)
returns the inner type name of a simple template or the typename without appended "List"...
static PyObject * convertQtValueToPythonInternal(int type, const void *data)
converts the Qt parameter given in data, interpreting it as a type registered qvariant/meta type...
PyObject * PythonQtConvertListOfValueTypeToPythonList(const void *inList, int metaTypeId)
static void registerMetaTypeToPythonConverter(int metaTypeId, PythonQtConvertMetaTypeToPythonCB *cb)
register a converter callback from cpp to python for given metatype
PythonQtClassInfo * getClassInfo(const QMetaObject *meta)
get the class info for a meta object (if available)
static QHash< int, PythonQtConvertPythonToMetaTypeCB * > _pythonToMetaTypeConverters
PYTHONQT_EXPORT PyTypeObject PythonQtInstanceWrapper_Type
bool PythonQtConvertPythonListToListOfKnownClass(PyObject *obj, void *outList, int metaTypeId, bool)