Python.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #ifndef Py_PYTHON_H
  2. #define Py_PYTHON_H
  3. /* Compat stuff */
  4. #ifdef __GNUC__
  5. #define _GNU_SOURCE 1
  6. #endif
  7. #ifndef _WIN32
  8. # include <inttypes.h>
  9. # include <stdint.h>
  10. # include <stddef.h>
  11. # include <limits.h>
  12. # include <math.h>
  13. # include <errno.h>
  14. # include <unistd.h>
  15. # define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
  16. # define PyAPI_FUNC(RTYPE) __attribute__((visibility("default"))) RTYPE
  17. # define PyAPI_DATA(RTYPE) extern PyAPI_FUNC(RTYPE)
  18. # define Py_LOCAL_INLINE(type) static inline type
  19. #else
  20. # define MS_WIN32 1
  21. # define MS_WINDOWS 1
  22. # ifdef _MSC_VER
  23. # include <crtdefs.h>
  24. # endif
  25. # ifdef __MINGW32__
  26. # include <limits.h>
  27. # endif
  28. # include <io.h>
  29. # include <sys/types.h> /* for 'off_t' */
  30. # define Py_DEPRECATED(VERSION_UNUSED)
  31. # ifdef Py_BUILD_CORE
  32. # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
  33. # define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE
  34. # else
  35. # define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
  36. # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
  37. # endif
  38. # define Py_LOCAL_INLINE(type) static __inline type __fastcall
  39. #endif
  40. /* Deprecated DL_IMPORT and DL_EXPORT macros */
  41. #ifdef _WIN32
  42. # if defined(Py_BUILD_CORE)
  43. # define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
  44. # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
  45. # else
  46. # define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
  47. # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
  48. # endif
  49. #endif
  50. #ifndef DL_EXPORT
  51. # define DL_EXPORT(RTYPE) PyAPI_FUNC(RTYPE)
  52. #endif
  53. #ifndef DL_IMPORT
  54. # define DL_IMPORT(RTYPE) RTYPE
  55. #endif
  56. #include <stdlib.h>
  57. #define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
  58. #define Py_USING_UNICODE
  59. /* Convert a possibly signed character to a nonnegative int */
  60. /* XXX This assumes characters are 8 bits wide */
  61. #ifdef __CHAR_UNSIGNED__
  62. #define Py_CHARMASK(c) (c)
  63. #else
  64. #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
  65. #endif
  66. #define statichere static
  67. #define Py_MEMCPY memcpy
  68. #include "pypy_macros.h"
  69. #define PyExc_EnvironmentError PyExc_OSError
  70. #define PyExc_IOError PyExc_OSError
  71. // TODO: fix windows support
  72. // #define PyExc_WindowsError PyExc_OSError
  73. #include "patchlevel.h"
  74. #include "pyconfig.h"
  75. #include "object.h"
  76. #include "typeslots.h"
  77. #include "abstract.h"
  78. #include "pymath.h"
  79. #include "pyport.h"
  80. #include "pymacro.h"
  81. #include "warnings.h"
  82. #include <stdarg.h>
  83. #include <stdio.h>
  84. #include <string.h>
  85. #include <assert.h>
  86. #include <locale.h>
  87. #include <ctype.h>
  88. #include "boolobject.h"
  89. #include "floatobject.h"
  90. #include "complexobject.h"
  91. #include "methodobject.h"
  92. #include "funcobject.h"
  93. #include "code.h"
  94. #include "moduleobject.h"
  95. #include "modsupport.h"
  96. #include "pythonrun.h"
  97. #include "pyerrors.h"
  98. #include "sysmodule.h"
  99. #include "bytearrayobject.h"
  100. #include "descrobject.h"
  101. #include "tupleobject.h"
  102. #include "dictobject.h"
  103. #include "longobject.h"
  104. #include "listobject.h"
  105. #include "longobject.h"
  106. #include "unicodeobject.h"
  107. #include "compile.h"
  108. #include "frameobject.h"
  109. #include "memoryobject.h"
  110. #include "eval.h"
  111. #include "pymem.h"
  112. #include "pycobject.h"
  113. #include "pycapsule.h"
  114. #include "bytesobject.h"
  115. #include "sliceobject.h"
  116. #include "genobject.h"
  117. #include "datetime.h"
  118. #include "pystate.h"
  119. #include "fileobject.h"
  120. #include "pysignals.h"
  121. #include "pythread.h"
  122. #include "traceback.h"
  123. #include "pylifecycle.h"
  124. /* Missing definitions */
  125. #include "missing.h"
  126. /* The declarations of most API functions are generated in a separate file */
  127. /* Don't include them while building PyPy, RPython also generated signatures
  128. * which are similar but not identical. */
  129. #ifndef PYPY_STANDALONE
  130. #ifdef __cplusplus
  131. extern "C" {
  132. #endif
  133. #include "pypy_decl.h"
  134. #ifdef __cplusplus
  135. }
  136. #endif
  137. #endif /* PYPY_STANDALONE */
  138. /* Define macros for inline documentation. */
  139. #define PyDoc_VAR(name) static char name[]
  140. #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
  141. #ifdef WITH_DOC_STRINGS
  142. #define PyDoc_STR(str) str
  143. #else
  144. #define PyDoc_STR(str) ""
  145. #endif
  146. /* PyPy does not implement --with-fpectl */
  147. #define PyFPE_START_PROTECT(err_string, leave_stmt)
  148. #define PyFPE_END_PROTECT(v)
  149. #endif