blob: 55e1ddd4eb193cc1c4c073a01a57e43a30ddadcd [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001
Guido van Rossum3f5da241990-12-20 15:06:42 +00002/* Interfaces to parse and execute pieces of python code */
3
Fred Drake3cf4d2b2000-07-09 00:55:06 +00004#ifndef Py_PYTHONRUN_H
5#define Py_PYTHONRUN_H
6#ifdef __cplusplus
7extern "C" {
8#endif
Guido van Rossum57d8e3f1997-07-19 19:50:52 +00009
Tim Peters5ba58662001-07-16 02:29:45 +000010/* These flags are named after the __future__ statements that introduced
11 them. May not remain true for later additions, so fiddle this comment
12 accordingly then. */
13#define PyCF_NESTED_SCOPES (0x00000001UL)
14#define PyCF_GENERATORS (0x00000002UL)
Guido van Rossum4668b002001-08-08 05:00:18 +000015#define PyCF_DIVISION (0x00000004UL)
Jeremy Hylton9f324e92001-03-01 22:59:14 +000016typedef struct {
Tim Peters5ba58662001-07-16 02:29:45 +000017 unsigned long cf_flags; /* bitmask of PyCF_xxx flags */
Jeremy Hylton9f324e92001-03-01 22:59:14 +000018} PyCompilerFlags;
19
Fred Drake3cf4d2b2000-07-09 00:55:06 +000020DL_IMPORT(void) Py_SetProgramName(char *);
21DL_IMPORT(char *) Py_GetProgramName(void);
Guido van Rossum66d4b901998-02-06 22:28:05 +000022
Fred Drake3cf4d2b2000-07-09 00:55:06 +000023DL_IMPORT(void) Py_SetPythonHome(char *);
24DL_IMPORT(char *) Py_GetPythonHome(void);
Guido van Rossum3f5da241990-12-20 15:06:42 +000025
Fred Drake3cf4d2b2000-07-09 00:55:06 +000026DL_IMPORT(void) Py_Initialize(void);
27DL_IMPORT(void) Py_Finalize(void);
28DL_IMPORT(int) Py_IsInitialized(void);
29DL_IMPORT(PyThreadState *) Py_NewInterpreter(void);
30DL_IMPORT(void) Py_EndInterpreter(PyThreadState *);
Guido van Rossum3f5da241990-12-20 15:06:42 +000031
Fred Drake3cf4d2b2000-07-09 00:55:06 +000032DL_IMPORT(int) PyRun_AnyFile(FILE *, char *);
Guido van Rossum0df002c2000-08-27 19:21:52 +000033DL_IMPORT(int) PyRun_AnyFileEx(FILE *, char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000034
Jeremy Hyltonbc320242001-03-22 02:47:58 +000035DL_IMPORT(int) PyRun_AnyFileFlags(FILE *, char *, PyCompilerFlags *);
36DL_IMPORT(int) PyRun_AnyFileExFlags(FILE *, char *, int, PyCompilerFlags *);
37
Fred Drake3cf4d2b2000-07-09 00:55:06 +000038DL_IMPORT(int) PyRun_SimpleString(char *);
39DL_IMPORT(int) PyRun_SimpleFile(FILE *, char *);
Guido van Rossum0df002c2000-08-27 19:21:52 +000040DL_IMPORT(int) PyRun_SimpleFileEx(FILE *, char *, int);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000041DL_IMPORT(int) PyRun_SimpleFileExFlags(FILE *, char *, int, PyCompilerFlags *);
Fred Drake3cf4d2b2000-07-09 00:55:06 +000042DL_IMPORT(int) PyRun_InteractiveOne(FILE *, char *);
Jeremy Hylton9f324e92001-03-01 22:59:14 +000043DL_IMPORT(int) PyRun_InteractiveOneFlags(FILE *, char *, PyCompilerFlags *);
Fred Drake3cf4d2b2000-07-09 00:55:06 +000044DL_IMPORT(int) PyRun_InteractiveLoop(FILE *, char *);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000045DL_IMPORT(int) PyRun_InteractiveLoopFlags(FILE *, char *, PyCompilerFlags *);
Guido van Rossum3f5da241990-12-20 15:06:42 +000046
Fred Drake3cf4d2b2000-07-09 00:55:06 +000047DL_IMPORT(struct _node *) PyParser_SimpleParseString(char *, int);
48DL_IMPORT(struct _node *) PyParser_SimpleParseFile(FILE *, char *, int);
Tim Petersfe2127d2001-07-16 05:37:24 +000049DL_IMPORT(struct _node *) PyParser_SimpleParseStringFlags(char *, int, int);
50DL_IMPORT(struct _node *) PyParser_SimpleParseFileFlags(FILE *, char *,
51 int, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000052
Fred Drake3cf4d2b2000-07-09 00:55:06 +000053DL_IMPORT(PyObject *) PyRun_String(char *, int, PyObject *, PyObject *);
54DL_IMPORT(PyObject *) PyRun_File(FILE *, char *, int, PyObject *, PyObject *);
Guido van Rossum0df002c2000-08-27 19:21:52 +000055DL_IMPORT(PyObject *) PyRun_FileEx(FILE *, char *, int,
56 PyObject *, PyObject *, int);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000057DL_IMPORT(PyObject *) PyRun_StringFlags(char *, int, PyObject *, PyObject *,
58 PyCompilerFlags *);
59DL_IMPORT(PyObject *) PyRun_FileFlags(FILE *, char *, int, PyObject *,
60 PyObject *, PyCompilerFlags *);
61DL_IMPORT(PyObject *) PyRun_FileExFlags(FILE *, char *, int, PyObject *,
62 PyObject *, int, PyCompilerFlags *);
Guido van Rossum5b722181993-03-30 17:46:03 +000063
Fred Drake3cf4d2b2000-07-09 00:55:06 +000064DL_IMPORT(PyObject *) Py_CompileString(char *, char *, int);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000065DL_IMPORT(PyObject *) Py_CompileStringFlags(char *, char *, int,
66 PyCompilerFlags *);
Jeremy Hylton4b38da62001-02-02 18:19:15 +000067DL_IMPORT(struct symtable *) Py_SymtableString(char *, char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000068
Fred Drake3cf4d2b2000-07-09 00:55:06 +000069DL_IMPORT(void) PyErr_Print(void);
70DL_IMPORT(void) PyErr_PrintEx(int);
Ka-Ping Yeeb5c51322001-03-23 02:46:52 +000071DL_IMPORT(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
Guido van Rossumc6cf1dd1994-09-07 14:35:10 +000072
Fred Drake3cf4d2b2000-07-09 00:55:06 +000073DL_IMPORT(int) Py_AtExit(void (*func)(void));
Guido van Rossuma3309961993-07-28 09:05:47 +000074
Fred Drake3cf4d2b2000-07-09 00:55:06 +000075DL_IMPORT(void) Py_Exit(int);
76
77DL_IMPORT(int) Py_FdIsInteractive(FILE *, char *);
Guido van Rossum5c4998b1997-02-14 19:51:34 +000078
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000079/* In getpath.c */
Fred Drake3cf4d2b2000-07-09 00:55:06 +000080DL_IMPORT(char *) Py_GetProgramFullPath(void);
81DL_IMPORT(char *) Py_GetPrefix(void);
82DL_IMPORT(char *) Py_GetExecPrefix(void);
83DL_IMPORT(char *) Py_GetPath(void);
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000084
85/* In their own files */
Fred Drake3cf4d2b2000-07-09 00:55:06 +000086DL_IMPORT(const char *) Py_GetVersion(void);
87DL_IMPORT(const char *) Py_GetPlatform(void);
88DL_IMPORT(const char *) Py_GetCopyright(void);
89DL_IMPORT(const char *) Py_GetCompiler(void);
90DL_IMPORT(const char *) Py_GetBuildInfo(void);
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000091
Guido van Rossum29e46a91997-08-02 02:56:48 +000092/* Internal -- various one-time initializations */
Fred Drake3cf4d2b2000-07-09 00:55:06 +000093DL_IMPORT(PyObject *) _PyBuiltin_Init(void);
94DL_IMPORT(PyObject *) _PySys_Init(void);
95DL_IMPORT(void) _PyImport_Init(void);
Tim Peters6d6c1a32001-08-02 04:15:00 +000096DL_IMPORT(void) _PyExc_Init(void);
Guido van Rossum29e46a91997-08-02 02:56:48 +000097
Guido van Rossum8e5e4461997-08-12 14:57:21 +000098/* Various internal finalizers */
Tim Peters6d6c1a32001-08-02 04:15:00 +000099DL_IMPORT(void) _PyExc_Fini(void);
Fred Drake3cf4d2b2000-07-09 00:55:06 +0000100DL_IMPORT(void) _PyImport_Fini(void);
101DL_IMPORT(void) PyMethod_Fini(void);
102DL_IMPORT(void) PyFrame_Fini(void);
103DL_IMPORT(void) PyCFunction_Fini(void);
104DL_IMPORT(void) PyTuple_Fini(void);
105DL_IMPORT(void) PyString_Fini(void);
106DL_IMPORT(void) PyInt_Fini(void);
107DL_IMPORT(void) PyFloat_Fini(void);
108DL_IMPORT(void) PyOS_FiniInterrupts(void);
Guido van Rossum8e5e4461997-08-12 14:57:21 +0000109
Guido van Rossum3fb1aea1997-08-12 15:14:22 +0000110/* Stuff with no proper home (yet) */
Fred Drake3cf4d2b2000-07-09 00:55:06 +0000111DL_IMPORT(char *) PyOS_Readline(char *);
112extern DL_IMPORT(int) (*PyOS_InputHook)(void);
113extern DL_IMPORT(char) *(*PyOS_ReadlineFunctionPointer)(char *);
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000114
115/* Stack size, in "pointers" (so we get extra safety margins
116 on 64-bit platforms). On a 32-bit platform, this translates
117 to a 8k margin. */
118#define PYOS_STACK_MARGIN 2048
119
Trent Mick0a7af402000-10-11 17:18:11 +0000120#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER)
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000121/* Enable stack checking under Microsoft C */
122#define USE_STACKCHECK
123#endif
124
Jack Jansen275abb32000-08-07 21:00:42 +0000125#ifdef USE_STACKCHECK
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000126/* Check that we aren't overflowing our stack */
127DL_IMPORT(int) PyOS_CheckStack(void);
Jack Jansen275abb32000-08-07 21:00:42 +0000128#endif
Guido van Rossum3fb1aea1997-08-12 15:14:22 +0000129
Guido van Rossumc7247ce2000-09-16 16:31:31 +0000130/* Signals */
131typedef void (*PyOS_sighandler_t)(int);
132DL_IMPORT(PyOS_sighandler_t) PyOS_getsig(int);
133DL_IMPORT(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
134
135
Guido van Rossuma3309961993-07-28 09:05:47 +0000136#ifdef __cplusplus
137}
138#endif
139#endif /* !Py_PYTHONRUN_H */