Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions Objects/cellobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

#include "Python.h"
#include "pycore_cell.h" // PyCell_GetRef()
#include "pycore_modsupport.h" // _PyArg_NoKeywords()
#include "pycore_object.h"

#include "clinic/cellobject.c.h"

#define _PyCell_CAST(op) _Py_CAST(PyCellObject*, (op))

/*[clinic input]
class cell "PyCellObject *" "&PyCell_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=3d6baba8cf810af0]*/

PyObject *
PyCell_New(PyObject *obj)
{
Expand All @@ -21,35 +27,28 @@ PyCell_New(PyObject *obj)
return (PyObject *)op;
}

PyDoc_STRVAR(cell_new_doc,
"cell([contents])\n"
"--\n"
"\n"
"Create a new cell object.\n"
"\n"
" contents\n"
" the contents of the cell. If not specified, the cell will be empty,\n"
" and further attempts to access its cell_contents attribute will\n"
" raise a ValueError.");
/*[clinic input]
@vectorcall
@classmethod
@text_signature "([contents])"
cell.__new__ as cell_new

contents: object = NULL
/

static PyObject *
cell_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
PyObject *obj = NULL;
Create a new cell object.

if (!_PyArg_NoKeywords("cell", kwargs)) {
goto exit;
}
/* min = 0: we allow the cell to be empty */
if (!PyArg_UnpackTuple(args, "cell", 0, 1, &obj)) {
goto exit;
}
return_value = PyCell_New(obj);
contents
the contents of the cell. If not specified, the cell will be empty,
and further attempts to access its cell_contents attribute will
raise a ValueError.
[clinic start generated code]*/

exit:
return return_value;
static PyObject *
cell_new_impl(PyTypeObject *type, PyObject *contents)
/*[clinic end generated code: output=0b7db264f0621bb4 input=4460339a82243798]*/
{
return PyCell_New(contents);
}

PyObject *
Expand Down Expand Up @@ -190,7 +189,7 @@ PyTypeObject PyCell_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
cell_new_doc, /* tp_doc */
cell_new__doc__, /* tp_doc */
cell_traverse, /* tp_traverse */
cell_clear, /* tp_clear */
cell_richcompare, /* tp_richcompare */
Expand All @@ -209,4 +208,5 @@ PyTypeObject PyCell_Type = {
0, /* tp_alloc */
cell_new, /* tp_new */
0, /* tp_free */
.tp_vectorcall = cell_vectorcall,
};
74 changes: 74 additions & 0 deletions Objects/clinic/cellobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading