Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:48

0001 /* Interface to random parts in ceval.c */
0002 
0003 #ifndef Py_CEVAL_H
0004 #define Py_CEVAL_H
0005 #ifdef __cplusplus
0006 extern "C" {
0007 #endif
0008 
0009 
0010 PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
0011 
0012 PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
0013                                          PyObject *globals,
0014                                          PyObject *locals,
0015                                          PyObject *const *args, int argc,
0016                                          PyObject *const *kwds, int kwdc,
0017                                          PyObject *const *defs, int defc,
0018                                          PyObject *kwdefs, PyObject *closure);
0019 
0020 /* PyEval_CallObjectWithKeywords(), PyEval_CallObject(), PyEval_CallFunction
0021  * and PyEval_CallMethod are deprecated. Since they are officially part of the
0022  * stable ABI (PEP 384), they must be kept for backward compatibility.
0023  * PyObject_Call(), PyObject_CallFunction() and PyObject_CallMethod() are
0024  * recommended to call a callable object.
0025  */
0026 
0027 Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
0028     PyObject *callable,
0029     PyObject *args,
0030     PyObject *kwargs);
0031 
0032 /* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
0033 #define PyEval_CallObject(callable, arg) \
0034     PyEval_CallObjectWithKeywords((callable), (arg), _PyObject_CAST(_Py_NULL))
0035 
0036 Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
0037     PyObject *callable, const char *format, ...);
0038 Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod(
0039     PyObject *obj, const char *name, const char *format, ...);
0040 
0041 PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
0042 PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
0043 PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
0044 PyAPI_FUNC(PyFrameObject *) PyEval_GetFrame(void);
0045 
0046 PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
0047 PyAPI_FUNC(int) Py_MakePendingCalls(void);
0048 
0049 /* Protection against deeply nested recursive calls
0050 
0051    In Python 3.0, this protection has two levels:
0052    * normal anti-recursion protection is triggered when the recursion level
0053      exceeds the current recursion limit. It raises a RecursionError, and sets
0054      the "overflowed" flag in the thread state structure. This flag
0055      temporarily *disables* the normal protection; this allows cleanup code
0056      to potentially outgrow the recursion limit while processing the
0057      RecursionError.
0058    * "last chance" anti-recursion protection is triggered when the recursion
0059      level exceeds "current recursion limit + 50". By construction, this
0060      protection can only be triggered when the "overflowed" flag is set. It
0061      means the cleanup code has itself gone into an infinite loop, or the
0062      RecursionError has been mistakingly ignored. When this protection is
0063      triggered, the interpreter aborts with a Fatal Error.
0064 
0065    In addition, the "overflowed" flag is automatically reset when the
0066    recursion level drops below "current recursion limit - 50". This heuristic
0067    is meant to ensure that the normal anti-recursion protection doesn't get
0068    disabled too long.
0069 
0070    Please note: this scheme has its own limitations. See:
0071    http://mail.python.org/pipermail/python-dev/2008-August/082106.html
0072    for some observations.
0073 */
0074 PyAPI_FUNC(void) Py_SetRecursionLimit(int);
0075 PyAPI_FUNC(int) Py_GetRecursionLimit(void);
0076 
0077 PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where);
0078 PyAPI_FUNC(void) Py_LeaveRecursiveCall(void);
0079 
0080 PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
0081 PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
0082 
0083 PyAPI_FUNC(PyObject *) PyEval_EvalFrame(PyFrameObject *);
0084 PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(PyFrameObject *f, int exc);
0085 
0086 /* Interface for threads.
0087 
0088    A module that plans to do a blocking system call (or something else
0089    that lasts a long time and doesn't touch Python data) can allow other
0090    threads to run as follows:
0091 
0092     ...preparations here...
0093     Py_BEGIN_ALLOW_THREADS
0094     ...blocking system call here...
0095     Py_END_ALLOW_THREADS
0096     ...interpret result here...
0097 
0098    The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
0099    {}-surrounded block.
0100    To leave the block in the middle (e.g., with return), you must insert
0101    a line containing Py_BLOCK_THREADS before the return, e.g.
0102 
0103     if (...premature_exit...) {
0104         Py_BLOCK_THREADS
0105         PyErr_SetFromErrno(PyExc_OSError);
0106         return NULL;
0107     }
0108 
0109    An alternative is:
0110 
0111     Py_BLOCK_THREADS
0112     if (...premature_exit...) {
0113         PyErr_SetFromErrno(PyExc_OSError);
0114         return NULL;
0115     }
0116     Py_UNBLOCK_THREADS
0117 
0118    For convenience, that the value of 'errno' is restored across
0119    Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
0120 
0121    WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
0122    Py_END_ALLOW_THREADS!!!
0123 
0124    Note that not yet all candidates have been converted to use this
0125    mechanism!
0126 */
0127 
0128 PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
0129 PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
0130 
0131 Py_DEPRECATED(3.9) PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
0132 Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
0133 /* PyEval_AcquireLock() and PyEval_ReleaseLock() are part of stable ABI.
0134  * They will be removed from this header file in the future version.
0135  * But they will be remained in ABI until Python 4.0.
0136  */
0137 Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_AcquireLock(void);
0138 Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_ReleaseLock(void);
0139 PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
0140 PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
0141 
0142 #define Py_BEGIN_ALLOW_THREADS { \
0143                         PyThreadState *_save; \
0144                         _save = PyEval_SaveThread();
0145 #define Py_BLOCK_THREADS        PyEval_RestoreThread(_save);
0146 #define Py_UNBLOCK_THREADS      _save = PyEval_SaveThread();
0147 #define Py_END_ALLOW_THREADS    PyEval_RestoreThread(_save); \
0148                  }
0149 
0150 /* Masks and values used by FORMAT_VALUE opcode. */
0151 #define FVC_MASK      0x3
0152 #define FVC_NONE      0x0
0153 #define FVC_STR       0x1
0154 #define FVC_REPR      0x2
0155 #define FVC_ASCII     0x3
0156 #define FVS_MASK      0x4
0157 #define FVS_HAVE_SPEC 0x4
0158 
0159 #ifndef Py_LIMITED_API
0160 #  define Py_CPYTHON_CEVAL_H
0161 #  include "cpython/ceval.h"
0162 #  undef Py_CPYTHON_CEVAL_H
0163 #endif
0164 
0165 #ifdef __cplusplus
0166 }
0167 #endif
0168 #endif /* !Py_CEVAL_H */