source: python/vendor/Python-2.6.5/Include/ceval.h

Last change on this file was 2, checked in by Yuri Dario, 15 years ago

Initial import for vendor code.

  • Property svn:eol-style set to native
File size: 4.8 KB
Line 
1#ifndef Py_CEVAL_H
2#define Py_CEVAL_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7
8/* Interface to random parts in ceval.c */
9
10PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
11 PyObject *, PyObject *, PyObject *);
12
13/* DLL-level Backwards compatibility: */
14#undef PyEval_CallObject
15PyAPI_FUNC(PyObject *) PyEval_CallObject(PyObject *, PyObject *);
16
17/* Inline this */
18#define PyEval_CallObject(func,arg) \
19 PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
20
21PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
22 const char *format, ...);
23PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
24 const char *methodname,
25 const char *format, ...);
26
27PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
28PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
29
30struct _frame; /* Avoid including frameobject.h */
31
32PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
33PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
34PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
35PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
36PyAPI_FUNC(int) PyEval_GetRestricted(void);
37
38/* Look at the current frame's (if any) code's co_flags, and turn on
39 the corresponding compiler flags in cf->cf_flags. Return 1 if any
40 flag was set, else return 0. */
41PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
42
43PyAPI_FUNC(int) Py_FlushLine(void);
44
45PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
46PyAPI_FUNC(int) Py_MakePendingCalls(void);
47
48/* Protection against deeply nested recursive calls */
49PyAPI_FUNC(void) Py_SetRecursionLimit(int);
50PyAPI_FUNC(int) Py_GetRecursionLimit(void);
51
52#define Py_EnterRecursiveCall(where) \
53 (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
54 _Py_CheckRecursiveCall(where))
55#define Py_LeaveRecursiveCall() \
56 (--PyThreadState_GET()->recursion_depth)
57PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where);
58PyAPI_DATA(int) _Py_CheckRecursionLimit;
59#ifdef USE_STACKCHECK
60# define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit)
61#else
62# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
63#endif
64
65PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
66PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
67
68PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
69PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
70PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
71
72/* this used to be handled on a per-thread basis - now just two globals */
73PyAPI_DATA(volatile int) _Py_Ticker;
74PyAPI_DATA(int) _Py_CheckInterval;
75
76/* Interface for threads.
77
78 A module that plans to do a blocking system call (or something else
79 that lasts a long time and doesn't touch Python data) can allow other
80 threads to run as follows:
81
82 ...preparations here...
83 Py_BEGIN_ALLOW_THREADS
84 ...blocking system call here...
85 Py_END_ALLOW_THREADS
86 ...interpret result here...
87
88 The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
89 {}-surrounded block.
90 To leave the block in the middle (e.g., with return), you must insert
91 a line containing Py_BLOCK_THREADS before the return, e.g.
92
93 if (...premature_exit...) {
94 Py_BLOCK_THREADS
95 PyErr_SetFromErrno(PyExc_IOError);
96 return NULL;
97 }
98
99 An alternative is:
100
101 Py_BLOCK_THREADS
102 if (...premature_exit...) {
103 PyErr_SetFromErrno(PyExc_IOError);
104 return NULL;
105 }
106 Py_UNBLOCK_THREADS
107
108 For convenience, that the value of 'errno' is restored across
109 Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
110
111 WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
112 Py_END_ALLOW_THREADS!!!
113
114 The function PyEval_InitThreads() should be called only from
115 initthread() in "threadmodule.c".
116
117 Note that not yet all candidates have been converted to use this
118 mechanism!
119*/
120
121PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
122PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
123
124#ifdef WITH_THREAD
125
126PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
127PyAPI_FUNC(void) PyEval_InitThreads(void);
128PyAPI_FUNC(void) PyEval_AcquireLock(void);
129PyAPI_FUNC(void) PyEval_ReleaseLock(void);
130PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
131PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
132PyAPI_FUNC(void) PyEval_ReInitThreads(void);
133
134#define Py_BEGIN_ALLOW_THREADS { \
135 PyThreadState *_save; \
136 _save = PyEval_SaveThread();
137#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
138#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
139#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
140 }
141
142#else /* !WITH_THREAD */
143
144#define Py_BEGIN_ALLOW_THREADS {
145#define Py_BLOCK_THREADS
146#define Py_UNBLOCK_THREADS
147#define Py_END_ALLOW_THREADS }
148
149#endif /* !WITH_THREAD */
150
151PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
152
153
154#ifdef __cplusplus
155}
156#endif
157#endif /* !Py_CEVAL_H */
Note: See TracBrowser for help on using the repository browser.