annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/python3.8/context.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 #ifndef Py_CONTEXT_H
jpayne@69 2 #define Py_CONTEXT_H
jpayne@69 3 #ifdef __cplusplus
jpayne@69 4 extern "C" {
jpayne@69 5 #endif
jpayne@69 6
jpayne@69 7 #ifndef Py_LIMITED_API
jpayne@69 8
jpayne@69 9
jpayne@69 10 PyAPI_DATA(PyTypeObject) PyContext_Type;
jpayne@69 11 typedef struct _pycontextobject PyContext;
jpayne@69 12
jpayne@69 13 PyAPI_DATA(PyTypeObject) PyContextVar_Type;
jpayne@69 14 typedef struct _pycontextvarobject PyContextVar;
jpayne@69 15
jpayne@69 16 PyAPI_DATA(PyTypeObject) PyContextToken_Type;
jpayne@69 17 typedef struct _pycontexttokenobject PyContextToken;
jpayne@69 18
jpayne@69 19
jpayne@69 20 #define PyContext_CheckExact(o) (Py_TYPE(o) == &PyContext_Type)
jpayne@69 21 #define PyContextVar_CheckExact(o) (Py_TYPE(o) == &PyContextVar_Type)
jpayne@69 22 #define PyContextToken_CheckExact(o) (Py_TYPE(o) == &PyContextToken_Type)
jpayne@69 23
jpayne@69 24
jpayne@69 25 PyAPI_FUNC(PyObject *) PyContext_New(void);
jpayne@69 26 PyAPI_FUNC(PyObject *) PyContext_Copy(PyObject *);
jpayne@69 27 PyAPI_FUNC(PyObject *) PyContext_CopyCurrent(void);
jpayne@69 28
jpayne@69 29 PyAPI_FUNC(int) PyContext_Enter(PyObject *);
jpayne@69 30 PyAPI_FUNC(int) PyContext_Exit(PyObject *);
jpayne@69 31
jpayne@69 32
jpayne@69 33 /* Create a new context variable.
jpayne@69 34
jpayne@69 35 default_value can be NULL.
jpayne@69 36 */
jpayne@69 37 PyAPI_FUNC(PyObject *) PyContextVar_New(
jpayne@69 38 const char *name, PyObject *default_value);
jpayne@69 39
jpayne@69 40
jpayne@69 41 /* Get a value for the variable.
jpayne@69 42
jpayne@69 43 Returns -1 if an error occurred during lookup.
jpayne@69 44
jpayne@69 45 Returns 0 if value either was or was not found.
jpayne@69 46
jpayne@69 47 If value was found, *value will point to it.
jpayne@69 48 If not, it will point to:
jpayne@69 49
jpayne@69 50 - default_value, if not NULL;
jpayne@69 51 - the default value of "var", if not NULL;
jpayne@69 52 - NULL.
jpayne@69 53
jpayne@69 54 '*value' will be a new ref, if not NULL.
jpayne@69 55 */
jpayne@69 56 PyAPI_FUNC(int) PyContextVar_Get(
jpayne@69 57 PyObject *var, PyObject *default_value, PyObject **value);
jpayne@69 58
jpayne@69 59
jpayne@69 60 /* Set a new value for the variable.
jpayne@69 61 Returns NULL if an error occurs.
jpayne@69 62 */
jpayne@69 63 PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
jpayne@69 64
jpayne@69 65
jpayne@69 66 /* Reset a variable to its previous value.
jpayne@69 67 Returns 0 on success, -1 on error.
jpayne@69 68 */
jpayne@69 69 PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
jpayne@69 70
jpayne@69 71
jpayne@69 72 /* This method is exposed only for CPython tests. Don not use it. */
jpayne@69 73 PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void);
jpayne@69 74
jpayne@69 75
jpayne@69 76 PyAPI_FUNC(int) PyContext_ClearFreeList(void);
jpayne@69 77
jpayne@69 78
jpayne@69 79 #endif /* !Py_LIMITED_API */
jpayne@69 80
jpayne@69 81 #ifdef __cplusplus
jpayne@69 82 }
jpayne@69 83 #endif
jpayne@69 84 #endif /* !Py_CONTEXT_H */