mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-31 15:20:34 +00:00
Remove PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL macro completely.
This commit is contained in:
parent
11adace1ea
commit
ae38889322
@ -69,13 +69,11 @@ struct type_uses_smart_holder_type_caster {
|
|||||||
// Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T
|
// Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename make_caster<T>::template cast_op_type<T> cast_op(make_caster<T> &caster) {
|
typename make_caster<T>::template cast_op_type<T> cast_op(make_caster<T> &caster) {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
return caster.operator typename make_caster<T>::template cast_op_type<T>();
|
return caster.operator typename make_caster<T>::template cast_op_type<T>();
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename make_caster<T>::template cast_op_type<typename std::add_rvalue_reference<T>::type>
|
typename make_caster<T>::template cast_op_type<typename std::add_rvalue_reference<T>::type>
|
||||||
cast_op(make_caster<T> &&caster) {
|
cast_op(make_caster<T> &&caster) {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
return std::move(caster).operator typename make_caster<T>::
|
return std::move(caster).operator typename make_caster<T>::
|
||||||
template cast_op_type<typename std::add_rvalue_reference<T>::type>();
|
template cast_op_type<typename std::add_rvalue_reference<T>::type>();
|
||||||
}
|
}
|
||||||
@ -95,15 +93,11 @@ private:
|
|||||||
"`operator T &()` or `operator const T &()`");
|
"`operator T &()` or `operator const T &()`");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool load(handle src, bool convert) {
|
bool load(handle src, bool convert) { return subcaster.load(src, convert); }
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(type)
|
|
||||||
return subcaster.load(src, convert);
|
|
||||||
}
|
|
||||||
static constexpr auto name = caster_t::name;
|
static constexpr auto name = caster_t::name;
|
||||||
PYBIND11_TYPE_CASTER_SOURCE_FILE_LINE
|
PYBIND11_TYPE_CASTER_SOURCE_FILE_LINE
|
||||||
static handle
|
static handle
|
||||||
cast(const std::reference_wrapper<type> &src, return_value_policy policy, handle parent) {
|
cast(const std::reference_wrapper<type> &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
|
// It is definitely wrong to take ownership of this pointer, so mask that rvp
|
||||||
if (policy == return_value_policy::take_ownership
|
if (policy == return_value_policy::take_ownership
|
||||||
|| policy == return_value_policy::automatic) {
|
|| policy == return_value_policy::automatic) {
|
||||||
@ -580,7 +574,6 @@ struct type_caster<CharT, enable_if_t<is_std_char_type<CharT>::value>> {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool load(handle src, bool convert) {
|
bool load(handle src, bool convert) {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(StringType)
|
|
||||||
if (!src) {
|
if (!src) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -596,7 +589,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static handle cast(const CharT *src, return_value_policy policy, handle parent) {
|
static handle cast(const CharT *src, return_value_policy policy, handle parent) {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(StringType)
|
|
||||||
if (src == nullptr) {
|
if (src == nullptr) {
|
||||||
return pybind11::none().inc_ref();
|
return pybind11::none().inc_ref();
|
||||||
}
|
}
|
||||||
@ -604,7 +596,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static handle cast(CharT src, return_value_policy policy, handle parent) {
|
static handle cast(CharT src, return_value_policy policy, handle parent) {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(StringType)
|
|
||||||
if (std::is_same<char, CharT>::value) {
|
if (std::is_same<char, CharT>::value) {
|
||||||
handle s = PyUnicode_DecodeLatin1((const char *) &src, 1, nullptr);
|
handle s = PyUnicode_DecodeLatin1((const char *) &src, 1, nullptr);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
@ -1098,7 +1089,6 @@ make_caster_intrinsic<T> &load_type(make_caster_intrinsic<T> &conv, const handle
|
|||||||
// Wrapper around the above that also constructs and returns a type_caster
|
// Wrapper around the above that also constructs and returns a type_caster
|
||||||
template <typename T>
|
template <typename T>
|
||||||
make_caster<T> load_type(const handle &handle) {
|
make_caster<T> load_type(const handle &handle) {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
make_caster<T> conv;
|
make_caster<T> conv;
|
||||||
load_type(conv, handle);
|
load_type(conv, handle);
|
||||||
return conv;
|
return conv;
|
||||||
@ -1136,7 +1126,6 @@ object cast(T &&value,
|
|||||||
: std::is_lvalue_reference<T>::value ? return_value_policy::copy
|
: std::is_lvalue_reference<T>::value ? return_value_policy::copy
|
||||||
: return_value_policy::move;
|
: return_value_policy::move;
|
||||||
}
|
}
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
return reinterpret_steal<object>(
|
return reinterpret_steal<object>(
|
||||||
detail::make_caster<T>::cast(std::forward<T>(value), policy, parent));
|
detail::make_caster<T>::cast(std::forward<T>(value), policy, parent));
|
||||||
}
|
}
|
||||||
@ -1237,7 +1226,6 @@ using override_caster_t = conditional_t<cast_is_temporary_value_reference<ret_ty
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_ref(object &&o,
|
enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_ref(object &&o,
|
||||||
make_caster<T> &caster) {
|
make_caster<T> &caster) {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
return cast_op<T>(load_type(caster, o));
|
return cast_op<T>(load_type(caster, o));
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -1349,7 +1337,6 @@ private:
|
|||||||
type(type_id<T>())
|
type(type_id<T>())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
// Workaround! See:
|
// Workaround! See:
|
||||||
// https://github.com/pybind/pybind11/issues/2336
|
// https://github.com/pybind/pybind11/issues/2336
|
||||||
// https://github.com/pybind/pybind11/pull/2685#issuecomment-731286700
|
// https://github.com/pybind/pybind11/pull/2685#issuecomment-731286700
|
||||||
@ -1580,7 +1567,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void process(list &args_list, T &&x) {
|
void process(list &args_list, T &&x) {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
auto o = reinterpret_steal<object>(
|
auto o = reinterpret_steal<object>(
|
||||||
detail::make_caster<T>::cast(std::forward<T>(x), policy, {}));
|
detail::make_caster<T>::cast(std::forward<T>(x), policy, {}));
|
||||||
if (!o) {
|
if (!o) {
|
||||||
@ -1725,7 +1711,6 @@ handle type::handle_of() {
|
|||||||
detail::type_uses_smart_holder_type_caster<T>>::value,
|
detail::type_uses_smart_holder_type_caster<T>>::value,
|
||||||
"py::type::of<T> only supports the case where T is a registered C++ types.");
|
"py::type::of<T> only supports the case where T is a registered C++ types.");
|
||||||
|
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
return detail::get_type_handle(typeid(T), true);
|
return detail::get_type_handle(typeid(T), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
# define PYBIND11_TYPE_CASTER_SOURCE_FILE_LINE
|
# define PYBIND11_TYPE_CASTER_SOURCE_FILE_LINE
|
||||||
|
|
||||||
# define PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(...)
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# if !defined(PYBIND11_CPP20) && defined(__GNUC__) && !defined(__clang__)
|
# if !defined(PYBIND11_CPP20) && defined(__GNUC__) && !defined(__clang__)
|
||||||
@ -211,6 +209,4 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|||||||
static constexpr auto source_file_line \
|
static constexpr auto source_file_line \
|
||||||
= ::pybind11::detail::tu_local_const_name(__FILE__ ":" PYBIND11_TOSTRING(__LINE__));
|
= ::pybind11::detail::tu_local_const_name(__FILE__ ":" PYBIND11_TOSTRING(__LINE__));
|
||||||
|
|
||||||
# define PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(...)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -213,9 +213,8 @@ protected:
|
|||||||
|
|
||||||
/* Type casters for the function arguments and return value */
|
/* Type casters for the function arguments and return value */
|
||||||
using cast_in = argument_loader<Args...>;
|
using cast_in = argument_loader<Args...>;
|
||||||
using make_caster_type_out = conditional_t<std::is_void<Return>::value, void_type, Return>;
|
using cast_out
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(make_caster_type_out)
|
= make_caster<conditional_t<std::is_void<Return>::value, void_type, Return>>;
|
||||||
using cast_out = make_caster<make_caster_type_out>;
|
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
expected_num_args<Extra...>(
|
expected_num_args<Extra...>(
|
||||||
@ -1855,7 +1854,6 @@ public:
|
|||||||
auto *ptr = new capture{std::forward<Func>(func)};
|
auto *ptr = new capture{std::forward<Func>(func)};
|
||||||
install_buffer_funcs(
|
install_buffer_funcs(
|
||||||
[](PyObject *obj, void *ptr) -> buffer_info * {
|
[](PyObject *obj, void *ptr) -> buffer_info * {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(type)
|
|
||||||
detail::make_caster<type> caster;
|
detail::make_caster<type> caster;
|
||||||
if (!caster.load(obj, false)) {
|
if (!caster.load(obj, false)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -2717,7 +2715,6 @@ void implicitly_convertible() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
set_flag flag_helper(currently_used);
|
set_flag flag_helper(currently_used);
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(InputType)
|
|
||||||
if (!detail::make_caster<InputType>().load(obj, false)) {
|
if (!detail::make_caster<InputType>().load(obj, false)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,6 @@ struct variant_caster_visitor {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
result_type operator()(T &&src) const {
|
result_type operator()(T &&src) const {
|
||||||
PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL(T)
|
|
||||||
return make_caster<T>::cast(std::forward<T>(src), policy, parent);
|
return make_caster<T>::cast(std::forward<T>(src), policy, parent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user