AddressList.__str__(): Get rid of useless, and broken method. Closes
[python/dscho.git] / Include / py_curses.h
blob3ecf48fcdff74e8b0a9484a4bdc9443114691f25
2 #ifndef Py_CURSES_H
3 #define Py_CURSES_H
5 #ifdef __APPLE__
6 /*
7 ** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
8 ** against multiple definition of wchar_t.
9 */
10 #ifdef _BSD_WCHAR_T_DEFINED_
11 #define _WCHAR_T
12 #endif
13 #endif
15 #ifdef __FreeBSD__
17 ** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
18 ** against multiple definition of wchar_t and wint_t.
20 #ifdef _XOPEN_SOURCE_EXTENDED
21 #ifndef _WCHAR_T
22 #define _WCHAR_T
23 #endif
24 #ifndef _WINT_T
25 #define _WINT_T
26 #endif
27 #endif
28 #endif
30 #ifdef HAVE_NCURSES_H
31 #include <ncurses.h>
32 #else
33 #include <curses.h>
34 #ifdef HAVE_TERM_H
35 /* for tigetstr, which is not declared in SysV curses */
36 #include <term.h>
37 #endif
38 #endif
40 #ifdef HAVE_NCURSES_H
41 /* configure was checking <curses.h>, but we will
42 use <ncurses.h>, which has all these features. */
43 #ifndef WINDOW_HAS_FLAGS
44 #define WINDOW_HAS_FLAGS 1
45 #endif
46 #ifndef MVWDELCH_IS_EXPRESSION
47 #define MVWDELCH_IS_EXPRESSION 1
48 #endif
49 #endif
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
55 #define PyCurses_API_pointers 4
57 /* Type declarations */
59 typedef struct {
60 PyObject_HEAD
61 WINDOW *win;
62 } PyCursesWindowObject;
64 #define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type)
66 #ifdef CURSES_MODULE
67 /* This section is used when compiling _cursesmodule.c */
69 #else
70 /* This section is used in modules that use the _cursesmodule API */
72 static void **PyCurses_API;
74 #define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0])
75 #define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;}
76 #define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;}
77 #define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}
79 #define import_curses() \
80 { \
81 PyObject *module = PyImport_ImportModule("_curses"); \
82 if (module != NULL) { \
83 PyObject *module_dict = PyModule_GetDict(module); \
84 PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \
85 if (PyCObject_Check(c_api_object)) { \
86 PyCurses_API = (void **)PyCObject_AsVoidPtr(c_api_object); \
87 } \
88 } \
90 #endif
92 /* general error messages */
93 static char *catchall_ERR = "curses function returned ERR";
94 static char *catchall_NULL = "curses function returned NULL";
96 /* Function Prototype Macros - They are ugly but very, very useful. ;-)
98 X - function name
99 TYPE - parameter Type
100 ERGSTR - format string for construction of the return value
101 PARSESTR - format string for argument parsing
104 #define NoArgNoReturnFunction(X) \
105 static PyObject *PyCurses_ ## X (PyObject *self) \
107 PyCursesInitialised \
108 return PyCursesCheckERR(X(), # X); }
110 #define NoArgOrFlagNoReturnFunction(X) \
111 static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
113 int flag = 0; \
114 PyCursesInitialised \
115 switch(PyTuple_Size(args)) { \
116 case 0: \
117 return PyCursesCheckERR(X(), # X); \
118 case 1: \
119 if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \
120 if (flag) return PyCursesCheckERR(X(), # X); \
121 else return PyCursesCheckERR(no ## X (), # X); \
122 default: \
123 PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \
124 return NULL; } }
126 #define NoArgReturnIntFunction(X) \
127 static PyObject *PyCurses_ ## X (PyObject *self) \
129 PyCursesInitialised \
130 return PyInt_FromLong((long) X()); }
133 #define NoArgReturnStringFunction(X) \
134 static PyObject *PyCurses_ ## X (PyObject *self) \
136 PyCursesInitialised \
137 return PyString_FromString(X()); }
139 #define NoArgTrueFalseFunction(X) \
140 static PyObject *PyCurses_ ## X (PyObject *self) \
142 PyCursesInitialised \
143 if (X () == FALSE) { \
144 Py_INCREF(Py_False); \
145 return Py_False; \
147 Py_INCREF(Py_True); \
148 return Py_True; }
150 #define NoArgNoReturnVoidFunction(X) \
151 static PyObject *PyCurses_ ## X (PyObject *self) \
153 PyCursesInitialised \
154 X(); \
155 Py_INCREF(Py_None); \
156 return Py_None; }
158 #ifdef __cplusplus
160 #endif
162 #endif /* !defined(Py_CURSES_H) */