Issue #14936: curses_panel was converted to PEP 3121 and PEP 384 API.
Patch by Robin Schreiber.
This commit is contained in:
parent
c838ec1f82
commit
bc07cb883e
|
@ -21,7 +21,7 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
- Issue #14936: curses_panel was converted to PEP 3121 API.
|
- Issue #14936: curses_panel was converted to PEP 3121 and PEP 384 API.
|
||||||
Patch by Robin Schreiber.
|
Patch by Robin Schreiber.
|
||||||
|
|
||||||
- Issue #1667546: On platforms supporting tm_zone and tm_gmtoff fields
|
- Issue #1667546: On platforms supporting tm_zone and tm_gmtoff fields
|
||||||
|
|
|
@ -18,12 +18,11 @@ static char *PyCursesVersion = "2.1";
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject *PyCursesError;
|
PyObject *PyCursesError;
|
||||||
|
PyObject *PyCursesPanel_Type;
|
||||||
} _curses_panelstate;
|
} _curses_panelstate;
|
||||||
|
|
||||||
#define _curses_panelstate(o) ((_curses_panelstate *)PyModule_GetState(o))
|
#define _curses_panelstate(o) ((_curses_panelstate *)PyModule_GetState(o))
|
||||||
|
|
||||||
/*static PyObject *PyCursesError;*/
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_curses_panel_clear(PyObject *m)
|
_curses_panel_clear(PyObject *m)
|
||||||
{
|
{
|
||||||
|
@ -84,9 +83,8 @@ typedef struct {
|
||||||
PyCursesWindowObject *wo; /* for reference counts */
|
PyCursesWindowObject *wo; /* for reference counts */
|
||||||
} PyCursesPanelObject;
|
} PyCursesPanelObject;
|
||||||
|
|
||||||
PyTypeObject PyCursesPanel_Type;
|
#define PyCursesPanel_Check(v) \
|
||||||
|
(Py_TYPE(v) == _curses_panelstate_global->PyCursesPanel_Type)
|
||||||
#define PyCursesPanel_Check(v) (Py_TYPE(v) == &PyCursesPanel_Type)
|
|
||||||
|
|
||||||
/* Some helper functions. The problem is that there's always a window
|
/* 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
|
associated with a panel. To ensure that Python's GC doesn't pull
|
||||||
|
@ -205,7 +203,8 @@ PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo)
|
||||||
{
|
{
|
||||||
PyCursesPanelObject *po;
|
PyCursesPanelObject *po;
|
||||||
|
|
||||||
po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type);
|
po = PyObject_NEW(PyCursesPanelObject,
|
||||||
|
(PyTypeObject *)(_curses_panelstate_global)->PyCursesPanel_Type);
|
||||||
if (po == NULL) return NULL;
|
if (po == NULL) return NULL;
|
||||||
po->pan = pan;
|
po->pan = pan;
|
||||||
if (insert_lop(po) < 0) {
|
if (insert_lop(po) < 0) {
|
||||||
|
@ -364,36 +363,18 @@ static PyMethodDef PyCursesPanel_Methods[] = {
|
||||||
|
|
||||||
/* -------------------------------------------------------*/
|
/* -------------------------------------------------------*/
|
||||||
|
|
||||||
PyTypeObject PyCursesPanel_Type = {
|
static PyType_Slot PyCursesPanel_Type_slots[] = {
|
||||||
PyVarObject_HEAD_INIT(NULL, 0)
|
{Py_tp_dealloc, PyCursesPanel_Dealloc},
|
||||||
"_curses_panel.curses panel", /*tp_name*/
|
{Py_tp_methods, PyCursesPanel_Methods},
|
||||||
sizeof(PyCursesPanelObject), /*tp_basicsize*/
|
{0, 0},
|
||||||
0, /*tp_itemsize*/
|
};
|
||||||
/* methods */
|
|
||||||
(destructor)PyCursesPanel_Dealloc, /*tp_dealloc*/
|
static PyType_Spec PyCursesPanel_Type_spec = {
|
||||||
0, /*tp_print*/
|
"_curses_panel.curses panel",
|
||||||
0, /*tp_getattr*/
|
sizeof(PyCursesPanelObject),
|
||||||
0, /*tp_setattr*/
|
0,
|
||||||
0, /*tp_reserved*/
|
Py_TPFLAGS_DEFAULT,
|
||||||
0, /*tp_repr*/
|
PyCursesPanel_Type_slots
|
||||||
0, /*tp_as_number*/
|
|
||||||
0, /*tp_as_sequence*/
|
|
||||||
0, /*tp_as_mapping*/
|
|
||||||
0, /*tp_hash*/
|
|
||||||
0, /*tp_call*/
|
|
||||||
0, /*tp_str*/
|
|
||||||
0, /*tp_getattro*/
|
|
||||||
0, /*tp_setattro*/
|
|
||||||
0, /*tp_as_buffer*/
|
|
||||||
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
|
||||||
0, /*tp_doc*/
|
|
||||||
0, /*tp_traverse*/
|
|
||||||
0, /*tp_clear*/
|
|
||||||
0, /*tp_richcompare*/
|
|
||||||
0, /*tp_weaklistoffset*/
|
|
||||||
0, /*tp_iter*/
|
|
||||||
0, /*tp_iternext*/
|
|
||||||
PyCursesPanel_Methods, /*tp_methods*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Wrapper for panel_above(NULL). This function returns the bottom
|
/* Wrapper for panel_above(NULL). This function returns the bottom
|
||||||
|
@ -510,18 +491,20 @@ PyInit__curses_panel(void)
|
||||||
{
|
{
|
||||||
PyObject *m, *d, *v;
|
PyObject *m, *d, *v;
|
||||||
|
|
||||||
/* Initialize object type */
|
|
||||||
if (PyType_Ready(&PyCursesPanel_Type) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
import_curses();
|
|
||||||
|
|
||||||
/* Create the module and add the functions */
|
/* Create the module and add the functions */
|
||||||
m = PyModule_Create(&_curses_panelmodule);
|
m = PyModule_Create(&_curses_panelmodule);
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return NULL;
|
goto fail;
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
|
/* Initialize object type */
|
||||||
|
_curses_panelstate(m)->PyCursesPanel_Type = \
|
||||||
|
PyType_FromSpec(&PyCursesPanel_Type_spec);
|
||||||
|
if (_curses_panelstate(m)->PyCursesPanel_Type == NULL)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
import_curses();
|
||||||
|
|
||||||
/* For exception _curses_panel.error */
|
/* For exception _curses_panel.error */
|
||||||
_curses_panelstate(m)->PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL);
|
_curses_panelstate(m)->PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", _curses_panelstate(m)->PyCursesError);
|
PyDict_SetItemString(d, "error", _curses_panelstate(m)->PyCursesError);
|
||||||
|
@ -532,4 +515,7 @@ PyInit__curses_panel(void)
|
||||||
PyDict_SetItemString(d, "__version__", v);
|
PyDict_SetItemString(d, "__version__", v);
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
return m;
|
return m;
|
||||||
|
fail:
|
||||||
|
Py_XDECREF(m);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue