From 03e4fceb4df0e7c56e953a0991f0b4fe4ca613b3 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Mon, 10 Aug 2020 19:13:57 -0500 Subject: [PATCH 01/16] port _curses_panel to multi-phase --- Modules/_curses_panel.c | 78 +++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index f124803493d88b..6408d6f3897c98 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -610,7 +610,6 @@ _curses_panel_update_panels_impl(PyObject *module) Py_RETURN_NONE; } - /* List of functions defined in the module */ static PyMethodDef PyCurses_methods[] = { @@ -622,57 +621,54 @@ static PyMethodDef PyCurses_methods[] = { }; /* Initialization function for the module */ - - -static struct PyModuleDef _curses_panelmodule = { - PyModuleDef_HEAD_INIT, - "_curses_panel", - NULL, - sizeof(_curses_panelstate), - PyCurses_methods, - NULL, - _curses_panel_traverse, - _curses_panel_clear, - _curses_panel_free -}; - -PyMODINIT_FUNC -PyInit__curses_panel(void) +static int +_curses_exec(PyObject *m) { - PyObject *m, *d, *v; - - /* Create the module and add the functions */ - m = PyModule_Create(&_curses_panelmodule); - if (m == NULL) - goto fail; - d = PyModule_GetDict(m); - + _curses_panel_state *st = get_curses_panelstate(m); /* Initialize object type */ - v = PyType_FromSpec(&PyCursesPanel_Type_spec); - if (v == NULL) - goto fail; - ((PyTypeObject *)v)->tp_new = NULL; - get_curses_panelstate(m)->PyCursesPanel_Type = v; + st->PyCursesPanel_Type = PyType_FromSpec(&PyCursesPanel_Type_spec); + if (st->PyCursesPanel_Type == NULL) + return -1; + + if (PyModule_AddType(m, st->PyCursesPanel_Type) < 0) + return -1; import_curses(); if (PyErr_Occurred()) - goto fail; + return -1; + PyObject *d = PyModule_GetDict(m); /* For exception _curses_panel.error */ - get_curses_panelstate(m)->PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL); - PyDict_SetItemString(d, "error", get_curses_panelstate(m)->PyCursesError); + st->PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL); + PyDict_SetItemString(d, "error", st->PyCursesError); /* Make the version available */ - v = PyUnicode_FromString(PyCursesVersion); + PyObject *v = PyUnicode_FromString(PyCursesVersion); PyDict_SetItemString(d, "version", v); PyDict_SetItemString(d, "__version__", v); Py_DECREF(v); - Py_INCREF(get_curses_panelstate(m)->PyCursesPanel_Type); - PyModule_AddObject(m, "panel", - (PyObject *)get_curses_panelstate(m)->PyCursesPanel_Type); - return m; - fail: - Py_XDECREF(m); - return NULL; + return 0; } + +static PyModuleDef_Slot _curses_slots[] = { + {Py_mod_exec, _curses_exec}, + {0, NULL} +}; + +static struct PyModuleDef _curses_panelmodule = { + PyModuleDef_HEAD_INIT, + .m_name = "_curses_panel", + .m_size = sizeof(_curses_panelstate), + .m_methods = PyCurses_methods, + .m_slots = _curses_slots, + .m_traverse = _curses_panel_traverse, + .m_clear = _curses_panel_clear, + .m_free = _curses_panel_free +}; + +PyMODINIT_FUNC +PyInit__curses_panel(void) +{ + return PyModuleDef_Init(&_curses_panelmodule); +} \ No newline at end of file From 95081a76559fef99876a8c5a8bea371721d9ddc2 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Tue, 1 Sep 2020 17:08:15 -0500 Subject: [PATCH 02/16] blurb --- .../2020-09-01-17-08-07.bpo-1635741.X9CZgo.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-08-07.bpo-1635741.X9CZgo.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-08-07.bpo-1635741.X9CZgo.rst b/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-08-07.bpo-1635741.X9CZgo.rst new file mode 100644 index 00000000000000..a39673a26307a9 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-09-01-17-08-07.bpo-1635741.X9CZgo.rst @@ -0,0 +1,2 @@ +Port the :mod:`_curses_panel` extension module to multi-phase initialization +(:pep:`489`). From c9e4c9ef0595153b896c1fdad0e64db91625c40e Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Tue, 1 Sep 2020 21:04:47 -0500 Subject: [PATCH 03/16] remove global module state --- Modules/_curses_panel.c | 144 +++--- Modules/clinic/_curses_panel.c.h | 734 +++++++++++++++++-------------- 2 files changed, 491 insertions(+), 387 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 6408d6f3897c98..1452f7f0bba203 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -50,11 +50,6 @@ _curses_panel_free(void *m) _curses_panel_clear((PyObject *) m); } -static struct PyModuleDef _curses_panelmodule; - -#define _curses_panelstate_global \ -((_curses_panelstate *) PyModule_GetState(PyState_FindModule(&_curses_panelmodule))) - /* Utility Functions */ /* @@ -63,15 +58,17 @@ static struct PyModuleDef _curses_panelmodule; */ static PyObject * -PyCursesCheckERR(int code, const char *fname) +PyCursesCheckERR(_curses_panelstate *st, int code, const char *fname) { if (code != ERR) { Py_RETURN_NONE; - } else { + } + else { if (fname == NULL) { - PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_ERR); - } else { - PyErr_Format(_curses_panelstate_global->PyCursesError, "%s() returned ERR", fname); + PyErr_SetString(st->PyCursesError, catchall_ERR); + } + else { + PyErr_Format(st->PyCursesError, "%s() returned ERR", fname); } return NULL; } @@ -89,9 +86,6 @@ typedef struct { PyCursesWindowObject *wo; /* for reference counts */ } PyCursesPanelObject; -#define PyCursesPanel_Check(v) \ - Py_IS_TYPE(v, _curses_panelstate_global->PyCursesPanel_Type) - /* Some helper functions. The problem is that there's always a window associated with a panel. To ensure that Python's GC doesn't pull this window from under our feet we need to keep track of references @@ -182,67 +176,83 @@ class _curses_panel.panel "PyCursesPanelObject *" "&PyCursesPanel_Type" /*[clinic input] _curses_panel.panel.bottom + cls: defining_class + Push the panel to the bottom of the stack. [clinic start generated code]*/ static PyObject * -_curses_panel_panel_bottom_impl(PyCursesPanelObject *self) -/*[clinic end generated code: output=7aa7d14d7e1d1ce6 input=b6c920c071b61e2e]*/ +_curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls) +/*[clinic end generated code: output=8ec7fbbc08554021 input=6b7d2c0578b5a1c4]*/ { - return PyCursesCheckERR(bottom_panel(self->pan), "bottom"); + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + + return PyCursesCheckERR(st, bottom_panel(self->pan), "bottom"); } /*[clinic input] _curses_panel.panel.hide + cls: defining_class + Hide the panel. This does not delete the object, it just makes the window on screen invisible. [clinic start generated code]*/ static PyObject * -_curses_panel_panel_hide_impl(PyCursesPanelObject *self) -/*[clinic end generated code: output=a7bbbd523e1eab49 input=f6ab884e99386118]*/ +_curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls) +/*[clinic end generated code: output=cc6ab7203cdc1450 input=1bfc741f473e6055]*/ { - return PyCursesCheckERR(hide_panel(self->pan), "hide"); + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(st, hide_panel(self->pan), "hide"); } /*[clinic input] _curses_panel.panel.show + cls: defining_class + Display the panel (which might have been hidden). [clinic start generated code]*/ static PyObject * -_curses_panel_panel_show_impl(PyCursesPanelObject *self) -/*[clinic end generated code: output=6b4553ab45c97769 input=57b167bbefaa3755]*/ +_curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls) +/*[clinic end generated code: output=dc3421de375f0409 input=8122e80151cb4379]*/ { - return PyCursesCheckERR(show_panel(self->pan), "show"); + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(st, show_panel(self->pan), "show"); } /*[clinic input] _curses_panel.panel.top + cls: defining_class + Push panel to the top of the stack. [clinic start generated code]*/ static PyObject * -_curses_panel_panel_top_impl(PyCursesPanelObject *self) -/*[clinic end generated code: output=0f5f2f8cdd2d1777 input=be33975ec3ca0e9a]*/ +_curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls) +/*[clinic end generated code: output=10a072e511e873f7 input=1f372d597dda3379]*/ { - return PyCursesCheckERR(top_panel(self->pan), "top"); + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(st, top_panel(self->pan), "top"); } /* Allocation and deallocation of Panel Objects */ static PyObject * -PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo) +PyCursesPanel_New(PyObject *module, PANEL *pan, PyCursesWindowObject *wo) { - PyCursesPanelObject *po; + _curses_panelstate *st = get_curses_panelstate(module); + + PyCursesPanelObject *po = PyObject_New(PyCursesPanelObject, + (PyTypeObject *)(_curses_panelstate->PyCursesPanel_Type); + if (po == NULL) { + return NULL; + } - po = PyObject_New(PyCursesPanelObject, - (PyTypeObject *)(_curses_panelstate_global)->PyCursesPanel_Type); - if (po == NULL) return NULL; po->pan = pan; if (insert_lop(po) < 0) { po->wo = NULL; @@ -267,7 +277,7 @@ PyCursesPanel_Dealloc(PyCursesPanelObject *po) } (void)del_panel(po->pan); if (po->wo != NULL) { - Py_DECREF(po->wo); + Py_DECREF(po->wo);_curses_panelstate remove_lop(po); } PyObject_DEL(po); @@ -355,6 +365,7 @@ _curses_panel_panel_hidden_impl(PyCursesPanelObject *self) /*[clinic input] _curses_panel.panel.move + cls: defining_class y: int x: int / @@ -363,10 +374,12 @@ Move the panel to the screen coordinates (y, x). [clinic start generated code]*/ static PyObject * -_curses_panel_panel_move_impl(PyCursesPanelObject *self, int y, int x) -/*[clinic end generated code: output=d867535a89777415 input=e0b36b78acc03fba]*/ +_curses_panel_panel_move_impl(PyCursesPanelObject *self, PyTypeObject *cls, + int y, int x) +/*[clinic end generated code: output=ce546c93e56867da input=60a0e7912ff99849]*/ { - return PyCursesCheckERR(move_panel(self->pan, y, x), "move_panel"); + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(st, move_panel(self->pan, y, x), "move_panel"); } /*[clinic input] @@ -386,6 +399,7 @@ _curses_panel_panel_window_impl(PyCursesPanelObject *self) /*[clinic input] _curses_panel.panel.replace + cls: defining_class win: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") / @@ -394,22 +408,22 @@ Change the window associated with the panel to the window win. static PyObject * _curses_panel_panel_replace_impl(PyCursesPanelObject *self, + PyTypeObject *cls, PyCursesWindowObject *win) -/*[clinic end generated code: output=2253a95f7b287255 input=4b1c4283987d9dfa]*/ +/*[clinic end generated code: output=c71f95c212d58ae7 input=dbec7180ece41ff5]*/ { - PyCursesPanelObject *po; - int rtn; + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); - po = find_po(self->pan); + PyCursesPanelObject *po = find_po(self->pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, "replace_panel: can't find Panel Object"); return NULL; } - rtn = replace_panel(self->pan, win->win); + int rtn = replace_panel(self->pan, win->win); if (rtn == ERR) { - PyErr_SetString(_curses_panelstate_global->PyCursesError, "replace_panel() returned ERR"); + PyErr_SetString(st->PyCursesError, "replace_panel() returned ERR"); return NULL; } Py_INCREF(win); @@ -420,6 +434,7 @@ _curses_panel_panel_replace_impl(PyCursesPanelObject *self, /*[clinic input] _curses_panel.panel.set_userptr + cls: defining_class obj: object / @@ -427,38 +442,43 @@ Set the panel's user pointer to obj. [clinic start generated code]*/ static PyObject * -_curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyObject *obj) -/*[clinic end generated code: output=6fb145b3af88cf4a input=d2c6a9dbefabbf39]*/ +_curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, + PyTypeObject *cls, PyObject *obj) +/*[clinic end generated code: output=db74f3db07b28080 input=e3fee2ff7b1b8e48]*/ { - PyObject *oldobj; - int rc; PyCursesInitialised; Py_INCREF(obj); - oldobj = (PyObject *) panel_userptr(self->pan); - rc = set_panel_userptr(self->pan, (void*)obj); + PyObject *oldobj = (PyObject *) panel_userptr(self->pan); + int rc = set_panel_userptr(self->pan, (void*)obj); if (rc == ERR) { /* In case of an ncurses error, decref the new object again */ Py_DECREF(obj); } Py_XDECREF(oldobj); - return PyCursesCheckERR(rc, "set_panel_userptr"); + + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(st, rc, "set_panel_userptr"); } /*[clinic input] _curses_panel.panel.userptr + cls: defining_class + Return the user pointer for the panel. [clinic start generated code]*/ static PyObject * -_curses_panel_panel_userptr_impl(PyCursesPanelObject *self) -/*[clinic end generated code: output=e849c307b5dc9237 input=f78b7a47aef0fd50]*/ +_curses_panel_panel_userptr_impl(PyCursesPanelObject *self, + PyTypeObject *cls) +/*[clinic end generated code: output=eea6e6f39ffc0179 input=f22ca4f115e30a80]*/ { - PyObject *obj; + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + PyCursesInitialised; - obj = (PyObject *) panel_userptr(self->pan); + PyObject *obj = (PyObject *) panel_userptr(self->pan); if (obj == NULL) { - PyErr_SetString(_curses_panelstate_global->PyCursesError, "no userptr set"); + PyErr_SetString(st->PyCursesError, "no userptr set"); return NULL; } @@ -539,6 +559,7 @@ _curses_panel_bottom_panel_impl(PyObject *module) /*[clinic input] _curses_panel.new_panel + cls: defining_class win: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") / @@ -546,15 +567,18 @@ Return a panel object, associating it with the given window win. [clinic start generated code]*/ static PyObject * -_curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win) -/*[clinic end generated code: output=45e948e0176a9bd2 input=74d4754e0ebe4800]*/ +_curses_panel_new_panel_impl(PyObject *module, PyTypeObject *cls, + PyCursesWindowObject *win) +/*[clinic end generated code: output=367de29657788b50 input=5814b695dc719da1]*/ { + _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + PANEL *pan = new_panel(win->win); if (pan == NULL) { - PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_NULL); + PyErr_SetString(st->PyCursesError, catchall_NULL); return NULL; } - return (PyObject *)PyCursesPanel_New(pan, win); + return (PyObject *)PyCursesPanel_New(module, pan, win); } @@ -626,12 +650,14 @@ _curses_exec(PyObject *m) { _curses_panel_state *st = get_curses_panelstate(m); /* Initialize object type */ - st->PyCursesPanel_Type = PyType_FromSpec(&PyCursesPanel_Type_spec); - if (st->PyCursesPanel_Type == NULL) + st->PyCursesPanel_Type = PyType_FromModuleAndSpec(m, &PyCursesPanel_Type_spec, NULL); + if (st->PyCursesPanel_Type == NULL) { return -1; + } - if (PyModule_AddType(m, st->PyCursesPanel_Type) < 0) + if (PyModule_AddType(m, st->PyCursesPanel_Type) < 0) { return -1; + } import_curses(); if (PyErr_Occurred()) diff --git a/Modules/clinic/_curses_panel.c.h b/Modules/clinic/_curses_panel.c.h index cff274657658ad..2222bc7f3e9131 100644 --- a/Modules/clinic/_curses_panel.c.h +++ b/Modules/clinic/_curses_panel.c.h @@ -1,328 +1,406 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, -"bottom($self, /)\n" -"--\n" -"\n" -"Push the panel to the bottom of the stack."); - -#define _CURSES_PANEL_PANEL_BOTTOM_METHODDEF \ - {"bottom", (PyCFunction)_curses_panel_panel_bottom, METH_NOARGS, _curses_panel_panel_bottom__doc__}, - -static PyObject * -_curses_panel_panel_bottom_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_bottom(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_bottom_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_hide__doc__, -"hide($self, /)\n" -"--\n" -"\n" -"Hide the panel.\n" -"\n" -"This does not delete the object, it just makes the window on screen invisible."); - -#define _CURSES_PANEL_PANEL_HIDE_METHODDEF \ - {"hide", (PyCFunction)_curses_panel_panel_hide, METH_NOARGS, _curses_panel_panel_hide__doc__}, - -static PyObject * -_curses_panel_panel_hide_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_hide(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_hide_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_show__doc__, -"show($self, /)\n" -"--\n" -"\n" -"Display the panel (which might have been hidden)."); - -#define _CURSES_PANEL_PANEL_SHOW_METHODDEF \ - {"show", (PyCFunction)_curses_panel_panel_show, METH_NOARGS, _curses_panel_panel_show__doc__}, - -static PyObject * -_curses_panel_panel_show_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_show(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_show_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_top__doc__, -"top($self, /)\n" -"--\n" -"\n" -"Push panel to the top of the stack."); - -#define _CURSES_PANEL_PANEL_TOP_METHODDEF \ - {"top", (PyCFunction)_curses_panel_panel_top, METH_NOARGS, _curses_panel_panel_top__doc__}, - -static PyObject * -_curses_panel_panel_top_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_top(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_top_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_above__doc__, -"above($self, /)\n" -"--\n" -"\n" -"Return the panel above the current panel."); - -#define _CURSES_PANEL_PANEL_ABOVE_METHODDEF \ - {"above", (PyCFunction)_curses_panel_panel_above, METH_NOARGS, _curses_panel_panel_above__doc__}, - -static PyObject * -_curses_panel_panel_above_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_above(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_above_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_below__doc__, -"below($self, /)\n" -"--\n" -"\n" -"Return the panel below the current panel."); - -#define _CURSES_PANEL_PANEL_BELOW_METHODDEF \ - {"below", (PyCFunction)_curses_panel_panel_below, METH_NOARGS, _curses_panel_panel_below__doc__}, - -static PyObject * -_curses_panel_panel_below_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_below(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_below_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_hidden__doc__, -"hidden($self, /)\n" -"--\n" -"\n" -"Return True if the panel is hidden (not visible), False otherwise."); - -#define _CURSES_PANEL_PANEL_HIDDEN_METHODDEF \ - {"hidden", (PyCFunction)_curses_panel_panel_hidden, METH_NOARGS, _curses_panel_panel_hidden__doc__}, - -static PyObject * -_curses_panel_panel_hidden_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_hidden(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_hidden_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_move__doc__, -"move($self, y, x, /)\n" -"--\n" -"\n" -"Move the panel to the screen coordinates (y, x)."); - -#define _CURSES_PANEL_PANEL_MOVE_METHODDEF \ - {"move", (PyCFunction)(void(*)(void))_curses_panel_panel_move, METH_FASTCALL, _curses_panel_panel_move__doc__}, - -static PyObject * -_curses_panel_panel_move_impl(PyCursesPanelObject *self, int y, int x); - -static PyObject * -_curses_panel_panel_move(PyCursesPanelObject *self, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - int y; - int x; - - if (!_PyArg_CheckPositional("move", nargs, 2, 2)) { - goto exit; - } - y = _PyLong_AsInt(args[0]); - if (y == -1 && PyErr_Occurred()) { - goto exit; - } - x = _PyLong_AsInt(args[1]); - if (x == -1 && PyErr_Occurred()) { - goto exit; - } - return_value = _curses_panel_panel_move_impl(self, y, x); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_window__doc__, -"window($self, /)\n" -"--\n" -"\n" -"Return the window object associated with the panel."); - -#define _CURSES_PANEL_PANEL_WINDOW_METHODDEF \ - {"window", (PyCFunction)_curses_panel_panel_window, METH_NOARGS, _curses_panel_panel_window__doc__}, - -static PyObject * -_curses_panel_panel_window_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_window(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_window_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_replace__doc__, -"replace($self, win, /)\n" -"--\n" -"\n" -"Change the window associated with the panel to the window win."); - -#define _CURSES_PANEL_PANEL_REPLACE_METHODDEF \ - {"replace", (PyCFunction)_curses_panel_panel_replace, METH_O, _curses_panel_panel_replace__doc__}, - -static PyObject * -_curses_panel_panel_replace_impl(PyCursesPanelObject *self, - PyCursesWindowObject *win); - -static PyObject * -_curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg) -{ - PyObject *return_value = NULL; - PyCursesWindowObject *win; - - if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { - _PyArg_BadArgument("replace", "argument", (&PyCursesWindow_Type)->tp_name, arg); - goto exit; - } - win = (PyCursesWindowObject *)arg; - return_value = _curses_panel_panel_replace_impl(self, win); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_set_userptr__doc__, -"set_userptr($self, obj, /)\n" -"--\n" -"\n" -"Set the panel\'s user pointer to obj."); - -#define _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF \ - {"set_userptr", (PyCFunction)_curses_panel_panel_set_userptr, METH_O, _curses_panel_panel_set_userptr__doc__}, - -PyDoc_STRVAR(_curses_panel_panel_userptr__doc__, -"userptr($self, /)\n" -"--\n" -"\n" -"Return the user pointer for the panel."); - -#define _CURSES_PANEL_PANEL_USERPTR_METHODDEF \ - {"userptr", (PyCFunction)_curses_panel_panel_userptr, METH_NOARGS, _curses_panel_panel_userptr__doc__}, - -static PyObject * -_curses_panel_panel_userptr_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_userptr(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_userptr_impl(self); -} - -PyDoc_STRVAR(_curses_panel_bottom_panel__doc__, -"bottom_panel($module, /)\n" -"--\n" -"\n" -"Return the bottom panel in the panel stack."); - -#define _CURSES_PANEL_BOTTOM_PANEL_METHODDEF \ - {"bottom_panel", (PyCFunction)_curses_panel_bottom_panel, METH_NOARGS, _curses_panel_bottom_panel__doc__}, - -static PyObject * -_curses_panel_bottom_panel_impl(PyObject *module); - -static PyObject * -_curses_panel_bottom_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_bottom_panel_impl(module); -} - -PyDoc_STRVAR(_curses_panel_new_panel__doc__, -"new_panel($module, win, /)\n" -"--\n" -"\n" -"Return a panel object, associating it with the given window win."); - -#define _CURSES_PANEL_NEW_PANEL_METHODDEF \ - {"new_panel", (PyCFunction)_curses_panel_new_panel, METH_O, _curses_panel_new_panel__doc__}, - -static PyObject * -_curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win); - -static PyObject * -_curses_panel_new_panel(PyObject *module, PyObject *arg) -{ - PyObject *return_value = NULL; - PyCursesWindowObject *win; - - if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { - _PyArg_BadArgument("new_panel", "argument", (&PyCursesWindow_Type)->tp_name, arg); - goto exit; - } - win = (PyCursesWindowObject *)arg; - return_value = _curses_panel_new_panel_impl(module, win); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_top_panel__doc__, -"top_panel($module, /)\n" -"--\n" -"\n" -"Return the top panel in the panel stack."); - -#define _CURSES_PANEL_TOP_PANEL_METHODDEF \ - {"top_panel", (PyCFunction)_curses_panel_top_panel, METH_NOARGS, _curses_panel_top_panel__doc__}, - -static PyObject * -_curses_panel_top_panel_impl(PyObject *module); - -static PyObject * -_curses_panel_top_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_top_panel_impl(module); -} - -PyDoc_STRVAR(_curses_panel_update_panels__doc__, -"update_panels($module, /)\n" -"--\n" -"\n" -"Updates the virtual screen after changes in the panel stack.\n" -"\n" -"This does not call curses.doupdate(), so you\'ll have to do this yourself."); - -#define _CURSES_PANEL_UPDATE_PANELS_METHODDEF \ - {"update_panels", (PyCFunction)_curses_panel_update_panels, METH_NOARGS, _curses_panel_update_panels__doc__}, - -static PyObject * -_curses_panel_update_panels_impl(PyObject *module); - -static PyObject * -_curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_update_panels_impl(module); -} -/*[clinic end generated code: output=1226d5f94361ebfb input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, +"bottom($self, /)\n" +"--\n" +"\n" +"Push the panel to the bottom of the stack."); + +#define _CURSES_PANEL_PANEL_BOTTOM_METHODDEF \ + {"bottom", (PyCFunction)(void(*)(void))_curses_panel_panel_bottom, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_bottom__doc__}, + +static PyObject * +_curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_bottom(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":bottom", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_bottom_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_hide__doc__, +"hide($self, /)\n" +"--\n" +"\n" +"Hide the panel.\n" +"\n" +"This does not delete the object, it just makes the window on screen invisible."); + +#define _CURSES_PANEL_PANEL_HIDE_METHODDEF \ + {"hide", (PyCFunction)(void(*)(void))_curses_panel_panel_hide, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_hide__doc__}, + +static PyObject * +_curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_hide(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":hide", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_hide_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_show__doc__, +"show($self, /)\n" +"--\n" +"\n" +"Display the panel (which might have been hidden)."); + +#define _CURSES_PANEL_PANEL_SHOW_METHODDEF \ + {"show", (PyCFunction)(void(*)(void))_curses_panel_panel_show, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_show__doc__}, + +static PyObject * +_curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_show(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":show", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_show_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_top__doc__, +"top($self, /)\n" +"--\n" +"\n" +"Push panel to the top of the stack."); + +#define _CURSES_PANEL_PANEL_TOP_METHODDEF \ + {"top", (PyCFunction)(void(*)(void))_curses_panel_panel_top, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_top__doc__}, + +static PyObject * +_curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_top(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":top", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_top_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_above__doc__, +"above($self, /)\n" +"--\n" +"\n" +"Return the panel above the current panel."); + +#define _CURSES_PANEL_PANEL_ABOVE_METHODDEF \ + {"above", (PyCFunction)_curses_panel_panel_above, METH_NOARGS, _curses_panel_panel_above__doc__}, + +static PyObject * +_curses_panel_panel_above_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_above(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_above_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_below__doc__, +"below($self, /)\n" +"--\n" +"\n" +"Return the panel below the current panel."); + +#define _CURSES_PANEL_PANEL_BELOW_METHODDEF \ + {"below", (PyCFunction)_curses_panel_panel_below, METH_NOARGS, _curses_panel_panel_below__doc__}, + +static PyObject * +_curses_panel_panel_below_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_below(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_below_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_hidden__doc__, +"hidden($self, /)\n" +"--\n" +"\n" +"Return True if the panel is hidden (not visible), False otherwise."); + +#define _CURSES_PANEL_PANEL_HIDDEN_METHODDEF \ + {"hidden", (PyCFunction)_curses_panel_panel_hidden, METH_NOARGS, _curses_panel_panel_hidden__doc__}, + +static PyObject * +_curses_panel_panel_hidden_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_hidden(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_hidden_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_move__doc__, +"move($self, y, x, /)\n" +"--\n" +"\n" +"Move the panel to the screen coordinates (y, x)."); + +#define _CURSES_PANEL_PANEL_MOVE_METHODDEF \ + {"move", (PyCFunction)(void(*)(void))_curses_panel_panel_move, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_move__doc__}, + +static PyObject * +_curses_panel_panel_move_impl(PyCursesPanelObject *self, PyTypeObject *cls, + int y, int x); + +static PyObject * +_curses_panel_panel_move(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "", NULL}; + static _PyArg_Parser _parser = {"ii:move", _keywords, 0}; + int y; + int x; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &y, &x)) { + goto exit; + } + return_value = _curses_panel_panel_move_impl(self, cls, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_window__doc__, +"window($self, /)\n" +"--\n" +"\n" +"Return the window object associated with the panel."); + +#define _CURSES_PANEL_PANEL_WINDOW_METHODDEF \ + {"window", (PyCFunction)_curses_panel_panel_window, METH_NOARGS, _curses_panel_panel_window__doc__}, + +static PyObject * +_curses_panel_panel_window_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_window(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_window_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_replace__doc__, +"replace($self, win, /)\n" +"--\n" +"\n" +"Change the window associated with the panel to the window win."); + +#define _CURSES_PANEL_PANEL_REPLACE_METHODDEF \ + {"replace", (PyCFunction)(void(*)(void))_curses_panel_panel_replace, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_replace__doc__}, + +static PyObject * +_curses_panel_panel_replace_impl(PyCursesPanelObject *self, + PyTypeObject *cls, + PyCursesWindowObject *win); + +static PyObject * +_curses_panel_panel_replace(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", NULL}; + static _PyArg_Parser _parser = {"O!:replace", _keywords, 0}; + PyCursesWindowObject *win; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &PyCursesWindow_Type, &win)) { + goto exit; + } + return_value = _curses_panel_panel_replace_impl(self, cls, win); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_set_userptr__doc__, +"set_userptr($self, obj, /)\n" +"--\n" +"\n" +"Set the panel\'s user pointer to obj."); + +#define _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF \ + {"set_userptr", (PyCFunction)(void(*)(void))_curses_panel_panel_set_userptr, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_set_userptr__doc__}, + +static PyObject * +_curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, + PyTypeObject *cls, PyObject *obj); + +static PyObject * +_curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", NULL}; + static _PyArg_Parser _parser = {"O:set_userptr", _keywords, 0}; + PyObject *obj; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &obj)) { + goto exit; + } + return_value = _curses_panel_panel_set_userptr_impl(self, cls, obj); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_userptr__doc__, +"userptr($self, /)\n" +"--\n" +"\n" +"Return the user pointer for the panel."); + +#define _CURSES_PANEL_PANEL_USERPTR_METHODDEF \ + {"userptr", (PyCFunction)(void(*)(void))_curses_panel_panel_userptr, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_userptr__doc__}, + +static PyObject * +_curses_panel_panel_userptr_impl(PyCursesPanelObject *self, + PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_userptr(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":userptr", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_userptr_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_bottom_panel__doc__, +"bottom_panel($module, /)\n" +"--\n" +"\n" +"Return the bottom panel in the panel stack."); + +#define _CURSES_PANEL_BOTTOM_PANEL_METHODDEF \ + {"bottom_panel", (PyCFunction)_curses_panel_bottom_panel, METH_NOARGS, _curses_panel_bottom_panel__doc__}, + +static PyObject * +_curses_panel_bottom_panel_impl(PyObject *module); + +static PyObject * +_curses_panel_bottom_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_bottom_panel_impl(module); +} + +PyDoc_STRVAR(_curses_panel_new_panel__doc__, +"new_panel($module, win, /)\n" +"--\n" +"\n" +"Return a panel object, associating it with the given window win."); + +#define _CURSES_PANEL_NEW_PANEL_METHODDEF \ + {"new_panel", (PyCFunction)(void(*)(void))_curses_panel_new_panel, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_new_panel__doc__}, + +static PyObject * +_curses_panel_new_panel_impl(PyObject *module, PyTypeObject *cls, + PyCursesWindowObject *win); + +static PyObject * +_curses_panel_new_panel(PyObject *module, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", NULL}; + static _PyArg_Parser _parser = {"O!:new_panel", _keywords, 0}; + PyCursesWindowObject *win; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &PyCursesWindow_Type, &win)) { + goto exit; + } + return_value = _curses_panel_new_panel_impl(module, cls, win); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_top_panel__doc__, +"top_panel($module, /)\n" +"--\n" +"\n" +"Return the top panel in the panel stack."); + +#define _CURSES_PANEL_TOP_PANEL_METHODDEF \ + {"top_panel", (PyCFunction)_curses_panel_top_panel, METH_NOARGS, _curses_panel_top_panel__doc__}, + +static PyObject * +_curses_panel_top_panel_impl(PyObject *module); + +static PyObject * +_curses_panel_top_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_top_panel_impl(module); +} + +PyDoc_STRVAR(_curses_panel_update_panels__doc__, +"update_panels($module, /)\n" +"--\n" +"\n" +"Updates the virtual screen after changes in the panel stack.\n" +"\n" +"This does not call curses.doupdate(), so you\'ll have to do this yourself."); + +#define _CURSES_PANEL_UPDATE_PANELS_METHODDEF \ + {"update_panels", (PyCFunction)_curses_panel_update_panels, METH_NOARGS, _curses_panel_update_panels__doc__}, + +static PyObject * +_curses_panel_update_panels_impl(PyObject *module); + +static PyObject * +_curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_update_panels_impl(module); +} +/*[clinic end generated code: output=17020aadebbac145 input=a9049054013a1b77]*/ From ba012cf26aba6974b983b153a8b8a43524492076 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 1 Sep 2020 21:14:44 -0500 Subject: [PATCH 04/16] regen clinic file on linux --- Modules/clinic/_curses_panel.c.h | 812 +++++++++++++++---------------- 1 file changed, 406 insertions(+), 406 deletions(-) diff --git a/Modules/clinic/_curses_panel.c.h b/Modules/clinic/_curses_panel.c.h index 2222bc7f3e9131..0e13b87db29266 100644 --- a/Modules/clinic/_curses_panel.c.h +++ b/Modules/clinic/_curses_panel.c.h @@ -1,406 +1,406 @@ -/*[clinic input] -preserve -[clinic start generated code]*/ - -PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, -"bottom($self, /)\n" -"--\n" -"\n" -"Push the panel to the bottom of the stack."); - -#define _CURSES_PANEL_PANEL_BOTTOM_METHODDEF \ - {"bottom", (PyCFunction)(void(*)(void))_curses_panel_panel_bottom, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_bottom__doc__}, - -static PyObject * -_curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls); - -static PyObject * -_curses_panel_panel_bottom(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":bottom", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; - } - return_value = _curses_panel_panel_bottom_impl(self, cls); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_hide__doc__, -"hide($self, /)\n" -"--\n" -"\n" -"Hide the panel.\n" -"\n" -"This does not delete the object, it just makes the window on screen invisible."); - -#define _CURSES_PANEL_PANEL_HIDE_METHODDEF \ - {"hide", (PyCFunction)(void(*)(void))_curses_panel_panel_hide, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_hide__doc__}, - -static PyObject * -_curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls); - -static PyObject * -_curses_panel_panel_hide(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":hide", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; - } - return_value = _curses_panel_panel_hide_impl(self, cls); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_show__doc__, -"show($self, /)\n" -"--\n" -"\n" -"Display the panel (which might have been hidden)."); - -#define _CURSES_PANEL_PANEL_SHOW_METHODDEF \ - {"show", (PyCFunction)(void(*)(void))_curses_panel_panel_show, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_show__doc__}, - -static PyObject * -_curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls); - -static PyObject * -_curses_panel_panel_show(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":show", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; - } - return_value = _curses_panel_panel_show_impl(self, cls); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_top__doc__, -"top($self, /)\n" -"--\n" -"\n" -"Push panel to the top of the stack."); - -#define _CURSES_PANEL_PANEL_TOP_METHODDEF \ - {"top", (PyCFunction)(void(*)(void))_curses_panel_panel_top, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_top__doc__}, - -static PyObject * -_curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls); - -static PyObject * -_curses_panel_panel_top(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":top", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; - } - return_value = _curses_panel_panel_top_impl(self, cls); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_above__doc__, -"above($self, /)\n" -"--\n" -"\n" -"Return the panel above the current panel."); - -#define _CURSES_PANEL_PANEL_ABOVE_METHODDEF \ - {"above", (PyCFunction)_curses_panel_panel_above, METH_NOARGS, _curses_panel_panel_above__doc__}, - -static PyObject * -_curses_panel_panel_above_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_above(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_above_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_below__doc__, -"below($self, /)\n" -"--\n" -"\n" -"Return the panel below the current panel."); - -#define _CURSES_PANEL_PANEL_BELOW_METHODDEF \ - {"below", (PyCFunction)_curses_panel_panel_below, METH_NOARGS, _curses_panel_panel_below__doc__}, - -static PyObject * -_curses_panel_panel_below_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_below(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_below_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_hidden__doc__, -"hidden($self, /)\n" -"--\n" -"\n" -"Return True if the panel is hidden (not visible), False otherwise."); - -#define _CURSES_PANEL_PANEL_HIDDEN_METHODDEF \ - {"hidden", (PyCFunction)_curses_panel_panel_hidden, METH_NOARGS, _curses_panel_panel_hidden__doc__}, - -static PyObject * -_curses_panel_panel_hidden_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_hidden(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_hidden_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_move__doc__, -"move($self, y, x, /)\n" -"--\n" -"\n" -"Move the panel to the screen coordinates (y, x)."); - -#define _CURSES_PANEL_PANEL_MOVE_METHODDEF \ - {"move", (PyCFunction)(void(*)(void))_curses_panel_panel_move, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_move__doc__}, - -static PyObject * -_curses_panel_panel_move_impl(PyCursesPanelObject *self, PyTypeObject *cls, - int y, int x); - -static PyObject * -_curses_panel_panel_move(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"", "", NULL}; - static _PyArg_Parser _parser = {"ii:move", _keywords, 0}; - int y; - int x; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &y, &x)) { - goto exit; - } - return_value = _curses_panel_panel_move_impl(self, cls, y, x); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_window__doc__, -"window($self, /)\n" -"--\n" -"\n" -"Return the window object associated with the panel."); - -#define _CURSES_PANEL_PANEL_WINDOW_METHODDEF \ - {"window", (PyCFunction)_curses_panel_panel_window, METH_NOARGS, _curses_panel_panel_window__doc__}, - -static PyObject * -_curses_panel_panel_window_impl(PyCursesPanelObject *self); - -static PyObject * -_curses_panel_panel_window(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_panel_window_impl(self); -} - -PyDoc_STRVAR(_curses_panel_panel_replace__doc__, -"replace($self, win, /)\n" -"--\n" -"\n" -"Change the window associated with the panel to the window win."); - -#define _CURSES_PANEL_PANEL_REPLACE_METHODDEF \ - {"replace", (PyCFunction)(void(*)(void))_curses_panel_panel_replace, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_replace__doc__}, - -static PyObject * -_curses_panel_panel_replace_impl(PyCursesPanelObject *self, - PyTypeObject *cls, - PyCursesWindowObject *win); - -static PyObject * -_curses_panel_panel_replace(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O!:replace", _keywords, 0}; - PyCursesWindowObject *win; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &PyCursesWindow_Type, &win)) { - goto exit; - } - return_value = _curses_panel_panel_replace_impl(self, cls, win); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_set_userptr__doc__, -"set_userptr($self, obj, /)\n" -"--\n" -"\n" -"Set the panel\'s user pointer to obj."); - -#define _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF \ - {"set_userptr", (PyCFunction)(void(*)(void))_curses_panel_panel_set_userptr, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_set_userptr__doc__}, - -static PyObject * -_curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, - PyTypeObject *cls, PyObject *obj); - -static PyObject * -_curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O:set_userptr", _keywords, 0}; - PyObject *obj; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &obj)) { - goto exit; - } - return_value = _curses_panel_panel_set_userptr_impl(self, cls, obj); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_panel_userptr__doc__, -"userptr($self, /)\n" -"--\n" -"\n" -"Return the user pointer for the panel."); - -#define _CURSES_PANEL_PANEL_USERPTR_METHODDEF \ - {"userptr", (PyCFunction)(void(*)(void))_curses_panel_panel_userptr, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_userptr__doc__}, - -static PyObject * -_curses_panel_panel_userptr_impl(PyCursesPanelObject *self, - PyTypeObject *cls); - -static PyObject * -_curses_panel_panel_userptr(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = { NULL}; - static _PyArg_Parser _parser = {":userptr", _keywords, 0}; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser - )) { - goto exit; - } - return_value = _curses_panel_panel_userptr_impl(self, cls); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_bottom_panel__doc__, -"bottom_panel($module, /)\n" -"--\n" -"\n" -"Return the bottom panel in the panel stack."); - -#define _CURSES_PANEL_BOTTOM_PANEL_METHODDEF \ - {"bottom_panel", (PyCFunction)_curses_panel_bottom_panel, METH_NOARGS, _curses_panel_bottom_panel__doc__}, - -static PyObject * -_curses_panel_bottom_panel_impl(PyObject *module); - -static PyObject * -_curses_panel_bottom_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_bottom_panel_impl(module); -} - -PyDoc_STRVAR(_curses_panel_new_panel__doc__, -"new_panel($module, win, /)\n" -"--\n" -"\n" -"Return a panel object, associating it with the given window win."); - -#define _CURSES_PANEL_NEW_PANEL_METHODDEF \ - {"new_panel", (PyCFunction)(void(*)(void))_curses_panel_new_panel, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_new_panel__doc__}, - -static PyObject * -_curses_panel_new_panel_impl(PyObject *module, PyTypeObject *cls, - PyCursesWindowObject *win); - -static PyObject * -_curses_panel_new_panel(PyObject *module, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) -{ - PyObject *return_value = NULL; - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O!:new_panel", _keywords, 0}; - PyCursesWindowObject *win; - - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &PyCursesWindow_Type, &win)) { - goto exit; - } - return_value = _curses_panel_new_panel_impl(module, cls, win); - -exit: - return return_value; -} - -PyDoc_STRVAR(_curses_panel_top_panel__doc__, -"top_panel($module, /)\n" -"--\n" -"\n" -"Return the top panel in the panel stack."); - -#define _CURSES_PANEL_TOP_PANEL_METHODDEF \ - {"top_panel", (PyCFunction)_curses_panel_top_panel, METH_NOARGS, _curses_panel_top_panel__doc__}, - -static PyObject * -_curses_panel_top_panel_impl(PyObject *module); - -static PyObject * -_curses_panel_top_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_top_panel_impl(module); -} - -PyDoc_STRVAR(_curses_panel_update_panels__doc__, -"update_panels($module, /)\n" -"--\n" -"\n" -"Updates the virtual screen after changes in the panel stack.\n" -"\n" -"This does not call curses.doupdate(), so you\'ll have to do this yourself."); - -#define _CURSES_PANEL_UPDATE_PANELS_METHODDEF \ - {"update_panels", (PyCFunction)_curses_panel_update_panels, METH_NOARGS, _curses_panel_update_panels__doc__}, - -static PyObject * -_curses_panel_update_panels_impl(PyObject *module); - -static PyObject * -_curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) -{ - return _curses_panel_update_panels_impl(module); -} -/*[clinic end generated code: output=17020aadebbac145 input=a9049054013a1b77]*/ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_curses_panel_panel_bottom__doc__, +"bottom($self, /)\n" +"--\n" +"\n" +"Push the panel to the bottom of the stack."); + +#define _CURSES_PANEL_PANEL_BOTTOM_METHODDEF \ + {"bottom", (PyCFunction)(void(*)(void))_curses_panel_panel_bottom, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_bottom__doc__}, + +static PyObject * +_curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_bottom(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":bottom", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_bottom_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_hide__doc__, +"hide($self, /)\n" +"--\n" +"\n" +"Hide the panel.\n" +"\n" +"This does not delete the object, it just makes the window on screen invisible."); + +#define _CURSES_PANEL_PANEL_HIDE_METHODDEF \ + {"hide", (PyCFunction)(void(*)(void))_curses_panel_panel_hide, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_hide__doc__}, + +static PyObject * +_curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_hide(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":hide", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_hide_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_show__doc__, +"show($self, /)\n" +"--\n" +"\n" +"Display the panel (which might have been hidden)."); + +#define _CURSES_PANEL_PANEL_SHOW_METHODDEF \ + {"show", (PyCFunction)(void(*)(void))_curses_panel_panel_show, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_show__doc__}, + +static PyObject * +_curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_show(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":show", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_show_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_top__doc__, +"top($self, /)\n" +"--\n" +"\n" +"Push panel to the top of the stack."); + +#define _CURSES_PANEL_PANEL_TOP_METHODDEF \ + {"top", (PyCFunction)(void(*)(void))_curses_panel_panel_top, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_top__doc__}, + +static PyObject * +_curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_top(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":top", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_top_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_above__doc__, +"above($self, /)\n" +"--\n" +"\n" +"Return the panel above the current panel."); + +#define _CURSES_PANEL_PANEL_ABOVE_METHODDEF \ + {"above", (PyCFunction)_curses_panel_panel_above, METH_NOARGS, _curses_panel_panel_above__doc__}, + +static PyObject * +_curses_panel_panel_above_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_above(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_above_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_below__doc__, +"below($self, /)\n" +"--\n" +"\n" +"Return the panel below the current panel."); + +#define _CURSES_PANEL_PANEL_BELOW_METHODDEF \ + {"below", (PyCFunction)_curses_panel_panel_below, METH_NOARGS, _curses_panel_panel_below__doc__}, + +static PyObject * +_curses_panel_panel_below_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_below(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_below_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_hidden__doc__, +"hidden($self, /)\n" +"--\n" +"\n" +"Return True if the panel is hidden (not visible), False otherwise."); + +#define _CURSES_PANEL_PANEL_HIDDEN_METHODDEF \ + {"hidden", (PyCFunction)_curses_panel_panel_hidden, METH_NOARGS, _curses_panel_panel_hidden__doc__}, + +static PyObject * +_curses_panel_panel_hidden_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_hidden(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_hidden_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_move__doc__, +"move($self, y, x, /)\n" +"--\n" +"\n" +"Move the panel to the screen coordinates (y, x)."); + +#define _CURSES_PANEL_PANEL_MOVE_METHODDEF \ + {"move", (PyCFunction)(void(*)(void))_curses_panel_panel_move, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_move__doc__}, + +static PyObject * +_curses_panel_panel_move_impl(PyCursesPanelObject *self, PyTypeObject *cls, + int y, int x); + +static PyObject * +_curses_panel_panel_move(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", "", NULL}; + static _PyArg_Parser _parser = {"ii:move", _keywords, 0}; + int y; + int x; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &y, &x)) { + goto exit; + } + return_value = _curses_panel_panel_move_impl(self, cls, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_window__doc__, +"window($self, /)\n" +"--\n" +"\n" +"Return the window object associated with the panel."); + +#define _CURSES_PANEL_PANEL_WINDOW_METHODDEF \ + {"window", (PyCFunction)_curses_panel_panel_window, METH_NOARGS, _curses_panel_panel_window__doc__}, + +static PyObject * +_curses_panel_panel_window_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_window(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_window_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_replace__doc__, +"replace($self, win, /)\n" +"--\n" +"\n" +"Change the window associated with the panel to the window win."); + +#define _CURSES_PANEL_PANEL_REPLACE_METHODDEF \ + {"replace", (PyCFunction)(void(*)(void))_curses_panel_panel_replace, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_replace__doc__}, + +static PyObject * +_curses_panel_panel_replace_impl(PyCursesPanelObject *self, + PyTypeObject *cls, + PyCursesWindowObject *win); + +static PyObject * +_curses_panel_panel_replace(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", NULL}; + static _PyArg_Parser _parser = {"O!:replace", _keywords, 0}; + PyCursesWindowObject *win; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &PyCursesWindow_Type, &win)) { + goto exit; + } + return_value = _curses_panel_panel_replace_impl(self, cls, win); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_set_userptr__doc__, +"set_userptr($self, obj, /)\n" +"--\n" +"\n" +"Set the panel\'s user pointer to obj."); + +#define _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF \ + {"set_userptr", (PyCFunction)(void(*)(void))_curses_panel_panel_set_userptr, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_set_userptr__doc__}, + +static PyObject * +_curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, + PyTypeObject *cls, PyObject *obj); + +static PyObject * +_curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", NULL}; + static _PyArg_Parser _parser = {"O:set_userptr", _keywords, 0}; + PyObject *obj; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &obj)) { + goto exit; + } + return_value = _curses_panel_panel_set_userptr_impl(self, cls, obj); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_userptr__doc__, +"userptr($self, /)\n" +"--\n" +"\n" +"Return the user pointer for the panel."); + +#define _CURSES_PANEL_PANEL_USERPTR_METHODDEF \ + {"userptr", (PyCFunction)(void(*)(void))_curses_panel_panel_userptr, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_panel_userptr__doc__}, + +static PyObject * +_curses_panel_panel_userptr_impl(PyCursesPanelObject *self, + PyTypeObject *cls); + +static PyObject * +_curses_panel_panel_userptr(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = { NULL}; + static _PyArg_Parser _parser = {":userptr", _keywords, 0}; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser + )) { + goto exit; + } + return_value = _curses_panel_panel_userptr_impl(self, cls); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_bottom_panel__doc__, +"bottom_panel($module, /)\n" +"--\n" +"\n" +"Return the bottom panel in the panel stack."); + +#define _CURSES_PANEL_BOTTOM_PANEL_METHODDEF \ + {"bottom_panel", (PyCFunction)_curses_panel_bottom_panel, METH_NOARGS, _curses_panel_bottom_panel__doc__}, + +static PyObject * +_curses_panel_bottom_panel_impl(PyObject *module); + +static PyObject * +_curses_panel_bottom_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_bottom_panel_impl(module); +} + +PyDoc_STRVAR(_curses_panel_new_panel__doc__, +"new_panel($module, win, /)\n" +"--\n" +"\n" +"Return a panel object, associating it with the given window win."); + +#define _CURSES_PANEL_NEW_PANEL_METHODDEF \ + {"new_panel", (PyCFunction)(void(*)(void))_curses_panel_new_panel, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_new_panel__doc__}, + +static PyObject * +_curses_panel_new_panel_impl(PyObject *module, PyTypeObject *cls, + PyCursesWindowObject *win); + +static PyObject * +_curses_panel_new_panel(PyObject *module, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"", NULL}; + static _PyArg_Parser _parser = {"O!:new_panel", _keywords, 0}; + PyCursesWindowObject *win; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &PyCursesWindow_Type, &win)) { + goto exit; + } + return_value = _curses_panel_new_panel_impl(module, cls, win); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_top_panel__doc__, +"top_panel($module, /)\n" +"--\n" +"\n" +"Return the top panel in the panel stack."); + +#define _CURSES_PANEL_TOP_PANEL_METHODDEF \ + {"top_panel", (PyCFunction)_curses_panel_top_panel, METH_NOARGS, _curses_panel_top_panel__doc__}, + +static PyObject * +_curses_panel_top_panel_impl(PyObject *module); + +static PyObject * +_curses_panel_top_panel(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_top_panel_impl(module); +} + +PyDoc_STRVAR(_curses_panel_update_panels__doc__, +"update_panels($module, /)\n" +"--\n" +"\n" +"Updates the virtual screen after changes in the panel stack.\n" +"\n" +"This does not call curses.doupdate(), so you\'ll have to do this yourself."); + +#define _CURSES_PANEL_UPDATE_PANELS_METHODDEF \ + {"update_panels", (PyCFunction)_curses_panel_update_panels, METH_NOARGS, _curses_panel_update_panels__doc__}, + +static PyObject * +_curses_panel_update_panels_impl(PyObject *module); + +static PyObject * +_curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_update_panels_impl(module); +} +/*[clinic end generated code: output=17020aadebbac145 input=a9049054013a1b77]*/ From 14a602719e88f68cf60837eec08804484eac883d Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Wed, 2 Sep 2020 18:13:12 -0500 Subject: [PATCH 05/16] rename variable & fix issue --- Modules/_curses_panel.c | 69 ++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 1452f7f0bba203..91b54a13932230 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -58,17 +58,17 @@ _curses_panel_free(void *m) */ static PyObject * -PyCursesCheckERR(_curses_panelstate *st, int code, const char *fname) +PyCursesCheckERR(_curses_panelstate *state, int code, const char *fname) { if (code != ERR) { Py_RETURN_NONE; } else { if (fname == NULL) { - PyErr_SetString(st->PyCursesError, catchall_ERR); + PyErr_SetString(state->PyCursesError, catchall_ERR); } else { - PyErr_Format(st->PyCursesError, "%s() returned ERR", fname); + PyErr_Format(state->PyCursesError, "%s() returned ERR", fname); } return NULL; } @@ -185,9 +185,10 @@ static PyObject * _curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=8ec7fbbc08554021 input=6b7d2c0578b5a1c4]*/ { - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); - return PyCursesCheckERR(st, bottom_panel(self->pan), "bottom"); + return PyCursesCheckERR(state, bottom_panel(self->pan), "bottom"); } /*[clinic input] @@ -204,8 +205,9 @@ static PyObject * _curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=cc6ab7203cdc1450 input=1bfc741f473e6055]*/ { - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); - return PyCursesCheckERR(st, hide_panel(self->pan), "hide"); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(state, hide_panel(self->pan), "hide"); } /*[clinic input] @@ -220,8 +222,9 @@ static PyObject * _curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=dc3421de375f0409 input=8122e80151cb4379]*/ { - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); - return PyCursesCheckERR(st, show_panel(self->pan), "show"); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(state, show_panel(self->pan), "show"); } /*[clinic input] @@ -236,8 +239,9 @@ static PyObject * _curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=10a072e511e873f7 input=1f372d597dda3379]*/ { - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); - return PyCursesCheckERR(st, top_panel(self->pan), "top"); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(state, top_panel(self->pan), "top"); } /* Allocation and deallocation of Panel Objects */ @@ -245,10 +249,10 @@ _curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls) static PyObject * PyCursesPanel_New(PyObject *module, PANEL *pan, PyCursesWindowObject *wo) { - _curses_panelstate *st = get_curses_panelstate(module); + _curses_panelstate *state = get_curses_panelstate(module); PyCursesPanelObject *po = PyObject_New(PyCursesPanelObject, - (PyTypeObject *)(_curses_panelstate->PyCursesPanel_Type); + (PyTypeObject *)(state->PyCursesPanel_Type); if (po == NULL) { return NULL; } @@ -378,8 +382,9 @@ _curses_panel_panel_move_impl(PyCursesPanelObject *self, PyTypeObject *cls, int y, int x) /*[clinic end generated code: output=ce546c93e56867da input=60a0e7912ff99849]*/ { - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); - return PyCursesCheckERR(st, move_panel(self->pan, y, x), "move_panel"); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(state, move_panel(self->pan, y, x), "move_panel"); } /*[clinic input] @@ -412,7 +417,8 @@ _curses_panel_panel_replace_impl(PyCursesPanelObject *self, PyCursesWindowObject *win) /*[clinic end generated code: output=c71f95c212d58ae7 input=dbec7180ece41ff5]*/ { - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); PyCursesPanelObject *po = find_po(self->pan); if (po == NULL) { @@ -423,7 +429,7 @@ _curses_panel_panel_replace_impl(PyCursesPanelObject *self, int rtn = replace_panel(self->pan, win->win); if (rtn == ERR) { - PyErr_SetString(st->PyCursesError, "replace_panel() returned ERR"); + PyErr_SetString(state->PyCursesError, "replace_panel() returned ERR"); return NULL; } Py_INCREF(win); @@ -456,8 +462,9 @@ _curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, } Py_XDECREF(oldobj); - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); - return PyCursesCheckERR(st, rc, "set_panel_userptr"); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); + return PyCursesCheckERR(state, rc, "set_panel_userptr"); } /*[clinic input] @@ -473,12 +480,13 @@ _curses_panel_panel_userptr_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=eea6e6f39ffc0179 input=f22ca4f115e30a80]*/ { - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); PyCursesInitialised; PyObject *obj = (PyObject *) panel_userptr(self->pan); if (obj == NULL) { - PyErr_SetString(st->PyCursesError, "no userptr set"); + PyErr_SetString(state->PyCursesError, "no userptr set"); return NULL; } @@ -571,11 +579,12 @@ _curses_panel_new_panel_impl(PyObject *module, PyTypeObject *cls, PyCursesWindowObject *win) /*[clinic end generated code: output=367de29657788b50 input=5814b695dc719da1]*/ { - _curses_panelstate *st = (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = + (_curses_panelstate *)PyType_GetModuleState(cls); PANEL *pan = new_panel(win->win); if (pan == NULL) { - PyErr_SetString(st->PyCursesError, catchall_NULL); + PyErr_SetString(state->PyCursesError, catchall_NULL); return NULL; } return (PyObject *)PyCursesPanel_New(module, pan, win); @@ -648,14 +657,15 @@ static PyMethodDef PyCurses_methods[] = { static int _curses_exec(PyObject *m) { - _curses_panel_state *st = get_curses_panelstate(m); + _curses_panel_state *state = get_curses_panelstate(m); /* Initialize object type */ - st->PyCursesPanel_Type = PyType_FromModuleAndSpec(m, &PyCursesPanel_Type_spec, NULL); - if (st->PyCursesPanel_Type == NULL) { + state->PyCursesPanel_Type = PyType_FromModuleAndSpec( + m, &PyCursesPanel_Type_spec, NULL); + if (state->PyCursesPanel_Type == NULL) { return -1; } - if (PyModule_AddType(m, st->PyCursesPanel_Type) < 0) { + if (PyModule_AddType(m, state->PyCursesPanel_Type) < 0) { return -1; } @@ -665,8 +675,9 @@ _curses_exec(PyObject *m) PyObject *d = PyModule_GetDict(m); /* For exception _curses_panel.error */ - st->PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL); - PyDict_SetItemString(d, "error", st->PyCursesError); + state->PyCursesError = PyErr_NewException( + "_curses_panel.error", NULL, NULL); + PyDict_SetItemString(d, "error", state->PyCursesError); /* Make the version available */ PyObject *v = PyUnicode_FromString(PyCursesVersion); From d0a6d8af60608683ec35712c243ade9f67754700 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Thu, 3 Sep 2020 11:08:23 -0500 Subject: [PATCH 06/16] remove unnecessary cast --- Modules/_curses_panel.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 91b54a13932230..53e17a5513a897 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -185,9 +185,7 @@ static PyObject * _curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=8ec7fbbc08554021 input=6b7d2c0578b5a1c4]*/ { - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); - + _curses_panelstate *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, bottom_panel(self->pan), "bottom"); } @@ -205,8 +203,7 @@ static PyObject * _curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=cc6ab7203cdc1450 input=1bfc741f473e6055]*/ { - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, hide_panel(self->pan), "hide"); } @@ -222,8 +219,7 @@ static PyObject * _curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=dc3421de375f0409 input=8122e80151cb4379]*/ { - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, show_panel(self->pan), "show"); } @@ -239,8 +235,7 @@ static PyObject * _curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=10a072e511e873f7 input=1f372d597dda3379]*/ { - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, top_panel(self->pan), "top"); } @@ -382,8 +377,7 @@ _curses_panel_panel_move_impl(PyCursesPanelObject *self, PyTypeObject *cls, int y, int x) /*[clinic end generated code: output=ce546c93e56867da input=60a0e7912ff99849]*/ { - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, move_panel(self->pan, y, x), "move_panel"); } @@ -417,8 +411,7 @@ _curses_panel_panel_replace_impl(PyCursesPanelObject *self, PyCursesWindowObject *win) /*[clinic end generated code: output=c71f95c212d58ae7 input=dbec7180ece41ff5]*/ { - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = PyType_GetModuleState(cls); PyCursesPanelObject *po = find_po(self->pan); if (po == NULL) { @@ -462,8 +455,7 @@ _curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, } Py_XDECREF(oldobj); - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, rc, "set_panel_userptr"); } @@ -480,8 +472,7 @@ _curses_panel_panel_userptr_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=eea6e6f39ffc0179 input=f22ca4f115e30a80]*/ { - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = PyType_GetModuleState(cls); PyCursesInitialised; PyObject *obj = (PyObject *) panel_userptr(self->pan); @@ -579,8 +570,7 @@ _curses_panel_new_panel_impl(PyObject *module, PyTypeObject *cls, PyCursesWindowObject *win) /*[clinic end generated code: output=367de29657788b50 input=5814b695dc719da1]*/ { - _curses_panelstate *state = - (_curses_panelstate *)PyType_GetModuleState(cls); + _curses_panelstate *state = PyType_GetModuleState(cls); PANEL *pan = new_panel(win->win); if (pan == NULL) { From 50751c2b5d52de0823cdd97b1547c13be12ed6fe Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Thu, 3 Sep 2020 11:08:57 -0500 Subject: [PATCH 07/16] fix compiler warning --- Modules/_curses_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 53e17a5513a897..500a43a5c0068a 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -247,7 +247,7 @@ PyCursesPanel_New(PyObject *module, PANEL *pan, PyCursesWindowObject *wo) _curses_panelstate *state = get_curses_panelstate(module); PyCursesPanelObject *po = PyObject_New(PyCursesPanelObject, - (PyTypeObject *)(state->PyCursesPanel_Type); + (PyTypeObject *)(state->PyCursesPanel_Type)); if (po == NULL) { return NULL; } From 174c64e292073afd233d1cd44dc76b4ece7c152c Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Fri, 4 Sep 2020 20:28:34 -0500 Subject: [PATCH 08/16] fix --- Modules/_curses_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 500a43a5c0068a..8899fe43e2c52a 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -276,7 +276,7 @@ PyCursesPanel_Dealloc(PyCursesPanelObject *po) } (void)del_panel(po->pan); if (po->wo != NULL) { - Py_DECREF(po->wo);_curses_panelstate + Py_DECREF(po->wo); remove_lop(po); } PyObject_DEL(po); From 8d1a79031ec77cba10d51f4a40bb1674689e131d Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Sun, 6 Sep 2020 16:45:32 -0500 Subject: [PATCH 09/16] fix build error --- Modules/_curses_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 8899fe43e2c52a..60aea1fe529b3b 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -647,7 +647,7 @@ static PyMethodDef PyCurses_methods[] = { static int _curses_exec(PyObject *m) { - _curses_panel_state *state = get_curses_panelstate(m); + _curses_panelstate *state = get_curses_panelstate(m); /* Initialize object type */ state->PyCursesPanel_Type = PyType_FromModuleAndSpec( m, &PyCursesPanel_Type_spec, NULL); From 34e43749d0ad59ffb1e14dd0b628b7f15a0e8397 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Sun, 6 Sep 2020 20:25:08 -0500 Subject: [PATCH 10/16] fix warning --- Modules/_curses_panel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 60aea1fe529b3b..56ad6f39e221fc 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -18,7 +18,7 @@ static const char PyCursesVersion[] = "2.1"; typedef struct { PyObject *PyCursesError; - PyObject *PyCursesPanel_Type; + PyTypeObject *PyCursesPanel_Type; } _curses_panelstate; static inline _curses_panelstate* @@ -247,7 +247,7 @@ PyCursesPanel_New(PyObject *module, PANEL *pan, PyCursesWindowObject *wo) _curses_panelstate *state = get_curses_panelstate(module); PyCursesPanelObject *po = PyObject_New(PyCursesPanelObject, - (PyTypeObject *)(state->PyCursesPanel_Type)); + state->PyCursesPanel_Type); if (po == NULL) { return NULL; } From f9b5d9fe71a55e18992b49fddfbd51c8a4c87198 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Sun, 6 Sep 2020 21:55:10 -0500 Subject: [PATCH 11/16] fix compiler warning --- Modules/_curses_panel.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 56ad6f39e221fc..91a99e73d6fc9a 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -513,11 +513,10 @@ static PyType_Slot PyCursesPanel_Type_slots[] = { }; static PyType_Spec PyCursesPanel_Type_spec = { - "_curses_panel.panel", - sizeof(PyCursesPanelObject), - 0, - Py_TPFLAGS_DEFAULT, - PyCursesPanel_Type_slots + .name = "_curses_panel.panel", + .basicsize = sizeof(PyCursesPanelObject), + .flags = Py_TPFLAGS_DEFAULT, + .slots = PyCursesPanel_Type_slots }; /* Wrapper for panel_above(NULL). This function returns the bottom @@ -649,7 +648,7 @@ _curses_exec(PyObject *m) { _curses_panelstate *state = get_curses_panelstate(m); /* Initialize object type */ - state->PyCursesPanel_Type = PyType_FromModuleAndSpec( + state->PyCursesPanel_Type = (PyTypeObject *)PyType_FromModuleAndSpec( m, &PyCursesPanel_Type_spec, NULL); if (state->PyCursesPanel_Type == NULL) { return -1; From f4274ed059493f83e9355d3a5dab6837093ba465 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Sun, 6 Sep 2020 22:06:35 -0500 Subject: [PATCH 12/16] fix issue --- Modules/_curses_panel.c | 8 +++----- Modules/clinic/_curses_panel.c.h | 18 ++++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 91a99e73d6fc9a..b59be2199479d2 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -557,7 +557,6 @@ _curses_panel_bottom_panel_impl(PyObject *module) /*[clinic input] _curses_panel.new_panel - cls: defining_class win: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") / @@ -565,11 +564,10 @@ Return a panel object, associating it with the given window win. [clinic start generated code]*/ static PyObject * -_curses_panel_new_panel_impl(PyObject *module, PyTypeObject *cls, - PyCursesWindowObject *win) -/*[clinic end generated code: output=367de29657788b50 input=5814b695dc719da1]*/ +_curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win) +/*[clinic end generated code: output=45e948e0176a9bd2 input=74d4754e0ebe4800]*/ { - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panelstate *state = get_curses_panelstate(module); PANEL *pan = new_panel(win->win); if (pan == NULL) { diff --git a/Modules/clinic/_curses_panel.c.h b/Modules/clinic/_curses_panel.c.h index 0e13b87db29266..45898070b1f543 100644 --- a/Modules/clinic/_curses_panel.c.h +++ b/Modules/clinic/_curses_panel.c.h @@ -342,25 +342,23 @@ PyDoc_STRVAR(_curses_panel_new_panel__doc__, "Return a panel object, associating it with the given window win."); #define _CURSES_PANEL_NEW_PANEL_METHODDEF \ - {"new_panel", (PyCFunction)(void(*)(void))_curses_panel_new_panel, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _curses_panel_new_panel__doc__}, + {"new_panel", (PyCFunction)_curses_panel_new_panel, METH_O, _curses_panel_new_panel__doc__}, static PyObject * -_curses_panel_new_panel_impl(PyObject *module, PyTypeObject *cls, - PyCursesWindowObject *win); +_curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win); static PyObject * -_curses_panel_new_panel(PyObject *module, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +_curses_panel_new_panel(PyObject *module, PyObject *arg) { PyObject *return_value = NULL; - static const char * const _keywords[] = {"", NULL}; - static _PyArg_Parser _parser = {"O!:new_panel", _keywords, 0}; PyCursesWindowObject *win; - if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, - &PyCursesWindow_Type, &win)) { + if (!PyObject_TypeCheck(arg, &PyCursesWindow_Type)) { + _PyArg_BadArgument("new_panel", "argument", (&PyCursesWindow_Type)->tp_name, arg); goto exit; } - return_value = _curses_panel_new_panel_impl(module, cls, win); + win = (PyCursesWindowObject *)arg; + return_value = _curses_panel_new_panel_impl(module, win); exit: return return_value; @@ -403,4 +401,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _curses_panel_update_panels_impl(module); } -/*[clinic end generated code: output=17020aadebbac145 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3081ef24e5560cb0 input=a9049054013a1b77]*/ From 1213b3545bebb17e78b8ebaf4322280e768e2d88 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Mon, 7 Sep 2020 07:33:17 -0500 Subject: [PATCH 13/16] update --- Modules/_curses_panel.c | 62 +++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index b59be2199479d2..eb56bfd88294e0 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -21,7 +21,7 @@ typedef struct { PyTypeObject *PyCursesPanel_Type; } _curses_panelstate; -static inline _curses_panelstate* +static inline _curses_panelstate * get_curses_panelstate(PyObject *module) { void *state = PyModule_GetState(module); @@ -30,24 +30,28 @@ get_curses_panelstate(PyObject *module) } static int -_curses_panel_clear(PyObject *m) +_curses_panel_clear(PyObject *mod) { - Py_CLEAR(get_curses_panelstate(m)->PyCursesError); + _curses_panelstate *state = get_curses_panelstate(mod); + Py_CLEAR(state->PyCursesError); + Py_CLEAR(state->PyCursesPanel_Type); return 0; } static int -_curses_panel_traverse(PyObject *m, visitproc visit, void *arg) +_curses_panel_traverse(PyObject *mod, visitproc visit, void *arg) { - Py_VISIT(Py_TYPE(m)); - Py_VISIT(get_curses_panelstate(m)->PyCursesError); + Py_VISIT(Py_TYPE(mod)); + _curses_panelstate *state = get_curses_panelstate(mod); + Py_VISIT(state->PyCursesError); + Py_VISIT(state->PyCursesPanel_Type); return 0; } static void -_curses_panel_free(void *m) +_curses_panel_free(void *mod) { - _curses_panel_clear((PyObject *) m); + _curses_panel_clear((PyObject *) mod); } /* Utility Functions */ @@ -242,10 +246,9 @@ _curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls) /* Allocation and deallocation of Panel Objects */ static PyObject * -PyCursesPanel_New(PyObject *module, PANEL *pan, PyCursesWindowObject *wo) +PyCursesPanel_New(_curses_panelstate *state, PANEL *pan, + PyCursesWindowObject *wo) { - _curses_panelstate *state = get_curses_panelstate(module); - PyCursesPanelObject *po = PyObject_New(PyCursesPanelObject, state->PyCursesPanel_Type); if (po == NULL) { @@ -574,7 +577,7 @@ _curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win) PyErr_SetString(state->PyCursesError, catchall_NULL); return NULL; } - return (PyObject *)PyCursesPanel_New(module, pan, win); + return (PyObject *)PyCursesPanel_New(state, pan, win); } @@ -642,34 +645,51 @@ static PyMethodDef PyCurses_methods[] = { /* Initialization function for the module */ static int -_curses_exec(PyObject *m) +_curses_exec(PyObject *mod) { - _curses_panelstate *state = get_curses_panelstate(m); + _curses_panelstate *state = get_curses_panelstate(mod); /* Initialize object type */ state->PyCursesPanel_Type = (PyTypeObject *)PyType_FromModuleAndSpec( - m, &PyCursesPanel_Type_spec, NULL); + mod, &PyCursesPanel_Type_spec, NULL); if (state->PyCursesPanel_Type == NULL) { return -1; } - if (PyModule_AddType(m, state->PyCursesPanel_Type) < 0) { + if (PyModule_AddType(mod, state->PyCursesPanel_Type) < 0) { return -1; } import_curses(); - if (PyErr_Occurred()) + if (PyErr_Occurred()) { return -1; + } - PyObject *d = PyModule_GetDict(m); /* For exception _curses_panel.error */ state->PyCursesError = PyErr_NewException( "_curses_panel.error", NULL, NULL); - PyDict_SetItemString(d, "error", state->PyCursesError); + + Py_INCREF(state->PyCursesError) + if (PyModule_AddObject(mod, "error", state->PyCursesError) < 0) { + Py_DECREF(state->PyCursesError); + return -1; + } /* Make the version available */ PyObject *v = PyUnicode_FromString(PyCursesVersion); - PyDict_SetItemString(d, "version", v); - PyDict_SetItemString(d, "__version__", v); + if (v == null) { + return -1; + } + + PyObject *d = PyModule_GetDict(mod); + if (PyDict_SetItemString(d, "version", v) < 0) { + Py_DECREF(v); + return -1; + } + if (PyDict_SetItemString(d, "__version__", v) < 0) { + Py_DECREF(v); + return -1; + } + Py_DECREF(v); return 0; From ea0136d06a4df7bf8f11379c313b63a991ff31a5 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Mon, 7 Sep 2020 08:25:22 -0500 Subject: [PATCH 14/16] fix compile error --- Modules/_curses_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index eb56bfd88294e0..6dcf424e6191e8 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -668,7 +668,7 @@ _curses_exec(PyObject *mod) state->PyCursesError = PyErr_NewException( "_curses_panel.error", NULL, NULL); - Py_INCREF(state->PyCursesError) + Py_INCREF(state->PyCursesError); if (PyModule_AddObject(mod, "error", state->PyCursesError) < 0) { Py_DECREF(state->PyCursesError); return -1; From 141c299322f505042d9e9b4b137356fe5988cb47 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Mon, 7 Sep 2020 08:58:03 -0500 Subject: [PATCH 15/16] fix --- Modules/_curses_panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 6dcf424e6191e8..8c72361981069d 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -676,7 +676,7 @@ _curses_exec(PyObject *mod) /* Make the version available */ PyObject *v = PyUnicode_FromString(PyCursesVersion); - if (v == null) { + if (v == NULL) { return -1; } From 4a9bf9304b8d25c16db749cfe6d8ce3604622a94 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Mon, 7 Sep 2020 09:47:59 -0500 Subject: [PATCH 16/16] rename --- Modules/_curses_panel.c | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 8c72361981069d..1a8f0b636821ff 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -19,20 +19,20 @@ static const char PyCursesVersion[] = "2.1"; typedef struct { PyObject *PyCursesError; PyTypeObject *PyCursesPanel_Type; -} _curses_panelstate; +} _curses_panel_state; -static inline _curses_panelstate * -get_curses_panelstate(PyObject *module) +static inline _curses_panel_state * +get_curses_panel_state(PyObject *module) { void *state = PyModule_GetState(module); assert(state != NULL); - return (_curses_panelstate *)state; + return (_curses_panel_state *)state; } static int _curses_panel_clear(PyObject *mod) { - _curses_panelstate *state = get_curses_panelstate(mod); + _curses_panel_state *state = get_curses_panel_state(mod); Py_CLEAR(state->PyCursesError); Py_CLEAR(state->PyCursesPanel_Type); return 0; @@ -42,7 +42,7 @@ static int _curses_panel_traverse(PyObject *mod, visitproc visit, void *arg) { Py_VISIT(Py_TYPE(mod)); - _curses_panelstate *state = get_curses_panelstate(mod); + _curses_panel_state *state = get_curses_panel_state(mod); Py_VISIT(state->PyCursesError); Py_VISIT(state->PyCursesPanel_Type); return 0; @@ -62,7 +62,7 @@ _curses_panel_free(void *mod) */ static PyObject * -PyCursesCheckERR(_curses_panelstate *state, int code, const char *fname) +PyCursesCheckERR(_curses_panel_state *state, int code, const char *fname) { if (code != ERR) { Py_RETURN_NONE; @@ -189,7 +189,7 @@ static PyObject * _curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=8ec7fbbc08554021 input=6b7d2c0578b5a1c4]*/ { - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panel_state *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, bottom_panel(self->pan), "bottom"); } @@ -207,7 +207,7 @@ static PyObject * _curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=cc6ab7203cdc1450 input=1bfc741f473e6055]*/ { - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panel_state *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, hide_panel(self->pan), "hide"); } @@ -223,7 +223,7 @@ static PyObject * _curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=dc3421de375f0409 input=8122e80151cb4379]*/ { - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panel_state *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, show_panel(self->pan), "show"); } @@ -239,14 +239,14 @@ static PyObject * _curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=10a072e511e873f7 input=1f372d597dda3379]*/ { - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panel_state *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, top_panel(self->pan), "top"); } /* Allocation and deallocation of Panel Objects */ static PyObject * -PyCursesPanel_New(_curses_panelstate *state, PANEL *pan, +PyCursesPanel_New(_curses_panel_state *state, PANEL *pan, PyCursesWindowObject *wo) { PyCursesPanelObject *po = PyObject_New(PyCursesPanelObject, @@ -380,7 +380,7 @@ _curses_panel_panel_move_impl(PyCursesPanelObject *self, PyTypeObject *cls, int y, int x) /*[clinic end generated code: output=ce546c93e56867da input=60a0e7912ff99849]*/ { - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panel_state *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, move_panel(self->pan, y, x), "move_panel"); } @@ -414,7 +414,7 @@ _curses_panel_panel_replace_impl(PyCursesPanelObject *self, PyCursesWindowObject *win) /*[clinic end generated code: output=c71f95c212d58ae7 input=dbec7180ece41ff5]*/ { - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panel_state *state = PyType_GetModuleState(cls); PyCursesPanelObject *po = find_po(self->pan); if (po == NULL) { @@ -458,7 +458,7 @@ _curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, } Py_XDECREF(oldobj); - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panel_state *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, rc, "set_panel_userptr"); } @@ -475,7 +475,7 @@ _curses_panel_panel_userptr_impl(PyCursesPanelObject *self, PyTypeObject *cls) /*[clinic end generated code: output=eea6e6f39ffc0179 input=f22ca4f115e30a80]*/ { - _curses_panelstate *state = PyType_GetModuleState(cls); + _curses_panel_state *state = PyType_GetModuleState(cls); PyCursesInitialised; PyObject *obj = (PyObject *) panel_userptr(self->pan); @@ -570,7 +570,7 @@ static PyObject * _curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win) /*[clinic end generated code: output=45e948e0176a9bd2 input=74d4754e0ebe4800]*/ { - _curses_panelstate *state = get_curses_panelstate(module); + _curses_panel_state *state = get_curses_panel_state(module); PANEL *pan = new_panel(win->win); if (pan == NULL) { @@ -645,9 +645,9 @@ static PyMethodDef PyCurses_methods[] = { /* Initialization function for the module */ static int -_curses_exec(PyObject *mod) +_curses_panel_exec(PyObject *mod) { - _curses_panelstate *state = get_curses_panelstate(mod); + _curses_panel_state *state = get_curses_panel_state(mod); /* Initialize object type */ state->PyCursesPanel_Type = (PyTypeObject *)PyType_FromModuleAndSpec( mod, &PyCursesPanel_Type_spec, NULL); @@ -696,14 +696,14 @@ _curses_exec(PyObject *mod) } static PyModuleDef_Slot _curses_slots[] = { - {Py_mod_exec, _curses_exec}, + {Py_mod_exec, _curses_panel_exec}, {0, NULL} }; static struct PyModuleDef _curses_panelmodule = { PyModuleDef_HEAD_INIT, .m_name = "_curses_panel", - .m_size = sizeof(_curses_panelstate), + .m_size = sizeof(_curses_panel_state), .m_methods = PyCurses_methods, .m_slots = _curses_slots, .m_traverse = _curses_panel_traverse,