comparison src/if_python3.c @ 5768:3ee5808a293c v7.4.228

updated for version 7.4.228 Problem: Compiler warnings when building with Python 3.2. Solution: Make type cast depend on Python version. (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Sun, 30 Mar 2014 16:11:43 +0200
parents 30e300c0b2c1
children 38add5a3d617
comparison
equal deleted inserted replaced
5767:f11d9682dddd 5768:3ee5808a293c
97 #define Py_ssize_t_fmt "n" 97 #define Py_ssize_t_fmt "n"
98 #define Py_bytes_fmt "y" 98 #define Py_bytes_fmt "y"
99 99
100 #define PyIntArgFunc ssizeargfunc 100 #define PyIntArgFunc ssizeargfunc
101 #define PyIntObjArgProc ssizeobjargproc 101 #define PyIntObjArgProc ssizeobjargproc
102
103 /*
104 * PySlice_GetIndicesEx(): first argument type changed from PySliceObject
105 * to PyObject in Python 3.2 or later.
106 */
107 #if PY_VERSION_HEX >= 0x030200f0
108 typedef PyObject PySliceObject_T;
109 #else
110 typedef PySliceObject PySliceObject_T;
111 #endif
102 112
103 #if defined(DYNAMIC_PYTHON3) || defined(PROTO) 113 #if defined(DYNAMIC_PYTHON3) || defined(PROTO)
104 114
105 # ifndef WIN3264 115 # ifndef WIN3264
106 # include <dlfcn.h> 116 # include <dlfcn.h>
292 static PyObject* (*py3_PySequence_Fast)(PyObject *, const char *); 302 static PyObject* (*py3_PySequence_Fast)(PyObject *, const char *);
293 static Py_ssize_t (*py3_PyTuple_Size)(PyObject *); 303 static Py_ssize_t (*py3_PyTuple_Size)(PyObject *);
294 static PyObject* (*py3_PyTuple_GetItem)(PyObject *, Py_ssize_t); 304 static PyObject* (*py3_PyTuple_GetItem)(PyObject *, Py_ssize_t);
295 static int (*py3_PyMapping_Check)(PyObject *); 305 static int (*py3_PyMapping_Check)(PyObject *);
296 static PyObject* (*py3_PyMapping_Keys)(PyObject *); 306 static PyObject* (*py3_PyMapping_Keys)(PyObject *);
297 static int (*py3_PySlice_GetIndicesEx)(PySliceObject *r, Py_ssize_t length, 307 static int (*py3_PySlice_GetIndicesEx)(PySliceObject_T *r, Py_ssize_t length,
298 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, 308 Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
299 Py_ssize_t *slicelen); 309 Py_ssize_t *slicelen);
300 static PyObject* (*py3_PyErr_NoMemory)(void); 310 static PyObject* (*py3_PyErr_NoMemory)(void);
301 static void (*py3_Py_Finalize)(void); 311 static void (*py3_Py_Finalize)(void);
302 static void (*py3_PyErr_SetString)(PyObject *, const char *); 312 static void (*py3_PyErr_SetString)(PyObject *, const char *);
1188 Py_ssize_t start, stop, step, slicelen; 1198 Py_ssize_t start, stop, step, slicelen;
1189 1199
1190 if (CheckBuffer((BufferObject *) self)) 1200 if (CheckBuffer((BufferObject *) self))
1191 return NULL; 1201 return NULL;
1192 1202
1193 if (PySlice_GetIndicesEx((PySliceObject *)idx, 1203 if (PySlice_GetIndicesEx((PySliceObject_T *)idx,
1194 (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count, 1204 (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
1195 &start, &stop, 1205 &start, &stop,
1196 &step, &slicelen) < 0) 1206 &step, &slicelen) < 0)
1197 { 1207 {
1198 return NULL; 1208 return NULL;
1220 Py_ssize_t start, stop, step, slicelen; 1230 Py_ssize_t start, stop, step, slicelen;
1221 1231
1222 if (CheckBuffer((BufferObject *) self)) 1232 if (CheckBuffer((BufferObject *) self))
1223 return -1; 1233 return -1;
1224 1234
1225 if (PySlice_GetIndicesEx((PySliceObject *)idx, 1235 if (PySlice_GetIndicesEx((PySliceObject_T *)idx,
1226 (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count, 1236 (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
1227 &start, &stop, 1237 &start, &stop,
1228 &step, &slicelen) < 0) 1238 &step, &slicelen) < 0)
1229 { 1239 {
1230 return -1; 1240 return -1;
1304 return RangeItem((RangeObject *)(self), _idx); 1314 return RangeItem((RangeObject *)(self), _idx);
1305 } else if (PySlice_Check(idx)) 1315 } else if (PySlice_Check(idx))
1306 { 1316 {
1307 Py_ssize_t start, stop, step, slicelen; 1317 Py_ssize_t start, stop, step, slicelen;
1308 1318
1309 if (PySlice_GetIndicesEx((PySliceObject *)idx, 1319 if (PySlice_GetIndicesEx((PySliceObject_T *)idx,
1310 ((RangeObject *)(self))->end-((RangeObject *)(self))->start+1, 1320 ((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
1311 &start, &stop, 1321 &start, &stop,
1312 &step, &slicelen) < 0) 1322 &step, &slicelen) < 0)
1313 { 1323 {
1314 return NULL; 1324 return NULL;
1331 return RangeAsItem(self, n, val); 1341 return RangeAsItem(self, n, val);
1332 } else if (PySlice_Check(idx)) 1342 } else if (PySlice_Check(idx))
1333 { 1343 {
1334 Py_ssize_t start, stop, step, slicelen; 1344 Py_ssize_t start, stop, step, slicelen;
1335 1345
1336 if (PySlice_GetIndicesEx((PySliceObject *)idx, 1346 if (PySlice_GetIndicesEx((PySliceObject_T *)idx,
1337 ((RangeObject *)(self))->end-((RangeObject *)(self))->start+1, 1347 ((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
1338 &start, &stop, 1348 &start, &stop,
1339 &step, &slicelen) < 0) 1349 &step, &slicelen) < 0)
1340 { 1350 {
1341 return -1; 1351 return -1;