From bea18ccde6bc12e061c21bb6b944379d8b123845 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 14 Jun 2002 20:41:17 +0000 Subject: 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] --- Objects/bufferobject.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'Objects/bufferobject.c') diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c index 51b9ef9b14..031c000b8e 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 */ }; -- cgit v1.2.1