Contents of /trunk/boost/patches/boost-1.33.1-ssize_t.patch
Parent Directory | Revision Log
Revision 330 -
(show annotations)
(download)
Mon Sep 3 15:40:50 2007 UTC (17 years ago) by niro
File size: 12375 byte(s)
Mon Sep 3 15:40:50 2007 UTC (17 years ago) by niro
File size: 12375 byte(s)
-fixes x86_64 builts with python-2.5
1 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/boost/python/converter/builtin_converters.hpp boost/boost/python/converter/builtin_converters.hpp |
2 | --- boost-2/boost/python/converter/builtin_converters.hpp 2007-01-13 07:32:49.000000000 +0200 |
3 | +++ boost/boost/python/converter/builtin_converters.hpp 2007-01-13 09:44:06.000000000 +0200 |
4 | @@ -7,6 +7,7 @@ |
5 | # include <boost/python/detail/prefix.hpp> |
6 | # include <boost/python/detail/none.hpp> |
7 | # include <boost/python/handle.hpp> |
8 | +# include <boost/python/ssize_t.hpp> |
9 | # include <boost/implicit_cast.hpp> |
10 | # include <string> |
11 | # include <complex> |
12 | @@ -115,9 +116,9 @@ BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned |
13 | |
14 | BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x)) |
15 | BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x)) |
16 | -BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast<int>(x.size()))) |
17 | +BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast<ssize_t>(x.size()))) |
18 | # ifndef BOOST_NO_STD_WSTRING |
19 | -BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast<int>(x.size()))) |
20 | +BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast<ssize_t>(x.size()))) |
21 | # endif |
22 | BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, ::PyFloat_FromDouble(x)) |
23 | BOOST_PYTHON_TO_PYTHON_BY_VALUE(double, ::PyFloat_FromDouble(x)) |
24 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/boost/python/detail/api_placeholder.hpp boost/boost/python/detail/api_placeholder.hpp |
25 | --- boost-2/boost/python/detail/api_placeholder.hpp 2007-01-13 07:32:49.000000000 +0200 |
26 | +++ boost/boost/python/detail/api_placeholder.hpp 2007-01-13 09:58:19.000000000 +0200 |
27 | @@ -5,11 +5,13 @@ |
28 | #ifndef BOOST_PYTHON_API_PLACE_HOLDER_HPP |
29 | #define BOOST_PYTHON_API_PLACE_HOLDER_HPP |
30 | |
31 | +# include <boost/python/ssize_t.hpp> |
32 | + |
33 | namespace boost { namespace python { |
34 | |
35 | - inline long len(object const& obj) |
36 | + inline ssize_t len(object const& obj) |
37 | { |
38 | - long result = PyObject_Length(obj.ptr()); |
39 | + ssize_t result = PyObject_Length(obj.ptr()); |
40 | if (PyErr_Occurred()) throw_error_already_set(); |
41 | return result; |
42 | } |
43 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/boost/python/list.hpp boost/boost/python/list.hpp |
44 | --- boost-2/boost/python/list.hpp 2007-01-13 07:32:49.000000000 +0200 |
45 | +++ boost/boost/python/list.hpp 2007-01-13 09:26:21.000000000 +0200 |
46 | @@ -9,6 +9,7 @@ |
47 | |
48 | # include <boost/python/object.hpp> |
49 | # include <boost/python/converter/pytype_object_mgr_traits.hpp> |
50 | +# include <boost/python/ssize_t.hpp> |
51 | |
52 | namespace boost { namespace python { |
53 | |
54 | @@ -24,11 +25,11 @@ namespace detail |
55 | |
56 | long index(object_cref value) const; // return index of first occurrence of value |
57 | |
58 | - void insert(int index, object_cref); // insert object before index |
59 | + void insert(ssize_t index, object_cref); // insert object before index |
60 | void insert(object const& index, object_cref); |
61 | |
62 | object pop(); // remove and return item at index (default last) |
63 | - object pop(long index); |
64 | + object pop(ssize_t index); |
65 | object pop(object const& index); |
66 | |
67 | void remove(object_cref value); // remove first occurrence of value |
68 | @@ -86,7 +87,7 @@ class list : public detail::list_base |
69 | } |
70 | |
71 | template <class T> |
72 | - void insert(int index, T const& x) // insert object before index |
73 | + void insert(ssize_t index, T const& x) // insert object before index |
74 | { |
75 | base::insert(index, object(x)); |
76 | } |
77 | @@ -98,7 +99,7 @@ class list : public detail::list_base |
78 | } |
79 | |
80 | object pop() { return base::pop(); } |
81 | - object pop(long index) { return base::pop(index); } |
82 | + object pop(ssize_t index) { return base::pop(index); } |
83 | |
84 | template <class T> |
85 | object pop(T const& index) |
86 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/boost/python/object.hpp boost/boost/python/object.hpp |
87 | --- boost-2/boost/python/object.hpp 2007-01-13 07:32:49.000000000 +0200 |
88 | +++ boost/boost/python/object.hpp 2007-01-13 09:57:33.000000000 +0200 |
89 | @@ -6,6 +6,7 @@ |
90 | # define OBJECT_DWA2002612_HPP |
91 | |
92 | # include <boost/python/detail/prefix.hpp> |
93 | +# include <boost/python/ssize_t.hpp> |
94 | # include <boost/python/object_core.hpp> |
95 | # include <boost/python/object_attributes.hpp> |
96 | # include <boost/python/object_items.hpp> |
97 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/boost/python/ssize_t.hpp boost/boost/python/ssize_t.hpp |
98 | --- boost-2/boost/python/ssize_t.hpp 1970-01-01 02:00:00.000000000 +0200 |
99 | +++ boost/boost/python/ssize_t.hpp 2007-01-13 09:47:10.000000000 +0200 |
100 | @@ -0,0 +1,29 @@ |
101 | +// Copyright Ralf W. Grosse-Kunstleve & David Abrahams 2006. |
102 | +// Distributed under the Boost Software License, Version 1.0. (See |
103 | +// accompanying file LICENSE_1_0.txt or copy at |
104 | +// http://www.boost.org/LICENSE_1_0.txt) |
105 | + |
106 | +#ifndef BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP |
107 | +# define BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP |
108 | + |
109 | +# include <boost/python/detail/prefix.hpp> |
110 | + |
111 | +namespace boost { namespace python { |
112 | + |
113 | +#if PY_VERSION_HEX >= 0x02050000 |
114 | + |
115 | +typedef Py_ssize_t ssize_t; |
116 | +ssize_t const ssize_t_max = PY_SSIZE_T_MAX; |
117 | +ssize_t const ssize_t_min = PY_SSIZE_T_MIN; |
118 | + |
119 | +#else |
120 | + |
121 | +typedef int ssize_t; |
122 | +ssize_t const ssize_t_max = INT_MAX; |
123 | +ssize_t const ssize_t_min = INT_MIN; |
124 | + |
125 | +#endif |
126 | + |
127 | +}} // namespace boost::python |
128 | + |
129 | +#endif // BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP |
130 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/libs/python/src/list.cpp boost/libs/python/src/list.cpp |
131 | --- boost-2/libs/python/src/list.cpp 2007-01-13 07:36:25.000000000 +0200 |
132 | +++ boost/libs/python/src/list.cpp 2007-01-13 09:28:09.000000000 +0200 |
133 | @@ -3,6 +3,7 @@ |
134 | // accompanying file LICENSE_1_0.txt or copy at |
135 | // http://www.boost.org/LICENSE_1_0.txt) |
136 | #include <boost/python/list.hpp> |
137 | +#include <boost/python/ssize_t.hpp> |
138 | |
139 | namespace boost { namespace python { namespace detail { |
140 | |
141 | @@ -53,7 +54,7 @@ long list_base::index(object_cref value) |
142 | return result; |
143 | } |
144 | |
145 | -void list_base::insert(int index, object_cref item) |
146 | +void list_base::insert(ssize_t index, object_cref item) |
147 | { |
148 | if (PyList_CheckExact(this->ptr())) |
149 | { |
150 | @@ -79,7 +80,7 @@ object list_base::pop() |
151 | return this->attr("pop")(); |
152 | } |
153 | |
154 | -object list_base::pop(long index) |
155 | +object list_base::pop(ssize_t index) |
156 | { |
157 | return this->pop(object(index)); |
158 | } |
159 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/libs/python/src/object/class.cpp boost/libs/python/src/object/class.cpp |
160 | --- boost-2/libs/python/src/object/class.cpp 2007-01-13 07:36:26.000000000 +0200 |
161 | +++ boost/libs/python/src/object/class.cpp 2007-01-13 09:28:10.000000000 +0200 |
162 | @@ -20,6 +20,7 @@ |
163 | #include <boost/python/self.hpp> |
164 | #include <boost/python/dict.hpp> |
165 | #include <boost/python/str.hpp> |
166 | +#include <boost/python/ssize_t.hpp> |
167 | #include <functional> |
168 | #include <vector> |
169 | #include <cstddef> |
170 | @@ -480,13 +481,14 @@ namespace objects |
171 | // were declared, we'll use our class_type() as the single base |
172 | // class. |
173 | std::size_t const num_bases = (std::max)(num_types - 1, static_cast<std::size_t>(1)); |
174 | - handle<> bases(PyTuple_New(num_bases)); |
175 | + assert(num_bases <= ssize_t_max); |
176 | + handle<> bases(PyTuple_New(static_cast<ssize_t>(num_bases))); |
177 | |
178 | for (std::size_t i = 1; i <= num_bases; ++i) |
179 | { |
180 | type_handle c = (i >= num_types) ? class_type() : get_class(types[i]); |
181 | // PyTuple_SET_ITEM steals this reference |
182 | - PyTuple_SET_ITEM(bases.get(), i - 1, upcast<PyObject>(c.release())); |
183 | + PyTuple_SET_ITEM(bases.get(), static_cast<ssize_t>(i - 1), upcast<PyObject>(c.release())); |
184 | } |
185 | |
186 | // Call the class metatype to create a new class |
187 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/libs/python/src/object/function.cpp boost/libs/python/src/object/function.cpp |
188 | --- boost-2/libs/python/src/object/function.cpp 2007-01-13 07:36:26.000000000 +0200 |
189 | +++ boost/libs/python/src/object/function.cpp 2007-01-13 09:28:11.000000000 +0200 |
190 | @@ -14,6 +14,7 @@ |
191 | #include <boost/python/extract.hpp> |
192 | #include <boost/python/tuple.hpp> |
193 | #include <boost/python/list.hpp> |
194 | +#include <boost/python/ssize_t.hpp> |
195 | |
196 | #include <boost/python/detail/api_placeholder.hpp> |
197 | #include <boost/python/detail/signature.hpp> |
198 | @@ -60,7 +61,7 @@ function::function( |
199 | = max_arity > num_keywords ? max_arity - num_keywords : 0; |
200 | |
201 | |
202 | - unsigned tuple_size = num_keywords ? max_arity : 0; |
203 | + ssize_t tuple_size = num_keywords ? max_arity : 0; |
204 | m_arg_names = object(handle<>(PyTuple_New(tuple_size))); |
205 | |
206 | if (num_keywords != 0) |
207 | @@ -154,7 +155,9 @@ PyObject* function::call(PyObject* args, |
208 | else |
209 | { |
210 | // build a new arg tuple, will adjust its size later |
211 | - inner_args = handle<>(PyTuple_New(max_arity)); |
212 | + assert(max_arity <= ssize_t_max); |
213 | + inner_args = handle<>( |
214 | + PyTuple_New(static_cast<ssize_t>(max_arity))); |
215 | |
216 | // Fill in the positional arguments |
217 | for (std::size_t i = 0; i < n_unnamed_actual; ++i) |
218 | @@ -237,7 +240,7 @@ void function::argument_error(PyObject* |
219 | % make_tuple(this->m_namespace, this->m_name); |
220 | |
221 | list actual_args; |
222 | - for (int i = 0; i < PyTuple_Size(args); ++i) |
223 | + for (ssize_t i = 0; i < PyTuple_Size(args); ++i) |
224 | { |
225 | char const* name = PyTuple_GetItem(args, i)->ob_type->tp_name; |
226 | actual_args.append(str(name)); |
227 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/libs/python/src/object_protocol.cpp boost/libs/python/src/object_protocol.cpp |
228 | --- boost-2/libs/python/src/object_protocol.cpp 2007-01-13 07:36:25.000000000 +0200 |
229 | +++ boost/libs/python/src/object_protocol.cpp 2007-01-13 09:28:10.000000000 +0200 |
230 | @@ -6,6 +6,7 @@ |
231 | #include <boost/python/object_protocol.hpp> |
232 | #include <boost/python/errors.hpp> |
233 | #include <boost/python/object.hpp> |
234 | +#include <boost/python/ssize_t.hpp> |
235 | |
236 | namespace boost { namespace python { namespace api { |
237 | |
238 | @@ -106,7 +107,7 @@ namespace // slicing code copied directl |
239 | PySequenceMethods *sq = tp->tp_as_sequence; |
240 | |
241 | if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) { |
242 | - int ilow = 0, ihigh = INT_MAX; |
243 | + ssize_t ilow = 0, ihigh = ssize_t_max; |
244 | if (!_PyEval_SliceIndex(v, &ilow)) |
245 | return NULL; |
246 | if (!_PyEval_SliceIndex(w, &ihigh)) |
247 | @@ -133,7 +134,7 @@ namespace // slicing code copied directl |
248 | PySequenceMethods *sq = tp->tp_as_sequence; |
249 | |
250 | if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) { |
251 | - int ilow = 0, ihigh = INT_MAX; |
252 | + ssize_t ilow = 0, ihigh = ssize_t_max; |
253 | if (!_PyEval_SliceIndex(v, &ilow)) |
254 | return -1; |
255 | if (!_PyEval_SliceIndex(w, &ihigh)) |
256 | diff -Nurp -x CVS -x '.#*' -x '*~' -x '*.html' boost-2/libs/python/src/str.cpp boost/libs/python/src/str.cpp |
257 | --- boost-2/libs/python/src/str.cpp 2007-01-13 07:36:25.000000000 +0200 |
258 | +++ boost/libs/python/src/str.cpp 2007-01-13 09:28:10.000000000 +0200 |
259 | @@ -3,6 +3,7 @@ |
260 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
261 | #include <boost/python/str.hpp> |
262 | #include <boost/python/extract.hpp> |
263 | +#include <boost/python/ssize_t.hpp> |
264 | |
265 | namespace boost { namespace python { namespace detail { |
266 | |
267 | @@ -21,10 +22,25 @@ str_base::str_base(const char* s) |
268 | : object(detail::new_reference(::PyString_FromString(s))) |
269 | {} |
270 | |
271 | +namespace { |
272 | + |
273 | + ssize_t str_size_as_py_ssize_t(std::size_t n) |
274 | + { |
275 | + if (n > ssize_t_max) |
276 | + { |
277 | + throw std::range_error("str size > ssize_t_max"); |
278 | + } |
279 | + return static_cast<ssize_t>(n); |
280 | + } |
281 | + |
282 | +} // namespace <anonymous> |
283 | + |
284 | str_base::str_base(char const* start, char const* finish) |
285 | : object( |
286 | detail::new_reference( |
287 | - ::PyString_FromStringAndSize(start, finish - start) |
288 | + ::PyString_FromStringAndSize( |
289 | + start, str_size_as_py_ssize_t(finish - start) |
290 | + ) |
291 | ) |
292 | ) |
293 | {} |
294 | @@ -32,7 +48,9 @@ str_base::str_base(char const* start, ch |
295 | str_base::str_base(char const* start, std::size_t length) // new str |
296 | : object( |
297 | detail::new_reference( |
298 | - ::PyString_FromStringAndSize(start, length) |
299 | + ::PyString_FromStringAndSize( |
300 | + start, str_size_as_py_ssize_t(length) |
301 | + ) |
302 | ) |
303 | ) |
304 | {} |