Skip to content

Commit ab80ad1

Browse files
committed
Correct erroneous usage of 'overload' instead of 'override' in the implementation and internals
1 parent f5c0838 commit ab80ad1

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

include/pybind11/cast.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,16 +1796,16 @@ PYBIND11_NAMESPACE_BEGIN(detail)
17961796
template <typename T, enable_if_t<!is_pyobject<T>::value, int>>
17971797
object object_or_cast(T &&o) { return pybind11::cast(std::forward<T>(o)); }
17981798

1799-
struct overload_unused {}; // Placeholder type for the unneeded (and dead code) static variable in the OVERLOAD_INT macro
1800-
template <typename ret_type> using overload_caster_t = conditional_t<
1801-
cast_is_temporary_value_reference<ret_type>::value, make_caster<ret_type>, overload_unused>;
1799+
struct override_unused {}; // Placeholder type for the unneeded (and dead code) static variable in the PYBIND11_OVERRIDE_OVERRIDE macro
1800+
template <typename ret_type> using override_caster_t = conditional_t<
1801+
cast_is_temporary_value_reference<ret_type>::value, make_caster<ret_type>, override_unused>;
18021802

18031803
// Trampoline use: for reference/pointer types to value-converted values, we do a value cast, then
18041804
// store the result in the given variable. For other types, this is a no-op.
18051805
template <typename T> enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_ref(object &&o, make_caster<T> &caster) {
18061806
return cast_op<T>(load_type(caster, o));
18071807
}
1808-
template <typename T> enable_if_t<!cast_is_temporary_value_reference<T>::value, T> cast_ref(object &&, overload_unused &) {
1808+
template <typename T> enable_if_t<!cast_is_temporary_value_reference<T>::value, T> cast_ref(object &&, override_unused &) {
18091809
pybind11_fail("Internal error: cast_ref fallback invoked"); }
18101810

18111811
// Trampoline use: Having a pybind11::cast with an invalid reference type is going to static_assert, even
@@ -2204,7 +2204,7 @@ PYBIND11_NAMESPACE_END(detail)
22042204
}}
22052205

22062206
/// Lets you pass a type containing a `,` through a macro parameter without needing a separate
2207-
/// typedef, e.g.: `PYBIND11_OVERLOAD(PYBIND11_TYPE(ReturnType<A, B>), PYBIND11_TYPE(Parent<C, D>), f, arg)`
2207+
/// typedef, e.g.: `PYBIND11_OVERRIDE(PYBIND11_TYPE(ReturnType<A, B>), PYBIND11_TYPE(Parent<C, D>), f, arg)`
22082208
#define PYBIND11_TYPE(...) __VA_ARGS__
22092209

22102210
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

include/pybind11/detail/internals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ struct type_equal_to {
8282
template <typename value_type>
8383
using type_map = std::unordered_map<std::type_index, value_type, type_hash, type_equal_to>;
8484

85-
struct overload_hash {
85+
struct override_hash {
8686
inline size_t operator()(const std::pair<const PyObject *, const char *>& v) const {
8787
size_t value = std::hash<const void *>()(v.first);
88-
value ^= std::hash<const void *>()(v.second) + 0x9e3779b9 + (value<<6) + (value>>2);
88+
value ^= std::hash<const void *>()(v.second) + 0x9e3779b9 + (value<<6) + (value>>2);
8989
return value;
9090
}
9191
};
@@ -97,7 +97,7 @@ struct internals {
9797
type_map<type_info *> registered_types_cpp; // std::type_index -> pybind11's type information
9898
std::unordered_map<PyTypeObject *, std::vector<type_info *>> registered_types_py; // PyTypeObject* -> base type_info(s)
9999
std::unordered_multimap<const void *, instance*> registered_instances; // void * -> instance*
100-
std::unordered_set<std::pair<const PyObject *, const char *>, overload_hash> inactive_overload_cache;
100+
std::unordered_set<std::pair<const PyObject *, const char *>, override_hash> inactive_override_cache;
101101
type_map<std::vector<bool (*)(PyObject *, void *&)>> direct_conversions;
102102
std::unordered_map<const PyObject *, std::vector<PyObject *>> patients;
103103
std::forward_list<void (*) (std::exception_ptr)> registered_exception_translators;

include/pybind11/pybind11.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,14 +2079,14 @@ inline function get_type_override(const void *this_ptr, const type_info *this_ty
20792079
handle type = self.get_type();
20802080
auto key = std::make_pair(type.ptr(), name);
20812081

2082-
/* Cache functions that aren't overloaded in Python to avoid
2082+
/* Cache functions that aren't overridden in Python to avoid
20832083
many costly Python dictionary lookups below */
2084-
auto &cache = get_internals().inactive_overload_cache;
2084+
auto &cache = get_internals().inactive_override_cache;
20852085
if (cache.find(key) != cache.end())
20862086
return function();
20872087

2088-
function overload = getattr(self, name, function());
2089-
if (overload.is_cpp_function()) {
2088+
function override = getattr(self, name, function());
2089+
if (override.is_cpp_function()) {
20902090
cache.insert(key);
20912091
return function();
20922092
}
@@ -2126,7 +2126,7 @@ inline function get_type_override(const void *this_ptr, const type_info *this_ty
21262126
Py_DECREF(result);
21272127
#endif
21282128

2129-
return overload;
2129+
return override;
21302130
}
21312131
PYBIND11_NAMESPACE_END(detail)
21322132

@@ -2150,7 +2150,7 @@ template <class T> function get_override(const T *this_ptr, const char *name) {
21502150
if (override) { \
21512151
auto o = override(__VA_ARGS__); \
21522152
if (pybind11::detail::cast_is_temporary_value_reference<ret_type>::value) { \
2153-
static pybind11::detail::overload_caster_t<ret_type> caster; \
2153+
static pybind11::detail::override_caster_t<ret_type> caster; \
21542154
return pybind11::detail::cast_ref<ret_type>(std::move(o), caster); \
21552155
} \
21562156
else return pybind11::detail::cast_safe<ret_type>(std::move(o)); \

0 commit comments

Comments
 (0)