cpython/Python/crossinterp_data_lookup.h

#include "pycore_weakref.h"       // _PyWeakref_GET_REF()


dlcontext_t;
dlregistry_t;
dlregitem_t;


// forward
static void _xidregistry_init(dlregistry_t *);
static void _xidregistry_fini(dlregistry_t *);
static xidatafunc _lookup_getdata_from_registry(dlcontext_t *, PyObject *);


/* used in crossinterp.c */

static void
xid_lookup_init(_PyXIData_lookup_t *state)
{}

static void
xid_lookup_fini(_PyXIData_lookup_t *state)
{}

static xidatafunc
lookup_getdata(dlcontext_t *ctx, PyObject *obj)
{}


/* exported API */

int
_PyXIData_GetLookupContext(PyInterpreterState *interp,
                           _PyXIData_lookup_context_t *res)
{}

xidatafunc
_PyXIData_Lookup(_PyXIData_lookup_context_t *ctx, PyObject *obj)
{}


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

/* 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.  */


/* registry lifecycle */

static void _register_builtins_for_crossinterpreter_data(dlregistry_t *);

static void
_xidregistry_init(dlregistry_t *registry)
{}

static void _xidregistry_clear(dlregistry_t *);

static void
_xidregistry_fini(dlregistry_t *registry)
{}


/* registry thread safety */

static void
_xidregistry_lock(dlregistry_t *registry)
{}

static void
_xidregistry_unlock(dlregistry_t *registry)
{}


/* accessing the registry */

static inline dlregistry_t *
_get_xidregistry_for_type(dlcontext_t *ctx, PyTypeObject *cls)
{}

static dlregitem_t* _xidregistry_remove_entry(dlregistry_t *, dlregitem_t *);

static dlregitem_t *
_xidregistry_find_type(dlregistry_t *xidregistry, PyTypeObject *cls)
{}

static xidatafunc
_lookup_getdata_from_registry(dlcontext_t *ctx, PyObject *obj)
{}


/* updating the registry */

static int
_xidregistry_add_type(dlregistry_t *xidregistry,
                      PyTypeObject *cls, xidatafunc getdata)
{}

static dlregitem_t *
_xidregistry_remove_entry(dlregistry_t *xidregistry, dlregitem_t *entry)
{}

static void
_xidregistry_clear(dlregistry_t *xidregistry)
{}

int
_PyXIData_RegisterClass(_PyXIData_lookup_context_t *ctx,
                        PyTypeObject *cls, xidatafunc getdata)
{}

int
_PyXIData_UnregisterClass(_PyXIData_lookup_context_t *ctx, PyTypeObject *cls)
{}


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

// bytes

struct _shared_bytes_data {};

static PyObject *
_new_bytes_object(_PyXIData_t *data)
{}

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

// str

struct _shared_str_data {};

static PyObject *
_new_str_object(_PyXIData_t *data)
{}

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

// int

static PyObject *
_new_long_object(_PyXIData_t *data)
{}

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

// float

static PyObject *
_new_float_object(_PyXIData_t *data)
{}

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

// None

static PyObject *
_new_none_object(_PyXIData_t *data)
{}

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

// bool

static PyObject *
_new_bool_object(_PyXIData_t *data)
{}

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

// tuple

struct _shared_tuple_data {};

static PyObject *
_new_tuple_object(_PyXIData_t *data)
{}

static void
_tuple_shared_free(void* data)
{}

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

// registration

static void
_register_builtins_for_crossinterpreter_data(dlregistry_t *xidregistry)
{}