[Python-checkins] r42332 - in python/branches/ssize_t: Include/object.h Modules/arraymodule.c Modules/mmapmodule.c Objects/bufferobject.c Objects/stringobject.c Objects/unicodeobject.c

martin.v.loewis python-checkins at python.org
Sun Feb 12 10:34:57 CET 2006


Author: martin.v.loewis
Date: Sun Feb 12 10:34:55 2006
New Revision: 42332

Modified:
   python/branches/ssize_t/Include/object.h
   python/branches/ssize_t/Modules/arraymodule.c
   python/branches/ssize_t/Modules/mmapmodule.c
   python/branches/ssize_t/Objects/bufferobject.c
   python/branches/ssize_t/Objects/stringobject.c
   python/branches/ssize_t/Objects/unicodeobject.c
Log:
Rename readbuffer function types, make them expect
and return Py_ssize_t.


Modified: python/branches/ssize_t/Include/object.h
==============================================================================
--- python/branches/ssize_t/Include/object.h	(original)
+++ python/branches/ssize_t/Include/object.h	Sun Feb 12 10:34:55 2006
@@ -139,10 +139,18 @@
 typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
 typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
 typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *);
-typedef Py_ssize_t (*getreadbufferproc)(PyObject *, int, void **);
-typedef Py_ssize_t (*getwritebufferproc)(PyObject *, int, void **);
+
+/* int-based buffer interface */
+typedef int (*getreadbufferproc)(PyObject *, int, void **);
+typedef int (*getwritebufferproc)(PyObject *, int, void **);
 typedef int (*getsegcountproc)(PyObject *, int *);
 typedef int (*getcharbufferproc)(PyObject *, int, const char **);
+/* ssize_t-based buffer interface */
+typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **);
+typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **);
+typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *);
+typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, const char **);
+
 typedef int (*objobjproc)(PyObject *, PyObject *);
 typedef int (*visitproc)(PyObject *, void *);
 typedef int (*traverseproc)(PyObject *, visitproc, void *);
@@ -221,10 +229,10 @@
 } PyMappingMethods;
 
 typedef struct {
-	getreadbufferproc bf_getreadbuffer;
-	getwritebufferproc bf_getwritebuffer;
-	getsegcountproc bf_getsegcount;
-	getcharbufferproc bf_getcharbuffer;
+	readbufferproc bf_getreadbuffer;
+	writebufferproc bf_getwritebuffer;
+	segcountproc bf_getsegcount;
+	charbufferproc bf_getcharbuffer;
 } PyBufferProcs;
 
 

Modified: python/branches/ssize_t/Modules/arraymodule.c
==============================================================================
--- python/branches/ssize_t/Modules/arraymodule.c	(original)
+++ python/branches/ssize_t/Modules/arraymodule.c	Sun Feb 12 10:34:55 2006
@@ -1747,7 +1747,7 @@
 	(objobjargproc)array_ass_subscr
 };
 
