]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.10/Include/py_curses.h
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Include / py_curses.h
CommitLineData
c8042e10
DM
1\r
2#ifndef Py_CURSES_H\r
3#define Py_CURSES_H\r
4\r
5#ifdef __APPLE__\r
6/*\r
7** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards\r
8** against multiple definition of wchar_t.\r
9*/\r
10#ifdef _BSD_WCHAR_T_DEFINED_\r
11#define _WCHAR_T\r
12#endif\r
13\r
14/* the following define is necessary for OS X 10.6; without it, the\r
15 Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python\r
16 can't get at the WINDOW flags field. */\r
17#define NCURSES_OPAQUE 0\r
18#endif /* __APPLE__ */\r
19\r
20#ifdef __FreeBSD__\r
21/*\r
22** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards\r
23** against multiple definition of wchar_t and wint_t.\r
24*/\r
25#ifdef _XOPEN_SOURCE_EXTENDED\r
26#ifndef __FreeBSD_version\r
27#include <osreldate.h>\r
28#endif\r
29#if __FreeBSD_version >= 500000\r
30#ifndef __wchar_t\r
31#define __wchar_t\r
32#endif\r
33#ifndef __wint_t\r
34#define __wint_t\r
35#endif\r
36#else\r
37#ifndef _WCHAR_T\r
38#define _WCHAR_T\r
39#endif\r
40#ifndef _WINT_T\r
41#define _WINT_T\r
42#endif\r
43#endif\r
44#endif\r
45#endif\r
46\r
47#ifdef HAVE_NCURSES_H\r
48#include <ncurses.h>\r
49#else\r
50#include <curses.h>\r
51#ifdef HAVE_TERM_H\r
52/* for tigetstr, which is not declared in SysV curses */\r
53#include <term.h>\r
54#endif\r
55#endif\r
56\r
57#ifdef HAVE_NCURSES_H\r
58/* configure was checking <curses.h>, but we will\r
59 use <ncurses.h>, which has all these features. */\r
60#ifndef WINDOW_HAS_FLAGS\r
61#define WINDOW_HAS_FLAGS 1\r
62#endif\r
63#ifndef MVWDELCH_IS_EXPRESSION\r
64#define MVWDELCH_IS_EXPRESSION 1\r
65#endif\r
66#endif\r
67\r
68#ifdef __cplusplus\r
69extern "C" {\r
70#endif\r
71\r
72#define PyCurses_API_pointers 4\r
73\r
74/* Type declarations */\r
75\r
76typedef struct {\r
77 PyObject_HEAD\r
78 WINDOW *win;\r
79} PyCursesWindowObject;\r
80\r
81#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type)\r
82\r
83#define PyCurses_CAPSULE_NAME "_curses._C_API"\r
84\r
85\r
86#ifdef CURSES_MODULE\r
87/* This section is used when compiling _cursesmodule.c */\r
88\r
89#else\r
90/* This section is used in modules that use the _cursesmodule API */\r
91\r
92static void **PyCurses_API;\r
93\r
94#define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0])\r
95#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;}\r
96#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;}\r
97#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}\r
98\r
99#define import_curses() \\r
100 PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1);\r
101\r
102#endif\r
103\r
104/* general error messages */\r
105static char *catchall_ERR = "curses function returned ERR";\r
106static char *catchall_NULL = "curses function returned NULL";\r
107\r
108/* Function Prototype Macros - They are ugly but very, very useful. ;-)\r
109\r
110 X - function name\r
111 TYPE - parameter Type\r
112 ERGSTR - format string for construction of the return value\r
113 PARSESTR - format string for argument parsing\r
114 */\r
115\r
116#define NoArgNoReturnFunction(X) \\r
117static PyObject *PyCurses_ ## X (PyObject *self) \\r
118{ \\r
119 PyCursesInitialised \\r
120 return PyCursesCheckERR(X(), # X); }\r
121\r
122#define NoArgOrFlagNoReturnFunction(X) \\r
123static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \\r
124{ \\r
125 int flag = 0; \\r
126 PyCursesInitialised \\r
127 switch(PyTuple_Size(args)) { \\r
128 case 0: \\r
129 return PyCursesCheckERR(X(), # X); \\r
130 case 1: \\r
131 if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \\r
132 if (flag) return PyCursesCheckERR(X(), # X); \\r
133 else return PyCursesCheckERR(no ## X (), # X); \\r
134 default: \\r
135 PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \\r
136 return NULL; } }\r
137\r
138#define NoArgReturnIntFunction(X) \\r
139static PyObject *PyCurses_ ## X (PyObject *self) \\r
140{ \\r
141 PyCursesInitialised \\r
142 return PyInt_FromLong((long) X()); }\r
143\r
144\r
145#define NoArgReturnStringFunction(X) \\r
146static PyObject *PyCurses_ ## X (PyObject *self) \\r
147{ \\r
148 PyCursesInitialised \\r
149 return PyString_FromString(X()); }\r
150\r
151#define NoArgTrueFalseFunction(X) \\r
152static PyObject *PyCurses_ ## X (PyObject *self) \\r
153{ \\r
154 PyCursesInitialised \\r
155 if (X () == FALSE) { \\r
156 Py_INCREF(Py_False); \\r
157 return Py_False; \\r
158 } \\r
159 Py_INCREF(Py_True); \\r
160 return Py_True; }\r
161\r
162#define NoArgNoReturnVoidFunction(X) \\r
163static PyObject *PyCurses_ ## X (PyObject *self) \\r
164{ \\r
165 PyCursesInitialised \\r
166 X(); \\r
167 Py_INCREF(Py_None); \\r
168 return Py_None; }\r
169\r
170#ifdef __cplusplus\r
171}\r
172#endif\r
173\r
174#endif /* !defined(Py_CURSES_H) */\r
175\r
176\r