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