Skip to content

Commit

Permalink
Merge ssize_t branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
loewis committed Feb 15, 2006
1 parent 4482929 commit 18e1655
Show file tree
Hide file tree
Showing 102 changed files with 2,659 additions and 1,677 deletions.
36 changes: 18 additions & 18 deletions Include/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
equivalent to the Python expression: type(o).
*/

PyAPI_FUNC(int) PyObject_Size(PyObject *o);
PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o);

/*
Return the size of object o. If the object, o, provides
Expand All @@ -419,10 +419,10 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

/* For DLL compatibility */
#undef PyObject_Length
PyAPI_FUNC(int) PyObject_Length(PyObject *o);
PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
#define PyObject_Length PyObject_Size

PyAPI_FUNC(int) _PyObject_LengthHint(PyObject *o);
PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o);

/*
Return the size of object o. If the object, o, provides
Expand Down Expand Up @@ -477,7 +477,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
const char **buffer,
int *buffer_len);
Py_ssize_t *buffer_len);

/*
Takes an arbitrary object which must support the (character,
Expand All @@ -502,7 +502,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
const void **buffer,
int *buffer_len);
Py_ssize_t *buffer_len);

/*
Same as PyObject_AsCharBuffer() except that this API expects
Expand All @@ -518,7 +518,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
void **buffer,
int *buffer_len);
Py_ssize_t *buffer_len);

/*
Takes an arbitrary object which must support the (writeable,
Expand Down Expand Up @@ -911,7 +911,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/

PyAPI_FUNC(int) PySequence_Size(PyObject *o);
PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o);

/*
Return the size of sequence object o, or -1 on failure.
Expand All @@ -920,7 +920,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

/* For DLL compatibility */
#undef PySequence_Length
PyAPI_FUNC(int) PySequence_Length(PyObject *o);
PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o);
#define PySequence_Length PySequence_Size


Expand All @@ -933,7 +933,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/

PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, int count);
PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count);

/*
Return the result of repeating sequence object o count times,
Expand All @@ -942,14 +942,14 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/

PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, int i);
PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);

/*
Return the ith element of o, or NULL on failure. This is the
equivalent of the Python expression: o[i].
*/

PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, int i1, int i2);
PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);

/*
Return the slice of sequence object o between i1 and i2, or
Expand All @@ -958,7 +958,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/

PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, int i, PyObject *v);
PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v);

/*
Assign object v to the ith element of o. Returns
Expand All @@ -967,15 +967,15 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/

PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, int i);
PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);

/*
Delete the ith element of object v. Returns
-1 on failure. This is the equivalent of the Python
statement: del o[i].
*/

PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, int i1, int i2,
PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2,
PyObject *v);

/*
Expand All @@ -984,7 +984,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
equivalent of the Python statement: o[i1:i2]=v.
*/

PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, int i1, int i2);
PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);

/*
Delete the slice in sequence object, o, from i1 to i2.
Expand Down Expand Up @@ -1105,7 +1105,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/

PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, int count);
PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);

/*
Repeat o1 by count, in-place when possible. Return the resulting
Expand All @@ -1125,7 +1125,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
This function always succeeds.
*/

PyAPI_FUNC(int) PyMapping_Size(PyObject *o);
PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o);

/*
Returns the number of keys in object o on success, and -1 on
Expand All @@ -1135,7 +1135,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/

/* For DLL compatibility */
#undef PyMapping_Length
PyAPI_FUNC(int) PyMapping_Length(PyObject *o);
PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
#define PyMapping_Length PyMapping_Size


Expand Down
12 changes: 6 additions & 6 deletions Include/bufferobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ PyAPI_DATA(PyTypeObject) PyBuffer_Type;
#define Py_END_OF_BUFFER (-1)

PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
int offset, int size);
Py_ssize_t offset, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
int offset,
int size);
Py_ssize_t offset,
Py_ssize_t size);

PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, int size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, int size);
PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);

PyAPI_FUNC(PyObject *) PyBuffer_New(int size);
PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions Include/cStringIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static struct PycStringIO_CAPI {
/* Read a string from an input object. If the last argument
is -1, the remainder will be read.
*/
int(*cread)(PyObject *, char **, int);
int(*cread)(PyObject *, char **, Py_ssize_t);

/* Read a line from an input object. Returns the length of the read
line as an int and a pointer inside the object buffer as char** (so
Expand All @@ -38,7 +38,7 @@ static struct PycStringIO_CAPI {
int(*creadline)(PyObject *, char **);

/* Write a string to an output object*/
int(*cwrite)(PyObject *, const char *, int);
int(*cwrite)(PyObject *, const char *, Py_ssize_t);

/* Get the output object as a Python string (returns new reference). */
PyObject *(*cgetvalue)(PyObject *);
Expand Down
2 changes: 1 addition & 1 deletion Include/ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ PyAPI_FUNC(void) PyEval_ReInitThreads(void);

#endif /* !WITH_THREAD */

PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, int *);
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);


