jpayne@69: #ifndef Py_CONTEXT_H jpayne@69: #define Py_CONTEXT_H jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: jpayne@69: jpayne@69: PyAPI_DATA(PyTypeObject) PyContext_Type; jpayne@69: typedef struct _pycontextobject PyContext; jpayne@69: jpayne@69: PyAPI_DATA(PyTypeObject) PyContextVar_Type; jpayne@69: typedef struct _pycontextvarobject PyContextVar; jpayne@69: jpayne@69: PyAPI_DATA(PyTypeObject) PyContextToken_Type; jpayne@69: typedef struct _pycontexttokenobject PyContextToken; jpayne@69: jpayne@69: jpayne@69: #define PyContext_CheckExact(o) (Py_TYPE(o) == &PyContext_Type) jpayne@69: #define PyContextVar_CheckExact(o) (Py_TYPE(o) == &PyContextVar_Type) jpayne@69: #define PyContextToken_CheckExact(o) (Py_TYPE(o) == &PyContextToken_Type) jpayne@69: jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyContext_New(void); jpayne@69: PyAPI_FUNC(PyObject *) PyContext_Copy(PyObject *); jpayne@69: PyAPI_FUNC(PyObject *) PyContext_CopyCurrent(void); jpayne@69: jpayne@69: PyAPI_FUNC(int) PyContext_Enter(PyObject *); jpayne@69: PyAPI_FUNC(int) PyContext_Exit(PyObject *); jpayne@69: jpayne@69: jpayne@69: /* Create a new context variable. jpayne@69: jpayne@69: default_value can be NULL. jpayne@69: */ jpayne@69: PyAPI_FUNC(PyObject *) PyContextVar_New( jpayne@69: const char *name, PyObject *default_value); jpayne@69: jpayne@69: jpayne@69: /* Get a value for the variable. jpayne@69: jpayne@69: Returns -1 if an error occurred during lookup. jpayne@69: jpayne@69: Returns 0 if value either was or was not found. jpayne@69: jpayne@69: If value was found, *value will point to it. jpayne@69: If not, it will point to: jpayne@69: jpayne@69: - default_value, if not NULL; jpayne@69: - the default value of "var", if not NULL; jpayne@69: - NULL. jpayne@69: jpayne@69: '*value' will be a new ref, if not NULL. jpayne@69: */ jpayne@69: PyAPI_FUNC(int) PyContextVar_Get( jpayne@69: PyObject *var, PyObject *default_value, PyObject **value); jpayne@69: jpayne@69: jpayne@69: /* Set a new value for the variable. jpayne@69: Returns NULL if an error occurs. jpayne@69: */ jpayne@69: PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value); jpayne@69: jpayne@69: jpayne@69: /* Reset a variable to its previous value. jpayne@69: Returns 0 on success, -1 on error. jpayne@69: */ jpayne@69: PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token); jpayne@69: jpayne@69: jpayne@69: /* This method is exposed only for CPython tests. Don not use it. */ jpayne@69: PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void); jpayne@69: jpayne@69: jpayne@69: PyAPI_FUNC(int) PyContext_ClearFreeList(void); jpayne@69: jpayne@69: jpayne@69: #endif /* !Py_LIMITED_API */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif /* !Py_CONTEXT_H */