Skip to content

Commit

Permalink
refactor: rename to _pybind_conduit_v1_
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Sep 12, 2024
1 parent 19106f5 commit 69890bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/pybind11/detail/cpp_conduit.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ inline object try_get_cpp_conduit_method(PyObject *obj) {
return object();
}
PyTypeObject *type_obj = Py_TYPE(obj);
str attr_name("__cpp_conduit__");
str attr_name("_pybind11_conduit_v1_");
bool assumed_to_be_callable = false;
if (type_is_managed_by_our_internals(type_obj)) {
if (!is_instance_method_of_type(type_obj, attr_name.ptr())) {
Expand Down Expand Up @@ -71,7 +71,7 @@ inline void *try_raw_pointer_ephemeral_from_cpp_conduit(handle src,
return nullptr;
}

#define PYBIND11_HAS_CPP_CONDUIT
#define PYBIND11_HAS_CPP_CONDUIT 1

PYBIND11_NAMESPACE_END(detail)
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
6 changes: 3 additions & 3 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ class cpp_function : public function {
/* Create a nice pydoc rec including all signatures and
docstrings of the functions in the overload chain */
if (chain && options::show_function_signatures()
&& std::strcmp(rec->name, "__cpp_conduit__") != 0) {
&& std::strcmp(rec->name, "_pybind11_conduit_v1_") != 0) {
// First a generic signature
signatures += rec->name;
signatures += "(*args, **kwargs)\n";
Expand All @@ -621,7 +621,7 @@ class cpp_function : public function {
bool first_user_def = true;
for (auto *it = chain_start; it != nullptr; it = it->next) {
if (options::show_function_signatures()
&& std::strcmp(rec->name, "__cpp_conduit__") != 0) {
&& std::strcmp(rec->name, "_pybind11_conduit_v1_") != 0) {
if (index > 0) {
signatures += '\n';
}
Expand Down Expand Up @@ -1654,7 +1654,7 @@ class class_ : public detail::generic_type {
= instances[std::type_index(typeid(type))];
});
}
def("__cpp_conduit__", cpp_conduit_method);
def("_pybind11_conduit_v1_", cpp_conduit_method);
}

template <typename Base, detail::enable_if_t<is_base<Base>::value, int> = 0>
Expand Down
2 changes: 1 addition & 1 deletion tests/exo_planet_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void *get_cpp_conduit_void_ptr(PyObject *py_obj, const std::type_info *cpp_type_
return nullptr;
}
PyObject *cpp_conduit = PyObject_CallMethod(py_obj,
"__cpp_conduit__",
"_pybind11_conduit_v1_",
"yOy",
PYBIND11_PLATFORM_ABI_ID,
cpp_type_info_capsule,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_cpp_conduit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_premium_traveler_getattr_actually_exists():

def test_call_cpp_conduit_success():
t_h = home_planet.Traveler("home")
cap = t_h.__cpp_conduit__(
cap = t_h._pybind11_conduit_v1_(
home_planet.PYBIND11_PLATFORM_ABI_ID,
home_planet.cpp_type_info_capsule_Traveler,
b"raw_pointer_ephemeral",
Expand All @@ -31,7 +31,7 @@ def test_call_cpp_conduit_success():

def test_call_cpp_conduit_platform_abi_id_mismatch():
t_h = home_planet.Traveler("home")
cap = t_h.__cpp_conduit__(
cap = t_h._pybind11_conduit_v1_(
home_planet.PYBIND11_PLATFORM_ABI_ID + b"MISMATCH",
home_planet.cpp_type_info_capsule_Traveler,
b"raw_pointer_ephemeral",
Expand All @@ -41,7 +41,7 @@ def test_call_cpp_conduit_platform_abi_id_mismatch():

def test_call_cpp_conduit_cpp_type_info_capsule_mismatch():
t_h = home_planet.Traveler("home")
cap = t_h.__cpp_conduit__(
cap = t_h._pybind11_conduit_v1_(
home_planet.PYBIND11_PLATFORM_ABI_ID,
home_planet.cpp_type_info_capsule_int,
b"raw_pointer_ephemeral",
Expand All @@ -54,7 +54,7 @@ def test_call_cpp_conduit_pointer_kind_invalid():
with pytest.raises(
RuntimeError, match='^Invalid pointer_kind: "raw_pointer_ephemreal"$'
):
t_h.__cpp_conduit__(
t_h._pybind11_conduit_v1_(
home_planet.PYBIND11_PLATFORM_ABI_ID,
home_planet.cpp_type_info_capsule_Traveler,
b"raw_pointer_ephemreal",
Expand Down

0 comments on commit 69890bb

Please sign in to comment.