Use full package paths in imports.
[python/dscho.git] / Include / ceval.h
blobae4d8583c6cc96226cf11d8bb809b5365f76cc6d
1 #ifndef Py_CEVAL_H
2 #define Py_CEVAL_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
8 /* Interface to random parts in ceval.c */
10 DL_IMPORT(PyObject *) PyEval_CallObjectWithKeywords
11 (PyObject *, PyObject *, PyObject *);
13 /* DLL-level Backwards compatibility: */
14 #undef PyEval_CallObject
15 DL_IMPORT(PyObject *) PyEval_CallObject(PyObject *, PyObject *);
17 /* Inline this */
18 #define PyEval_CallObject(func,arg) \
19 PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
21 DL_IMPORT(PyObject *) PyEval_CallFunction(PyObject *obj, char *format, ...);
22 DL_IMPORT(PyObject *) PyEval_CallMethod(PyObject *obj,
23 char *methodname, char *format, ...);
25 DL_IMPORT(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
26 DL_IMPORT(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
28 DL_IMPORT(PyObject *) PyEval_GetBuiltins(void);
29 DL_IMPORT(PyObject *) PyEval_GetGlobals(void);
30 DL_IMPORT(PyObject *) PyEval_GetLocals(void);
31 DL_IMPORT(PyObject *) PyEval_GetOwner(void);
32 DL_IMPORT(PyObject *) PyEval_GetFrame(void);
33 DL_IMPORT(int) PyEval_GetRestricted(void);
35 /* Look at the current frame's (if any) code's co_flags, and turn on
36 the corresponding compiler flags in cf->cf_flags. Return 1 if any
37 flag was set, else return 0. */
38 DL_IMPORT(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
40 DL_IMPORT(int) Py_FlushLine(void);
42 DL_IMPORT(int) Py_AddPendingCall(int (*func)(void *), void *arg);
43 DL_IMPORT(int) Py_MakePendingCalls(void);
45 DL_IMPORT(void) Py_SetRecursionLimit(int);
46 DL_IMPORT(int) Py_GetRecursionLimit(void);
48 DL_IMPORT(char *) PyEval_GetFuncName(PyObject *);
49 DL_IMPORT(char *) PyEval_GetFuncDesc(PyObject *);
51 /* Interface for threads.
53 A module that plans to do a blocking system call (or something else
54 that lasts a long time and doesn't touch Python data) can allow other
55 threads to run as follows:
57 ...preparations here...
58 Py_BEGIN_ALLOW_THREADS
59 ...blocking system call here...
60 Py_END_ALLOW_THREADS
61 ...interpret result here...
63 The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
64 {}-surrounded block.
65 To leave the block in the middle (e.g., with return), you must insert
66 a line containing Py_BLOCK_THREADS before the return, e.g.
68 if (...premature_exit...) {
69 Py_BLOCK_THREADS
70 PyErr_SetFromErrno(PyExc_IOError);
71 return NULL;
74 An alternative is:
76 Py_BLOCK_THREADS
77 if (...premature_exit...) {
78 PyErr_SetFromErrno(PyExc_IOError);
79 return NULL;
81 Py_UNBLOCK_THREADS
83 For convenience, that the value of 'errno' is restored across
84 Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
86 WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
87 Py_END_ALLOW_THREADS!!!
89 The function PyEval_InitThreads() should be called only from
90 initthread() in "threadmodule.c".
92 Note that not yet all candidates have been converted to use this
93 mechanism!
96 extern DL_IMPORT(PyThreadState *) PyEval_SaveThread(void);
97 extern DL_IMPORT(void) PyEval_RestoreThread(PyThreadState *);
99 #ifdef WITH_THREAD
101 extern DL_IMPORT(void) PyEval_InitThreads(void);
102 extern DL_IMPORT(void) PyEval_AcquireLock(void);
103 extern DL_IMPORT(void) PyEval_ReleaseLock(void);
104 extern DL_IMPORT(void) PyEval_AcquireThread(PyThreadState *tstate);
105 extern DL_IMPORT(void) PyEval_ReleaseThread(PyThreadState *tstate);
106 extern DL_IMPORT(void) PyEval_ReInitThreads(void);
108 #define Py_BEGIN_ALLOW_THREADS { \
109 PyThreadState *_save; \
110 _save = PyEval_SaveThread();
111 #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
112 #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
113 #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
116 #else /* !WITH_THREAD */
118 #define Py_BEGIN_ALLOW_THREADS {
119 #define Py_BLOCK_THREADS
120 #define Py_UNBLOCK_THREADS
121 #define Py_END_ALLOW_THREADS }
123 #endif /* !WITH_THREAD */
125 extern DL_IMPORT(int) _PyEval_SliceIndex(PyObject *, int *);
128 #ifdef __cplusplus
130 #endif
131 #endif /* !Py_CEVAL_H */