Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c0e1671c
Commit
c0e1671c
authored
Jan 17, 2002
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #477752: Drop old-style getargs from curses.
parent
ac6dd0a8
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
316 additions
and
388 deletions
+316
-388
Include/py_curses.h
Include/py_curses.h
+7
-16
Modules/_curses_panel.c
Modules/_curses_panel.c
+23
-41
Modules/_cursesmodule.c
Modules/_cursesmodule.c
+286
-331
No files found.
Include/py_curses.h
View file @
c0e1671c
...
...
@@ -68,10 +68,6 @@ static void **PyCurses_API;
static
char
*
catchall_ERR
=
"curses function returned ERR"
;
static
char
*
catchall_NULL
=
"curses function returned NULL"
;
/* Utility macros */
#define ARG_COUNT(X) \
(((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1))
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
X - function name
...
...
@@ -81,10 +77,9 @@ static char *catchall_NULL = "curses function returned NULL";
*/
#define NoArgNoReturnFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self
, PyObject *args
) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
return PyCursesCheckERR(X(), # X); }
#define NoArgOrFlagNoReturnFunction(X) \
...
...
@@ -92,11 +87,11 @@ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
{ \
int flag = 0; \
PyCursesInitialised \
switch(
ARG_COUNT
(args)) { \
switch(
PyTuple_Size
(args)) { \
case 0: \
return PyCursesCheckERR(X(), # X); \
case 1: \
if (!PyArg_Parse(args, "i;True(1) or False(0)", &flag)) return NULL; \
if (!PyArg_Parse
Tuple
(args, "i;True(1) or False(0)", &flag)) return NULL; \
if (flag) return PyCursesCheckERR(X(), # X); \
else return PyCursesCheckERR(no ## X (), # X); \
default: \
...
...
@@ -104,25 +99,22 @@ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
return NULL; } }
#define NoArgReturnIntFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self
, PyObject *args
) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
return PyInt_FromLong((long) X()); }
#define NoArgReturnStringFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self
, PyObject *args
) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
return PyString_FromString(X()); }
#define NoArgTrueFalseFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self
, PyObject *args
) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
if (X () == FALSE) { \
Py_INCREF(Py_False); \
return Py_False; \
...
...
@@ -131,10 +123,9 @@ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
return Py_True; }
#define NoArgNoReturnVoidFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self
, PyObject *args
) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
X(); \
Py_INCREF(Py_None); \
return Py_None; }
...
...
Modules/_curses_panel.c
View file @
c0e1671c
...
...
@@ -141,14 +141,12 @@ find_po(PANEL *pan)
PARSESTR - format string for argument parsing */
#define Panel_NoArgNoReturnFunction(X) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \
{ if (!PyArg_NoArgs(args)) return NULL; \
return PyCursesCheckERR(X(self->pan), # X); }
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
{ return PyCursesCheckERR(X(self->pan), # X); }
#define Panel_NoArgTrueFalseFunction(X) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self
, PyObject *args
) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
{ \
if (!PyArg_NoArgs(args)) return NULL; \
if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \
else { Py_INCREF(Py_True); return Py_True; } }
...
...
@@ -156,7 +154,7 @@ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \
{ \
TYPE arg1, arg2; \
if (!PyArg_Parse
(args,
PARSESTR, &arg1, &arg2)) return NULL; \
if (!PyArg_Parse
Tuple(args,
PARSESTR, &arg1, &arg2)) return NULL; \
return PyCursesCheckERR(X(self->pan, arg1, arg2), # X); }
/* ------------- PANEL routines --------------- */
...
...
@@ -166,7 +164,7 @@ Panel_NoArgNoReturnFunction(hide_panel)
Panel_NoArgNoReturnFunction
(
show_panel
)
Panel_NoArgNoReturnFunction
(
top_panel
)
Panel_NoArgTrueFalseFunction
(
panel_hidden
)
Panel_TwoArgNoReturnFunction
(
move_panel
,
int
,
"
(ii)
;y,x"
)
Panel_TwoArgNoReturnFunction
(
move_panel
,
int
,
"
ii
;y,x"
)
/* Allocation and deallocation of Panel Objects */
...
...
@@ -199,13 +197,11 @@ PyCursesPanel_Dealloc(PyCursesPanelObject *po)
/* panel_above(NULL) returns the bottom panel in the stack. To get
this behaviour we use curses.panel.bottom_panel(). */
static
PyObject
*
PyCursesPanel_above
(
PyCursesPanelObject
*
self
,
PyObject
*
args
)
PyCursesPanel_above
(
PyCursesPanelObject
*
self
)
{
PANEL
*
pan
;
PyCursesPanelObject
*
po
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
pan
=
panel_above
(
self
->
pan
);
if
(
pan
==
NULL
)
{
/* valid output, it means the calling panel
...
...
@@ -226,13 +222,11 @@ PyCursesPanel_above(PyCursesPanelObject *self, PyObject *args)
/* panel_below(NULL) returns the top panel in the stack. To get
this behaviour we use curses.panel.top_panel(). */
static
PyObject
*
PyCursesPanel_below
(
PyCursesPanelObject
*
self
,
PyObject
*
args
)
PyCursesPanel_below
(
PyCursesPanelObject
*
self
)
{
PANEL
*
pan
;
PyCursesPanelObject
*
po
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
pan
=
panel_below
(
self
->
pan
);
if
(
pan
==
NULL
)
{
/* valid output, it means the calling panel
...
...
@@ -251,10 +245,8 @@ PyCursesPanel_below(PyCursesPanelObject *self, PyObject *args)
}
static
PyObject
*
PyCursesPanel_window
(
PyCursesPanelObject
*
self
,
PyObject
*
args
)
PyCursesPanel_window
(
PyCursesPanelObject
*
self
)
{
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
Py_INCREF
(
self
->
wo
);
return
(
PyObject
*
)
self
->
wo
;
}
...
...
@@ -266,7 +258,7 @@ PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args)
PyCursesWindowObject
*
temp
;
int
rtn
;
if
(
ARG_COUNT
(
args
)
!=
1
)
{
if
(
PyTuple_Size
(
args
)
!=
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"replace requires one argument"
);
return
NULL
;
}
...
...
@@ -294,27 +286,18 @@ PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args)
}
static
PyObject
*
PyCursesPanel_set_panel_userptr
(
PyCursesPanelObject
*
self
,
PyObject
*
args
)
PyCursesPanel_set_panel_userptr
(
PyCursesPanelObject
*
self
,
PyObject
*
obj
)
{
PyObject
*
obj
;
if
(
ARG_COUNT
(
args
)
!=
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"set_userptr requires one argument"
);
return
NULL
;
}
obj
=
PyTuple_GetItem
(
args
,
0
);
Py_INCREF
(
obj
);
return
PyCursesCheckERR
(
set_panel_userptr
(
self
->
pan
,
(
void
*
)
obj
),
"set_panel_userptr"
);
}
static
PyObject
*
PyCursesPanel_userptr
(
PyCursesPanelObject
*
self
,
PyObject
*
args
)
static
PyObject
*
PyCursesPanel_userptr
(
PyCursesPanelObject
*
self
)
{
PyObject
*
obj
;
PyCursesInitialised
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
obj
=
(
PyObject
*
)
panel_userptr
(
self
->
pan
);
Py_INCREF
(
obj
);
return
obj
;
...
...
@@ -324,20 +307,19 @@ static PyObject *PyCursesPanel_userptr
/* Module interface */
static
PyMethodDef
PyCursesPanel_Methods
[]
=
{
{
"above"
,
(
PyCFunction
)
PyCursesPanel_above
},
{
"below"
,
(
PyCFunction
)
PyCursesPanel_below
},
{
"bottom"
,
(
PyCFunction
)
PyCursesPanel_bottom_panel
},
{
"hidden"
,
(
PyCFunction
)
PyCursesPanel_panel_hidden
},
{
"hide"
,
(
PyCFunction
)
PyCursesPanel_hide_panel
},
{
"move"
,
(
PyCFunction
)
PyCursesPanel_move_panel
},
{
"above"
,
(
PyCFunction
)
PyCursesPanel_above
,
METH_NOARGS
},
{
"below"
,
(
PyCFunction
)
PyCursesPanel_below
,
METH_NOARGS
},
{
"bottom"
,
(
PyCFunction
)
PyCursesPanel_bottom_panel
,
METH_NOARGS
},
{
"hidden"
,
(
PyCFunction
)
PyCursesPanel_panel_hidden
,
METH_NOARGS
},
{
"hide"
,
(
PyCFunction
)
PyCursesPanel_hide_panel
,
METH_NOARGS
},
{
"move"
,
(
PyCFunction
)
PyCursesPanel_move_panel
,
METH_VARARGS
},
{
"replace"
,
(
PyCFunction
)
PyCursesPanel_replace_panel
,
METH_VARARGS
},
{
"set_userptr"
,
(
PyCFunction
)
PyCursesPanel_set_panel_userptr
,
METH_VARARGS
},
{
"show"
,
(
PyCFunction
)
PyCursesPanel_show_panel
},
{
"top"
,
(
PyCFunction
)
PyCursesPanel_top_panel
},
{
"userptr"
,
(
PyCFunction
)
PyCursesPanel_userptr
},
{
"window"
,
(
PyCFunction
)
PyCursesPanel_window
},
{
"set_userptr"
,
(
PyCFunction
)
PyCursesPanel_set_panel_userptr
,
METH_O
},
{
"show"
,
(
PyCFunction
)
PyCursesPanel_show_panel
,
METH_NOARGS
},
{
"top"
,
(
PyCFunction
)
PyCursesPanel_top_panel
,
METH_NOARGS
},
{
"userptr"
,
(
PyCFunction
)
PyCursesPanel_userptr
,
METH_NOARGS
},
{
"window"
,
(
PyCFunction
)
PyCursesPanel_window
,
METH_NOARGS
},
{
NULL
,
NULL
}
/* sentinel */
};
...
...
Modules/_cursesmodule.c
View file @
c0e1671c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment