mirror of
https://github.com/python/cpython.git
synced 2025-10-28 12:15:13 +00:00
These changes makes it easier to backport the _interpreters, _interpqueues, and _interpchannels modules to Python 3.12. This involves the following: * add the _PyXI_GET_STATE() and _PyXI_GET_GLOBAL_STATE() macros * add _PyXIData_lookup_context_t and _PyXIData_GetLookupContext() * add _Py_xi_state_init() and _Py_xi_state_fini()
41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
#ifndef Py_CORE_CROSSINTERP_DATA_REGISTRY_H
|
|
# error "this header must not be included directly"
|
|
#endif
|
|
|
|
|
|
// For now we use a global registry of shareable classes. An
|
|
// alternative would be to add a tp_* slot for a class's
|
|
// xidatafunc. It would be simpler and more efficient.
|
|
|
|
struct _xid_regitem;
|
|
|
|
typedef struct _xid_regitem {
|
|
struct _xid_regitem *prev;
|
|
struct _xid_regitem *next;
|
|
/* This can be a dangling pointer, but only if weakref is set. */
|
|
PyTypeObject *cls;
|
|
/* This is NULL for builtin types. */
|
|
PyObject *weakref;
|
|
size_t refcount;
|
|
xidatafunc getdata;
|
|
} _PyXIData_regitem_t;
|
|
|
|
typedef struct {
|
|
int global; /* builtin types or heap types */
|
|
int initialized;
|
|
PyMutex mutex;
|
|
_PyXIData_regitem_t *head;
|
|
} _PyXIData_registry_t;
|
|
|
|
PyAPI_FUNC(int) _PyXIData_RegisterClass(
|
|
_PyXIData_lookup_context_t *,
|
|
PyTypeObject *,
|
|
xidatafunc);
|
|
PyAPI_FUNC(int) _PyXIData_UnregisterClass(
|
|
_PyXIData_lookup_context_t *,
|
|
PyTypeObject *);
|
|
|
|
struct _xid_lookup_state {
|
|
// XXX Remove this field once we have a tp_* slot.
|
|
_PyXIData_registry_t registry;
|
|
};
|