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.

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