Menu

Diff of /src/PythonQtConversion.cpp [r3] .. [r4]  Maximize  Restore

Switch to unified view

a/src/PythonQtConversion.cpp b/src/PythonQtConversion.cpp
...
...
66
      // convert argList[0] to python
66
      // convert argList[0] to python
67
      PyObject* pyObj = PythonQt::priv()->wrapPtr(*((void**)data), info.name);
67
      PyObject* pyObj = PythonQt::priv()->wrapPtr(*((void**)data), info.name);
68
      if (pyObj) {
68
      if (pyObj) {
69
        return pyObj;
69
        return pyObj;
70
      } else {
70
      } else {
71
        std::cerr << "unknown pointer type " << info.name.data() << std::endl;
71
        std::cerr << "unknown pointer type " << info.name.data() << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
72
        Py_INCREF(Py_None);
72
        Py_INCREF(Py_None);
73
        return Py_None;
73
        return Py_None;
74
      }
74
      }
75
    } else {
75
    } else {
76
      return ConvertQtValueToPython(info.typeId, data);
76
      return ConvertQtValueToPython(info.typeId, data);
...
...
78
  }
78
  }
79
}
79
}
80
80
81
PyObject* PythonQtConv::ConvertQtValueToPython(int type, void* data) {
81
PyObject* PythonQtConv::ConvertQtValueToPython(int type, void* data) {
82
  switch (type) {
82
  switch (type) {
83
  case PythonQtMethodInfo::Void:
84
    Py_INCREF(Py_None);
85
    return Py_None;
83
  case PythonQtMethodInfo::Char:
86
  case PythonQtMethodInfo::Char:
84
    return PyInt_FromLong(*((char*)data));
87
    return PyInt_FromLong(*((char*)data));
85
  case PythonQtMethodInfo::UChar:
88
  case PythonQtMethodInfo::UChar:
86
    return PyInt_FromLong(*((unsigned char*)data));
89
    return PyInt_FromLong(*((unsigned char*)data));
87
  case PythonQtMethodInfo::Short:
90
  case PythonQtMethodInfo::Short:
...
...
185
    return PythonQtConv::QVariantToPyObject(*((QVariant*)data));
188
    return PythonQtConv::QVariantToPyObject(*((QVariant*)data));
186
  case QMetaType::QObjectStar:
189
  case QMetaType::QObjectStar:
187
  case QMetaType::QWidgetStar:
190
  case QMetaType::QWidgetStar:
188
    return PythonQt::priv()->wrapQObject(*((QObject**)data));
191
    return PythonQt::priv()->wrapQObject(*((QObject**)data));
189
  default:
192
  default:
190
    std::cerr << "unknown type " << type << std::endl;
193
    std::cerr << "unknown type " << type << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
191
}
194
}
192
Py_INCREF(Py_None);
195
Py_INCREF(Py_None);
193
return Py_None;
196
return Py_None;
194
 }
197
 }
195
198
...
...
254
      if (ok) {
257
      if (ok) {
255
        void* ptr2 = NULL;
258
        void* ptr2 = NULL;
256
        PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant(str.toUtf8()), ptr2);
259
        PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant(str.toUtf8()), ptr2);
257
        PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, (((QByteArray*)((QVariant*)ptr2)->constData())->data()), ptr);
260
        PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, (((QByteArray*)((QVariant*)ptr2)->constData())->data()), ptr);
258
      }
261
      }
262
    } else if (info.name == "PyObject") {
263
      // handle low level PyObject directly
264
      PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, obj, ptr);
259
    }
265
    }
260
    // EXTRA: we could support pointers to other simple types, but this would not make sense in most situations
266
    // EXTRA: we could support pointers to other simple types, but this would not make sense in most situations
261
267
262
  } else {
268
  } else {
269
    // not a pointer
263
    switch (info.typeId) {
270
    switch (info.typeId) {
264
      case PythonQtMethodInfo::Char:
271
      case PythonQtMethodInfo::Char:
265
        {
272
        {
266
          int val = PyObjGetInt(obj, strict, ok);
273
          int val = PyObjGetInt(obj, strict, ok);
267
          if (ok) {
274
          if (ok) {
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.