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