pythonrun.h 6.06 KB
Newer Older
1

Guido van Rossum's avatar
Guido van Rossum committed
2 3
/* Interfaces to parse and execute pieces of python code */

4 5 6 7 8 9
#ifndef Py_PYTHONRUN_H
#define Py_PYTHONRUN_H
#ifdef __cplusplus
extern "C" {
#endif

10 11
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
12
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
13 14 15 16 17 18 19 20 21 22 23 24 25 26
PyAPI_FUNC(int) PyRun_AnyFileExFlags(
    FILE *fp,
    const char *filename,       /* decoded from the filesystem encoding */
    int closeit,
    PyCompilerFlags *flags);
PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
    FILE *fp,
    const char *filename,       /* decoded from the filesystem encoding */
    int closeit,
    PyCompilerFlags *flags);
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
    FILE *fp,
    const char *filename,       /* decoded from the filesystem encoding */
    PyCompilerFlags *flags);
27 28 29 30
PyAPI_FUNC(int) PyRun_InteractiveOneObject(
    FILE *fp,
    PyObject *filename,
    PyCompilerFlags *flags);
31 32 33 34 35 36 37 38 39 40 41
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
    FILE *fp,
    const char *filename,       /* decoded from the filesystem encoding */
    PyCompilerFlags *flags);

PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(
    const char *s,
    const char *filename,       /* decoded from the filesystem encoding */
    int start,
    PyCompilerFlags *flags,
    PyArena *arena);
42 43 44 45 46 47
PyAPI_FUNC(struct _mod *) PyParser_ASTFromStringObject(
    const char *s,
    PyObject *filename,
    int start,
    PyCompilerFlags *flags,
    PyArena *arena);
48 49 50 51 52
PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
    FILE *fp,
    const char *filename,       /* decoded from the filesystem encoding */
    const char* enc,
    int start,
53 54
    const char *ps1,
    const char *ps2,
55 56 57
    PyCompilerFlags *flags,
    int *errcode,
    PyArena *arena);
58 59 60 61 62
PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject(
    FILE *fp,
    PyObject *filename,
    const char* enc,
    int start,
63 64
    const char *ps1,
    const char *ps2,
65 66 67
    PyCompilerFlags *flags,
    int *errcode,
    PyArena *arena);
68 69 70
#endif

#ifndef PyParser_SimpleParseString
Jeremy Hylton's avatar
Jeremy Hylton committed
71
#define PyParser_SimpleParseString(S, B) \
72
    PyParser_SimpleParseStringFlags(S, B, 0)
Jeremy Hylton's avatar
Jeremy Hylton committed
73
#define PyParser_SimpleParseFile(FP, S, B) \
74
    PyParser_SimpleParseFileFlags(FP, S, B, 0)
75
#endif
76
PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
77
                                                           int);
78
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
79 80 81
PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *,
                                                                   const char *,
                                                                   int, int);
82
#endif
83
PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
84
                                                         int, int);
Guido van Rossum's avatar
Guido van Rossum committed
85

86
#ifndef Py_LIMITED_API
87 88
PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
                                         PyObject *, PyCompilerFlags *);
Jeremy Hylton's avatar
Jeremy Hylton committed
89

90 91 92 93 94 95 96 97
PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
    FILE *fp,
    const char *filename,       /* decoded from the filesystem encoding */
    int start,
    PyObject *globals,
    PyObject *locals,
    int closeit,
    PyCompilerFlags *flags);
98
#endif
Jeremy Hylton's avatar
Jeremy Hylton committed
99

100
#ifdef Py_LIMITED_API
101
PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
102
#else
103 104
#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
105 106 107 108 109 110
PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
    const char *str,
    const char *filename,       /* decoded from the filesystem encoding */
    int start,
    PyCompilerFlags *flags,
    int optimize);
111 112 113 114 115
PyAPI_FUNC(PyObject *) Py_CompileStringObject(
    const char *str,
    PyObject *filename, int start,
    PyCompilerFlags *flags,
    int optimize);
116
#endif
117 118 119 120
PyAPI_FUNC(struct symtable *) Py_SymtableString(
    const char *str,
    const char *filename,       /* decoded from the filesystem encoding */
    int start);
121
#ifndef Py_LIMITED_API
122 123 124 125
PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
    const char *str,
    PyObject *filename,
    int start);
126
#endif
127

128 129 130
PyAPI_FUNC(void) PyErr_Print(void);
PyAPI_FUNC(void) PyErr_PrintEx(int);
PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
Guido van Rossum's avatar
Guido van Rossum committed
131

132
#ifndef Py_LIMITED_API
Jeremy Hylton's avatar
Jeremy Hylton committed
133 134 135 136
/* Use macros for a bunch of old variants */
#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
#define PyRun_AnyFileEx(fp, name, closeit) \
137
    PyRun_AnyFileExFlags(fp, name, closeit, NULL)
Jeremy Hylton's avatar
Jeremy Hylton committed
138
#define PyRun_AnyFileFlags(fp, name, flags) \
139
    PyRun_AnyFileExFlags(fp, name, 0, flags)
140
#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
Jeremy Hylton's avatar
Jeremy Hylton committed
141 142 143 144 145
#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
#define PyRun_File(fp, p, s, g, l) \
146
    PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
Jeremy Hylton's avatar
Jeremy Hylton committed
147
#define PyRun_FileEx(fp, p, s, g, l, c) \
148
    PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
Jeremy Hylton's avatar
Jeremy Hylton committed
149
#define PyRun_FileFlags(fp, p, s, g, l, flags) \
150
    PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
151
#endif
Jeremy Hylton's avatar
Jeremy Hylton committed
152

153
/* Stuff with no proper home (yet) */
154
#ifndef Py_LIMITED_API
155
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
156
#endif
157
PyAPI_DATA(int) (*PyOS_InputHook)(void);
158
PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
159
#ifndef Py_LIMITED_API
160
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
161
#endif
162 163 164

/* Stack size, in "pointers" (so we get extra safety margins
   on 64-bit platforms).  On a 32-bit platform, this translates
165
   to an 8k margin. */
166 167
#define PYOS_STACK_MARGIN 2048

168
#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300
169 170 171 172
/* Enable stack checking under Microsoft C */
#define USE_STACKCHECK
#endif

173
#ifdef USE_STACKCHECK
174
/* Check that we aren't overflowing our stack */
175
PyAPI_FUNC(int) PyOS_CheckStack(void);
176
#endif
177

178 179 180 181
#ifdef __cplusplus
}
#endif
#endif /* !Py_PYTHONRUN_H */