You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
6.5 KiB

  1. /* Interfaces to parse and execute pieces of python code */
  2. #ifndef Py_PYTHONRUN_H
  3. #define Py_PYTHONRUN_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
  8. CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
  9. CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL)
  10. #define PyCF_MASK_OBSOLETE (CO_NESTED)
  11. #define PyCF_SOURCE_IS_UTF8 0x0100
  12. #define PyCF_DONT_IMPLY_DEDENT 0x0200
  13. #define PyCF_ONLY_AST 0x0400
  14. #define PyCF_IGNORE_COOKIE 0x0800
  15. #ifndef Py_LIMITED_API
  16. typedef struct {
  17. int cf_flags; /* bitmask of CO_xxx flags relevant to future */
  18. } PyCompilerFlags;
  19. #endif
  20. #ifndef Py_LIMITED_API
  21. PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
  22. PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
  23. PyAPI_FUNC(int) PyRun_AnyFileExFlags(
  24. FILE *fp,
  25. const char *filename, /* decoded from the filesystem encoding */
  26. int closeit,
  27. PyCompilerFlags *flags);
  28. PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
  29. FILE *fp,
  30. const char *filename, /* decoded from the filesystem encoding */
  31. int closeit,
  32. PyCompilerFlags *flags);
  33. PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
  34. FILE *fp,
  35. const char *filename, /* decoded from the filesystem encoding */
  36. PyCompilerFlags *flags);
  37. PyAPI_FUNC(int) PyRun_InteractiveOneObject(
  38. FILE *fp,
  39. PyObject *filename,
  40. PyCompilerFlags *flags);
  41. PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
  42. FILE *fp,
  43. const char *filename, /* decoded from the filesystem encoding */
  44. PyCompilerFlags *flags);
  45. PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(
  46. const char *s,
  47. const char *filename, /* decoded from the filesystem encoding */
  48. int start,
  49. PyCompilerFlags *flags,
  50. PyArena *arena);
  51. PyAPI_FUNC(struct _mod *) PyParser_ASTFromStringObject(
  52. const char *s,
  53. PyObject *filename,
  54. int start,
  55. PyCompilerFlags *flags,
  56. PyArena *arena);
  57. PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
  58. FILE *fp,
  59. const char *filename, /* decoded from the filesystem encoding */
  60. const char* enc,
  61. int start,
  62. char *ps1,
  63. char *ps2,
  64. PyCompilerFlags *flags,
  65. int *errcode,
  66. PyArena *arena);
  67. PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject(
  68. FILE *fp,
  69. PyObject *filename,
  70. const char* enc,
  71. int start,
  72. char *ps1,
  73. char *ps2,
  74. PyCompilerFlags *flags,
  75. int *errcode,
  76. PyArena *arena);
  77. #endif
  78. #ifndef PyParser_SimpleParseString
  79. #define PyParser_SimpleParseString(S, B) \
  80. PyParser_SimpleParseStringFlags(S, B, 0)
  81. #define PyParser_SimpleParseFile(FP, S, B) \
  82. PyParser_SimpleParseFileFlags(FP, S, B, 0)
  83. #endif
  84. PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
  85. int);
  86. PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *,
  87. const char *,
  88. int, int);
  89. PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
  90. int, int);
  91. #ifndef Py_LIMITED_API
  92. PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
  93. PyObject *, PyCompilerFlags *);
  94. PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
  95. FILE *fp,
  96. const char *filename, /* decoded from the filesystem encoding */
  97. int start,
  98. PyObject *globals,
  99. PyObject *locals,
  100. int closeit,
  101. PyCompilerFlags *flags);
  102. #endif
  103. #ifdef Py_LIMITED_API
  104. PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
  105. #else
  106. #define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
  107. #define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
  108. PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
  109. const char *str,
  110. const char *filename, /* decoded from the filesystem encoding */
  111. int start,
  112. PyCompilerFlags *flags,
  113. int optimize);
  114. PyAPI_FUNC(PyObject *) Py_CompileStringObject(
  115. const char *str,
  116. PyObject *filename, int start,
  117. PyCompilerFlags *flags,
  118. int optimize);
  119. #endif
  120. PyAPI_FUNC(struct symtable *) Py_SymtableString(
  121. const char *str,
  122. const char *filename, /* decoded from the filesystem encoding */
  123. int start);
  124. #ifndef Py_LIMITED_API
  125. PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
  126. const char *str,
  127. PyObject *filename,
  128. int start);
  129. #endif
  130. PyAPI_FUNC(void) PyErr_Print(void);
  131. PyAPI_FUNC(void) PyErr_PrintEx(int);
  132. PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
  133. #ifndef Py_LIMITED_API
  134. /* Use macros for a bunch of old variants */
  135. #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
  136. #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
  137. #define PyRun_AnyFileEx(fp, name, closeit) \
  138. PyRun_AnyFileExFlags(fp, name, closeit, NULL)
  139. #define PyRun_AnyFileFlags(fp, name, flags) \
  140. PyRun_AnyFileExFlags(fp, name, 0, flags)
  141. #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
  142. #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
  143. #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
  144. #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
  145. #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
  146. #define PyRun_File(fp, p, s, g, l) \
  147. PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
  148. #define PyRun_FileEx(fp, p, s, g, l, c) \
  149. PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
  150. #define PyRun_FileFlags(fp, p, s, g, l, flags) \
  151. PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
  152. #endif
  153. /* Stuff with no proper home (yet) */
  154. #ifndef Py_LIMITED_API
  155. PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
  156. #endif
  157. PyAPI_DATA(int) (*PyOS_InputHook)(void);
  158. PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
  159. #ifndef Py_LIMITED_API
  160. PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
  161. #endif
  162. /* Stack size, in "pointers" (so we get extra safety margins
  163. on 64-bit platforms). On a 32-bit platform, this translates
  164. to a 8k margin. */
  165. #define PYOS_STACK_MARGIN 2048
  166. #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300
  167. /* Enable stack checking under Microsoft C */
  168. #define USE_STACKCHECK
  169. #endif
  170. #ifdef USE_STACKCHECK
  171. /* Check that we aren't overflowing our stack */
  172. PyAPI_FUNC(int) PyOS_CheckStack(void);
  173. #endif
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif /* !Py_PYTHONRUN_H */