Maintain backwards compatibility with python < 2.3 by dynamically
[python/dscho.git] / Include / pythonrun.h
blob746ba7ed93cc98e86064535d7cd1d319d7421e08
2 /* Interfaces to parse and execute pieces of python code */
4 #ifndef Py_PYTHONRUN_H
5 #define Py_PYTHONRUN_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 #define PyCF_MASK (CO_FUTURE_DIVISION)
11 #define PyCF_MASK_OBSOLETE (CO_GENERATOR_ALLOWED | CO_NESTED)
12 #define PyCF_SOURCE_IS_UTF8 0x0100
13 #define PyCF_DONT_IMPLY_DEDENT 0x0200
15 typedef struct {
16 int cf_flags; /* bitmask of CO_xxx flags relevant to future */
17 } PyCompilerFlags;
19 PyAPI_FUNC(void) Py_SetProgramName(char *);
20 PyAPI_FUNC(char *) Py_GetProgramName(void);
22 PyAPI_FUNC(void) Py_SetPythonHome(char *);
23 PyAPI_FUNC(char *) Py_GetPythonHome(void);
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 *);
31 PyAPI_FUNC(int) PyRun_AnyFile(FILE *, const char *);
32 PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *, const char *, int);
34 PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
35 PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
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 *);
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 *,
52 int,
53 int);
54 PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
55 int, int);
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,
60 PyObject *, PyObject *, int);
61 PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, PyObject *,
62 PyCompilerFlags *);
63 PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *, const char *, int, PyObject *,
64 PyObject *, PyCompilerFlags *);
65 PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, PyObject *,
66 PyObject *, int, PyCompilerFlags *);
68 PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
69 PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
70 PyCompilerFlags *);
71 PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
73 PyAPI_FUNC(void) PyErr_Print(void);
74 PyAPI_FUNC(void) PyErr_PrintEx(int);
75 PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
77 PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
79 PyAPI_FUNC(void) Py_Exit(int);
81 PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
83 /* Bootstrap */
84 PyAPI_FUNC(int) Py_Main(int argc, char **argv);
86 /* In getpath.c */
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);
92 /* In their own files */
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);
99 /* Internal -- various one-time initializations */
100 PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
101 PyAPI_FUNC(PyObject *) _PySys_Init(void);
102 PyAPI_FUNC(void) _PyImport_Init(void);
103 PyAPI_FUNC(void) _PyExc_Init(void);
104 PyAPI_FUNC(void) _PyImportHooks_Init(void);
105 PyAPI_FUNC(int) _PyFrame_Init(void);
106 PyAPI_FUNC(int) _PyInt_Init(void);
108 /* Various internal finalizers */
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);
120 /* Stuff with no proper home (yet) */
121 PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
122 PyAPI_DATA(int) (*PyOS_InputHook)(void);
123 PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
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
130 #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER)
131 /* Enable stack checking under Microsoft C */
132 #define USE_STACKCHECK
133 #endif
135 #ifdef USE_STACKCHECK
136 /* Check that we aren't overflowing our stack */
137 PyAPI_FUNC(int) PyOS_CheckStack(void);
138 #endif
140 /* Signals */
141 typedef void (*PyOS_sighandler_t)(int);
142 PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
143 PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
146 #ifdef __cplusplus
148 #endif
149 #endif /* !Py_PYTHONRUN_H */