diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 992a90f84..93978b539 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -125,11 +125,15 @@ private: "`operator T &()` or `operator const T &()`"); public: - bool load(handle src, bool convert) { return subcaster.load(src, convert); } + bool load(handle src, bool convert) { + PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(type) + return subcaster.load(src, convert); + } static constexpr auto name = caster_t::name; PYBIND11_TYPE_CASTER_SOURCE_FILE_LINE static handle cast(const std::reference_wrapper &src, return_value_policy policy, handle parent) { + PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(type) // It is definitely wrong to take ownership of this pointer, so mask that rvp if (policy == return_value_policy::take_ownership || policy == return_value_policy::automatic) { @@ -591,6 +595,7 @@ struct type_caster::value>> { public: bool load(handle src, bool convert) { + PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(StringType) if (!src) { return false; } @@ -606,6 +611,7 @@ public: } static handle cast(const CharT *src, return_value_policy policy, handle parent) { + PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(StringType) if (src == nullptr) { return pybind11::none().inc_ref(); } @@ -613,6 +619,7 @@ public: } static handle cast(CharT src, return_value_policy policy, handle parent) { + PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(StringType) if (std::is_same::value) { handle s = PyUnicode_DecodeLatin1((const char *) &src, 1, nullptr); if (!s) { @@ -786,6 +793,7 @@ protected: return result.release(); } + // TODO: PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL...? Tuple...> subcasters; }; @@ -1295,6 +1303,7 @@ tuple make_tuple() { template tuple make_tuple(Args &&...args_) { + // TODO: PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL...? constexpr size_t size = sizeof...(Args); std::array args{{reinterpret_steal( detail::make_caster::cast(std::forward(args_), policy, nullptr))...}}; @@ -1525,6 +1534,7 @@ private: return std::forward(f)(cast_op(std::move(std::get(argcasters)))...); } + // TODO: PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL...? std::tuple...> argcasters; }; diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 6ba2cff81..7a3183fb0 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -213,8 +213,9 @@ protected: /* Type casters for the function arguments and return value */ using cast_in = argument_loader; - using cast_out - = make_caster::value, void_type, Return>>; + using make_caster_type_out = conditional_t::value, void_type, Return>; + PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(make_caster_type_out); + using cast_out = make_caster; static_assert( expected_num_args( @@ -1854,6 +1855,7 @@ public: auto *ptr = new capture{std::forward(func)}; install_buffer_funcs( [](PyObject *obj, void *ptr) -> buffer_info * { + PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(type); detail::make_caster caster; if (!caster.load(obj, false)) { return nullptr; @@ -2715,6 +2717,7 @@ void implicitly_convertible() { return nullptr; } set_flag flag_helper(currently_used); + PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(InputType); if (!detail::make_caster().load(obj, false)) { return nullptr; }