10 /* for tigetstr, which is not declared in SysV curses */
16 /* configure was checking <curses.h>, but we will
17 use <ncurses.h>, which has all these features. */
18 #ifndef WINDOW_HAS_FLAGS
19 #define WINDOW_HAS_FLAGS 1
21 #ifndef MVWDELCH_IS_EXPRESSION
22 #define MVWDELCH_IS_EXPRESSION 1
30 #define PyCurses_API_pointers 4
32 /* Type declarations */
37 } PyCursesWindowObject
;
39 #define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type)
42 /* This section is used when compiling _cursesmodule.c */
45 /* This section is used in modules that use the _cursesmodule API */
47 static void **PyCurses_API
;
49 #define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0])
50 #define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;}
51 #define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;}
52 #define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}
54 #define import_curses() \
56 PyObject *module = PyImport_ImportModule("_curses"); \
57 if (module != NULL) { \
58 PyObject *module_dict = PyModule_GetDict(module); \
59 PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \
60 if (PyCObject_Check(c_api_object)) { \
61 PyCurses_API = (void **)PyCObject_AsVoidPtr(c_api_object); \
67 /* general error messages */
68 static char *catchall_ERR
= "curses function returned ERR";
69 static char *catchall_NULL
= "curses function returned NULL";
71 /* Function Prototype Macros - They are ugly but very, very useful. ;-)
75 ERGSTR - format string for construction of the return value
76 PARSESTR - format string for argument parsing
79 #define NoArgNoReturnFunction(X) \
80 static PyObject *PyCurses_ ## X (PyObject *self) \
83 return PyCursesCheckERR(X(), # X); }
85 #define NoArgOrFlagNoReturnFunction(X) \
86 static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
90 switch(PyTuple_Size(args)) { \
92 return PyCursesCheckERR(X(), # X); \
94 if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \
95 if (flag) return PyCursesCheckERR(X(), # X); \
96 else return PyCursesCheckERR(no ## X (), # X); \
98 PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \
101 #define NoArgReturnIntFunction(X) \
102 static PyObject *PyCurses_ ## X (PyObject *self) \
104 PyCursesInitialised \
105 return PyInt_FromLong((long) X()); }
108 #define NoArgReturnStringFunction(X) \
109 static PyObject *PyCurses_ ## X (PyObject *self) \
111 PyCursesInitialised \
112 return PyString_FromString(X()); }
114 #define NoArgTrueFalseFunction(X) \
115 static PyObject *PyCurses_ ## X (PyObject *self) \
117 PyCursesInitialised \
118 if (X () == FALSE) { \
119 Py_INCREF(Py_False); \
122 Py_INCREF(Py_True); \
125 #define NoArgNoReturnVoidFunction(X) \
126 static PyObject *PyCurses_ ## X (PyObject *self) \
128 PyCursesInitialised \
130 Py_INCREF(Py_None); \
137 #endif /* !defined(Py_CURSES_H) */