1111
1212#include "pycore_interpolation.h"
1313
14- static PyInterpolationObject *
14+ typedef struct {
15+ PyObject_HEAD
16+ PyObject * value ;
17+ PyObject * expr ;
18+ PyObject * conv ;
19+ PyObject * format_spec ;
20+ } interpolationobject ;
21+
22+ static interpolationobject *
1523interpolation_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
1624{
17- PyInterpolationObject * self = (PyInterpolationObject * ) type -> tp_alloc (type , 0 );
25+ interpolationobject * self = (interpolationobject * ) type -> tp_alloc (type , 0 );
1826 if (!self ) {
1927 return NULL ;
2028 }
@@ -40,7 +48,7 @@ interpolation_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
4048}
4149
4250static void
43- interpolation_dealloc (PyInterpolationObject * self )
51+ interpolation_dealloc (interpolationobject * self )
4452{
4553 Py_CLEAR (self -> value );
4654 Py_CLEAR (self -> expr );
@@ -50,7 +58,7 @@ interpolation_dealloc(PyInterpolationObject *self)
5058}
5159
5260static PyObject *
53- interpolation_repr (PyInterpolationObject * self )
61+ interpolation_repr (interpolationobject * self )
5462{
5563 return PyUnicode_FromFormat ("%s(%R, %R, %R, %R)" ,
5664 _PyType_Name (Py_TYPE (self )),
@@ -59,18 +67,18 @@ interpolation_repr(PyInterpolationObject *self)
5967}
6068
6169static PyMemberDef interpolation_members [] = {
62- {"value" , Py_T_OBJECT_EX , offsetof(PyInterpolationObject , value ), Py_READONLY , "Value" },
63- {"expr" , Py_T_OBJECT_EX , offsetof(PyInterpolationObject , expr ), Py_READONLY , "Expr" },
64- {"conv" , Py_T_OBJECT_EX , offsetof(PyInterpolationObject , conv ), Py_READONLY , "Conversion" },
65- {"format_spec" , Py_T_OBJECT_EX , offsetof(PyInterpolationObject , format_spec ), Py_READONLY , "Format specifier" },
70+ {"value" , Py_T_OBJECT_EX , offsetof(interpolationobject , value ), Py_READONLY , "Value" },
71+ {"expr" , Py_T_OBJECT_EX , offsetof(interpolationobject , expr ), Py_READONLY , "Expr" },
72+ {"conv" , Py_T_OBJECT_EX , offsetof(interpolationobject , conv ), Py_READONLY , "Conversion" },
73+ {"format_spec" , Py_T_OBJECT_EX , offsetof(interpolationobject , format_spec ), Py_READONLY , "Format specifier" },
6674 {NULL }
6775};
6876
69- PyTypeObject PyInterpolation_Type = {
77+ PyTypeObject _PyInterpolation_Type = {
7078 PyVarObject_HEAD_INIT (NULL , 0 )
71- .tp_name = "Interpolation" ,
79+ .tp_name = "templatelib. Interpolation" ,
7280 .tp_doc = PyDoc_STR ("Interpolation object" ),
73- .tp_basicsize = sizeof (PyInterpolationObject ),
81+ .tp_basicsize = sizeof (interpolationobject ),
7482 .tp_itemsize = 0 ,
7583 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | _Py_TPFLAGS_MATCH_SELF ,
7684 .tp_new = (newfunc ) interpolation_new ,
@@ -79,21 +87,6 @@ PyTypeObject PyInterpolation_Type = {
7987 .tp_members = interpolation_members ,
8088};
8189
82- PyStatus
83- _PyInterpolation_InitTypes (PyInterpreterState * interp )
84- {
85- if (_PyStaticType_InitBuiltin (interp , & PyInterpolation_Type ) < 0 ) {
86- return _PyStatus_ERR ("Can't initialize builtin type" );
87- }
88- return _PyStatus_OK ();
89- }
90-
91- void
92- _PyInterpolation_FiniTypes (PyInterpreterState * interp )
93- {
94- _PyStaticType_FiniBuiltin (interp , & PyInterpolation_Type );
95- }
96-
9790PyObject *
9891_PyInterpolation_FromStackRefSteal (_PyStackRef * values )
9992{
@@ -111,7 +104,7 @@ _PyInterpolation_FromStackRefSteal(_PyStackRef *values)
111104 PyObject * format_spec = PyStackRef_AsPyObjectSteal (values [3 ]);
112105 PyTuple_SET_ITEM (args , 3 , format_spec ? format_spec : & _Py_STR (empty ));
113106
114- PyObject * interpolation = PyObject_CallObject ((PyObject * ) & PyInterpolation_Type , args );
107+ PyObject * interpolation = PyObject_CallObject ((PyObject * ) & _PyInterpolation_Type , args );
115108 if (!interpolation ) {
116109 Py_DECREF (args );
117110 goto error ;
0 commit comments