-static int
+static Py_ssize_t
 array_buffer_getreadbuf(arrayobject *self, Py_ssize_t index, const void **ptr)
 {
 	if ( index != 0 ) {
@@ -1759,7 +1759,7 @@
 	return self->ob_size*self->ob_descr->itemsize;
 }
 
-static int
+static Py_ssize_t
 array_buffer_getwritebuf(arrayobject *self, Py_ssize_t index, const void **ptr)
 {
 	if ( index != 0 ) {
@@ -1771,7 +1771,7 @@
 	return self->ob_size*self->ob_descr->itemsize;
 }
 
-static int
+static Py_ssize_t
 array_buffer_getsegcount(arrayobject *self, Py_ssize_t *lenp)
 {
 	if ( lenp )
@@ -1793,9 +1793,9 @@
 };
 
 static PyBufferProcs array_as_buffer = {
-	(getreadbufferproc)array_buffer_getreadbuf,
-	(getwritebufferproc)array_buffer_getwritebuf,
-	(getsegcountproc)array_buffer_getsegcount,
+	(readbufferproc)array_buffer_getreadbuf,
+	(writebufferproc)array_buffer_getwritebuf,
+	(segcountproc)array_buffer_getsegcount,
 };
 
 static PyObject *

Modified: python/branches/ssize_t/Modules/mmapmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/mmapmodule.c	(original)
+++ python/branches/ssize_t/Modules/mmapmodule.c	Sun Feb 12 10:34:55 2006
@@ -578,8 +578,8 @@
 
 /* Functions for treating an mmap'ed file as a buffer */
 
-static int
-mmap_buffer_getreadbuf(mmap_object *self, int index, const void **ptr)
+static Py_ssize_t
+mmap_buffer_getreadbuf(mmap_object *self, Py_ssize_t index, const void **ptr)
 {
 	CHECK_VALID(-1);
 	if ( index != 0 ) {
@@ -591,8 +591,8 @@
 	return self->size;
 }
 
-static int
-mmap_buffer_getwritebuf(mmap_object *self, int index, const void **ptr)
+static Py_ssize_t
+mmap_buffer_getwritebuf(mmap_object *self, Py_ssize_t index, const void **ptr)
 {  
 	CHECK_VALID(-1);
 	if ( index != 0 ) {
@@ -606,8 +606,8 @@
 	return self->size;
 }
 
-static int
-mmap_buffer_getsegcount(mmap_object *self, int *lenp)
+static Py_ssize_t
+mmap_buffer_getsegcount(mmap_object *self, Py_ssize_t *lenp)
 {
 	CHECK_VALID(-1);
 	if (lenp) 
@@ -615,8 +615,8 @@
 	return 1;
 }
 
-static int
-mmap_buffer_getcharbuffer(mmap_object *self, int index, const void **ptr)
+static Py_ssize_t
+mmap_buffer_getcharbuffer(mmap_object *self, Py_ssize_t index, const void **ptr)
 {
 	if ( index != 0 ) {
 		PyErr_SetString(PyExc_SystemError,
@@ -764,10 +764,10 @@
 };
 
 static PyBufferProcs mmap_as_buffer = {
-	(getreadbufferproc)mmap_buffer_getreadbuf,
-	(getwritebufferproc)mmap_buffer_getwritebuf,
-	(getsegcountproc)mmap_buffer_getsegcount,
-	(getcharbufferproc)mmap_buffer_getcharbuffer,
+	(readbufferproc)mmap_buffer_getreadbuf,
+	(writebufferproc)mmap_buffer_getwritebuf,
+	(segcountproc)mmap_buffer_getsegcount,
+	(charbufferproc)mmap_buffer_getcharbuffer,
 };
 
 static PyTypeObject mmap_object_type = {

Modified: python/branches/ssize_t/Objects/bufferobject.c
==============================================================================
--- python/branches/ssize_t/Objects/bufferobject.c	(original)
+++ python/branches/ssize_t/Objects/bufferobject.c	Sun Feb 12 10:34:55 2006
@@ -25,7 +25,7 @@
 	}
 	else {
 		Py_ssize_t count, offset;
-		getreadbufferproc proc;
+		readbufferproc proc;
 		PyBufferProcs *bp = self->b_base->ob_type->tp_as_buffer;
 		if ((*bp->bf_getsegcount)(self->b_base, NULL) != 1) {
 			PyErr_SetString(PyExc_TypeError,
@@ -35,7 +35,7 @@
 		if (self->b_readonly)
 			proc = bp->bf_getreadbuffer;
 		else
-			proc = (getreadbufferproc)bp->bf_getwritebuffer;
+			proc = (readbufferproc)bp->bf_getwritebuffer;
 		if ((count = (*proc)(self->b_base, 0, ptr)) < 0)
 			return 0;
 		/* apply constraints to the start/end */
@@ -544,7 +544,7 @@
 /* Buffer methods */
 
 static Py_ssize_t
-buffer_getreadbuf(PyBufferObject *self, int idx, void **pp)
+buffer_getreadbuf(PyBufferObject *self, Py_ssize_t idx, void **pp)
 {
 	Py_ssize_t size;
 	if ( idx != 0 ) {
@@ -558,7 +558,7 @@
 }
 
 static Py_ssize_t
-buffer_getwritebuf(PyBufferObject *self, int idx, void **pp)
+buffer_getwritebuf(PyBufferObject *self, Py_ssize_t idx, void **pp)
 {
 	if ( self->b_readonly )
 	{
@@ -568,7 +568,7 @@
 	return buffer_getreadbuf(self, idx, pp);
 }
 
-static int
+static Py_ssize_t
 buffer_getsegcount(PyBufferObject *self, Py_ssize_t *lenp)
 {
 	void *ptr;
@@ -608,10 +608,10 @@
 };
 
 static PyBufferProcs buffer_as_buffer = {
-	(getreadbufferproc)buffer_getreadbuf,
-	(getwritebufferproc)buffer_getwritebuf,
-	(getsegcountproc)buffer_getsegcount,
-	(getcharbufferproc)buffer_getcharbuf,
+	(readbufferproc)buffer_getreadbuf,
+	(writebufferproc)buffer_getwritebuf,
+	(segcountproc)buffer_getsegcount,
+	(charbufferproc)buffer_getcharbuf,
 };
 
 PyTypeObject PyBuffer_Type = {

Modified: python/branches/ssize_t/Objects/stringobject.c
==============================================================================
--- python/branches/ssize_t/Objects/stringobject.c	(original)
+++ python/branches/ssize_t/Objects/stringobject.c	Sun Feb 12 10:34:55 2006
@@ -1217,7 +1217,7 @@
 }
 
 static Py_ssize_t
-string_buffer_getreadbuf(PyStringObject *self, /*XXX*/int index, const void **ptr)
+string_buffer_getreadbuf(PyStringObject *self, Py_ssize_t index, const void **ptr)
 {
 	if ( index != 0 ) {
 		PyErr_SetString(PyExc_SystemError,
@@ -1228,15 +1228,15 @@
 	return self->ob_size;
 }
 
-static int
-string_buffer_getwritebuf(PyStringObject *self, int index, const void **ptr)
+static Py_ssize_t
+string_buffer_getwritebuf(PyStringObject *self, Py_ssize_t index, const void **ptr)
 {
 	PyErr_SetString(PyExc_TypeError,
 			"Cannot use string as modifiable buffer");
 	return -1;
 }
 
-static int
+static Py_ssize_t
 string_buffer_getsegcount(PyStringObject *self, Py_ssize_t *lenp)
 {
 	if ( lenp )
@@ -1274,10 +1274,10 @@
 };
 
 static PyBufferProcs string_as_buffer = {
-	(getreadbufferproc)string_buffer_getreadbuf,
-	(getwritebufferproc)string_buffer_getwritebuf,
-	(getsegcountproc)string_buffer_getsegcount,
-	(getcharbufferproc)string_buffer_getcharbuf,
+	(readbufferproc)string_buffer_getreadbuf,
+	(writebufferproc)string_buffer_getwritebuf,
+	(segcountproc)string_buffer_getsegcount,
+	(charbufferproc)string_buffer_getcharbuf,
 };
 
 

Modified: python/branches/ssize_t/Objects/unicodeobject.c
==============================================================================
--- python/branches/ssize_t/Objects/unicodeobject.c	(original)
+++ python/branches/ssize_t/Objects/unicodeobject.c	Sun Feb 12 10:34:55 2006
@@ -6514,7 +6514,7 @@
 
 static Py_ssize_t
 unicode_buffer_getreadbuf(PyUnicodeObject *self,
-			  int index,
+			  Py_ssize_t index,
 			  const void **ptr)
 {
     if (index != 0) {
@@ -7242,10 +7242,10 @@
 }
 
 static PyBufferProcs unicode_as_buffer = {
-    (getreadbufferproc) unicode_buffer_getreadbuf,
-    (getwritebufferproc) unicode_buffer_getwritebuf,
-    (getsegcountproc) unicode_buffer_getsegcount,
-    (getcharbufferproc) unicode_buffer_getcharbuf,
+    (readbufferproc) unicode_buffer_getreadbuf,
+    (writebufferproc) unicode_buffer_getwritebuf,
+    (segcountproc) unicode_buffer_getsegcount,
+    (charbufferproc) unicode_buffer_getcharbuf,
 };
 
 static PyObject *


More information about the Python-checkins mailing list