MCPcopy Create free account
hub / github.com/pybind/pybind11 / init_slots

Function init_slots

include/pybind11/pybind11.h:1559–1585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1557/// Initialize an array of slots based on the supplied exec slot and options.
1558template <typename... Options>
1559inline slots_array init_slots(int (*exec_fn)(PyObject *), Options &&...options) noexcept {
1560 /* NOTE: slots_array MUST be large enough to hold all possible options. If you add an option
1561 here, you MUST also increase the size of slots_array in the type alias above! */
1562 slots_array mod_def_slots;
1563 size_t next_slot = 0;
1564
1565 mod_def_slots[next_slot++] = {Py_mod_create, reinterpret_cast<void *>(&cached_create_module)};
1566
1567 if (exec_fn != nullptr) {
1568 mod_def_slots[next_slot++] = {Py_mod_exec, reinterpret_cast<void *>(exec_fn)};
1569 }
1570
1571#ifdef Py_mod_multiple_interpreters
1572 mod_def_slots[next_slot++] = {Py_mod_multiple_interpreters, multi_interp_slot(options...)};
1573#endif
1574
1575 if (gil_not_used_option(options...)) {
1576#if defined(Py_mod_gil) && defined(Py_GIL_DISABLED)
1577 mod_def_slots[next_slot++] = {Py_mod_gil, Py_MOD_GIL_NOT_USED};
1578#endif
1579 }
1580
1581 // slots must have a zero end sentinel
1582 mod_def_slots[next_slot++] = {0, nullptr};
1583
1584 return mod_def_slots;
1585}
1586
1587PYBIND11_NAMESPACE_END(detail)
1588

Callers

nothing calls this directly

Calls 2

multi_interp_slotFunction · 0.85
gil_not_used_optionFunction · 0.85

Tested by

no test coverage detected