cpython/Python/crossinterp_data_lookup.h


static crossinterpdatafunc _lookup_getdata_from_registry(
                                            PyInterpreterState *, PyObject *);

static crossinterpdatafunc
lookup_getdata(PyInterpreterState *interp, PyObject *obj)
{}

crossinterpdatafunc
_PyCrossInterpreterData_Lookup(PyObject *obj)
{}


/***********************************************/
/* a registry of {type -> crossinterpdatafunc} */
/***********************************************/

/* For now we use a global registry of shareable classes.  An
   alternative would be to add a tp_* slot for a class's
   crossinterpdatafunc. It would be simpler and more efficient.  */


/* registry lifecycle */

static void _register_builtins_for_crossinterpreter_data(struct _xidregistry *);

static void
_xidregistry_init(struct _xidregistry *registry)
{}

static void _xidregistry_clear(struct _xidregistry *);

static void
_xidregistry_fini(struct _xidregistry *registry)
{}

static inline struct _xidregistry * _get_global_xidregistry(_PyRuntimeState *);
static inline struct _xidregistry * _get_xidregistry(PyInterpreterState *);

static void
xid_lookup_init(PyInterpreterState *interp)
{}

static void
xid_lookup_fini(PyInterpreterState *interp)
{}


/* registry thread safety */

static void
_xidregistry_lock(struct _xidregistry *registry)
{}

static void
_xidregistry_unlock(struct _xidregistry *registry)
{}


/* accessing the registry */

static inline struct _xidregistry *
_get_global_xidregistry(_PyRuntimeState *runtime)
{}

static inline struct _xidregistry *
_get_xidregistry(PyInterpreterState *interp)
{}

static inline struct _xidregistry *
_get_xidregistry_for_type(PyInterpreterState *interp, PyTypeObject *cls)
{}

static struct _xidregitem * _xidregistry_remove_entry(
        struct _xidregistry *, struct _xidregitem *);

static struct _xidregitem *
_xidregistry_find_type(struct _xidregistry *xidregistry, PyTypeObject *cls)
{}

static crossinterpdatafunc
_lookup_getdata_from_registry(PyInterpreterState *interp, PyObject *obj)
{}


/* updating the registry */

static int
_xidregistry_add_type(struct _xidregistry *xidregistry,
                      PyTypeObject *cls, crossinterpdatafunc getdata)
{}

static struct _xidregitem *
_xidregistry_remove_entry(struct _xidregistry *xidregistry,
                          struct _xidregitem *entry)
{}

static void
_xidregistry_clear(struct _xidregistry *xidregistry)
{}

int
_PyCrossInterpreterData_RegisterClass(PyTypeObject *cls,
                                      crossinterpdatafunc getdata)
{}

int
_PyCrossInterpreterData_UnregisterClass(PyTypeObject *cls)
{}


/********************************************/
/* cross-interpreter data for builtin types */
/********************************************/

// bytes

struct _shared_bytes_data {};

static PyObject *
_new_bytes_object(_PyCrossInterpreterData *data)
{}

static int
_bytes_shared(PyThreadState *tstate, PyObject *obj,
              _PyCrossInterpreterData *data)
{}

// str

struct _shared_str_data {};

static PyObject *
_new_str_object(_PyCrossInterpreterData *data)
{}

static int
_str_shared(PyThreadState *tstate, PyObject *obj,
            _PyCrossInterpreterData *data)
{}

// int

static PyObject *
_new_long_object(_PyCrossInterpreterData *data)
{}

static int
_long_shared(PyThreadState *tstate, PyObject *obj,
             _PyCrossInterpreterData *data)
{}

// float

static PyObject *
_new_float_object(_PyCrossInterpreterData *data)
{}

static int
_float_shared(PyThreadState *tstate, PyObject *obj,
             _PyCrossInterpreterData *data)
{}

// None

static PyObject *
_new_none_object(_PyCrossInterpreterData *data)
{}

static int
_none_shared(PyThreadState *tstate, PyObject *obj,
             _PyCrossInterpreterData *data)
{}

// bool

static PyObject *
_new_bool_object(_PyCrossInterpreterData *data)
{}

static int
_bool_shared(PyThreadState *tstate, PyObject *obj,
             _PyCrossInterpreterData *data)
{}

// tuple

struct _shared_tuple_data {};

static PyObject *
_new_tuple_object(_PyCrossInterpreterData *data)
{}

static void
_tuple_shared_free(void* data)
{}

static int
_tuple_shared(PyThreadState *tstate, PyObject *obj,
             _PyCrossInterpreterData *data)
{}

// registration

static void
_register_builtins_for_crossinterpreter_data(struct _xidregistry *xidregistry)
{}