sip49_support.patch

sip patch to compile qgis 1.0.2 on SLES 10 - Otto Dassau, 2010-02-12 07:44 AM

Download (7.02 KB)

View differences:

qgis_head/python/core/conversions.sip 2009-12-01 12:49:07.000000000 +0100
3 3
which are not wrapped by PyQt:
4 4
- QVector< QVector<TYPE> >
5 5
- QVector< QVector< QVector<TYPE> > >
6
- QList< QList<TYPE> >
6 7
- QSet<int>
7 8
- QSet<TYPE>
8 9
- QMap<int, QMap<int, TYPE> >
9 10
- QMap<QString, QVariant::Type>
10 11
- QMap<TYPE1, TYPE2*>
11 12
- QMultiMap<double, TYPE2>
13
- QMap<int, QgsOverlayObject*>*
12 14
*/
13 15

  
14 16
%ModuleHeaderCode
......
18 20
#if (PY_VERSION_HEX < 0x02050000)
19 21
typedef int Py_ssize_t;
20 22
#endif
23

  
21 24
%End
22 25

  
23 26

  
27

  
24 28
template <TYPE>
25 29
%MappedType QVector< QVector<TYPE> >
26 30
{
27 31
%TypeHeaderCode
28 32
#include <QVector>
33
#if (SIP_VERSION >= 0x040900)
34
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
35
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
36
#endif
29 37
%End
30 38

  
31 39
%ConvertFromTypeCode
......
102 110
{
103 111
%TypeHeaderCode
104 112
#include <QVector>
113
#if (SIP_VERSION >= 0x040900)
114
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
115
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
116
#endif
105 117
%End
106 118

  
107 119
%ConvertFromTypeCode
......
173 185
};
174 186

  
175 187

  
188

  
189
template <TYPE>
190
%MappedType QList< QList<TYPE> >
191
{
192
%TypeHeaderCode
193
#include <QList>
194
%End
195

  
196
%ConvertFromTypeCode
197
  // Create the list.
198
  PyObject *l;
199

  
200
  if ((l = PyList_New(sipCpp->size())) == NULL)
201
    return NULL;
202

  
203
  const sipMappedType* qlist_type = sipFindMappedType("QList<TYPE>");
204

  
205
  // Set the list elements.
206
  for (int i = 0; i < sipCpp->size(); ++i)
207
  {
208
    QList<TYPE>* t = new QList<TYPE>(sipCpp->at(i));
209
    PyObject *tobj;
210

  
211
    if ((tobj = sipConvertFromMappedType(t, qlist_type, sipTransferObj)) == NULL)
212
    {
213
      Py_DECREF(l);
214
      delete t;
215
      return NULL;
216
    }
217
    PyList_SET_ITEM(l, i, tobj);
218
  }
219

  
220
  return l;
221
%End
222

  
223
%ConvertToTypeCode
224
  const sipMappedType* qlist_type = sipFindMappedType("QList<TYPE>");
225

  
226
  // Check the type if that is all that is required.
227
  if (sipIsErr == NULL)
228
  {
229
    if (!PyList_Check(sipPy))
230
      return 0;
231

  
232
    for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
233
      if (!sipCanConvertToMappedType(PyList_GET_ITEM(sipPy, i), qlist_type, SIP_NOT_NONE))
234
        return 0;
235

  
236
    return 1;
237
  }
238

  
239

  
240
  QList< QList<TYPE> > *ql = new QList< QList<TYPE> >;
241

  
242
  for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
243
  {
244
    int state;
245
    //TYPE *t = reinterpret_cast<TYPE *>(sipConvertToInstance(PyList_GET_ITEM(sipPy, i), sipClass_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
246
    QList<TYPE> * t = reinterpret_cast< QList<TYPE> * >(sipConvertToMappedType(PyList_GET_ITEM(sipPy, i), qlist_type, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
247

  
248
    if (*sipIsErr)
249
    {
250
      sipReleaseInstance(t, sipClass_TYPE, state);
251
      delete ql;
252
      return 0;
253
    }
254
    ql->append(*t);
255
    sipReleaseInstance(t, sipClass_TYPE, state);
256
  }
257

  
258
  *sipCppPtr = ql;
259
  return sipGetState(sipTransferObj);
260
%End
261

  
262
};
263

  
264

  
265

  
266

  
176 267
%MappedType QSet<int>
177 268
{
178 269
%TypeHeaderCode
179 270
#include <QSet>
271
#if (SIP_VERSION >= 0x040900)
272
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
273
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
274
#endif
180 275
%End
181 276

  
182 277
%ConvertFromTypeCode
......
227 322
{
228 323
%TypeHeaderCode
229 324
#include <QSet>
325
#if (SIP_VERSION >= 0x040900)
326
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
327
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
328
#endif
230 329
%End
231 330

  
232 331
%ConvertFromTypeCode
......
299 398
{
300 399
%TypeHeaderCode
301 400
#include <QMap>
401
#if (SIP_VERSION >= 0x040900)
402
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
403
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
404
#endif
302 405
%End
303 406

  
304 407
%ConvertFromTypeCode
......
416 519
{
417 520
%TypeHeaderCode
418 521
#include <QMap>
522
#if (SIP_VERSION >= 0x040900)
523
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
524
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
525
#endif
419 526
%End
420 527

  
421 528
%ConvertFromTypeCode
......
516 623
%MappedType QMap<TYPE1, TYPE2*>
517 624
{
518 625
%TypeHeaderCode
519
#include <qmap.h>
626
#include <QMap>
627
#if (SIP_VERSION >= 0x040900)
628
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
629
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
630
#endif
520 631
%End
521 632

  
522 633
%ConvertFromTypeCode
......
624 735
{
625 736
%TypeHeaderCode
626 737
#include <QMultiMap>
738
#if (SIP_VERSION >= 0x040900)
739
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
740
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
741
#endif
627 742
%End
628 743

  
629 744
%ConvertFromTypeCode
......
737 852
    return sipGetState(sipTransferObj);
738 853
%End
739 854
   };
855

  
856
%MappedType QMap<int, QgsOverlayObject*>
857
{
858
%TypeHeaderCode
859
#include <QMap>
860
#if (SIP_VERSION >= 0x040900)
861
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
862
#define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
863
#endif
864
%End
865

  
866
%ConvertFromTypeCode
867

  
868
//convert map to a python dictionary
869
    PyObject *d;
870

  
871
    if ((d = PyDict_New()) == NULL)
872
      return NULL;
873

  
874
    for (QMap<int, QgsOverlayObject*>::iterator it = sipCpp->begin(); it != sipCpp->end(); ++it)
875
    {
876
        QgsOverlayObject* oobj = new QgsOverlayObject(*it.value());
877

  
878
        PyObject* keyobj = PyInt_FromLong(it.key());
879
        PyObject* pyOobj = sipConvertFromInstance(oobj, sipClass_QgsOverlayObject, sipTransferObj);
880
        PyDict_SetItem(d, keyobj, pyOobj);
881

  
882
        if(pyOobj == NULL || keyobj == NULL || PyDict_SetItem(d, keyobj, pyOobj) < 0)
883
        {
884
            Py_DECREF(d);
885

  
886
            if (pyOobj)
887
            {
888
                Py_DECREF(pyOobj);
889
            }
890

  
891
            if (keyobj)
892
            {
893
                Py_DECREF(keyobj);
894
            }
895
            return NULL;
896
          }
897
        Py_DECREF(pyOobj);
898
        Py_DECREF(keyobj);
899
        }
900
    return d;
901

  
902
%End
903
%ConvertToTypeCode
904
 PyObject *t1obj, *t2obj;
905
#if PY_VERSION_HEX >= 0x02050000
906
    Py_ssize_t i = 0;
907
#else
908
    int i = 0;
909
#endif
910

  
911
    QMap<int, QgsOverlayObject*> *qm = new QMap<int, QgsOverlayObject*>;
912

  
913
    while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
914
    {
915
        int state;
916
        int t1 = (int)(PyFloat_AsDouble(t1obj));
917
        QgsOverlayObject* t2 = reinterpret_cast<QgsOverlayObject*>(sipConvertToInstance(t2obj, sipClass_QgsOverlayObject, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
918

  
919
        if (*sipIsErr)
920
        {
921
            sipReleaseInstance(t2, sipClass_QgsOverlayObject, state);
922
            delete qm;
923
            return 0;
924
        }
925

  
926
        qm->insert(t1, t2);
927

  
928
        sipReleaseInstance(t2, sipClass_QgsOverlayObject, state);
929
    }
930

  
931
    *sipCppPtr = qm;
932

  
933
    return sipGetState(sipTransferObj);
934
%End
935
};