Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 | |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 2 | /* Interfaces to parse and execute pieces of python code */ |
| 3 | |
Fred Drake | 3cf4d2b | 2000-07-09 00:55:06 +0000 | [diff] [blame] | 4 | #ifndef Py_PYTHONRUN_H |
| 5 | #define Py_PYTHONRUN_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
Guido van Rossum | 57d8e3f | 1997-07-19 19:50:52 +0000 | [diff] [blame] | 9 | |
Tim Peters | 2bbdba3 | 2002-04-12 01:20:10 +0000 | [diff] [blame] | 10 | #define PyCF_MASK (CO_FUTURE_DIVISION) |
| 11 | #define PyCF_MASK_OBSOLETE (CO_GENERATOR_ALLOWED | CO_NESTED) |
Just van Rossum | 3aaf42c | 2003-02-10 08:21:10 +0000 | [diff] [blame] | 12 | #define PyCF_SOURCE_IS_UTF8 0x0100 |
Guido van Rossum | 4b499dd3 | 2003-02-13 22:07:59 +0000 | [diff] [blame] | 13 | #define PyCF_DONT_IMPLY_DEDENT 0x0200 |
Tim Peters | e2c18e9 | 2001-08-17 20:47:47 +0000 | [diff] [blame] | 14 | |
Jeremy Hylton | 9f324e9 | 2001-03-01 22:59:14 +0000 | [diff] [blame] | 15 | typedef struct { |
Jeremy Hylton | fdd12f6 | 2001-08-10 21:38:04 +0000 | [diff] [blame] | 16 | int cf_flags; /* bitmask of CO_xxx flags relevant to future */ |
Jeremy Hylton | 9f324e9 | 2001-03-01 22:59:14 +0000 | [diff] [blame] | 17 | } PyCompilerFlags; |
| 18 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 19 | PyAPI_FUNC(void) Py_SetProgramName(char *); |
| 20 | PyAPI_FUNC(char *) Py_GetProgramName(void); |
Guido van Rossum | 66d4b90 | 1998-02-06 22:28:05 +0000 | [diff] [blame] | 21 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 22 | PyAPI_FUNC(void) Py_SetPythonHome(char *); |
| 23 | PyAPI_FUNC(char *) Py_GetPythonHome(void); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 24 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 25 | PyAPI_FUNC(void) Py_Initialize(void); |
| 26 | PyAPI_FUNC(void) Py_Finalize(void); |
| 27 | PyAPI_FUNC(int) Py_IsInitialized(void); |
| 28 | PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); |
| 29 | PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 30 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 31 | PyAPI_FUNC(int) PyRun_AnyFile(FILE *, const char *); |
| 32 | PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *, const char *, int); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 33 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 34 | PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *); |
| 35 | PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *); |
Jeremy Hylton | bc32024 | 2001-03-22 02:47:58 +0000 | [diff] [blame] | 36 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 37 | PyAPI_FUNC(int) PyRun_SimpleString(const char *); |
| 38 | PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); |
| 39 | PyAPI_FUNC(int) PyRun_SimpleFile(FILE *, const char *); |
| 40 | PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *, const char *, int); |
| 41 | PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *); |
| 42 | PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *, const char *); |
| 43 | PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *); |
| 44 | PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *, const char *); |
| 45 | PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 46 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 47 | PyAPI_FUNC(struct _node *) PyParser_SimpleParseString(const char *, int); |
| 48 | PyAPI_FUNC(struct _node *) PyParser_SimpleParseFile(FILE *, const char *, int); |
| 49 | PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, int); |
| 50 | PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *, |
| 51 | const char *, |
Thomas Heller | 6b17abf | 2002-07-09 09:23:27 +0000 | [diff] [blame] | 52 | int, |
| 53 | int); |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 54 | PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, |
Tim Peters | fe2127d | 2001-07-16 05:37:24 +0000 | [diff] [blame] | 55 | int, int); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 56 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 57 | PyAPI_FUNC(PyObject *) PyRun_String(const char *, int, PyObject *, PyObject *); |
| 58 | PyAPI_FUNC(PyObject *) PyRun_File(FILE *, const char *, int, PyObject *, PyObject *); |
| 59 | PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *, const char *, int, |
Guido van Rossum | 0df002c | 2000-08-27 19:21:52 +0000 | [diff] [blame] | 60 | PyObject *, PyObject *, int); |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 61 | PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, PyObject *, |
Jeremy Hylton | bc32024 | 2001-03-22 02:47:58 +0000 | [diff] [blame] | 62 | PyCompilerFlags *); |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 63 | PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *, const char *, int, PyObject *, |
Jeremy Hylton | bc32024 | 2001-03-22 02:47:58 +0000 | [diff] [blame] | 64 | PyObject *, PyCompilerFlags *); |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 65 | PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, PyObject *, |
Jeremy Hylton | bc32024 | 2001-03-22 02:47:58 +0000 | [diff] [blame] | 66 | PyObject *, int, PyCompilerFlags *); |
Guido van Rossum | 5b72218 | 1993-03-30 17:46:03 +0000 | [diff] [blame] | 67 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 68 | PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int); |
| 69 | PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int, |
Jeremy Hylton | bc32024 | 2001-03-22 02:47:58 +0000 | [diff] [blame] | 70 | PyCompilerFlags *); |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 71 | PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 72 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 73 | PyAPI_FUNC(void) PyErr_Print(void); |
| 74 | PyAPI_FUNC(void) PyErr_PrintEx(int); |
| 75 | PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); |
Guido van Rossum | c6cf1dd | 1994-09-07 14:35:10 +0000 | [diff] [blame] | 76 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 77 | PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 78 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 79 | PyAPI_FUNC(void) Py_Exit(int); |
Fred Drake | 3cf4d2b | 2000-07-09 00:55:06 +0000 | [diff] [blame] | 80 | |
Martin v. Löwis | 95292d6 | 2002-12-11 14:04:59 +0000 | [diff] [blame] | 81 | PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); |
Guido van Rossum | 5c4998b | 1997-02-14 19:51:34 +0000 | [diff] [blame] | 82 | |
Mark Hammond | fe51c6d | 2002-08-02 02:27:13 +0000 | [diff] [blame] | 83 | /* Bootstrap */ |
| 84 | PyAPI_FUNC(int) Py_Main(int argc, char **argv); |
| 85 | |
Guido van Rossum | 57d8e3f | 1997-07-19 19:50:52 +0000 | [diff] [blame] | 86 | /* In getpath.c */ |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 87 | PyAPI_FUNC(char *) Py_GetProgramFullPath(void); |
| 88 | PyAPI_FUNC(char *) Py_GetPrefix(void); |
| 89 | PyAPI_FUNC(char *) Py_GetExecPrefix(void); |
| 90 | PyAPI_FUNC(char *) Py_GetPath(void); |
Guido van Rossum | 57d8e3f | 1997-07-19 19:50:52 +0000 | [diff] [blame] | 91 | |
| 92 | /* In their own files */ |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 93 | PyAPI_FUNC(const char *) Py_GetVersion(void); |
| 94 | PyAPI_FUNC(const char *) Py_GetPlatform(void); |
| 95 | PyAPI_FUNC(const char *) Py_GetCopyright(void); |
| 96 | PyAPI_FUNC(const char *) Py_GetCompiler(void); |
| 97 | PyAPI_FUNC(const char *) Py_GetBuildInfo(void); |
Guido van Rossum | 57d8e3f | 1997-07-19 19:50:52 +0000 | [diff] [blame] | 98 | |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 99 | /* Internal -- various one-time initializations */ |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 100 | PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); |
| 101 | PyAPI_FUNC(PyObject *) _PySys_Init(void); |
| 102 | PyAPI_FUNC(void) _PyImport_Init(void); |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 103 | PyAPI_FUNC(void) _PyExc_Init(void); |
Just van Rossum | 52e14d6 | 2002-12-30 22:08:05 +0000 | [diff] [blame] | 104 | PyAPI_FUNC(void) _PyImportHooks_Init(void); |
Neal Norwitz | b2501f4 | 2002-12-31 03:42:13 +0000 | [diff] [blame] | 105 | PyAPI_FUNC(int) _PyFrame_Init(void); |
Neal Norwitz | dc392e3 | 2003-01-01 15:18:32 +0000 | [diff] [blame] | 106 | PyAPI_FUNC(int) _PyInt_Init(void); |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 107 | |
Guido van Rossum | 8e5e446 | 1997-08-12 14:57:21 +0000 | [diff] [blame] | 108 | /* Various internal finalizers */ |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 109 | PyAPI_FUNC(void) _PyExc_Fini(void); |
| 110 | PyAPI_FUNC(void) _PyImport_Fini(void); |
| 111 | PyAPI_FUNC(void) PyMethod_Fini(void); |
| 112 | PyAPI_FUNC(void) PyFrame_Fini(void); |
| 113 | PyAPI_FUNC(void) PyCFunction_Fini(void); |
| 114 | PyAPI_FUNC(void) PyTuple_Fini(void); |
| 115 | PyAPI_FUNC(void) PyString_Fini(void); |
| 116 | PyAPI_FUNC(void) PyInt_Fini(void); |
| 117 | PyAPI_FUNC(void) PyFloat_Fini(void); |
| 118 | PyAPI_FUNC(void) PyOS_FiniInterrupts(void); |
Guido van Rossum | 8e5e446 | 1997-08-12 14:57:21 +0000 | [diff] [blame] | 119 | |
Guido van Rossum | 3fb1aea | 1997-08-12 15:14:22 +0000 | [diff] [blame] | 120 | /* Stuff with no proper home (yet) */ |
Martin v. Löwis | 566f6af | 2002-10-26 14:39:10 +0000 | [diff] [blame] | 121 | PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *); |
Mark Hammond | 5d54667 | 2002-08-12 13:06:35 +0000 | [diff] [blame] | 122 | PyAPI_DATA(int) (*PyOS_InputHook)(void); |
Martin v. Löwis | 566f6af | 2002-10-26 14:39:10 +0000 | [diff] [blame] | 123 | PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *); |
Fredrik Lundh | 2f15b25 | 2000-08-27 19:15:31 +0000 | [diff] [blame] | 124 | |
| 125 | /* Stack size, in "pointers" (so we get extra safety margins |
| 126 | on 64-bit platforms). On a 32-bit platform, this translates |
| 127 | to a 8k margin. */ |
| 128 | #define PYOS_STACK_MARGIN 2048 |
| 129 | |
Trent Mick | 0a7af40 | 2000-10-11 17:18:11 +0000 | [diff] [blame] | 130 | #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) |
Fredrik Lundh | 2f15b25 | 2000-08-27 19:15:31 +0000 | [diff] [blame] | 131 | /* Enable stack checking under Microsoft C */ |
| 132 | #define USE_STACKCHECK |
| 133 | #endif |
| 134 | |
Jack Jansen | 275abb3 | 2000-08-07 21:00:42 +0000 | [diff] [blame] | 135 | #ifdef USE_STACKCHECK |
Fredrik Lundh | 2f15b25 | 2000-08-27 19:15:31 +0000 | [diff] [blame] | 136 | /* Check that we aren't overflowing our stack */ |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 137 | PyAPI_FUNC(int) PyOS_CheckStack(void); |
Jack Jansen | 275abb3 | 2000-08-07 21:00:42 +0000 | [diff] [blame] | 138 | #endif |
Guido van Rossum | 3fb1aea | 1997-08-12 15:14:22 +0000 | [diff] [blame] | 139 | |
Guido van Rossum | c7247ce | 2000-09-16 16:31:31 +0000 | [diff] [blame] | 140 | /* Signals */ |
| 141 | typedef void (*PyOS_sighandler_t)(int); |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 142 | PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); |
| 143 | PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); |
Guido van Rossum | c7247ce | 2000-09-16 16:31:31 +0000 | [diff] [blame] | 144 | |
| 145 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 146 | #ifdef __cplusplus |
| 147 | } |
| 148 | #endif |
| 149 | #endif /* !Py_PYTHONRUN_H */ |