Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
32552687
Kaydet (Commit)
32552687
authored
Ara 22, 2000
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Export C API from this module.
Remove several macros and #includes; py_curses.h contains them now.
üst
0c7a0bdf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
99 deletions
+47
-99
_cursesmodule.c
Modules/_cursesmodule.c
+47
-99
No files found.
Modules/_cursesmodule.c
Dosyayı görüntüle @
32552687
...
...
@@ -95,23 +95,19 @@ Form extension (ncurses and probably SYSV):
/* Release Number */
char
*
PyCursesVersion
=
"
1.6
"
;
char
*
PyCursesVersion
=
"
2.1
"
;
/* Includes */
#include "Python.h"
#define CURSES_MODULE
#include "py_curses.h"
#ifdef __osf__
#define _XOPEN_SOURCE_EXTENDED
/* Define macro for OSF/1 */
#define STRICT_SYSV_CURSES
/* Don't use ncurses extensions */
#endif
#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#endif
/* These prototypes are in <term.h>, but including this header
#defines many common symbols (such as "lines") which breaks the
curses module in other ways. So the code will just specify
...
...
@@ -130,46 +126,40 @@ typedef chtype attr_t; /* No attr_t type is available */
static
PyObject
*
PyCursesError
;
/* general error messages */
static
char
*
catchall_ERR
=
"curses function returned ERR"
;
static
char
*
catchall_NULL
=
"curses function returned NULL"
;
/* Tells whether setupterm() has been called to initialise terminfo. */
static
int
initialised_setupterm
=
FALSE
;
/* Tells whether initscr() has been called to initialise curses. */
static
int
initialised
=
FALSE
;
/* Tells whether start_color() has been called to initialise colorusage. */
/* Tells whether start_color() has been called to initialise color
usage. */
static
int
initialisedcolors
=
FALSE
;
/* Utility Macros */
#define ARG_COUNT(X) \
(((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1))
#define PyCursesSetupTermCalled \
if (initialised_setupterm != TRUE) { \
PyErr_SetString(PyCursesError, \
"must call (at least) setupterm() first"); \
return
NULL
; }
return
0
; }
#define PyCursesInitialised \
if (initialised != TRUE) { \
PyErr_SetString(PyCursesError, \
"must call initscr() first"); \
return
NULL
; }
return
0
; }
#define PyCursesInitialisedColor \
if (initialisedcolors != TRUE) { \
PyErr_SetString(PyCursesError, \
"must call start_color() first"); \
return
NULL
; }
return
0
; }
/* Utility Functions */
/*
* Check the return code from a curses function and return None
* or raise an exception as appropriate.
* or raise an exception as appropriate. These are exported using the
* CObject API.
*/
static
PyObject
*
...
...
@@ -202,22 +192,36 @@ PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
return
1
;
}
/* Function versions of the 3 functions for tested whether curses has been
initialised or not. */
static
int
func_PyCursesSetupTermCalled
(
void
)
{
PyCursesSetupTermCalled
;
return
1
;
}
static
int
func_PyCursesInitialised
(
void
)
{
PyCursesInitialised
;
return
1
;
}
static
int
func_PyCursesInitialisedColor
(
void
)
{
PyCursesInitialisedColor
;
return
1
;
}
/*****************************************************************************
The Window Object
******************************************************************************/
/* Definition of the window object and window type */
typedef
struct
{
PyObject_HEAD
WINDOW
*
win
;
}
PyCursesWindowObject
;
/* Definition of the window type */
PyTypeObject
PyCursesWindow_Type
;
#define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type)
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
/* Function prototype macros for Window object
X - function name
TYPE - parameter Type
...
...
@@ -1458,75 +1462,6 @@ PyTypeObject PyCursesWindow_Type = {
Global Functions
**********************************************************************/
static
PyObject
*
ModDict
;
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
X - function name
TYPE - parameter Type
ERGSTR - format string for construction of the return value
PARSESTR - format string for argument parsing
*/
#define NoArgNoReturnFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
return PyCursesCheckERR(X(), # X); }
#define NoArgOrFlagNoReturnFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
{ \
int flag = 0; \
PyCursesInitialised \
switch(ARG_COUNT(args)) { \
case 0: \
return PyCursesCheckERR(X(), # X); \
case 1: \
if (!PyArg_Parse(args, "i;True(1) or False(0)", &flag)) return NULL; \
if (flag) return PyCursesCheckERR(X(), # X); \
else return PyCursesCheckERR(no ## X (), # X); \
default: \
PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \
return NULL; } }
#define NoArgReturnIntFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
return PyInt_FromLong((long) X()); }
#define NoArgReturnStringFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
return PyString_FromString(X()); }
#define NoArgTrueFalseFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
if (X () == FALSE) { \
Py_INCREF(Py_False); \
return Py_False; \
} \
Py_INCREF(Py_True); \
return Py_True; }
#define NoArgNoReturnVoidFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(args)) return NULL; \
X(); \
Py_INCREF(Py_None); \
return Py_None; }
NoArgNoReturnFunction
(
beep
)
NoArgNoReturnFunction
(
def_prog_mode
)
NoArgNoReturnFunction
(
def_shell_mode
)
...
...
@@ -1805,6 +1740,8 @@ PyCurses_Init_Pair(PyObject *self, PyObject *args)
return
PyCursesCheckERR
(
init_pair
(
pair
,
f
,
b
),
"init_pair"
);
}
static
PyObject
*
ModDict
;
static
PyObject
*
PyCurses_InitScr
(
PyObject
*
self
,
PyObject
*
args
)
{
...
...
@@ -2497,14 +2434,25 @@ static PyMethodDef PyCurses_methods[] = {
void
init_curses
(
void
)
{
PyObject
*
m
,
*
d
,
*
v
;
PyObject
*
m
,
*
d
,
*
v
,
*
c_api_object
;
static
void
*
PyCurses_API
[
PyCurses_API_pointers
];
/* Initialize the C API pointer array */
PyCurses_API
[
0
]
=
(
void
*
)
&
PyCursesWindow_Type
;
PyCurses_API
[
1
]
=
(
void
*
)
func_PyCursesSetupTermCalled
;
PyCurses_API
[
2
]
=
(
void
*
)
func_PyCursesInitialised
;
PyCurses_API
[
3
]
=
(
void
*
)
func_PyCursesInitialisedColor
;
/* Create the module and add the functions */
m
=
Py_InitModule
(
"_curses"
,
PyCurses_methods
);
/* Add some symbolic constants to the module */
d
=
PyModule_GetDict
(
m
);
ModDict
=
d
;
/* For PyCurses_InitScr */
ModDict
=
d
;
/* For PyCurses_InitScr to use later */
/* Add a CObject for the C API */
c_api_object
=
PyCObject_FromVoidPtr
((
void
*
)
PyCurses_API
,
NULL
);
PyDict_SetItemString
(
d
,
"_C_API"
,
c_api_object
);
/* For exception curses.error */
PyCursesError
=
PyErr_NewException
(
"_curses.error"
,
NULL
,
NULL
);
...
...
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