@@ -15,9 +15,10 @@ Hopper_Pipe_SETSTR(endpoint)
1515Hopper_Pipe_SETSTR (hopper );
1616// clang-format on
1717
18- static PyObject * _hopper_pipe_new (PyTypeObject * type , PyObject * args ,
19- PyObject * kwds ) {
20- struct _hopper_pipe * self = (struct _hopper_pipe * )type -> tp_alloc (type , 0 );
18+ static PyObject * hopper_pipe_new (PyTypeObject * type , PyObject * args ,
19+ PyObject * kwds ) {
20+ struct py_hopper_pipe * self =
21+ (struct py_hopper_pipe * )type -> tp_alloc (type , 0 );
2122 if (!self )
2223 return NULL ;
2324
@@ -40,8 +41,8 @@ static PyObject *_hopper_pipe_new(PyTypeObject *type, PyObject *args,
4041 return (PyObject * )self ;
4142}
4243
43- static int _hopper_pipe_init (struct _hopper_pipe * self , PyObject * args ,
44- PyObject * kwds ) {
44+ static int hopper_pipe_init (struct py_hopper_pipe * self , PyObject * args ,
45+ PyObject * kwds ) {
4546 static char * kwlist [] = {"name" , "endpoint" , "hopper" , "fd" , "flags" , NULL };
4647 PyObject * name = NULL , * endpoint = NULL , * hopper = NULL ;
4748
@@ -61,7 +62,7 @@ static int _hopper_pipe_init(struct _hopper_pipe *self, PyObject *args,
6162 return 0 ;
6263}
6364
64- static void _hopper_pipe_dealloc (struct _hopper_pipe * self ) {
65+ static void hopper_pipe_dealloc (struct py_hopper_pipe * self ) {
6566 assert (self -> name );
6667 assert (self -> endpoint );
6768 assert (self -> hopper );
@@ -72,14 +73,20 @@ static void _hopper_pipe_dealloc(struct _hopper_pipe *self) {
7273 Py_TYPE (self )-> tp_free ((PyObject * )self );
7374}
7475
75- static PyMemberDef _hopper_pipe_members [] = {
76- {"fd" , Py_T_INT , offsetof(struct _hopper_pipe , fd ), 0 ,
76+ static PyObject * hopper_pipe_open (PyObject * self , PyObject * args ) {}
77+ static PyObject * hopper_pipe_close (PyObject * self , PyObject * args ) {}
78+ static PyObject * hopper_pipe_read (PyObject * self , PyObject * args ) {}
79+ static PyObject * hopper_pipe_write (PyObject * self , PyObject * args ) {}
80+
81+ static PyMemberDef hopper_pipe_members [] = {
82+ {"fd" , Py_T_INT , offsetof(struct py_hopper_pipe , fd ), 0 ,
7783 "pipe file descriptor" },
78- {"flags" , Py_T_INT , offsetof(struct _hopper_pipe , flags ), 0 , "pipe flags" },
84+ {"flags" , Py_T_INT , offsetof(struct py_hopper_pipe , flags ), 0 ,
85+ "pipe flags" },
7986 {NULL },
8087};
8188
82- static PyGetSetDef _hopper_get_set [] = {
89+ static PyGetSetDef hopper_pipe_get_set [] = {
8390 {"name" , (getter )_hopper_pipe_getname , (setter )_hopper_pipe_setname ,
8491 "pipe name" , NULL },
8592 {"endpoint" , (getter )_hopper_pipe_getendpoint ,
@@ -88,46 +95,42 @@ static PyGetSetDef _hopper_get_set[] = {
8895 "pipe hopper" , NULL },
8996};
9097
98+ static PyMethodDef hopper_pipe_methods [] = {
99+ {"open" , hopper_pipe_open , METH_VARARGS , "" },
100+ {"close" , hopper_pipe_close , METH_VARARGS , "" },
101+ {"read" , hopper_pipe_read , METH_VARARGS , "" },
102+ {"write" , hopper_pipe_write , METH_VARARGS , "" },
103+ {NULL , NULL , 0 , NULL },
104+ };
105+
91106// clang-format off
92- static PyTypeObject _hopper_pipe_object = {
107+ static PyTypeObject hopper_pipe_type = {
93108 .ob_base = PyVarObject_HEAD_INIT (NULL , 0 )
94109 .tp_name = "hopper.HopperPipe" ,
95110 .tp_doc = PyDoc_STR ("A object representing a Hopper pipe" ),
96- .tp_basicsize = sizeof (struct _hopper_pipe ),
111+ .tp_basicsize = sizeof (struct py_hopper_pipe ),
97112 .tp_itemsize = 0 ,
98113 .tp_flags = Py_TPFLAGS_DEFAULT ,
99- .tp_new = _hopper_pipe_new ,
100- .tp_init = (initproc )_hopper_pipe_init ,
101- .tp_dealloc = (destructor )_hopper_pipe_dealloc ,
102- .tp_members = _hopper_pipe_members ,
103- .tp_getset = _hopper_get_set ,
114+ .tp_new = hopper_pipe_new ,
115+ .tp_init = (initproc )hopper_pipe_init ,
116+ .tp_dealloc = (destructor )hopper_pipe_dealloc ,
117+ .tp_members = hopper_pipe_members ,
118+ .tp_getset = hopper_pipe_get_set ,
119+ .tp_methods = hopper_pipe_methods ,
104120};
105121// clang-format on
106122
107- static PyObject * hopper_open_pipe (PyObject * self , PyObject * args ) {}
108- static PyObject * hopper_close_pipe (PyObject * self , PyObject * args ) {}
109- static PyObject * hopper_read_pipe (PyObject * self , PyObject * args ) {}
110- static PyObject * hopper_write_pipe (PyObject * self , PyObject * args ) {}
111-
112123static int hopper_module_exec (PyObject * m ) {
113- if (PyType_Ready (& _hopper_pipe_object ) < 0 )
124+ if (PyType_Ready (& hopper_pipe_type ) < 0 )
114125 return -1 ;
115126
116- if (PyModule_AddObjectRef (m , "HopperPipe" ,
117- ( PyObject * ) & _hopper_pipe_object ) < 0 )
127+ if (PyModule_AddObjectRef (m , "HopperPipe" , ( PyObject * ) & hopper_pipe_type ) <
128+ 0 )
118129 return -1 ;
119130
120131 return 0 ;
121132}
122133
123- static PyMethodDef hopper_methods [] = {
124- {"open" , hopper_open_pipe , METH_VARARGS , "" },
125- {"close" , hopper_close_pipe , METH_VARARGS , "" },
126- {"read" , hopper_read_pipe , METH_VARARGS , "" },
127- {"write" , hopper_write_pipe , METH_VARARGS , "" },
128- {NULL , NULL , 0 , NULL },
129- };
130-
131134static PyModuleDef_Slot hopper_slots [] = {
132135 {Py_mod_exec , hopper_module_exec },
133136 {Py_mod_multiple_interpreters , Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED },
@@ -138,7 +141,6 @@ static struct PyModuleDef hoppermodule = {
138141 .m_base = PyModuleDef_HEAD_INIT ,
139142 .m_name = "hopper" ,
140143 .m_doc = NULL ,
141- .m_methods = hopper_methods ,
142144 .m_slots = hopper_slots ,
143145};
144146
0 commit comments