@@ -14,15 +14,12 @@ get_mod_state(PyObject *mod)
1414 return state ;
1515}
1616
17-
18- #define PyBool_As_CBool (obj ) \
19- PyObject_IsTrue(obj) ? true: false
17+ #define PyBool_As_CBool (obj ) PyObject_IsTrue(obj) ? true : false
2018
2119#define RETURN_NULL_OR_NEWREF (ITEM ) \
22- PyObject* REF = ITEM; \
20+ PyObject * REF = ITEM; \
2321 return (REF != NULL) ? Py_NewRef(REF) : NULL
2422
25-
2623/* module functions */
2724
2825static PyObject *
@@ -54,221 +51,212 @@ md_add(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
5451 Py_RETURN_NONE ;
5552}
5653
57- static PyObject *
58- md_clear (
59- PyObject * self , PyObject * arg
60- ){
54+ static PyObject *
55+ md_clear (PyObject * self , PyObject * arg )
56+ {
6157 mod_state * state = get_mod_state (self );
62- if (MultiDict_Clear (state -> capi , arg ) < 0 ){
58+ if (MultiDict_Clear (state -> capi , arg ) < 0 ) {
6359 return NULL ;
6460 }
6561 Py_RETURN_NONE ;
6662}
6763
68-
69- static PyObject *
70- md_set_default ( PyObject * self , PyObject * const * args , Py_ssize_t nargs ) {
64+ static PyObject *
65+ md_set_default ( PyObject * self , PyObject * const * args , Py_ssize_t nargs )
66+ {
7167 if (nargs != 3 ) {
72- PyErr_SetString (PyExc_TypeError ,
73- "md_set_default should be called with md, key and value" );
68+ PyErr_SetString (
69+ PyExc_TypeError ,
70+ "md_set_default should be called with md, key and value" );
7471 return NULL ;
7572 }
76- mod_state * state = get_mod_state (self );
77- RETURN_NULL_OR_NEWREF (Multidict_SetDefault (state -> capi , args [0 ], args [1 ], args [2 ]));
73+ mod_state * state = get_mod_state (self );
74+ RETURN_NULL_OR_NEWREF (
75+ Multidict_SetDefault (state -> capi , args [0 ], args [1 ], args [2 ]));
7876}
7977
80- static PyObject *
81- md_del (
82- PyObject * self , PyObject * const * args , Py_ssize_t nargs
83- ){
78+ static PyObject *
79+ md_del (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
80+ {
8481 if (nargs != 2 ) {
8582 PyErr_SetString (PyExc_TypeError ,
8683 "md_del should be called with md and key" );
8784 return NULL ;
8885 }
89- mod_state * state = get_mod_state (self );
90- if ((MutliDict_Del (state -> capi , args [0 ], args [1 ])) < 0 ){
86+ mod_state * state = get_mod_state (self );
87+ if ((MutliDict_Del (state -> capi , args [0 ], args [1 ])) < 0 ) {
9188 return NULL ;
9289 }
9390 Py_RETURN_NONE ;
9491}
9592
96- static PyObject *
97- md_version (
98- PyObject * self , PyObject * arg
99- ){
100- mod_state * state = get_mod_state (self );
93+ static PyObject *
94+ md_version (PyObject * self , PyObject * arg )
95+ {
96+ mod_state * state = get_mod_state (self );
10197 return PyLong_FromUnsignedLongLong (MultiDict_Version (state -> capi , arg ));
10298}
10399
104- static PyObject *
105- md_contains (
106- PyObject * self , PyObject * const * args , Py_ssize_t nargs
107- ){
100+ static PyObject *
101+ md_contains (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
102+ {
108103 if (nargs != 2 ) {
109104 PyErr_SetString (PyExc_TypeError ,
110105 "md_contains should be called with md and key" );
111106 return NULL ;
112107 }
113- mod_state * state = get_mod_state (self );
108+ mod_state * state = get_mod_state (self );
114109 int ret = MultiDict_Contains (state -> capi , args [0 ], args [1 ]);
115- if (ret == -1 ){
110+ if (ret == -1 ) {
116111 return NULL ;
117112 }
118113 return PyBool_FromLong (ret );
119114}
120115
121- static PyObject *
122- md_get (
123- PyObject * self , PyObject * const * args , Py_ssize_t nargs
124- ){
116+ static PyObject *
117+ md_get (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
118+ {
125119 if (nargs != 2 ) {
126120 PyErr_SetString (PyExc_TypeError ,
127121 "md_get should be called with md and key" );
128122 return NULL ;
129123 }
130- mod_state * state = get_mod_state (self );
124+ mod_state * state = get_mod_state (self );
131125 RETURN_NULL_OR_NEWREF (MultiDict_Get (state -> capi , args [0 ], args [1 ]));
132126}
133127
134- static PyObject *
135- md_get_all (
136- PyObject * self , PyObject * const * args , Py_ssize_t nargs
137- ){
128+ static PyObject *
129+ md_get_all (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
130+ {
138131 if (nargs != 2 ) {
139132 PyErr_SetString (PyExc_TypeError ,
140133 "md_get_all should be called with md and key" );
141134 return NULL ;
142135 }
143- mod_state * state = get_mod_state (self );
136+ mod_state * state = get_mod_state (self );
144137 RETURN_NULL_OR_NEWREF (MultiDict_GetAll (state -> capi , args [0 ], args [1 ]));
145138}
146139
147- static PyObject *
148- md_pop (
149- PyObject * self , PyObject * const * args , Py_ssize_t nargs
150- ){
140+ static PyObject *
141+ md_pop (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
142+ {
151143 if (nargs != 2 ) {
152144 PyErr_SetString (PyExc_TypeError ,
153145 "md_pop should be called with md and key" );
154146 return NULL ;
155147 }
156- mod_state * state = get_mod_state (self );
148+ mod_state * state = get_mod_state (self );
157149 RETURN_NULL_OR_NEWREF (MultiDict_Pop (state -> capi , args [0 ], args [1 ]));
158150}
159151
160- static PyObject *
161- md_popone (
162- PyObject * self , PyObject * const * args , Py_ssize_t nargs
163- ){
164- if (nargs != 2 ){
152+ static PyObject *
153+ md_popone (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
154+ {
155+ if (nargs != 2 ) {
165156 PyErr_SetString (PyExc_TypeError ,
166157 "md_popone should be called with md and key" );
167158 return NULL ;
168159 }
169- mod_state * state = get_mod_state (self );
160+ mod_state * state = get_mod_state (self );
170161 RETURN_NULL_OR_NEWREF (MultiDict_PopOne (state -> capi , args [0 ], args [1 ]));
171162}
172163
173- static PyObject *
174- md_popall (
175- PyObject * self , PyObject * const * args , Py_ssize_t nargs
176- ){
177- if (nargs != 2 ){
164+ static PyObject *
165+ md_popall (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
166+ {
167+ if (nargs != 2 ) {
178168 PyErr_SetString (PyExc_TypeError ,
179169 "md_popone should be called with md and key" );
180170 return NULL ;
181171 }
182- mod_state * state = get_mod_state (self );
172+ mod_state * state = get_mod_state (self );
183173 RETURN_NULL_OR_NEWREF (MultiDict_PopAll (state -> capi , args [0 ], args [1 ]));
184174}
185175
186- static PyObject *
187- md_popitem (
188- PyObject * self , PyObject * arg
189- ){
190- mod_state * state = get_mod_state (self );
176+ static PyObject *
177+ md_popitem (PyObject * self , PyObject * arg )
178+ {
179+ mod_state * state = get_mod_state (self );
191180 RETURN_NULL_OR_NEWREF (MultiDict_PopItem (state -> capi , arg ));
192181}
193182
194- static PyObject *
195- md_replace (
196- PyObject * self , PyObject * const * args , Py_ssize_t nargs
197- ){
198- if (nargs != 3 ){
183+ static PyObject *
184+ md_replace (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
185+ {
186+ if (nargs != 3 ) {
199187 PyErr_SetString (PyExc_TypeError ,
200188 "md_replace should be called with md, key and value" );
201189 return NULL ;
202190 }
203- mod_state * state = get_mod_state (self );
204- if (MultiDict_Replace (state -> capi , args [0 ], args [1 ], args [2 ]) < 0 ){
205- return NULL ;
191+ mod_state * state = get_mod_state (self );
192+ if (MultiDict_Replace (state -> capi , args [0 ], args [1 ], args [2 ]) < 0 ) {
193+ return NULL ;
206194 }
207195 Py_RETURN_NONE ;
208196}
209197
210- static PyObject *
211- md_update_from_md (
212- PyObject * self , PyObject * const * args , Py_ssize_t nargs
213- ) {
214- if ( nargs != 3 ){
215- PyErr_SetString ( PyExc_TypeError ,
216- "md_update_from_md should be called with md, other, and update" );
198+ static PyObject *
199+ md_update_from_md (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
200+ {
201+ if ( nargs != 3 ) {
202+ PyErr_SetString (
203+ PyExc_TypeError ,
204+ "md_update_from_md should be called with md, other, and update" );
217205 return NULL ;
218206 }
219- mod_state * state = get_mod_state (self );
220-
221- if (MultiDict_UpdateFromMultiDict (state -> capi , args [0 ], args [1 ], PyBool_As_CBool (args [2 ])) < 0 ){
207+ mod_state * state = get_mod_state (self );
208+
209+ if (MultiDict_UpdateFromMultiDict (
210+ state -> capi , args [0 ], args [1 ], PyBool_As_CBool (args [2 ])) < 0 ) {
222211 return NULL ;
223212 }
224213 Py_RETURN_NONE ;
225214}
226215
227- static PyObject *
228- md_update_from_dict (
229- PyObject * self , PyObject * const * args , Py_ssize_t nargs
230- ) {
231- if ( nargs != 3 ){
232- PyErr_SetString ( PyExc_TypeError ,
233- "md_update_from_dict should be called with md, other, and update" );
216+ static PyObject *
217+ md_update_from_dict (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
218+ {
219+ if ( nargs != 3 ) {
220+ PyErr_SetString (
221+ PyExc_TypeError ,
222+ "md_update_from_dict should be called with md, other, and update" );
234223 return NULL ;
235224 }
236- mod_state * state = get_mod_state (self );
237-
238- if (MultiDict_UpdateFromDict (state -> capi , args [0 ], args [1 ], PyBool_As_CBool (args [2 ])) < 0 ){
225+ mod_state * state = get_mod_state (self );
226+
227+ if (MultiDict_UpdateFromDict (
228+ state -> capi , args [0 ], args [1 ], PyBool_As_CBool (args [2 ])) < 0 ) {
239229 return NULL ;
240230 }
241231 Py_RETURN_NONE ;
242232}
243233
244-
245-
246- static PyObject *
247- md_update_from_seq (
248- PyObject * self , PyObject * const * args , Py_ssize_t nargs
249- ){
250- if (nargs != 3 ){
251- PyErr_SetString (PyExc_TypeError ,
252- "md_update_from_seq should be called with md, other, and update" );
234+ static PyObject *
235+ md_update_from_seq (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
236+ {
237+ if (nargs != 3 ) {
238+ PyErr_SetString (
239+ PyExc_TypeError ,
240+ "md_update_from_seq should be called with md, other, and update" );
253241 return NULL ;
254242 }
255- mod_state * state = get_mod_state (self );
256- if (MultiDict_UpdateFromSequence (state -> capi , args [0 ], args [1 ], PyBool_As_CBool (args [2 ]))){
243+ mod_state * state = get_mod_state (self );
244+ if (MultiDict_UpdateFromSequence (
245+ state -> capi , args [0 ], args [1 ], PyBool_As_CBool (args [2 ]))) {
257246 return NULL ;
258247 };
259248 Py_RETURN_NONE ;
260249}
261250
262- static PyObject *
263- md_equals (
264- PyObject * self , PyObject * const * args , Py_ssize_t nargs
265- ){
266- if (nargs != 2 ){
251+ static PyObject *
252+ md_equals (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
253+ {
254+ if (nargs != 2 ) {
267255 PyErr_SetString (PyExc_TypeError ,
268256 "md_equals should be called with md and other" );
269257 return NULL ;
270258 }
271- mod_state * state = get_mod_state (self );
259+ mod_state * state = get_mod_state (self );
272260
273261 switch (MultiDict_Equals (state -> capi , args [0 ], args [1 ])) {
274262 case -1 :
@@ -280,8 +268,6 @@ md_equals(
280268 }
281269}
282270
283-
284-
285271/* module slots */
286272
287273static int
0 commit comments