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