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.

160 lines
5.8 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_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(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
  32. PyObject *, PyCompilerFlags *);
  33. PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
  34. FILE *fp,
  35. const char *filename, /* decoded from the filesystem encoding */
  36. int start,
  37. PyObject *globals,
  38. PyObject *locals,
  39. int closeit,
  40. PyCompilerFlags *flags);
  41. #endif
  42. #ifdef Py_LIMITED_API
  43. PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
  44. #else
  45. #define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
  46. #define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
  47. PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
  48. const char *str,
  49. const char *filename, /* decoded from the filesystem encoding */
  50. int start,
  51. PyCompilerFlags *flags,
  52. int optimize);
  53. PyAPI_FUNC(PyObject *) Py_CompileStringObject(
  54. const char *str,
  55. PyObject *filename, int start,
  56. PyCompilerFlags *flags,
  57. int optimize);
  58. #endif
  59. PyAPI_FUNC(struct symtable *) Py_SymtableString(
  60. const char *str,
  61. const char *filename, /* decoded from the filesystem encoding */
  62. int start);
  63. #ifndef Py_LIMITED_API
  64. PyAPI_FUNC(const char *) _Py_SourceAsString(
  65. PyObject *cmd,
  66. const char *funcname,
  67. const char *what,
  68. PyCompilerFlags *cf,
  69. PyObject **cmd_copy);
  70. PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
  71. const char *str,
  72. PyObject *filename,
  73. int start);
  74. PyAPI_FUNC(struct symtable *) _Py_SymtableStringObjectFlags(
  75. const char *str,
  76. PyObject *filename,
  77. int start,
  78. PyCompilerFlags *flags);
  79. #endif
  80. PyAPI_FUNC(void) PyErr_Print(void);
  81. PyAPI_FUNC(void) PyErr_PrintEx(int);
  82. PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
  83. #ifndef Py_LIMITED_API
  84. /* A function flavor is also exported by libpython. It is required when
  85. libpython is accessed directly rather than using header files which defines
  86. macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
  87. export functions in pythonXX.dll. */
  88. PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
  89. PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
  90. PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
  91. PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
  92. PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
  93. PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
  94. PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
  95. PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
  96. PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
  97. PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
  98. PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
  99. PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
  100. /* Use macros for a bunch of old variants */
  101. #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
  102. #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
  103. #define PyRun_AnyFileEx(fp, name, closeit) \
  104. PyRun_AnyFileExFlags(fp, name, closeit, NULL)
  105. #define PyRun_AnyFileFlags(fp, name, flags) \
  106. PyRun_AnyFileExFlags(fp, name, 0, flags)
  107. #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
  108. #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
  109. #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
  110. #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
  111. #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
  112. #define PyRun_File(fp, p, s, g, l) \
  113. PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
  114. #define PyRun_FileEx(fp, p, s, g, l, c) \
  115. PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
  116. #define PyRun_FileFlags(fp, p, s, g, l, flags) \
  117. PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
  118. #endif
  119. /* Stuff with no proper home (yet) */
  120. #ifndef Py_LIMITED_API
  121. PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
  122. #endif
  123. PyAPI_DATA(int) (*PyOS_InputHook)(void);
  124. PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
  125. #ifndef Py_LIMITED_API
  126. PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
  127. #endif
  128. /* Stack size, in "pointers" (so we get extra safety margins
  129. on 64-bit platforms). On a 32-bit platform, this translates
  130. to an 8k margin. */
  131. #define PYOS_STACK_MARGIN 2048
  132. #if defined(WIN32) && !defined(MS_WIN64) && !defined(_M_ARM) && defined(_MSC_VER) && _MSC_VER >= 1300
  133. /* Enable stack checking under Microsoft C */
  134. #define USE_STACKCHECK
  135. #endif
  136. #ifdef USE_STACKCHECK
  137. /* Check that we aren't overflowing our stack */
  138. PyAPI_FUNC(int) PyOS_CheckStack(void);
  139. #endif
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143. #endif /* !Py_PYTHONRUN_H */