Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 813312
Collapse All | Expand All

(-)a/project.py (-1 / +1 lines)
Lines 42-48 class PopplerQt5Bindings(PyQtBindings): Link Here
42
    def run_pkg_config(option):
42
    def run_pkg_config(option):
43
        output = subprocess.check_output(
43
        output = subprocess.check_output(
44
            ['pkg-config', option, 'poppler-qt5'],
44
            ['pkg-config', option, 'poppler-qt5'],
45
            text=True)
45
            universal_newlines=True)
46
        return output.rstrip()
46
        return output.rstrip()
47
47
48
    def apply_user_defaults(self, tool):
48
    def apply_user_defaults(self, tool):
(-)a/types.sip (+93 lines)
Lines 331-335 template <TYPE> Link Here
331
};
331
};
332
332
333
333
334
/**
335
 * Convert QVector< QPair<TYPE, TYPE> >
336
 * from and to a Python list of a 2-item tuple
337
 */
338
339
template<TYPE>
340
%MappedType QVector< QPair<TYPE, TYPE> >
341
{
342
%TypeHeaderCode
343
#include <qvector.h>
344
#include <qpair.h>
345
%End
346
347
%ConvertFromTypeCode
348
  // Create the list.
349
  PyObject *l;
350
351
  if ((l = PyList_New(sipCpp->size())) == NULL)
352
      return NULL;
353
354
  // Set the list elements.
355
  for (int i = 0; i < sipCpp->size(); ++i)
356
  {
357
    QPair<TYPE, TYPE>* p = new QPair<TYPE, TYPE>(sipCpp->at(i));
358
    PyObject *ptuple = PyTuple_New(2);
359
    PyObject *pfirst;
360
    PyObject *psecond;
361
362
    TYPE *sfirst = new TYPE(p->first);
363
    if ((pfirst = sipConvertFromType(sfirst, sipType_TYPE, sipTransferObj)) == NULL)
364
    {
365
      Py_DECREF(l);
366
      Py_DECREF(ptuple);
367
      return NULL;
368
    }
369
    PyTuple_SET_ITEM(ptuple, 0, pfirst);
370
371
    TYPE *ssecond = new TYPE(p->second);
372
    if ((psecond = sipConvertFromType(ssecond, sipType_TYPE, sipTransferObj)) == NULL)
373
    {
374
      Py_DECREF(l);
375
      Py_DECREF(ptuple);
376
      Py_DECREF(pfirst);
377
      return NULL;
378
    }
379
    PyTuple_SET_ITEM(ptuple, 1, psecond);
380
381
    PyList_SET_ITEM(l, i, ptuple);
382
  }
383
384
  return l;
385
%End
386
387
%ConvertToTypeCode
388
  const sipTypeDef* qpair_type = sipFindType("QPair<TYPE, TYPE>");
389
390
  // Check the type if that is all that is required.
391
  if (sipIsErr == NULL)
392
  {
393
    if (!PySequence_Check(sipPy))
394
      return 0;
395
396
    for (int i = 0; i < PySequence_Size(sipPy); ++i)
397
      if (!sipCanConvertToType(PySequence_ITEM(sipPy, i), qpair_type, SIP_NOT_NONE))
398
        return 0;
399
400
    return 1;
401
  }
402
403
404
  QVector< QPair<TYPE, TYPE> > *qv = new QVector< QPair<TYPE, TYPE> >;
405
406
  for (int i = 0; i < PySequence_Size(sipPy); ++i)
407
  {
408
    int state;
409
    QPair<TYPE, TYPE> * p = reinterpret_cast< QPair<TYPE, TYPE> * >(sipConvertToType(PySequence_ITEM(sipPy, i), qpair_type, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
410
411
    if (*sipIsErr)
412
    {
413
      sipReleaseType(p, qpair_type, state);
414
      delete qv;
415
      return 0;
416
    }
417
    qv->append(*p);
418
    sipReleaseType(p, qpair_type, state);
419
  }
420
421
  *sipCppPtr = qv;
422
  return sipGetState(sipTransferObj);
423
%End
424
425
};
426
334
427
335
/* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */
428
/* kate: indent-width 4; space-indent on; hl c++; indent-mode cstyle; */

Return to bug 813312