Coverage Report

Created: 2022-07-08 09:39

/home/mdboom/Work/builds/cpython/Include/ceval.h
Line
Count
Source
1
/* Interface to random parts in ceval.c */
2
3
#ifndef Py_CEVAL_H
4
#define Py_CEVAL_H
5
#ifdef __cplusplus
6
extern "C" {
7
#endif
8
9
10
PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
11
12
PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
13
                                         PyObject *globals,
14
                                         PyObject *locals,
15
                                         PyObject *const *args, int argc,
16
                                         PyObject *const *kwds, int kwdc,
17
                                         PyObject *const *defs, int defc,
18
                                         PyObject *kwdefs, PyObject *closure);
19
20
/* PyEval_CallObjectWithKeywords(), PyEval_CallObject(), PyEval_CallFunction
21
 * and PyEval_CallMethod are deprecated. Since they are officially part of the
22
 * stable ABI (PEP 384), they must be kept for backward compatibility.
23
 * PyObject_Call(), PyObject_CallFunction() and PyObject_CallMethod() are
24
 * recommended to call a callable object.
25
 */
26
27
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
28
    PyObject *callable,
29
    PyObject *args,
30
    PyObject *kwargs);
31
32
/* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
33
#define PyEval_CallObject(callable, arg) \
34
    PyEval_CallObjectWithKeywords((callable), (arg), _PyObject_CAST(_Py_NULL))
35
36
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
37
    PyObject *callable, const char *format, ...);
38
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod(
39
    PyObject *obj, const char *name, const char *format, ...);
40
41
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
42
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
43
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
44
PyAPI_FUNC(PyFrameObject *) PyEval_GetFrame(void);
45
46
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
47
PyAPI_FUNC(int) Py_MakePendingCalls(void);
48
49
/* Protection against deeply nested recursive calls
50
51
   In Python 3.0, this protection has two levels:
52
   * normal anti-recursion protection is triggered when the recursion level
53
     exceeds the current recursion limit. It raises a RecursionError, and sets
54
     the "overflowed" flag in the thread state structure. This flag
55
     temporarily *disables* the normal protection; this allows cleanup code
56
     to potentially outgrow the recursion limit while processing the
57
     RecursionError.
58
   * "last chance" anti-recursion protection is triggered when the recursion
59
     level exceeds "current recursion limit + 50". By construction, this
60
     protection can only be triggered when the "overflowed" flag is set. It
61
     means the cleanup code has itself gone into an infinite loop, or the
62
     RecursionError has been mistakingly ignored. When this protection is
63
     triggered, the interpreter aborts with a Fatal Error.
64
65
   In addition, the "overflowed" flag is automatically reset when the
66
   recursion level drops below "current recursion limit - 50". This heuristic
67
   is meant to ensure that the normal anti-recursion protection doesn't get
68
   disabled too long.
69
70
   Please note: this scheme has its own limitations. See:
71
   http://mail.python.org/pipermail/python-dev/2008-August/082106.html
72
   for some observations.
73
*/
74
PyAPI_FUNC(void) Py_SetRecursionLimit(int);
75
PyAPI_FUNC(int) Py_GetRecursionLimit(void);
76
77
PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where);
78
PyAPI_FUNC(void) Py_LeaveRecursiveCall(void);
79
80
PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
81
PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
82
83
PyAPI_FUNC(PyObject *) PyEval_EvalFrame(PyFrameObject *);
84
PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(PyFrameObject *f, int exc);
85
86
/* Interface for threads.
87
88
   A module that plans to do a blocking system call (or something else
89
   that lasts a long time and doesn't touch Python data) can allow other
90
   threads to run as follows:
91
92
    ...preparations here...
93
    Py_BEGIN_ALLOW_THREADS
94
    ...blocking system call here...
95
    Py_END_ALLOW_THREADS
96
    ...interpret result here...
97
98
   The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
99
   {}-surrounded block.
100
   To leave the block in the middle (e.g., with return), you must insert
101
   a line containing Py_BLOCK_THREADS before the return, e.g.
102
103
    if (...premature_exit...) {
104
        Py_BLOCK_THREADS
105
        PyErr_SetFromErrno(PyExc_OSError);
106
        return NULL;
107
    }
108
109
   An alternative is:
110
111
    Py_BLOCK_THREADS
112
    if (...premature_exit...) {
113
        PyErr_SetFromErrno(PyExc_OSError);
114
        return NULL;
115
    }
116
    Py_UNBLOCK_THREADS
117
118
   For convenience, that the value of 'errno' is restored across
119
   Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
120
121
   WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
122
   Py_END_ALLOW_THREADS!!!
123
124
   Note that not yet all candidates have been converted to use this
125
   mechanism!
126
*/
127
128
PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
129
PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
130
131
Py_DEPRECATED(3.9) PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
132
Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
133
/* PyEval_AcquireLock() and PyEval_ReleaseLock() are part of stable ABI.
134
 * They will be removed from this header file in the future version.
135
 * But they will be remained in ABI until Python 4.0.
136
 */
137
Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_AcquireLock(void);
138
Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_ReleaseLock(void);
139
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
140
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
141
142
#define Py_BEGIN_ALLOW_THREADS { \
143
                        PyThreadState *_save; \
144
                        _save = PyEval_SaveThread();
145
#define Py_BLOCK_THREADS        PyEval_RestoreThread(_save);
146
#define Py_UNBLOCK_THREADS      _save = PyEval_SaveThread();
147
#define Py_END_ALLOW_THREADS    PyEval_RestoreThread(_save); \
148
                 }
149
150
/* Masks and values used by FORMAT_VALUE opcode. */
151
#define FVC_MASK      0x3
152
#define FVC_NONE      0x0
153
#define FVC_STR       0x1
154
#define FVC_REPR      0x2
155
#define FVC_ASCII     0x3
156
#define FVS_MASK      0x4
157
#define FVS_HAVE_SPEC 0x4
158
159
#ifndef Py_LIMITED_API
160
#  define Py_CPYTHON_CEVAL_H
161
#  include "cpython/ceval.h"
162
#  undef Py_CPYTHON_CEVAL_H
163
#endif
164
165
#ifdef __cplusplus
166
}
167
#endif
168
#endif /* !Py_CEVAL_H */