7 ** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
8 ** against multiple definition of wchar_t.
10 #ifdef _BSD_WCHAR_T_DEFINED_
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
35 /* for tigetstr, which is not declared in SysV curses */
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
46 #ifndef MVWDELCH_IS_EXPRESSION
47 #define MVWDELCH_IS_EXPRESSION 1
55 #define PyCurses_API_pointers 4
57 /* Type declarations */
62 } PyCursesWindowObject
;
64 #define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type)
67 /* This section is used when compiling _cursesmodule.c */
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() \
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); \
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. ;-)
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) \
114 PyCursesInitialised \
115 switch(PyTuple_Size(args)) { \
117 return PyCursesCheckERR(X(), # X); \
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); \
123 PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \
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); \
147 Py_INCREF(Py_True); \
150 #define NoArgNoReturnVoidFunction(X) \
151 static PyObject *PyCurses_ ## X (PyObject *self) \
153 PyCursesInitialised \
155 Py_INCREF(Py_None); \
162 #endif /* !defined(Py_CURSES_H) */