| 1 | # This Python script creates a full set of C++ C header files that |
|---|
| 2 | # are missing on some platforms. |
|---|
| 3 | # |
|---|
| 4 | # Usage: |
|---|
| 5 | # mkdir cpp_c_headers |
|---|
| 6 | # cd cpp_c_headers |
|---|
| 7 | # python generate_cpp_c_headers.py |
|---|
| 8 | # |
|---|
| 9 | # The files created by this script are in the directory: |
|---|
| 10 | # root/boost/compatibility/cpp_c_headers |
|---|
| 11 | # |
|---|
| 12 | # Supported platforms: |
|---|
| 13 | # Compaq Alpha, RedHat 6.2 Linux, Compaq C++ V6.3 (cxx) |
|---|
| 14 | # Compaq Alpha, Tru64 Unix V5.0, Compaq C++ V6.2 (cxx) |
|---|
| 15 | # Silicon Graphics, IRIX 6.5, MIPSpro Compilers: Version 7.3.1.1m (CC) |
|---|
| 16 | # |
|---|
| 17 | # Support for additional platforms can be added by extending the |
|---|
| 18 | # "defines" Python dictionary below. |
|---|
| 19 | # |
|---|
| 20 | # Python is available at: |
|---|
| 21 | # http://www.python.org/ |
|---|
| 22 | # |
|---|
| 23 | # Copyright (c) 2001 Ralf W. Grosse-Kunstleve. Permission to copy, |
|---|
| 24 | # use, modify, sell and distribute this script is granted provided this |
|---|
| 25 | # copyright notice appears in all copies. This document is provided "as |
|---|
| 26 | # is" without express or implied warranty, and with no claim as to its |
|---|
| 27 | # suitability for any purpose. |
|---|
| 28 | # |
|---|
| 29 | # Revision history: |
|---|
| 30 | # 16 Apr 01 moved to boost CVS tree (R.W. Grosse-Kunstleve) |
|---|
| 31 | # 17 Jan 01 Alpha Linux cxx V6.3 support (R.W. Grosse-Kunstleve) |
|---|
| 32 | # 15 Dec 00 posted to boost e-group file upload area (R.W. Grosse-Kunstleve) |
|---|
| 33 | |
|---|
| 34 | # Definition of platform specific exclusion of identifiers. |
|---|
| 35 | defines = { |
|---|
| 36 | 'defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 740': ( |
|---|
| 37 | 'btowc', 'fwide', 'fwprintf', 'fwscanf', 'mbrlen', 'mbrtowc', |
|---|
| 38 | 'mbsinit', 'mbsrtowcs', 'swprintf', 'swscanf', 'towctrans', 'vfwprintf', |
|---|
| 39 | 'vswprintf', 'vwprintf', 'wcrtomb', 'wcsrtombs', 'wctob', 'wctrans', |
|---|
| 40 | 'wctrans_t', 'wmemchr', 'wmemcmp', 'wmemcpy', 'wmemmove', 'wmemset', |
|---|
| 41 | 'wprintf', 'wscanf', |
|---|
| 42 | ), |
|---|
| 43 | 'defined(__DECCXX_VER) && __DECCXX_VER <= 60290024': ( |
|---|
| 44 | 'fwide', |
|---|
| 45 | ), |
|---|
| 46 | 'defined(__linux) && defined(__DECCXX_VER) && __DECCXX_VER <= 60390005': ( |
|---|
| 47 | 'getwchar', 'ungetwc', 'fgetwc', 'vfwprintf', 'fgetws', 'vswprintf', |
|---|
| 48 | 'wcsftime', 'fputwc', 'vwprintf', 'fputws', 'fwide', 'putwc', |
|---|
| 49 | 'wprintf', 'fwprintf', 'putwchar', 'wscanf', 'fwscanf', 'swprintf', |
|---|
| 50 | 'getwc', 'swscanf', |
|---|
| 51 | ), |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | # The information below was copied directly from the file: |
|---|
| 55 | # ISO+IEC+14882-1998.pdf |
|---|
| 56 | # The exact source of the information is given in the format |
|---|
| 57 | # PDF #, p. #, Table # |
|---|
| 58 | # Where |
|---|
| 59 | # PDF # = page number as shown by the Acrobat Reader |
|---|
| 60 | # p. # = page number printed at the bottom of the page |
|---|
| 61 | # Table # = number printed in caption of table |
|---|
| 62 | hfiles = { |
|---|
| 63 | 'cassert': ( # PDF 378, p. 352, Table 25 |
|---|
| 64 | # Macro: assert |
|---|
| 65 | ), |
|---|
| 66 | 'cctype': ( # PDF 431, p. 405, Table 45 |
|---|
| 67 | # Functions: |
|---|
| 68 | 'isalnum', 'isdigit', 'isprint', 'isupper', 'tolower', |
|---|
| 69 | 'isalpha', 'isgraph', 'ispunct', 'isxdigit', 'toupper', |
|---|
| 70 | 'iscntrl', 'islower', 'isspace', |
|---|
| 71 | ), |
|---|
| 72 | 'cerrno': ( # PDF 378, p. 352, Table 26 |
|---|
| 73 | # Macros: EDOM ERANGE errno |
|---|
| 74 | ), |
|---|
| 75 | 'cfloat': ( # PDF 361, p. 335, Table 17 |
|---|
| 76 | # Macros: DBL_DIG DBL_MIN_EXP FLT_MIN_10_EXP LDBL_MAX_10_EXP |
|---|
| 77 | # DBL_EPSILON FLT_DIG FLT_MIN_EXP LDBL_MAX_EXP |
|---|
| 78 | # DBL_MANT_DIG FLT_EPSILON FLT_RADIX LDBL_MIN |
|---|
| 79 | # DBL_MAX FLT_MANT_DIG FLT_ROUNDS LDBL_MIN_10_EXP |
|---|
| 80 | # DBL_MAX_10_EXP FLT_MAX LDBL_DIG LDBL_MIN_EXP |
|---|
| 81 | # DBL_MAX_EXP FLT_MAX_10_EXP LDBL_EPSILON |
|---|
| 82 | # DBL_MIN FLT_MAX_EXP LDBL_MANT_DIG |
|---|
| 83 | # DBL_MIN_10_EXP FLT_MIN LDBL_MAX |
|---|
| 84 | ), |
|---|
| 85 | #'ciso646': ( |
|---|
| 86 | #), |
|---|
| 87 | 'climits': ( # PDF 361, p. 335, Table 16 |
|---|
| 88 | # Macros: CHAR_BIT INT_MAX LONG_MIN SCHAR_MIN UCHAR_MAX USHRT_MAX |
|---|
| 89 | # CHAR_MAX INT_MIN MB_LEN_MAX SHRT_MAX UINT_MAX |
|---|
| 90 | # CHAR_MIN LONG_MAX SCHAR_MAX SHRT_MIN ULONG_MAX |
|---|
| 91 | ), |
|---|
| 92 | 'clocale': ( # PDF 483, p. 457, Table 62 |
|---|
| 93 | # Macros: LC_ALL LC_COLLATE LC_CTYPE |
|---|
| 94 | # LC_MONETARY LC_NUMERIC LC_TIME |
|---|
| 95 | # NULL |
|---|
| 96 | # Struct: |
|---|
| 97 | 'lconv', |
|---|
| 98 | # Functions: |
|---|
| 99 | 'localeconv', 'setlocale', |
|---|
| 100 | ), |
|---|
| 101 | 'cmath': ( # PDF 622, p. 596, Table 80 |
|---|
| 102 | # Macro: HUGE_VAL |
|---|
| 103 | # Functions: |
|---|
| 104 | 'acos', 'cos', 'fmod', 'modf', 'tan', |
|---|
| 105 | 'asin', 'cosh', 'frexp', 'pow', 'tanh', |
|---|
| 106 | 'atan', 'exp', 'ldexp', 'sin', |
|---|
| 107 | 'atan2', 'fabs', 'log', 'sinh', |
|---|
| 108 | 'ceil', 'floor', 'log10', 'sqrt', |
|---|
| 109 | ), |
|---|
| 110 | 'csetjmp': ( # PDF 372, p. 346, Table 20 |
|---|
| 111 | # Macro: setjmp |
|---|
| 112 | # Type: |
|---|
| 113 | 'jmp_buf', |
|---|
| 114 | # Function: |
|---|
| 115 | 'longjmp', |
|---|
| 116 | ), |
|---|
| 117 | 'csignal': ( # PDF 372, p. 346, Table 22 |
|---|
| 118 | # Macros: SIGABRT SIGILL SIGSEGV SIG_DFL |
|---|
| 119 | # SIG_IGN SIGFPE SIGINT SIGTERM SIG_ERR |
|---|
| 120 | # Type: |
|---|
| 121 | 'sig_atomic_t', |
|---|
| 122 | # Functions: |
|---|
| 123 | 'raise', 'signal', |
|---|
| 124 | ), |
|---|
| 125 | 'cstdarg': ( # PDF 372, p. 346, Table 19 |
|---|
| 126 | # Macros: va_arg va_end va_start |
|---|
| 127 | # Type: |
|---|
| 128 | 'va_list', |
|---|
| 129 | ), |
|---|
| 130 | 'cstddef': ( # PDF 353, p. 327, Table 15 |
|---|
| 131 | # Macros: NULL offsetof |
|---|
| 132 | # Types: |
|---|
| 133 | 'ptrdiff_t', 'size_t', |
|---|
| 134 | ), |
|---|
| 135 | 'cstdio': ( # PDF 692, p. 666, Table 94 |
|---|
| 136 | # Macros: BUFSIZ FOPEN_MAX SEEK_CUR TMP_MAX _IONBF stdout |
|---|
| 137 | # EOF L_tmpnam SEEK_END _IOFBF stderr |
|---|
| 138 | # FILENAME_MAX NULL <cstdio> SEEK_SET _IOLBF stdin |
|---|
| 139 | # Types: |
|---|
| 140 | 'FILE', 'fpos_t', 'size_t', |
|---|
| 141 | # Functions: |
|---|
| 142 | 'clearerr', 'fgets', 'fscanf', 'gets', 'rename', 'tmpfile', |
|---|
| 143 | 'fclose', 'fopen', 'fseek', 'perror', 'rewind', 'tmpnam', |
|---|
| 144 | 'feof', 'fprintf', 'fsetpos', 'printf', 'scanf', 'ungetc', |
|---|
| 145 | 'ferror', 'fputc', 'ftell', 'putc', 'setbuf', 'vfprintf', |
|---|
| 146 | 'fflush', 'fputs', 'fwrite', 'putchar', 'setvbuf', 'vprintf', |
|---|
| 147 | 'fgetc', 'fread', 'getc', 'puts', 'sprintf', 'vsprintf', |
|---|
| 148 | 'fgetpos', 'freopen', 'getchar', 'remove', 'sscanf', |
|---|
| 149 | ), |
|---|
| 150 | 'cstdlib': ( # PDF 362, p. 336, Table 18 |
|---|
| 151 | # Macros: EXIT_FAILURE EXIT_SUCCESS |
|---|
| 152 | # Functions: |
|---|
| 153 | 'abort', 'atexit', 'exit', |
|---|
| 154 | # PDF 373, p. 347, Table 23 |
|---|
| 155 | # Functions: |
|---|
| 156 | 'getenv', 'system', |
|---|
| 157 | # PDF 400, p. 374, Table 33 |
|---|
| 158 | # Functions: |
|---|
| 159 | 'calloc', 'malloc', |
|---|
| 160 | 'free', 'realloc', |
|---|
| 161 | # PDF 433, p. 417, Table 49 |
|---|
| 162 | # Macros: MB_CUR_MAX |
|---|
| 163 | # Functions: |
|---|
| 164 | 'atol', 'mblen', 'strtod', 'wctomb', |
|---|
| 165 | 'atof', 'mbstowcs', 'strtol', 'wcstombs', |
|---|
| 166 | 'atoi', 'mbtowc', 'strtoul', |
|---|
| 167 | # PDF 589, p. 563, Table 78 |
|---|
| 168 | # Functions: |
|---|
| 169 | 'bsearch', 'qsort', |
|---|
| 170 | # PDF 622, p. 596, Table 81 |
|---|
| 171 | # Macros: RAND_MAX |
|---|
| 172 | # Types: |
|---|
| 173 | 'div_t', 'ldiv_t', |
|---|
| 174 | # Functions: |
|---|
| 175 | 'abs', 'labs', 'srand', |
|---|
| 176 | 'div', 'ldiv', 'rand', |
|---|
| 177 | ), |
|---|
| 178 | 'cstring': ( # PDF 401, p. 375, Table 34 |
|---|
| 179 | # Macro: NULL |
|---|
| 180 | # Type: size_t |
|---|
| 181 | # Functions: |
|---|
| 182 | # 'memchr', 'memcmp', |
|---|
| 183 | # 'memcpy', 'memmove', 'memset', |
|---|
| 184 | # PDF 432, p. 406, Table 47 |
|---|
| 185 | # Macro: NULL |
|---|
| 186 | # Type: |
|---|
| 187 | 'size_t', |
|---|
| 188 | # Functions: |
|---|
| 189 | 'memchr', 'strcat', 'strcspn', 'strncpy', 'strtok', |
|---|
| 190 | 'memcmp', 'strchr', 'strerror', 'strpbrk', 'strxfrm', |
|---|
| 191 | 'memcpy', 'strcmp', 'strlen', 'strrchr', |
|---|
| 192 | 'memmove', 'strcoll', 'strncat', 'strspn', |
|---|
| 193 | 'memset', 'strcpy', 'strncmp', 'strstr', |
|---|
| 194 | ), |
|---|
| 195 | 'ctime': ( # PDF 372, p. 346, Table 21 |
|---|
| 196 | # Macros: CLOCKS_PER_SEC |
|---|
| 197 | # Types: |
|---|
| 198 | # 'clock_t', |
|---|
| 199 | # Functions: |
|---|
| 200 | # 'clock', |
|---|
| 201 | # PDF 401, p. 375, Table 35 |
|---|
| 202 | # Macros: NULL |
|---|
| 203 | # Types: |
|---|
| 204 | 'size_t', 'clock_t', 'time_t', |
|---|
| 205 | # Struct: |
|---|
| 206 | 'tm', |
|---|
| 207 | # Functions: |
|---|
| 208 | 'asctime', 'clock', 'difftime', 'localtime', 'strftime', |
|---|
| 209 | 'ctime', 'gmtime', 'mktime', 'time', |
|---|
| 210 | ), |
|---|
| 211 | 'cwchar': ( # PDF 432, p. 406, Table 48 |
|---|
| 212 | # Macros: NULL WCHAR_MAX WCHAR_MIN WEOF |
|---|
| 213 | # Types: |
|---|
| 214 | 'mbstate_t', 'wint_t', 'size_t', |
|---|
| 215 | # Functions: |
|---|
| 216 | 'btowc', 'getwchar', 'ungetwc', 'wcscpy', 'wcsrtombs', 'wmemchr', |
|---|
| 217 | 'fgetwc', 'mbrlen', 'vfwprintf', 'wcscspn', 'wcsspn', 'wmemcmp', |
|---|
| 218 | 'fgetws', 'mbrtowc', 'vswprintf', 'wcsftime', 'wcsstr', 'wmemcpy', |
|---|
| 219 | 'fputwc', 'mbsinit', 'vwprintf', 'wcslen', 'wcstod', 'wmemmove', |
|---|
| 220 | 'fputws', 'mbsrtowcs', 'wcrtomb', 'wcsncat', 'wcstok', 'wmemset', |
|---|
| 221 | 'fwide', 'putwc', 'wcscat', 'wcsncmp', 'wcstol', 'wprintf', |
|---|
| 222 | 'fwprintf', 'putwchar', 'wcschr', 'wcsncpy', 'wcstoul', 'wscanf', |
|---|
| 223 | 'fwscanf', 'swprintf', 'wcscmp', 'wcspbrk', 'wcsxfrm', |
|---|
| 224 | 'getwc', 'swscanf', 'wcscoll', 'wcsrchr', 'wctob', |
|---|
| 225 | ), |
|---|
| 226 | 'cwctype': ( # PDF 432, p. 406, Table 46 |
|---|
| 227 | # Macro: WEOF |
|---|
| 228 | # Types: |
|---|
| 229 | 'wctrans_t', 'wctype_t', 'wint_t', |
|---|
| 230 | # Functions: |
|---|
| 231 | 'iswalnum', 'iswctype', 'iswlower', 'iswspace', 'towctrans', 'wctrans', |
|---|
| 232 | 'iswalpha', 'iswdigit', 'iswprint', 'iswupper', 'towlower', 'wctype', |
|---|
| 233 | 'iswcntrl', 'iswgraph', 'iswpunct', 'iswxdigit', 'towupper', |
|---|
| 234 | ), |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | if (__name__ == "__main__"): |
|---|
| 238 | |
|---|
| 239 | import sys, string, time |
|---|
| 240 | |
|---|
| 241 | now = time.asctime(time.localtime(time.time())) + ' ' + str(time.tzname) |
|---|
| 242 | |
|---|
| 243 | for hfile in hfiles.keys(): |
|---|
| 244 | HFILE = string.upper(hfile) |
|---|
| 245 | f = open(hfile, 'w') |
|---|
| 246 | sys.stdout = f |
|---|
| 247 | print '// This file is automatically generated. Do not edit.' |
|---|
| 248 | print '//', sys.argv |
|---|
| 249 | print '//', now |
|---|
| 250 | print |
|---|
| 251 | print '#ifndef __' + HFILE + '_HEADER' |
|---|
| 252 | print '#define __' + HFILE + '_HEADER' |
|---|
| 253 | print '' |
|---|
| 254 | print '#include <' + hfile[1:] + '.h>' |
|---|
| 255 | print '' |
|---|
| 256 | if (len(hfiles[hfile]) > 0): |
|---|
| 257 | print 'namespace std {' |
|---|
| 258 | for s in hfiles[hfile]: |
|---|
| 259 | n_endif = 0 |
|---|
| 260 | for d in defines.keys(): |
|---|
| 261 | if (s in defines[d]): |
|---|
| 262 | print '#if !(' + d + ')' |
|---|
| 263 | n_endif = n_endif + 1 |
|---|
| 264 | print ' using ::' + s + ';' |
|---|
| 265 | for i in xrange(n_endif): print '#endif' |
|---|
| 266 | print '}' |
|---|
| 267 | print '' |
|---|
| 268 | print '#endif // ' + HFILE + '_HEADER' |
|---|
| 269 | sys.stdout = sys.__stdout__ |
|---|