pythonrun.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. #ifndef Py_LIMITED_API
  8. PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
  9. PyAPI_FUNC(int) PyRun_AnyFileExFlags(
  10. FILE *fp,
  11. const char *filename, /* decoded from the filesystem encoding */
  12. int closeit,
  13. PyCompilerFlags *flags);
  14. PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
  15. FILE *fp,
  16. const char *filename, /* decoded from the filesystem encoding */
  17. int closeit,
  18. PyCompilerFlags *flags);
  19. PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
  20. FILE *fp,
  21. const char *filename, /* decoded from the filesystem encoding */
  22. PyCompilerFlags *flags);
  23. PyAPI_FUNC(int) PyRun_InteractiveOneObject(
  24. FILE *fp,
  25. PyObject *filename,
  26. PyCompilerFlags *flags);
  27. PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
  28. FILE *fp,
  29. const char *filename, /* decoded from the filesystem encoding */
  30. PyCompilerFlags *flags);
  31. PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(
  32. const char *s,
  33. const char *filename, /* decoded from the filesystem encoding */
  34. int start,
  35. PyCompilerFlags *flags,
  36. PyArena *arena);
  37. PyAPI_FUNC(struct _mod *) PyParser_ASTFromStringObject(
  38. const char *s,
  39. PyObject *filename,
  40. int start,
  41. PyCompilerFlags *flags,
  42. PyArena *arena);
  43. PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
  44. FILE *fp,
  45. const char *filename, /* decoded from the filesystem encoding */
  46. const char* enc,
  47. int start,
  48. const char *ps1,
  49. const char *ps2,
  50. PyCompilerFlags *flags,
  51. int *errcode,
  52. PyArena *arena);
  53. PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject(
  54. FILE *fp,
  55. PyObject *filename,
  56. const char* enc,
  57. int start,
  58. const char *ps1,
  59. const char *ps2,
  60. PyCompilerFlags *flags,
  61. int *errcode,
  62. PyArena *arena);
  63. #endif
  64. #ifndef PyParser_SimpleParseString
  65. #define PyParser_SimpleParseString(S, B) \
  66. PyParser_SimpleParseStringFlags(S, B, 0)
  67. #define PyParser_SimpleParseFile(FP, S, B) \
  68. PyParser_SimpleParseFileFlags(FP, S, B, 0)
  69. #endif
  70. #ifndef Py_BUILD_CORE
  71. Py_DEPRECATED(3.9)
  72. #endif
  73. PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, int);
  74. #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
  75. #ifndef Py_BUILD_CORE
  76. Py_DEPRECATED(3.9)
  77. #endif
  78. PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *,
  79. const char *,
  80. int, int);
  81. #endif
  82. #ifndef Py_BUILD_CORE
  83. Py_DEPRECATED(3.9)
  84. #endif
  85. PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, int, int);
  86. #ifndef Py_LIMITED_API
  87. PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
  88. PyObject *, PyCompilerFlags *);
  89. PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
  90. FILE *fp,
  91. const char *filename, /* decoded from the filesystem encoding */
  92. int start,
  93. PyObject *globals,
  94. PyObject *locals,
  95. int closeit,
  96. PyCompilerFlags *flags);
  97. #endif
  98. #ifdef Py_LIMITED_API
  99. PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
  100. #else
  101. #define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
  102. #define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
  103. PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
  104. const char *str,
  105. const char *filename, /* decoded from the filesystem encoding */
  106. int start,
  107. PyCompilerFlags *flags,
  108. int optimize);
  109. PyAPI_FUNC(PyObject *) Py_CompileStringObject(
  110. const char *str,
  111. PyObject *filename, int start,
  112. PyCompilerFlags *flags,
  113. int optimize);
  114. #endif
  115. PyAPI_FUNC(struct symtable *) Py_SymtableString(
  116. const char *str,
  117. const char *filename, /* decoded from the filesystem encoding */
  118. int start);
  119. #ifndef Py_LIMITED_API
  120. PyAPI_FUNC(const char *) _Py_SourceAsString(
  121. PyObject *cmd,
  122. const char *funcname,
  123. const char *what,
  124. PyCompilerFlags *cf,
  125. PyObject **cmd_copy);
  126. PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
  127. const char *str,
  128. PyObject *filename,
  129. int start);
  130. PyAPI_FUNC(struct symtable *) _Py_SymtableStringObjectFlags(
  131. const char *str,
  132. PyObject *filename,
  133. int start,
  134. PyCompilerFlags *flags);
  135. #endif
  136. PyAPI_FUNC(void) PyErr_Print(void);
  137. PyAPI_FUNC(void) PyErr_PrintEx(int);
  138. PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
  139. #ifndef Py_LIMITED_API
  140. /* A function flavor is also exported by libpython. It is required when
  141. libpython is accessed directly rather than using header files which defines
  142. macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
  143. export functions in pythonXX.dll. */
  144. PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
  145. PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
  146. PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
  147. PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
  148. PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
  149. PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
  150. PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
  151. PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
  152. PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
  153. PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
  154. PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
  155. PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
  156. /* Use macros for a bunch of old variants */
  157. #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
  158. #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
  159. #define PyRun_AnyFileEx(fp, name, closeit) \
  160. PyRun_AnyFileExFlags(fp, name, closeit, NULL)
  161. #define PyRun_AnyFileFlags(fp, name, flags) \
  162. PyRun_AnyFileExFlags(fp, name, 0, flags)
  163. #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
  164. #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
  165. #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
  166. #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
  167. #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
  168. #define PyRun_File(fp, p, s, g, l) \
  169. PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
  170. #define PyRun_FileEx(fp, p, s, g, l, c) \
  171. PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
  172. #define PyRun_FileFlags(fp, p, s, g, l, flags) \
  173. PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
  174. #endif
  175. /* Stuff with no proper home (yet) */
  176. #ifndef Py_LIMITED_API
  177. PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
  178. #endif
  179. PyAPI_DATA(int) (*PyOS_InputHook)(void);
  180. PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
  181. #ifndef Py_LIMITED_API
  182. PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
  183. #endif
  184. /* Stack size, in "pointers" (so we get extra safety margins
  185. on 64-bit platforms). On a 32-bit platform, this translates
  186. to an 8k margin. */
  187. #define PYOS_STACK_MARGIN 2048
  188. #if defined(WIN32) && !defined(MS_WIN64) && !defined(_M_ARM) && defined(_MSC_VER) && _MSC_VER >= 1300
  189. /* Enable stack checking under Microsoft C */
  190. #define USE_STACKCHECK
  191. #endif
  192. #ifdef USE_STACKCHECK
  193. /* Check that we aren't overflowing our stack */
  194. PyAPI_FUNC(int) PyOS_CheckStack(void);
  195. #endif
  196. #ifdef __cplusplus
  197. }
  198. #endif
  199. #endif /* !Py_PYTHONRUN_H */