/[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.1 - (show annotations) (download) (as text)
Wed Jun 16 01:41:45 2010 UTC (9 years, 11 months ago) by chiiph
Branch: MAIN
File MIME type: text/x-diff
Add patch for qreal/float support in ARM wrt bug 322349
(Portage version: 2.2_rc67/cvs/Linux i686)

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

  ViewVC Help
Powered by ViewVC 1.1.20