#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions Include/dictobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
PyAPI_FUNC(int) PyDict_Next(
PyObject *mp, int *pos, PyObject **key, PyObject **value);
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
PyAPI_FUNC(int) PyDict_Size(PyObject *mp);
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);

Expand Down
5 changes: 4 additions & 1 deletion Include/intobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ PyAPI_DATA(PyTypeObject) PyInt_Type;

PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
#ifdef Py_USING_UNICODE
PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, int, int);
PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
#endif
PyAPI_FUNC(PyObject *) PyInt_FromLong(long);
PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t);
PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t);
PyAPI_FUNC(long) PyInt_AsLong(PyObject *);
PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *);
PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *);
#ifdef HAVE_LONG_LONG
PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
Expand Down
16 changes: 8 additions & 8 deletions Include/listobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ typedef struct {
* Items must normally not be NULL, except during construction when
* the list is not yet visible outside the function that builds it.
*/
int allocated;
Py_ssize_t allocated;
} PyListObject;

PyAPI_DATA(PyTypeObject) PyList_Type;

#define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type)
#define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)

PyAPI_FUNC(PyObject *) PyList_New(int size);
PyAPI_FUNC(int) PyList_Size(PyObject *);
PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, int);
PyAPI_FUNC(int) PyList_SetItem(PyObject *, int, PyObject *);
PyAPI_FUNC(int) PyList_Insert(PyObject *, int, PyObject *);
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, int, int);
PyAPI_FUNC(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
PyAPI_FUNC(int) PyList_Sort(PyObject *);
PyAPI_FUNC(int) PyList_Reverse(PyObject *);
PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
Expand Down
2 changes: 1 addition & 1 deletion Include/longintrepr.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct _longobject {
digit ob_digit[1];
};

PyAPI_FUNC(PyLongObject *) _PyLong_New(int);
PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t);

/* Return a copy of src. */
PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src);
Expand Down
7 changes: 6 additions & 1 deletion Include/longobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);

/* For use by intobject.c only */
PyAPI_FUNC(Py_ssize_t) _PyLong_AsSsize_t(PyObject *);
PyAPI_FUNC(PyObject *) _PyLong_FromSize_t(size_t);
PyAPI_FUNC(PyObject *) _PyLong_FromSsize_t(Py_ssize_t);

/* _PyLong_AsScaledDouble returns a double x and an exponent e such that
the true value is approximately equal to x * 2**(SHIFT*e). e is >= 0.
x is 0.0 if and only if the input is 0 (in which case, e and x are both
Expand All @@ -43,7 +48,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);

PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
#ifdef Py_USING_UNICODE
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, int, int);
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
#endif

/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
Expand Down
2 changes: 1 addition & 1 deletion Include/marshal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, int);
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);

#ifdef __cplusplus
}
Expand Down
32 changes: 28 additions & 4 deletions Include/modsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ extern "C" {

#include <stdarg.h>

/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
to mean Py_ssize_t */
#ifdef PY_SSIZE_T_CLEAN
#define PyArg_Parse _PyArg_Parse_SizeT
#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT
#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
#define PyArg_VaParse _PyArg_VaParse_SizeT
#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
#define PyArg_BuildValue _PyArg_BuildValue_SizeT
#define PyArg_VaBuildValue _PyArg_VaBuildValue_SizeT
#endif

PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
Expand All @@ -26,6 +38,7 @@ PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);


#define PYTHON_API_VERSION 1012
#define PYTHON_API_STRING "1012"
/* The API version is maintained (independently from the Python version)
Expand Down Expand Up @@ -77,11 +90,22 @@ PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char
without actually needing a recompile. */
#endif /* MS_WINDOWS */

#if SIZEOF_SIZE_T != SIZEOF_INT
/* On a 64-bit system, rename the Py_InitModule4 so that 2.4
modules cannot get loaded into a 2.5 interpreter */
#define Py_InitModule4 Py_InitModule4_64
#endif

#ifdef Py_TRACE_REFS
/* When we are tracing reference counts, rename Py_InitModule4 so
modules compiled with incompatible settings will generate a
link-time error. */
#define Py_InitModule4 Py_InitModule4TraceRefs
/* When we are tracing reference counts, rename Py_InitModule4 so
modules compiled with incompatible settings will generate a
link-time error. */
#if SIZEOF_SIZE_T != SIZEOF_INT
#undef Py_InitModule4
#define Py_InitModule4 Py_InitModule4TraceRefs_64
#else
#define Py_InitModule4 Py_InitModule4TraceRefs
#endif
#endif

PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods,
Expand Down
Loading

0 comments on commit 18e1655

Please sign in to comment.