/[gentoo-x86]/dev-python/PyQt4/files/PyQt4-4.7.3-qreal_float_support.patch
Gentoo

Contents of /dev-python/PyQt4/files/PyQt4-4.7.3-qreal_float_support.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download) (as text)
Sat Dec 28 18:46:22 2013 UTC (6 years, 5 months ago) by nerdboy
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -15 lines
File MIME type: text/x-diff
Updated qreal_float patch (for arm) to remove obsolete hunk.

(Portage version: 2.2.7/cvs/Linux x86_64, signed Manifest commit with key )

1 chiiph 1.1 #! /bin/sh /usr/share/dpatch/dpatch-run
2     ## 03_qreal_float_support.dpatch by Michael Casadevall <sonicmctails@gmail.com>
3     ##
4     ## DP: Corrects a configure test, and adds explicate double handling
5     ## to qlist.sip on architectures where qreal != double
6    
7     @DPATCH@
8     Index: python-qt4-4.7.2/sip/QtCore/qlist.sip
9     ===================================================================
10     --- python-qt4-4.7.2.orig/sip/QtCore/qlist.sip 2010-03-17 19:29:26.000000000 +0100
11     +++ python-qt4-4.7.2/sip/QtCore/qlist.sip 2010-03-25 23:53:55.468631945 +0100
12     @@ -749,3 +749,227 @@
13     return sipGetState(sipTransferObj);
14     %End
15     };
16     +
17     +// If we're on an architecture where qreal != double, then we need to also
18     +// explicately handle doubles. On architectures where qreal == double, they
19     +// will automaticially be cast upwards
20     +
21     +%If (!PyQt_qreal_double)
22     +
23     +%If (Qt_4_3_0 -)
24     +// QList<QPair<double, double> > is implemented as a Python list of 2-element tuples.
25     +%MappedType QList<QPair<double, double> >
26     +{
27     +%TypeHeaderCode
28     +#include <qlist.h>
29     +#include <qpair.h>
30     +%End
31     +
32     +%ConvertFromTypeCode
33     + // Create the list.
34     + PyObject *l;
35     +
36     + if ((l = PyList_New(sipCpp->size())) == NULL)
37     + return NULL;
38     +
39     + // Set the list elements.
40     + for (int i = 0; i < sipCpp->size(); ++i)
41     + {
42     + const QPair<double, double> &p = sipCpp->at(i);
43     + PyObject *pobj;
44     +
45     + if ((pobj = Py_BuildValue((char *)"dd", p.first, p.second)) == NULL)
46     + {
47     + Py_DECREF(l);
48     +
49     + return NULL;
50     + }
51     +
52     + PyList_SET_ITEM(l, i, pobj);
53     + }
54     +
55     + return l;
56     +%End
57     +
58     +%ConvertToTypeCode
59     + SIP_SSIZE_T len;
60     +
61     + // Check the type if that is all that is required.
62     + if (sipIsErr == NULL)
63     + {
64     + if (!PySequence_Check(sipPy) || (len = PySequence_Size(sipPy)) < 0)
65     + return 0;
66     +
67     + for (SIP_SSIZE_T i = 0; i < len; ++i)
68     + {
69     + PyObject *tup = PySequence_ITEM(sipPy, i);
70     +
71     + if (!PySequence_Check(tup) || PySequence_Size(tup) != 2)
72     + return 0;
73     + }
74     +
75     + return 1;
76     + }
77     +
78     + QList<QPair<double, double> > *ql = new QList<QPair<double, double> >;
79     + len = PySequence_Size(sipPy);
80     +
81     + for (SIP_SSIZE_T i = 0; i < len; ++i)
82     + {
83     + PyObject *tup = PySequence_ITEM(sipPy, i);
84     +
85     + double first = PyFloat_AsDouble(PySequence_ITEM(tup, 0));
86     + double second = PyFloat_AsDouble(PySequence_ITEM(tup, 1));
87     +
88     + ql->append(QPair<double, double>(first, second));
89     + }
90     +
91     + *sipCppPtr = ql;
92     +
93     + return sipGetState(sipTransferObj);
94     +%End
95     +};
96     +%End
97     +%If (Qt_4_3_0 -)
98     +// QList<QPair<double, TYPE> > is implemented as a Python list of 2-element tuples.
99     +template<double, TYPE>
100     +%MappedType QList<QPair<double, TYPE> >
101     +{
102     +%TypeHeaderCode
103     +#include <qlist.h>
104     +#include <qpair.h>
105     +%End
106     +
107     +%ConvertFromTypeCode
108     + // Create the list.
109     + PyObject *l;
110     +
111     + if ((l = PyList_New(sipCpp->size())) == NULL)
112     + return NULL;
113     +
114     + // Set the list elements.
115     + for (int i = 0; i < sipCpp->size(); ++i)
116     + {
117     + const QPair<double, TYPE> &p = sipCpp->at(i);
118     + TYPE *t = new TYPE(p.second);
119     + PyObject *pobj;
120     +
121     + if ((pobj = sipBuildResult(NULL, "(dB)", p.first, t, sipClass_TYPE, sipTransferObj)) == NULL)
122     + {
123     + Py_DECREF(l);
124     + delete t;
125     +
126     + return NULL;
127     + }
128     +
129     + PyList_SET_ITEM(l, i, pobj);
130     + }
131     +
132     + return l;
133     +%End
134     +
135     +%ConvertToTypeCode
136     + SIP_SSIZE_T len;
137     +
138     + // Check the type if that is all that is required.
139     + if (sipIsErr == NULL)
140     + {
141     + if (!PySequence_Check(sipPy) || (len = PySequence_Size(sipPy)) < 0)
142     + return 0;
143     +
144     + for (SIP_SSIZE_T i = 0; i < len; ++i)
145     + {
146     + PyObject *tup = PySequence_ITEM(sipPy, i);
147     +
148     + if (!PySequence_Check(tup) || PySequence_Size(tup) != 2)
149     + return 0;
150     +
151     + if (!sipCanConvertToInstance(PySequence_ITEM(tup, 1), sipClass_TYPE, SIP_NOT_NONE))
152     + return 0;
153     + }
154     +
155     + return 1;
156     + }
157     +
158     + QList<QPair<double, TYPE> > *ql = new QList<QPair<double, TYPE> >;
159     + len = PySequence_Size(sipPy);
160     +
161     + for (SIP_SSIZE_T i = 0; i < len; ++i)
162     + {
163     + PyObject *tup = PySequence_ITEM(sipPy, i);
164     + double d;
165     + int state;
166     +
167     + d = PyFloat_AsDouble(PySequence_ITEM(tup, 0));
168     + TYPE *t = reinterpret_cast<TYPE *>(sipConvertToInstance(PySequence_ITEM(tup, 1), sipClass_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
169     +
170     + if (*sipIsErr)
171     + {
172     + sipReleaseInstance(t, sipClass_TYPE, state);
173     +
174     + delete ql;
175     + return 0;
176     + }
177     +
178     + ql->append(QPair<double, TYPE>(d, *t));
179     +
180     + sipReleaseInstance(t, sipClass_TYPE, state);
181     + }
182     +
183     + *sipCppPtr = ql;
184     +
185     + return sipGetState(sipTransferObj);
186     +%End
187     +};
188     +%End
189     +
190     +// QList<double> is implemented as a Python list of doubles.
191     +%MappedType QList<double>
192     +{
193     +%TypeHeaderCode
194     +#include <qlist.h>
195     +%End
196     +
197     +%ConvertFromTypeCode
198     + // Create the list.
199     + PyObject *l;
200     +
201     + if ((l = PyList_New(sipCpp->size())) == NULL)
202     + return NULL;
203     +
204     + // Set the list elements.
205     + for (int i = 0; i < sipCpp->size(); ++i)
206     + {
207     + PyObject *pobj;
208     +
209     + if ((pobj = PyFloat_FromDouble(sipCpp->value(i))) == NULL)
210     + {
211     + Py_DECREF(l);
212     +
213     + return NULL;
214     + }
215     +
216     + PyList_SET_ITEM(l, i, pobj);
217     + }
218     +
219     + return l;
220     +%End
221     +
222     +%ConvertToTypeCode
223     + // Check the type if that is all that is required.
224     + if (sipIsErr == NULL)
225     + return (PySequence_Check(sipPy) && PySequence_Size(sipPy) >= 0);
226     +
227     + QList<double> *ql = new QList<double>;
228     + SIP_SSIZE_T len = PySequence_Size(sipPy);
229     +
230     + for (SIP_SSIZE_T i = 0; i < len; ++i)
231     + ql->append(PyFloat_AsDouble(PySequence_ITEM(sipPy, i)));
232     +
233     + *sipCppPtr = ql;
234     +
235     + return sipGetState(sipTransferObj);
236     +%End
237     +};
238     +
239     +%End

  ViewVC Help
Powered by ViewVC 1.1.20