File: pycore_crossinterp_data_registry.h

package info (click to toggle)
python3.14 3.14.0~rc1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 126,824 kB
  • sloc: python: 745,274; ansic: 713,752; xml: 31,250; sh: 5,822; cpp: 4,063; makefile: 1,988; objc: 787; lisp: 502; javascript: 136; asm: 75; csh: 12
file content (41 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download
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
#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;
    _PyXIData_getdata_t 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(
    PyThreadState *,
    PyTypeObject *,
    _PyXIData_getdata_t);
PyAPI_FUNC(int) _PyXIData_UnregisterClass(
    PyThreadState *,
    PyTypeObject *);

struct _xid_lookup_state {
    // XXX Remove this field once we have a tp_* slot.
    _PyXIData_registry_t registry;
};