summaryrefslogtreecommitdiffstats
path: root/Objects/bufferobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-06-14 20:41:17 (GMT)
committerGuido van Rossum <guido@python.org>2002-06-14 20:41:17 (GMT)
commitbea18ccde6bc12e061c21bb6b944379d8b123845 (patch)
treed5366d2bba31bde0cf6d05e1b55cde64cf3d3864 /Objects/bufferobject.c
parent57454e57f83b407dd2653cbfcead7c9801beeff0 (diff)
downloadcpython-bea18ccde6bc12e061c21bb6b944379d8b123845.zip
cpython-bea18ccde6bc12e061c21bb6b944379d8b123845.tar.gz
cpython-bea18ccde6bc12e061c21bb6b944379d8b123845.tar.bz2
SF patch 568629 by Oren Tirosh: types made callable.
These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido]
Diffstat (limited to 'Objects/bufferobject.c')
-rw-r--r--Objects/bufferobject.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c
index 51b9ef9..031c000 100644
--- a/Objects/bufferobject.c
+++ b/Objects/bufferobject.c
@@ -155,6 +155,27 @@ PyBuffer_New(int size)
/* Methods */
+static PyObject *
+buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw)
+{
+ PyObject *ob;
+ int offset = 0;
+ int size = Py_END_OF_BUFFER;
+
+ if ( !PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size) )
+ return NULL;
+ return PyBuffer_FromObject(ob, offset, size);
+}
+
+PyDoc_STRVAR(buffer_doc,
+"buffer(object [, offset[, size]])\n\
+\n\
+Create a new buffer object which references the given object.\n\
+The buffer will reference a slice of the target object from the\n\
+start of the object (or at the specified offset). The slice will\n\
+extend to the end of the target object (or with the specified size).");
+
+
static void
buffer_dealloc(PyBufferObject *self)
{
@@ -539,5 +560,22 @@ PyTypeObject PyBuffer_Type = {
0, /* tp_setattro */
&buffer_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
- 0, /* tp_doc */
+ buffer_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ buffer_new, /* tp_new */
};