pythonrun.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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)
  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. typedef struct {
  15. int cf_flags; /* bitmask of CO_xxx flags relevant to future */
  16. } PyCompilerFlags;
  17. PyAPI_FUNC(void) Py_SetProgramName(char *);
  18. PyAPI_FUNC(char *) Py_GetProgramName(void);
  19. PyAPI_FUNC(void) Py_SetPythonHome(char *);
  20. PyAPI_FUNC(char *) Py_GetPythonHome(void);
  21. PyAPI_FUNC(void) Py_Initialize(void);
  22. PyAPI_FUNC(void) Py_InitializeEx(int);
  23. PyAPI_FUNC(void) Py_Finalize(void);
  24. PyAPI_FUNC(int) Py_IsInitialized(void);
  25. PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
  26. PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
  27. PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
  28. PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
  29. PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
  30. PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
  31. PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
  32. PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
  33. PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *,
  34. int, PyCompilerFlags *flags,
  35. PyArena *);
  36. PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, int,
  37. char *, char *,
  38. PyCompilerFlags *, int *,
  39. PyArena *);
  40. #define PyParser_SimpleParseString(S, B) \
  41. PyParser_SimpleParseStringFlags(S, B, 0)
  42. #define PyParser_SimpleParseFile(FP, S, B) \
  43. PyParser_SimpleParseFileFlags(FP, S, B, 0)
  44. PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
  45. int);
  46. PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
  47. int, int);
  48. PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
  49. PyObject *, PyCompilerFlags *);
  50. PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int,
  51. PyObject *, PyObject *, int,
  52. PyCompilerFlags *);
  53. #define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL)
  54. PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
  55. PyCompilerFlags *);
  56. PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
  57. PyAPI_FUNC(void) PyErr_Print(void);
  58. PyAPI_FUNC(void) PyErr_PrintEx(int);
  59. PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
  60. PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
  61. PyAPI_FUNC(void) Py_Exit(int);
  62. PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
  63. /* Bootstrap */
  64. PyAPI_FUNC(int) Py_Main(int argc, char **argv);
  65. /* Use macros for a bunch of old variants */
  66. #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
  67. #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
  68. #define PyRun_AnyFileEx(fp, name, closeit) \
  69. PyRun_AnyFileExFlags(fp, name, closeit, NULL)
  70. #define PyRun_AnyFileFlags(fp, name, flags) \
  71. PyRun_AnyFileExFlags(fp, name, 0, flags)
  72. #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
  73. #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
  74. #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
  75. #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
  76. #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
  77. #define PyRun_File(fp, p, s, g, l) \
  78. PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
  79. #define PyRun_FileEx(fp, p, s, g, l, c) \
  80. PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
  81. #define PyRun_FileFlags(fp, p, s, g, l, flags) \
  82. PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
  83. /* In getpath.c */
  84. PyAPI_FUNC(char *) Py_GetProgramFullPath(void);
  85. PyAPI_FUNC(char *) Py_GetPrefix(void);
  86. PyAPI_FUNC(char *) Py_GetExecPrefix(void);
  87. PyAPI_FUNC(char *) Py_GetPath(void);
  88. /* In their own files */
  89. PyAPI_FUNC(const char *) Py_GetVersion(void);
  90. PyAPI_FUNC(const char *) Py_GetPlatform(void);
  91. PyAPI_FUNC(const char *) Py_GetCopyright(void);
  92. PyAPI_FUNC(const char *) Py_GetCompiler(void);
  93. PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
  94. PyAPI_FUNC(const char *) _Py_svnversion(void);
  95. PyAPI_FUNC(const char *) Py_SubversionRevision(void);
  96. PyAPI_FUNC(const char *) Py_SubversionShortBranch(void);
  97. PyAPI_FUNC(const char *) _Py_hgidentifier(void);
  98. PyAPI_FUNC(const char *) _Py_hgversion(void);
  99. /* Internal -- various one-time initializations */
  100. PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
  101. PyAPI_FUNC(PyObject *) _PySys_Init(void);
  102. PyAPI_FUNC(void) _PyImport_Init(void);
  103. PyAPI_FUNC(void) _PyExc_Init(void);
  104. PyAPI_FUNC(void) _PyImportHooks_Init(void);
  105. PyAPI_FUNC(int) _PyFrame_Init(void);
  106. PyAPI_FUNC(int) _PyInt_Init(void);
  107. PyAPI_FUNC(int) _PyLong_Init(void);
  108. PyAPI_FUNC(void) _PyFloat_Init(void);
  109. PyAPI_FUNC(int) PyByteArray_Init(void);
  110. PyAPI_FUNC(void) _PyRandom_Init(void);
  111. /* Various internal finalizers */
  112. PyAPI_FUNC(void) _PyExc_Fini(void);
  113. PyAPI_FUNC(void) _PyImport_Fini(void);
  114. PyAPI_FUNC(void) PyMethod_Fini(void);
  115. PyAPI_FUNC(void) PyFrame_Fini(void);
  116. PyAPI_FUNC(void) PyCFunction_Fini(void);
  117. PyAPI_FUNC(void) PyDict_Fini(void);
  118. PyAPI_FUNC(void) PyTuple_Fini(void);
  119. PyAPI_FUNC(void) PyList_Fini(void);
  120. PyAPI_FUNC(void) PySet_Fini(void);
  121. PyAPI_FUNC(void) PyString_Fini(void);
  122. PyAPI_FUNC(void) PyInt_Fini(void);
  123. PyAPI_FUNC(void) PyFloat_Fini(void);
  124. PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
  125. PyAPI_FUNC(void) PyByteArray_Fini(void);
  126. PyAPI_FUNC(void) _PyRandom_Fini(void);
  127. /* Stuff with no proper home (yet) */
  128. PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
  129. PyAPI_DATA(int) (*PyOS_InputHook)(void);
  130. PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
  131. PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
  132. /* Stack size, in "pointers" (so we get extra safety margins
  133. on 64-bit platforms). On a 32-bit platform, this translates
  134. to an 8k margin. */
  135. #define PYOS_STACK_MARGIN 2048
  136. #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300
  137. /* Enable stack checking under Microsoft C */
  138. #define USE_STACKCHECK
  139. #endif
  140. #ifdef USE_STACKCHECK
  141. /* Check that we aren't overflowing our stack */
  142. PyAPI_FUNC(int) PyOS_CheckStack(void);
  143. #endif
  144. /* Signals */
  145. typedef void (*PyOS_sighandler_t)(int);
  146. PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
  147. PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
  148. /* Random */
  149. PyAPI_FUNC(int) _PyOS_URandom (void *buffer, Py_ssize_t size);
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif /* !Py_PYTHONRUN_H */