From b78d2e480cc181dec3e20e4509d5336a22615dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:16:57 +0200 Subject: [PATCH 1/3] Cleanup some macros for readability. --- Modules/_cursesmodule.c | 192 +++++++++++++++++++++++----------------- 1 file changed, 110 insertions(+), 82 deletions(-) diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index ece6b13c78851f..df60fb4a8b00ca 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -279,8 +279,8 @@ _PyCursesSetError(_cursesmodule_state *state, const char *funcname) } /* - * Check the return code from a curses function and return None - * or raise an exception as appropriate. + * Check the return code from a curses function, returning None + * on success and setting an exception on error. */ static PyObject * @@ -654,59 +654,79 @@ PyTypeObject PyCursesWindow_Type; /* Function prototype macros for Window object - X - function name + X - function name (may be a macro or a C function) TYPE - parameter Type ERGSTR - format string for construction of the return value PARSESTR - format string for argument parsing */ -#define Window_NoArgNoReturnFunction(X) \ - static PyObject *PyCursesWindow_ ## X \ - (PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) \ - { return PyCursesCheckERR_ForWin(self, X(self->win), # X); } +#define Window_NoArgNoReturnFunction(X) \ + static PyObject *PyCursesWindow_ ## X \ + (PyCursesWindowObject *self, PyObject *Py_UNUSED(args)) \ + { \ + int rtn = X(self->win); \ + return PyCursesCheckERR_ForWin(self, rtn, # X); \ + } + +#define Window_NoArgTrueFalseFunction(X) \ + static PyObject * PyCursesWindow_ ## X \ + (PyCursesWindowObject *self, PyObject *Py_UNUSED(args)) \ + { \ + return PyBool_FromLong(X(self->win)); \ + } + +#define Window_NoArgNoReturnVoidFunction(X) \ + static PyObject * PyCursesWindow_ ## X \ + (PyCursesWindowObject *self, PyObject *Py_UNUSED(args)) \ + { \ + X(self->win); \ + Py_RETURN_NONE; \ + } -#define Window_NoArgTrueFalseFunction(X) \ - static PyObject * PyCursesWindow_ ## X \ - (PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) \ - { \ - return PyBool_FromLong(X(self->win)); } +#define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR) \ + static PyObject * PyCursesWindow_ ## X \ + (PyCursesWindowObject *self, PyObject *Py_UNUSED(args)) \ + { \ + TYPE arg1, arg2; \ + X(self->win, arg1, arg2); \ + return Py_BuildValue(ERGSTR, arg1, arg2); \ + } -#define Window_NoArgNoReturnVoidFunction(X) \ +#define Window_OneArgNoReturnVoidFunction(X, TYPE, PARSESTR) \ static PyObject * PyCursesWindow_ ## X \ - (PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) \ + (PyCursesWindowObject *self, PyObject *args) \ { \ - X(self->win); Py_RETURN_NONE; } - -#define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR) \ - static PyObject * PyCursesWindow_ ## X \ - (PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) \ - { \ - TYPE arg1, arg2; \ - X(self->win,arg1,arg2); return Py_BuildValue(ERGSTR, arg1, arg2); } - -#define Window_OneArgNoReturnVoidFunction(X, TYPE, PARSESTR) \ - static PyObject * PyCursesWindow_ ## X \ - (PyCursesWindowObject *self, PyObject *args) \ - { \ - TYPE arg1; \ - if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) return NULL; \ - X(self->win,arg1); Py_RETURN_NONE; } - -#define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR) \ - static PyObject * PyCursesWindow_ ## X \ - (PyCursesWindowObject *self, PyObject *args) \ - { \ - TYPE arg1; \ - if (!PyArg_ParseTuple(args,PARSESTR, &arg1)) return NULL; \ - return PyCursesCheckERR_ForWin(self, X(self->win, arg1), # X); } - -#define Window_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ - static PyObject * PyCursesWindow_ ## X \ - (PyCursesWindowObject *self, PyObject *args) \ - { \ - TYPE arg1, arg2; \ - if (!PyArg_ParseTuple(args,PARSESTR, &arg1, &arg2)) return NULL; \ - return PyCursesCheckERR_ForWin(self, X(self->win, arg1, arg2), # X); } + TYPE arg; \ + if (!PyArg_ParseTuple(args, PARSESTR, &arg)) { \ + return NULL; \ + } \ + X(self->win, arg); \ + Py_RETURN_NONE; \ + } + +#define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR) \ + static PyObject * PyCursesWindow_ ## X \ + (PyCursesWindowObject *self, PyObject *args) \ + { \ + TYPE arg; \ + if (!PyArg_ParseTuple(args, PARSESTR, &arg)) { \ + return NULL; \ + } \ + int rtn = X(self->win, arg); \ + return PyCursesCheckERR_ForWin(self, rtn, # X); \ + } + +#define Window_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ + static PyObject * PyCursesWindow_ ## X \ + (PyCursesWindowObject *self, PyObject *args) \ + { \ + TYPE arg1, arg2; \ + if (!PyArg_ParseTuple(args, PARSESTR, &arg1, &arg2)) { \ + return NULL; \ + } \ + int rtn = X(self->win, arg1, arg2); \ + return PyCursesCheckERR_ForWin(self, rtn, # X); \ + } /* ------------- WINDOW routines --------------- */ @@ -2714,49 +2734,57 @@ PyTypeObject PyCursesWindow_Type = { PyCursesWindow_getsets, /* tp_getset */ }; -/* Function Body Macros - They are ugly but very, very useful. ;-) +/* + * Function Body Macros - They are ugly but very, very useful. ;-) + * + * Parameters + * + * X The name of the curses function to invoke. + * flag When false, prefixes the function name with 'no' at runtime, + * This parameter is present in the signature and auto-generated + * by Argument Clinic. + * + * These macros should only be used for generating the body of + * the module's methods since they need a module reference. +*/ - X - function name - TYPE - parameter Type - ERGSTR - format string for construction of the return value - PARSESTR - format string for argument parsing - */ - -#define NoArgNoReturnFunctionBody(X) \ -{ \ - PyCursesStatefulInitialised(module); \ - return PyCursesCheckERR(module, X(), # X); } - -#define NoArgOrFlagNoReturnFunctionBody(X, flag) \ -{ \ - PyCursesStatefulInitialised(module); \ - if (flag) \ - return PyCursesCheckERR(module, X(), # X); \ - else \ - return PyCursesCheckERR(module, no ## X(), # X); \ +#define NoArgNoReturnFunctionBody(X) \ +{ \ + PyCursesStatefulInitialised(module); \ + return PyCursesCheckERR(module, X(), # X); \ } -#define NoArgReturnIntFunctionBody(X) \ -{ \ - PyCursesStatefulInitialised(module); \ - return PyLong_FromLong((long) X()); } +#define NoArgOrFlagNoReturnFunctionBody(X, flag) \ +{ \ + PyCursesStatefulInitialised(module); \ + int rtn = (flag) ? X() : no ## X(); \ + return PyCursesCheckERR(module, rtn, # X); \ +} +#define NoArgReturnIntFunctionBody(X) \ +{ \ + PyCursesStatefulInitialised(module); \ + return PyLong_FromLong((long) X()); \ +} -#define NoArgReturnStringFunctionBody(X) \ -{ \ - PyCursesStatefulInitialised(module); \ - return PyBytes_FromString(X()); } +#define NoArgReturnStringFunctionBody(X) \ +{ \ + PyCursesStatefulInitialised(module); \ + return PyBytes_FromString(X()); \ +} -#define NoArgTrueFalseFunctionBody(X) \ -{ \ - PyCursesStatefulInitialised(module); \ - return PyBool_FromLong(X()); } +#define NoArgTrueFalseFunctionBody(X) \ +{ \ + PyCursesStatefulInitialised(module); \ + return PyBool_FromLong(X()); \ +} -#define NoArgNoReturnVoidFunctionBody(X) \ -{ \ - PyCursesStatefulInitialised(module); \ - X(); \ - Py_RETURN_NONE; } +#define NoArgNoReturnVoidFunctionBody(X) \ +{ \ + PyCursesStatefulInitialised(module); \ + X(); \ + Py_RETURN_NONE; \ +} /********************************************************************* Global Functions From 6f9338d705b4a400a0d2064143a533bb89e0c93c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sat, 12 Oct 2024 11:23:42 +0200 Subject: [PATCH 2/3] update comments --- Modules/_cursesmodule.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index a9a7ea825982da..8a7d8a0a88580f 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -646,13 +646,16 @@ class component_converter(CConverter): The Window Object ******************************************************************************/ -/* Function prototype macros for Window object - - X - function name (may be a macro or a C function) - TYPE - parameter Type - ERGSTR - format string for construction of the return value - PARSESTR - format string for argument parsing -*/ +/* + * Macros for creating a PyCursesWindowObject object's method. + * + * Parameters + * + * X The name of the curses C function or macro to invoke. + * TYPE The function parameter(s) type. + * ERGSTR The format string for construction of the return value. + * PARSESTR The format string for argument parsing. + */ #define Window_NoArgNoReturnFunction(X) \ static PyObject *PyCursesWindow_ ## X \ @@ -2734,12 +2737,12 @@ static PyType_Spec PyCursesWindow_Type_spec = { /* -------------------------------------------------------*/ /* - * Function Body Macros - They are ugly but very, very useful. ;-) + * Macros for implementing simple module's methods. * * Parameters * - * X The name of the curses function to invoke. - * flag When false, prefixes the function name with 'no' at runtime, + * X The name of the curses C function or macro to invoke. + * FLAG When false, prefixes the function name with 'no' at runtime, * This parameter is present in the signature and auto-generated * by Argument Clinic. * @@ -2753,10 +2756,10 @@ static PyType_Spec PyCursesWindow_Type_spec = { return PyCursesCheckERR(module, X(), # X); \ } -#define NoArgOrFlagNoReturnFunctionBody(X, flag) \ +#define NoArgOrFlagNoReturnFunctionBody(X, FLAG) \ { \ PyCursesStatefulInitialised(module); \ - int rtn = (flag) ? X() : no ## X(); \ + int rtn = (FLAG) ? X() : no ## X(); \ return PyCursesCheckERR(module, rtn, # X); \ } From 6f84b18a238cfac597622f6401348b25c439de68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 13 Oct 2024 14:36:01 +0200 Subject: [PATCH 3/3] simplify function names --- Modules/_cursesmodule.c | 172 ++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 8a7d8a0a88580f..14458c4db26fea 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -219,7 +219,7 @@ static const char *curses_screen_encoding = NULL; * is imported on demand. */ static inline int -_PyCursesCheckFunction(int called, const char *funcname) +_PyCursesStatelessCheckFunction(int called, const char *funcname) { if (called == TRUE) { return 1; @@ -241,7 +241,7 @@ _PyCursesCheckFunction(int called, const char *funcname) * The exception type is obtained from the 'module' state. */ static inline int -_PyCursesStatefulCheckFunction(PyObject *module, int called, const char *funcname) +_PyCursesCheckFunction(PyObject *module, int called, const char *funcname) { if (called == TRUE) { return 1; @@ -251,34 +251,34 @@ _PyCursesStatefulCheckFunction(PyObject *module, int called, const char *funcnam return 0; } -#define PyCursesStatefulSetupTermCalled(MODULE) \ - do { \ - if (!_PyCursesStatefulCheckFunction(MODULE, \ - curses_setupterm_called, \ - "setupterm")) \ - { \ - return 0; \ - } \ +#define PyCursesCheckSetupTermCalled(MODULE) \ + do { \ + if (!_PyCursesCheckFunction(MODULE, \ + curses_setupterm_called, \ + "setupterm")) \ + { \ + return 0; \ + } \ } while (0) -#define PyCursesStatefulInitialised(MODULE) \ - do { \ - if (!_PyCursesStatefulCheckFunction(MODULE, \ - curses_initscr_called, \ - "initscr")) \ - { \ - return 0; \ - } \ +#define PyCursesCheckInitialised(MODULE) \ + do { \ + if (!_PyCursesCheckFunction(MODULE, \ + curses_initscr_called, \ + "initscr")) \ + { \ + return 0; \ + } \ } while (0) -#define PyCursesStatefulInitialisedColor(MODULE) \ - do { \ - if (!_PyCursesStatefulCheckFunction(MODULE, \ - curses_start_color_called, \ - "start_color")) \ - { \ - return 0; \ - } \ +#define PyCursesCheckInitialisedColor(MODULE) \ + do { \ + if (!_PyCursesCheckFunction(MODULE, \ + curses_start_color_called, \ + "start_color")) \ + { \ + return 0; \ + } \ } while (0) /* Utility Functions */ @@ -2752,38 +2752,38 @@ static PyType_Spec PyCursesWindow_Type_spec = { #define NoArgNoReturnFunctionBody(X) \ { \ - PyCursesStatefulInitialised(module); \ + PyCursesCheckInitialised(module); \ return PyCursesCheckERR(module, X(), # X); \ } #define NoArgOrFlagNoReturnFunctionBody(X, FLAG) \ { \ - PyCursesStatefulInitialised(module); \ + PyCursesCheckInitialised(module); \ int rtn = (FLAG) ? X() : no ## X(); \ return PyCursesCheckERR(module, rtn, # X); \ } -#define NoArgReturnIntFunctionBody(X) \ -{ \ - PyCursesStatefulInitialised(module); \ - return PyLong_FromLong((long) X()); \ +#define NoArgReturnIntFunctionBody(X) \ +{ \ + PyCursesCheckInitialised(module); \ + return PyLong_FromLong((long) X()); \ } #define NoArgReturnStringFunctionBody(X) \ { \ - PyCursesStatefulInitialised(module); \ + PyCursesCheckInitialised(module); \ return PyBytes_FromString(X()); \ } -#define NoArgTrueFalseFunctionBody(X) \ -{ \ - PyCursesStatefulInitialised(module); \ - return PyBool_FromLong(X()); \ +#define NoArgTrueFalseFunctionBody(X) \ +{ \ + PyCursesCheckInitialised(module); \ + return PyBool_FromLong(X()); \ } #define NoArgNoReturnVoidFunctionBody(X) \ { \ - PyCursesStatefulInitialised(module); \ + PyCursesCheckInitialised(module); \ X(); \ Py_RETURN_NONE; \ } @@ -2882,8 +2882,8 @@ _curses_color_content_impl(PyObject *module, int color_number) { _CURSES_COLOR_VAL_TYPE r,g,b; - PyCursesStatefulInitialised(module); - PyCursesStatefulInitialisedColor(module); + PyCursesCheckInitialised(module); + PyCursesCheckInitialisedColor(module); if (_COLOR_CONTENT_FUNC(color_number, &r, &g, &b) == ERR) { cursesmodule_state *state = get_cursesmodule_state(module); @@ -2912,8 +2912,8 @@ static PyObject * _curses_color_pair_impl(PyObject *module, int pair_number) /*[clinic end generated code: output=60718abb10ce9feb input=6034e9146f343802]*/ { - PyCursesStatefulInitialised(module); - PyCursesStatefulInitialisedColor(module); + PyCursesCheckInitialised(module); + PyCursesCheckInitialisedColor(module); return PyLong_FromLong(COLOR_PAIR(pair_number)); } @@ -2939,7 +2939,7 @@ _curses_curs_set_impl(PyObject *module, int visibility) { int erg; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); erg = curs_set(visibility); if (erg == ERR) return PyCursesCheckERR(module, erg, "curs_set"); @@ -2991,7 +2991,7 @@ static PyObject * _curses_delay_output_impl(PyObject *module, int ms) /*[clinic end generated code: output=b6613a67f17fa4f4 input=5316457f5f59196c]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return PyCursesCheckERR(module, delay_output(ms), "delay_output"); } @@ -3047,7 +3047,7 @@ _curses_erasechar_impl(PyObject *module) { char ch; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); ch = erasechar(); @@ -3097,7 +3097,7 @@ _curses_getsyx_impl(PyObject *module) int x = 0; int y = 0; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); getsyx(y, x); @@ -3122,7 +3122,7 @@ _curses_getmouse_impl(PyObject *module) int rtn; MEVENT event; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); rtn = getmouse( &event ); if (rtn == ERR) { @@ -3158,7 +3158,7 @@ _curses_ungetmouse_impl(PyObject *module, short id, int x, int y, int z, { MEVENT event; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); event.id = id; event.x = x; @@ -3191,7 +3191,7 @@ _curses_getwin(PyObject *module, PyObject *file) WINDOW *win; PyObject *res = NULL; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); fp = tmpfile(); if (fp == NULL) @@ -3249,7 +3249,7 @@ static PyObject * _curses_halfdelay_impl(PyObject *module, unsigned char tenths) /*[clinic end generated code: output=e92cdf0ef33c0663 input=e42dce7259c15100]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return PyCursesCheckERR(module, halfdelay(tenths), "halfdelay"); } @@ -3302,7 +3302,7 @@ static PyObject * _curses_has_key_impl(PyObject *module, int key) /*[clinic end generated code: output=19ad48319414d0b1 input=78bd44acf1a4997c]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return PyBool_FromLong(has_key(key)); } @@ -3333,8 +3333,8 @@ _curses_init_color_impl(PyObject *module, int color_number, short r, short g, short b) /*[clinic end generated code: output=d7ed71b2d818cdf2 input=ae2b8bea0f152c80]*/ { - PyCursesStatefulInitialised(module); - PyCursesStatefulInitialisedColor(module); + PyCursesCheckInitialised(module); + PyCursesCheckInitialisedColor(module); return PyCursesCheckERR(module, _CURSES_INIT_COLOR_FUNC(color_number, r, g, b), @@ -3362,8 +3362,8 @@ static PyObject * _curses_init_pair_impl(PyObject *module, int pair_number, int fg, int bg) /*[clinic end generated code: output=a0bba03d2bbc3ee6 input=54b421b44c12c389]*/ { - PyCursesStatefulInitialised(module); - PyCursesStatefulInitialisedColor(module); + PyCursesCheckInitialised(module); + PyCursesCheckInitialisedColor(module); if (_CURSES_INIT_PAIR_FUNC(pair_number, fg, bg) == ERR) { if (pair_number >= COLOR_PAIRS) { @@ -3663,7 +3663,7 @@ static PyObject * _curses_intrflush_impl(PyObject *module, int flag) /*[clinic end generated code: output=c1986df35e999a0f input=c65fe2ef973fe40a]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return PyCursesCheckERR(module, intrflush(NULL, flag), "intrflush"); } @@ -3696,7 +3696,7 @@ static PyObject * _curses_is_term_resized_impl(PyObject *module, int nlines, int ncols) /*[clinic end generated code: output=aafe04afe50f1288 input=ca9c0bd0fb8ab444]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return PyBool_FromLong(is_term_resized(nlines, ncols)); } @@ -3718,7 +3718,7 @@ _curses_keyname_impl(PyObject *module, int key) { const char *knp; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); if (key < 0) { PyErr_SetString(PyExc_ValueError, "invalid key number"); @@ -3776,7 +3776,7 @@ static PyObject * _curses_meta_impl(PyObject *module, int yes) /*[clinic end generated code: output=22f5abda46a605d8 input=cfe7da79f51d0e30]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return PyCursesCheckERR(module, meta(stdscr, yes), "meta"); } @@ -3800,7 +3800,7 @@ static PyObject * _curses_mouseinterval_impl(PyObject *module, int interval) /*[clinic end generated code: output=c4f5ff04354634c5 input=75aaa3f0db10ac4e]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return PyCursesCheckERR(module, mouseinterval(interval), "mouseinterval"); } @@ -3825,7 +3825,7 @@ _curses_mousemask_impl(PyObject *module, unsigned long newmask) { mmask_t oldmask, availmask; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); availmask = mousemask((mmask_t)newmask, &oldmask); return Py_BuildValue("(kk)", (unsigned long)availmask, (unsigned long)oldmask); @@ -3846,7 +3846,7 @@ static int _curses_napms_impl(PyObject *module, int ms) /*[clinic end generated code: output=5f292a6a724491bd input=c6d6e01f2f1df9f7]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return napms(ms); } @@ -3870,7 +3870,7 @@ _curses_newpad_impl(PyObject *module, int nlines, int ncols) { WINDOW *win; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); win = newpad(nlines, ncols); @@ -3912,7 +3912,7 @@ _curses_newwin_impl(PyObject *module, int nlines, int ncols, { WINDOW *win; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); win = newwin(nlines,ncols,begin_y,begin_x); if (win == NULL) { @@ -4026,8 +4026,8 @@ _curses_pair_content_impl(PyObject *module, int pair_number) { _CURSES_COLOR_NUM_TYPE f, b; - PyCursesStatefulInitialised(module); - PyCursesStatefulInitialisedColor(module); + PyCursesCheckInitialised(module); + PyCursesCheckInitialisedColor(module); if (_CURSES_PAIR_CONTENT_FUNC(pair_number, &f, &b) == ERR) { if (pair_number >= COLOR_PAIRS) { @@ -4061,8 +4061,8 @@ static PyObject * _curses_pair_number_impl(PyObject *module, int attr) /*[clinic end generated code: output=85bce7d65c0aa3f4 input=d478548e33f5e61a]*/ { - PyCursesStatefulInitialised(module); - PyCursesStatefulInitialisedColor(module); + PyCursesCheckInitialised(module); + PyCursesCheckInitialisedColor(module); return PyLong_FromLong(PAIR_NUMBER(attr)); } @@ -4102,7 +4102,7 @@ static PyObject * _curses_qiflush_impl(PyObject *module, int flag) /*[clinic end generated code: output=9167e862f760ea30 input=6ec8b3e2b717ec40]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); if (flag) { qiflush(); @@ -4257,7 +4257,7 @@ _curses_resizeterm_impl(PyObject *module, short nlines, short ncols) { PyObject *result; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); result = PyCursesCheckERR(module, resizeterm(nlines, ncols), "resizeterm"); if (!result) @@ -4296,7 +4296,7 @@ _curses_resize_term_impl(PyObject *module, short nlines, short ncols) { PyObject *result; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); result = PyCursesCheckERR(module, resize_term(nlines, ncols), "resize_term"); if (!result) @@ -4339,7 +4339,7 @@ static PyObject * _curses_setsyx_impl(PyObject *module, int y, int x) /*[clinic end generated code: output=23dcf753511a2464 input=fa7f2b208e10a557]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); setsyx(y,x); @@ -4364,7 +4364,7 @@ static PyObject * _curses_start_color_impl(PyObject *module) /*[clinic end generated code: output=8b772b41d8090ede input=0ca0ecb2b77e1a12]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); if (start_color() == ERR) { cursesmodule_state *state = get_cursesmodule_state(module); @@ -4437,7 +4437,7 @@ static PyObject * _curses_tigetflag_impl(PyObject *module, const char *capname) /*[clinic end generated code: output=8853c0e55542195b input=b0787af9e3e9a6ce]*/ { - PyCursesStatefulSetupTermCalled(module); + PyCursesCheckSetupTermCalled(module); return PyLong_FromLong( (long) tigetflag( (char *)capname ) ); } @@ -4459,7 +4459,7 @@ static PyObject * _curses_tigetnum_impl(PyObject *module, const char *capname) /*[clinic end generated code: output=46f8b0a1b5dff42f input=5cdf2f410b109720]*/ { - PyCursesStatefulSetupTermCalled(module); + PyCursesCheckSetupTermCalled(module); return PyLong_FromLong( (long) tigetnum( (char *)capname ) ); } @@ -4481,7 +4481,7 @@ static PyObject * _curses_tigetstr_impl(PyObject *module, const char *capname) /*[clinic end generated code: output=f22b576ad60248f3 input=36644df25c73c0a7]*/ { - PyCursesStatefulSetupTermCalled(module); + PyCursesCheckSetupTermCalled(module); capname = tigetstr( (char *)capname ); if (capname == NULL || capname == (char*) -1) { @@ -4516,7 +4516,7 @@ _curses_tparm_impl(PyObject *module, const char *str, int i1, int i2, int i3, { char* result = NULL; - PyCursesStatefulSetupTermCalled(module); + PyCursesCheckSetupTermCalled(module); result = tparm((char *)str,i1,i2,i3,i4,i5,i6,i7,i8,i9); if (!result) { @@ -4545,7 +4545,7 @@ static PyObject * _curses_typeahead_impl(PyObject *module, int fd) /*[clinic end generated code: output=084bb649d7066583 input=f2968d8e1805051b]*/ { - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); return PyCursesCheckERR(module, typeahead( fd ), "typeahead"); } @@ -4569,7 +4569,7 @@ _curses_unctrl(PyObject *module, PyObject *ch) { chtype ch_; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); if (!PyCurses_ConvertToChtype(NULL, ch, &ch_)) return NULL; @@ -4592,7 +4592,7 @@ _curses_ungetch(PyObject *module, PyObject *ch) { chtype ch_; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); if (!PyCurses_ConvertToChtype(NULL, ch, &ch_)) return NULL; @@ -4663,7 +4663,7 @@ _curses_unget_wch(PyObject *module, PyObject *ch) { wchar_t wch; - PyCursesStatefulInitialised(module); + PyCursesCheckInitialised(module); if (!PyCurses_ConvertToWchar_t(ch, &wch)) return NULL; @@ -4715,8 +4715,8 @@ _curses_use_default_colors_impl(PyObject *module) { int code; - PyCursesStatefulInitialised(module); - PyCursesStatefulInitialisedColor(module); + PyCursesCheckInitialised(module); + PyCursesCheckInitialisedColor(module); code = use_default_colors(); if (code != ERR) { @@ -4896,19 +4896,19 @@ static PyMethodDef cursesmodule_methods[] = { static inline int curses_capi_setupterm_called(void) { - return _PyCursesCheckFunction(curses_setupterm_called, "setupterm"); + return _PyCursesStatelessCheckFunction(curses_setupterm_called, "setupterm"); } static inline int curses_capi_initscr_called(void) { - return _PyCursesCheckFunction(curses_initscr_called, "initscr"); + return _PyCursesStatelessCheckFunction(curses_initscr_called, "initscr"); } static inline int curses_capi_start_color_called(void) { - return _PyCursesCheckFunction(curses_start_color_called, "start_color"); + return _PyCursesStatelessCheckFunction(curses_start_color_called, "start_color"); } static void *