jpayne@69: jpayne@69: /* Interfaces to parse and execute pieces of python code */ jpayne@69: jpayne@69: #ifndef Py_PYTHONRUN_H jpayne@69: #define Py_PYTHONRUN_H jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); jpayne@69: PyAPI_FUNC(int) PyRun_AnyFileExFlags( jpayne@69: FILE *fp, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: int closeit, jpayne@69: PyCompilerFlags *flags); jpayne@69: PyAPI_FUNC(int) PyRun_SimpleFileExFlags( jpayne@69: FILE *fp, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: int closeit, jpayne@69: PyCompilerFlags *flags); jpayne@69: PyAPI_FUNC(int) PyRun_InteractiveOneFlags( jpayne@69: FILE *fp, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: PyCompilerFlags *flags); jpayne@69: PyAPI_FUNC(int) PyRun_InteractiveOneObject( jpayne@69: FILE *fp, jpayne@69: PyObject *filename, jpayne@69: PyCompilerFlags *flags); jpayne@69: PyAPI_FUNC(int) PyRun_InteractiveLoopFlags( jpayne@69: FILE *fp, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: PyCompilerFlags *flags); jpayne@69: jpayne@69: PyAPI_FUNC(struct _mod *) PyParser_ASTFromString( jpayne@69: const char *s, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: int start, jpayne@69: PyCompilerFlags *flags, jpayne@69: PyArena *arena); jpayne@69: PyAPI_FUNC(struct _mod *) PyParser_ASTFromStringObject( jpayne@69: const char *s, jpayne@69: PyObject *filename, jpayne@69: int start, jpayne@69: PyCompilerFlags *flags, jpayne@69: PyArena *arena); jpayne@69: PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile( jpayne@69: FILE *fp, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: const char* enc, jpayne@69: int start, jpayne@69: const char *ps1, jpayne@69: const char *ps2, jpayne@69: PyCompilerFlags *flags, jpayne@69: int *errcode, jpayne@69: PyArena *arena); jpayne@69: PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject( jpayne@69: FILE *fp, jpayne@69: PyObject *filename, jpayne@69: const char* enc, jpayne@69: int start, jpayne@69: const char *ps1, jpayne@69: const char *ps2, jpayne@69: PyCompilerFlags *flags, jpayne@69: int *errcode, jpayne@69: PyArena *arena); jpayne@69: #endif jpayne@69: jpayne@69: #ifndef PyParser_SimpleParseString jpayne@69: #define PyParser_SimpleParseString(S, B) \ jpayne@69: PyParser_SimpleParseStringFlags(S, B, 0) jpayne@69: #define PyParser_SimpleParseFile(FP, S, B) \ jpayne@69: PyParser_SimpleParseFileFlags(FP, S, B, 0) jpayne@69: #endif jpayne@69: PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, jpayne@69: int); jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *, jpayne@69: const char *, jpayne@69: int, int); jpayne@69: #endif jpayne@69: PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, jpayne@69: int, int); jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, jpayne@69: PyObject *, PyCompilerFlags *); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyRun_FileExFlags( jpayne@69: FILE *fp, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: int start, jpayne@69: PyObject *globals, jpayne@69: PyObject *locals, jpayne@69: int closeit, jpayne@69: PyCompilerFlags *flags); jpayne@69: #endif jpayne@69: jpayne@69: #ifdef Py_LIMITED_API jpayne@69: PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int); jpayne@69: #else jpayne@69: #define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1) jpayne@69: #define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1) jpayne@69: PyAPI_FUNC(PyObject *) Py_CompileStringExFlags( jpayne@69: const char *str, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: int start, jpayne@69: PyCompilerFlags *flags, jpayne@69: int optimize); jpayne@69: PyAPI_FUNC(PyObject *) Py_CompileStringObject( jpayne@69: const char *str, jpayne@69: PyObject *filename, int start, jpayne@69: PyCompilerFlags *flags, jpayne@69: int optimize); jpayne@69: #endif jpayne@69: PyAPI_FUNC(struct symtable *) Py_SymtableString( jpayne@69: const char *str, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: int start); jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(const char *) _Py_SourceAsString( jpayne@69: PyObject *cmd, jpayne@69: const char *funcname, jpayne@69: const char *what, jpayne@69: PyCompilerFlags *cf, jpayne@69: PyObject **cmd_copy); jpayne@69: jpayne@69: PyAPI_FUNC(struct symtable *) Py_SymtableStringObject( jpayne@69: const char *str, jpayne@69: PyObject *filename, jpayne@69: int start); jpayne@69: jpayne@69: PyAPI_FUNC(struct symtable *) _Py_SymtableStringObjectFlags( jpayne@69: const char *str, jpayne@69: PyObject *filename, jpayne@69: int start, jpayne@69: PyCompilerFlags *flags); jpayne@69: #endif jpayne@69: jpayne@69: PyAPI_FUNC(void) PyErr_Print(void); jpayne@69: PyAPI_FUNC(void) PyErr_PrintEx(int); jpayne@69: PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: /* A function flavor is also exported by libpython. It is required when jpayne@69: libpython is accessed directly rather than using header files which defines jpayne@69: macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to jpayne@69: export functions in pythonXX.dll. */ jpayne@69: PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l); jpayne@69: PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name); jpayne@69: PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit); jpayne@69: PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *); jpayne@69: PyAPI_FUNC(int) PyRun_SimpleString(const char *s); jpayne@69: PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p); jpayne@69: PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c); jpayne@69: PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p); jpayne@69: PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p); jpayne@69: PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l); jpayne@69: PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c); jpayne@69: PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags); jpayne@69: jpayne@69: /* Use macros for a bunch of old variants */ jpayne@69: #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL) jpayne@69: #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL) jpayne@69: #define PyRun_AnyFileEx(fp, name, closeit) \ jpayne@69: PyRun_AnyFileExFlags(fp, name, closeit, NULL) jpayne@69: #define PyRun_AnyFileFlags(fp, name, flags) \ jpayne@69: PyRun_AnyFileExFlags(fp, name, 0, flags) jpayne@69: #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) jpayne@69: #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL) jpayne@69: #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL) jpayne@69: #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL) jpayne@69: #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL) jpayne@69: #define PyRun_File(fp, p, s, g, l) \ jpayne@69: PyRun_FileExFlags(fp, p, s, g, l, 0, NULL) jpayne@69: #define PyRun_FileEx(fp, p, s, g, l, c) \ jpayne@69: PyRun_FileExFlags(fp, p, s, g, l, c, NULL) jpayne@69: #define PyRun_FileFlags(fp, p, s, g, l, flags) \ jpayne@69: PyRun_FileExFlags(fp, p, s, g, l, 0, flags) jpayne@69: #endif jpayne@69: jpayne@69: /* Stuff with no proper home (yet) */ jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *); jpayne@69: #endif jpayne@69: PyAPI_DATA(int) (*PyOS_InputHook)(void); jpayne@69: PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *); jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState; jpayne@69: #endif jpayne@69: jpayne@69: /* Stack size, in "pointers" (so we get extra safety margins jpayne@69: on 64-bit platforms). On a 32-bit platform, this translates jpayne@69: to an 8k margin. */ jpayne@69: #define PYOS_STACK_MARGIN 2048 jpayne@69: jpayne@69: #if defined(WIN32) && !defined(MS_WIN64) && !defined(_M_ARM) && defined(_MSC_VER) && _MSC_VER >= 1300 jpayne@69: /* Enable stack checking under Microsoft C */ jpayne@69: #define USE_STACKCHECK jpayne@69: #endif jpayne@69: jpayne@69: #ifdef USE_STACKCHECK jpayne@69: /* Check that we aren't overflowing our stack */ jpayne@69: PyAPI_FUNC(int) PyOS_CheckStack(void); jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif /* !Py_PYTHONRUN_H */