modsupport.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef Py_MODSUPPORT_H
  2. #define Py_MODSUPPORT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* Module support interface */
  7. #include <stdarg.h>
  8. /* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
  9. to mean Py_ssize_t */
  10. #ifdef PY_SSIZE_T_CLEAN
  11. #define PyArg_Parse _PyArg_Parse_SizeT
  12. #define PyArg_ParseTuple _PyArg_ParseTuple_SizeT
  13. #define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
  14. #define PyArg_VaParse _PyArg_VaParse_SizeT
  15. #define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
  16. #define Py_BuildValue _Py_BuildValue_SizeT
  17. #define Py_VaBuildValue _Py_VaBuildValue_SizeT
  18. #else
  19. PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
  20. #endif
  21. /* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */
  22. #if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
  23. PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
  24. PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
  25. PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
  26. const char *, char **, ...);
  27. PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
  28. PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
  29. PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
  30. PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
  31. #endif
  32. #ifndef Py_LIMITED_API
  33. PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
  34. PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
  35. PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
  36. PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
  37. const char *, char **, va_list);
  38. #endif
  39. PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
  40. PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
  41. PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
  42. PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
  43. #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
  44. #define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c)
  45. #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
  46. /* New in 3.5 */
  47. PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *);
  48. PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *);
  49. PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
  50. #endif
  51. #define Py_CLEANUP_SUPPORTED 0x20000
  52. #define PYTHON_API_VERSION 1013
  53. #define PYTHON_API_STRING "1013"
  54. /* The API version is maintained (independently from the Python version)
  55. so we can detect mismatches between the interpreter and dynamically
  56. loaded modules. These are diagnosed by an error message but
  57. the module is still loaded (because the mismatch can only be tested
  58. after loading the module). The error message is intended to
  59. explain the core dump a few seconds later.
  60. The symbol PYTHON_API_STRING defines the same value as a string
  61. literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. ***
  62. Please add a line or two to the top of this log for each API
  63. version change:
  64. 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths
  65. 19-Aug-2002 GvR 1012 Changes to string object struct for
  66. interning changes, saving 3 bytes.
  67. 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side
  68. 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and
  69. PyFrame_New(); Python 2.1a2
  70. 14-Mar-2000 GvR 1009 Unicode API added
  71. 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!)
  72. 3-Dec-1998 GvR 1008 Python 1.5.2b1
  73. 18-Jan-1997 GvR 1007 string interning and other speedups
  74. 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-(
  75. 30-Jul-1996 GvR Slice and ellipses syntax added
  76. 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-)
  77. 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( )
  78. 10-Jan-1995 GvR Renamed globals to new naming scheme
  79. 9-Jan-1995 GvR Initial version (incompatible with older API)
  80. */
  81. /* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of
  82. Python 3, it will stay at the value of 3; changes to the limited API
  83. must be performed in a strictly backwards-compatible manner. */
  84. #define PYTHON_ABI_VERSION 3
  85. #define PYTHON_ABI_STRING "3"
  86. #ifdef Py_TRACE_REFS
  87. /* When we are tracing reference counts, rename module creation functions so
  88. modules compiled with incompatible settings will generate a
  89. link-time error. */
  90. #define PyModule_Create2 PyModule_Create2TraceRefs
  91. #define PyModule_FromDefAndSpec2 PyModule_FromDefAndSpec2TraceRefs
  92. #endif
  93. PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
  94. int apiver);
  95. #ifdef Py_LIMITED_API
  96. #define PyModule_Create(module) \
  97. PyModule_Create2(module, PYTHON_ABI_VERSION)
  98. #else
  99. #define PyModule_Create(module) \
  100. PyModule_Create2(module, PYTHON_API_VERSION)
  101. #endif
  102. #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
  103. /* New in 3.5 */
  104. PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def,
  105. PyObject *spec,
  106. int module_api_version);
  107. #ifdef Py_LIMITED_API
  108. #define PyModule_FromDefAndSpec(module, spec) \
  109. PyModule_FromDefAndSpec2(module, spec, PYTHON_ABI_VERSION)
  110. #else
  111. #define PyModule_FromDefAndSpec(module, spec) \
  112. PyModule_FromDefAndSpec2(module, spec, PYTHON_API_VERSION)
  113. #endif /* Py_LIMITED_API */
  114. #endif /* New in 3.5 */
  115. #ifndef Py_LIMITED_API
  116. PyAPI_DATA(char *) _Py_PackageContext;
  117. #endif
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif /* !Py_MODSUPPORT_H */