• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef Py_INTERNAL_CONTEXT_H
2 #define Py_INTERNAL_CONTEXT_H
3 
4 #ifndef Py_BUILD_CORE
5 #  error "this header requires Py_BUILD_CORE define"
6 #endif
7 
8 #include "pycore_freelist.h"      // _PyFreeListState
9 #include "pycore_hamt.h"          // PyHamtObject
10 
11 
12 extern PyTypeObject _PyContextTokenMissing_Type;
13 
14 /* runtime lifecycle */
15 
16 PyStatus _PyContext_Init(PyInterpreterState *);
17 
18 
19 /* other API */
20 
21 typedef struct {
22     PyObject_HEAD
23 } _PyContextTokenMissing;
24 
25 struct _pycontextobject {
26     PyObject_HEAD
27     PyContext *ctx_prev;
28     PyHamtObject *ctx_vars;
29     PyObject *ctx_weakreflist;
30     int ctx_entered;
31 };
32 
33 
34 struct _pycontextvarobject {
35     PyObject_HEAD
36     PyObject *var_name;
37     PyObject *var_default;
38 #ifndef Py_GIL_DISABLED
39     PyObject *var_cached;
40     uint64_t var_cached_tsid;
41     uint64_t var_cached_tsver;
42 #endif
43     Py_hash_t var_hash;
44 };
45 
46 
47 struct _pycontexttokenobject {
48     PyObject_HEAD
49     PyContext *tok_ctx;
50     PyContextVar *tok_var;
51     PyObject *tok_oldval;
52     int tok_used;
53 };
54 
55 
56 // _testinternalcapi.hamt() used by tests.
57 // Export for '_testcapi' shared extension
58 PyAPI_FUNC(PyObject*) _PyContext_NewHamtForTests(void);
59 
60 
61 #endif /* !Py_INTERNAL_CONTEXT_H */
62