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