1+
2+ /* Record object implementation */
3+
4+ #include "Python.h"
5+ #include "pycore_abstract.h" // _PyIndex_Check()
6+ #include "pycore_gc.h" // _PyObject_GC_IS_TRACKED()
7+ #include "pycore_initconfig.h" // _PyStatus_OK()
8+ #include "pycore_object.h" // _PyObject_GC_TRACK()
9+ #include "recordobject.h"
10+
11+ PyAPI_FUNC (PyObject * ) PyRecord_New (Py_ssize_t size )
12+ {
13+ return NULL ;
14+ }
15+
16+ static void
17+ record_dealloc (PyRecordObject * op )
18+ {
19+ // TODO
20+ }
21+
22+ static PyObject *
23+ record_repr (PyRecordObject * v )
24+ {
25+ // TODO
26+ return NULL ;
27+ }
28+
29+ static Py_ssize_t
30+ record_length (PyRecordObject * a )
31+ {
32+ return Py_SIZE (a );
33+ }
34+
35+ static PyObject *
36+ recorditem (PyRecordObject * a , Py_ssize_t i )
37+ {
38+ if (i < 0 || i >= Py_SIZE (a )) {
39+ PyErr_SetString (PyExc_IndexError , "record index out of range" );
40+ return NULL ;
41+ }
42+ Py_INCREF (a -> ob_item [i ]);
43+ return a -> ob_item [i ];
44+ }
45+
46+
47+ static PySequenceMethods record_as_sequence = {
48+ (lenfunc )record_length , /* sq_length */
49+ 0 , /* sq_concat */
50+ 0 , /* sq_repeat */
51+ (ssizeargfunc )recorditem , /* sq_item */
52+ 0 , /* sq_slice */
53+ 0 , /* sq_ass_item */
54+ 0 , /* sq_ass_slice */
55+ 0 , /* sq_contains */
56+ };
57+
58+ static Py_hash_t
59+ record_hash (PyRecordObject * v )
60+ {
61+ return -1 ;
62+ }
63+
64+ PyObject *
65+ record_getattro (PyObject * obj , PyObject * name )
66+ {
67+ // TODO
68+ return NULL ;
69+ }
70+
71+ static PyObject *
72+ record_rich_compare (PyObject * v , PyObject * w , int op )
73+ {
74+ return NULL ;
75+ }
76+
77+ static PyObject *
78+ record_new (PyTypeObject * type , PyObject * args , PyObject * kwargs )
79+ {
80+ return NULL ;
81+ }
82+
83+ PyTypeObject PyRecord_Type = {
84+ PyVarObject_HEAD_INIT (& PyType_Type , 0 )
85+ "record" ,
86+ sizeof (PyRecordObject ) - sizeof (PyObject * ),
87+ sizeof (PyObject * ),
88+ (destructor )record_dealloc , /* tp_dealloc */
89+ 0 , /* tp_vectorcall_offset */
90+ 0 , /* tp_getattr */
91+ 0 , /* tp_setattr */
92+ 0 , /* tp_as_async */
93+ (reprfunc )record_repr , /* tp_repr */
94+ 0 , /* tp_as_number */
95+ & record_as_sequence , /* tp_as_sequence */
96+ 0 , /* tp_as_mapping */
97+ (hashfunc )record_hash , /* tp_hash */
98+ 0 , /* tp_call */
99+ 0 , /* tp_str */
100+ record_getattro , /* tp_getattro */
101+ 0 , /* tp_setattro */
102+ 0 , /* tp_as_buffer */
103+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE , /* tp_flags */
104+ 0 , /* tp_doc */
105+ 0 , /* tp_traverse */
106+ 0 , /* tp_clear */
107+ record_rich_compare , /* tp_richcompare */
108+ 0 , /* tp_weaklistoffset */
109+ 0 , /* tp_iter */
110+ 0 , /* tp_iternext */
111+ 0 , /* tp_methods */
112+ 0 , /* tp_members */
113+ 0 , /* tp_getset */
114+ 0 , /* tp_base */
115+ 0 , /* tp_dict */
116+ 0 , /* tp_descr_get */
117+ 0 , /* tp_descr_set */
118+ 0 , /* tp_dictoffset */
119+ 0 , /* tp_init */
120+ 0 , /* tp_alloc */
121+ record_new , /* tp_new */
122+ PyObject_GC_Del , /* tp_free */
123+ 0 ,
124+ };
0 commit comments