Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

context.h 2.0 KB

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

Press p or to see the previous file or, n or to see the next file

Comments

Loading...