2323
2424#include "row.h"
2525#include "cursor.h"
26+ #include "clinic/row.c.h"
27+
28+ /*[clinic input]
29+ module _sqlite3
30+ class _sqlite3.Row "pysqlite_Row *" "pysqlite_RowType"
31+ [clinic start generated code]*/
32+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=384227da65f250fd]*/
2633
2734void pysqlite_row_dealloc (pysqlite_Row * self )
2835{
@@ -35,30 +42,25 @@ void pysqlite_row_dealloc(pysqlite_Row* self)
3542 Py_DECREF (tp );
3643}
3744
45+ /*[clinic input]
46+ @classmethod
47+ _sqlite3.Row.__new__ as pysqlite_row_new
48+
49+ cursor: object(type='pysqlite_Cursor *', subclass_of='pysqlite_CursorType')
50+ data: object(subclass_of='&PyTuple_Type')
51+ /
52+
53+ [clinic start generated code]*/
54+
3855static PyObject *
39- pysqlite_row_new (PyTypeObject * type , PyObject * args , PyObject * kwargs )
56+ pysqlite_row_new_impl (PyTypeObject * type , pysqlite_Cursor * cursor ,
57+ PyObject * data )
58+ /*[clinic end generated code: output=10d58b09a819a4c1 input=f6cd7e6e0935828d]*/
4059{
4160 pysqlite_Row * self ;
42- PyObject * data ;
43- pysqlite_Cursor * cursor ;
4461
4562 assert (type != NULL && type -> tp_alloc != NULL );
4663
47- if (!_PyArg_NoKeywords ("Row" , kwargs ))
48- return NULL ;
49- if (!PyArg_ParseTuple (args , "OO" , & cursor , & data ))
50- return NULL ;
51-
52- if (!PyObject_TypeCheck ((PyObject * )cursor , pysqlite_CursorType )) {
53- PyErr_SetString (PyExc_TypeError , "instance of cursor required for first argument" );
54- return NULL ;
55- }
56-
57- if (!PyTuple_Check (data )) {
58- PyErr_SetString (PyExc_TypeError , "tuple required for second argument" );
59- return NULL ;
60- }
61-
6264 self = (pysqlite_Row * ) type -> tp_alloc (type , 0 );
6365 if (self == NULL )
6466 return NULL ;
@@ -153,7 +155,15 @@ pysqlite_row_length(pysqlite_Row* self)
153155 return PyTuple_GET_SIZE (self -> data );
154156}
155157
156- PyObject * pysqlite_row_keys (pysqlite_Row * self , PyObject * Py_UNUSED (ignored ))
158+ /*[clinic input]
159+ _sqlite3.Row.keys as pysqlite_row_keys
160+
161+ Returns the keys of the row.
162+ [clinic start generated code]*/
163+
164+ static PyObject *
165+ pysqlite_row_keys_impl (pysqlite_Row * self )
166+ /*[clinic end generated code: output=efe3dfb3af6edc07 input=7549a122827c5563]*/
157167{
158168 PyObject * list ;
159169 Py_ssize_t nitems , i ;
@@ -204,8 +214,7 @@ static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other,
204214}
205215
206216static PyMethodDef row_methods [] = {
207- {"keys" , (PyCFunction )pysqlite_row_keys , METH_NOARGS ,
208- PyDoc_STR ("Returns the keys of the row." )},
217+ PYSQLITE_ROW_KEYS_METHODDEF
209218 {NULL , NULL }
210219};
211220
0 commit comments