Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef Py_LIMITED_API
0002 #ifndef Py_CONTEXT_H
0003 #define Py_CONTEXT_H
0004 #ifdef __cplusplus
0005 extern "C" {
0006 #endif
0007 
0008 PyAPI_DATA(PyTypeObject) PyContext_Type;
0009 typedef struct _pycontextobject PyContext;
0010 
0011 PyAPI_DATA(PyTypeObject) PyContextVar_Type;
0012 typedef struct _pycontextvarobject PyContextVar;
0013 
0014 PyAPI_DATA(PyTypeObject) PyContextToken_Type;
0015 typedef struct _pycontexttokenobject PyContextToken;
0016 
0017 
0018 #define PyContext_CheckExact(o) Py_IS_TYPE((o), &PyContext_Type)
0019 #define PyContextVar_CheckExact(o) Py_IS_TYPE((o), &PyContextVar_Type)
0020 #define PyContextToken_CheckExact(o) Py_IS_TYPE((o), &PyContextToken_Type)
0021 
0022 
0023 PyAPI_FUNC(PyObject *) PyContext_New(void);
0024 PyAPI_FUNC(PyObject *) PyContext_Copy(PyObject *);
0025 PyAPI_FUNC(PyObject *) PyContext_CopyCurrent(void);
0026 
0027 PyAPI_FUNC(int) PyContext_Enter(PyObject *);
0028 PyAPI_FUNC(int) PyContext_Exit(PyObject *);
0029 
0030 
0031 /* Create a new context variable.
0032 
0033    default_value can be NULL.
0034 */
0035 PyAPI_FUNC(PyObject *) PyContextVar_New(
0036     const char *name, PyObject *default_value);
0037 
0038 
0039 /* Get a value for the variable.
0040 
0041    Returns -1 if an error occurred during lookup.
0042 
0043    Returns 0 if value either was or was not found.
0044 
0045    If value was found, *value will point to it.
0046    If not, it will point to:
0047 
0048    - default_value, if not NULL;
0049    - the default value of "var", if not NULL;
0050    - NULL.
0051 
0052    '*value' will be a new ref, if not NULL.
0053 */
0054 PyAPI_FUNC(int) PyContextVar_Get(
0055     PyObject *var, PyObject *default_value, PyObject **value);
0056 
0057 
0058 /* Set a new value for the variable.
0059    Returns NULL if an error occurs.
0060 */
0061 PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
0062 
0063 
0064 /* Reset a variable to its previous value.
0065    Returns 0 on success, -1 on error.
0066 */
0067 PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
0068 
0069 
0070 /* This method is exposed only for CPython tests. Don not use it. */
0071 PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void);
0072 
0073 
0074 #ifdef __cplusplus
0075 }
0076 #endif
0077 #endif /* !Py_CONTEXT_H */
0078 #endif /* !Py_LIMITED_API */