mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 23:22:01 +00:00
Rename user_type
to UserType
This commit is contained in:
parent
11040768ca
commit
e5f210e61b
@ -5,25 +5,25 @@
|
|||||||
|
|
||||||
namespace test_cases_for_stubgen {
|
namespace test_cases_for_stubgen {
|
||||||
|
|
||||||
struct user_type {
|
struct UserType {
|
||||||
bool operator<(const user_type &) const { return false; }
|
bool operator<(const UserType &) const { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct minimal_caster {
|
struct minimal_caster {
|
||||||
static constexpr auto name = py::detail::const_name<user_type>();
|
static constexpr auto name = py::detail::const_name<UserType>();
|
||||||
|
|
||||||
static py::handle
|
static py::handle
|
||||||
cast(user_type const & /*src*/, py::return_value_policy /*policy*/, py::handle /*parent*/) {
|
cast(UserType const & /*src*/, py::return_value_policy /*policy*/, py::handle /*parent*/) {
|
||||||
return py::none().release();
|
return py::none().release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maximizing simplicity. This will go terribly wrong for other arg types.
|
// Maximizing simplicity. This will go terribly wrong for other arg types.
|
||||||
template <typename>
|
template <typename>
|
||||||
using cast_op_type = const user_type &;
|
using cast_op_type = const UserType &;
|
||||||
|
|
||||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||||
operator user_type const &() {
|
operator UserType const &() {
|
||||||
static user_type obj;
|
static UserType obj;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,19 +36,19 @@ namespace pybind11 {
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct type_caster<test_cases_for_stubgen::user_type> : test_cases_for_stubgen::minimal_caster {};
|
struct type_caster<test_cases_for_stubgen::UserType> : test_cases_for_stubgen::minimal_caster {};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace pybind11
|
} // namespace pybind11
|
||||||
|
|
||||||
TEST_SUBMODULE(cases_for_stubgen, m) {
|
TEST_SUBMODULE(cases_for_stubgen, m) {
|
||||||
using namespace test_cases_for_stubgen;
|
using UserType = test_cases_for_stubgen::UserType;
|
||||||
|
|
||||||
m.def("pass_user_type", [](const user_type &) {});
|
m.def("pass_user_type", [](const UserType &) {});
|
||||||
m.def("return_user_type", []() { return user_type(); });
|
m.def("return_user_type", []() { return UserType(); });
|
||||||
|
|
||||||
py::bind_map<std::map<int, user_type>>(m, "MapIntUserType");
|
py::bind_map<std::map<int, UserType>>(m, "MapIntUserType");
|
||||||
py::bind_map<std::map<user_type, int>>(m, "MapUserTypeInt");
|
py::bind_map<std::map<UserType, int>>(m, "MapUserTypeInt");
|
||||||
|
|
||||||
#define MAP_TYPE(MapTypePythonName, ...) \
|
#define MAP_TYPE(MapTypePythonName, ...) \
|
||||||
py::class_<__VA_ARGS__>(m, MapTypePythonName) \
|
py::class_<__VA_ARGS__>(m, MapTypePythonName) \
|
||||||
@ -65,8 +65,8 @@ TEST_SUBMODULE(cases_for_stubgen, m) {
|
|||||||
[](const __VA_ARGS__ &v) { return py::make_iterator(v.begin(), v.end()); }, \
|
[](const __VA_ARGS__ &v) { return py::make_iterator(v.begin(), v.end()); }, \
|
||||||
py::keep_alive<0, 1>())
|
py::keep_alive<0, 1>())
|
||||||
|
|
||||||
MAP_TYPE("MapFloatUserType", std::map<float, user_type>);
|
MAP_TYPE("MapFloatUserType", std::map<float, UserType>);
|
||||||
MAP_TYPE("MapUserTypeFloat", std::map<user_type, float>);
|
MAP_TYPE("MapUserTypeFloat", std::map<UserType, float>);
|
||||||
|
|
||||||
#undef MAP_TYPE
|
#undef MAP_TYPE
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@ from pybind11_tests import stl as test_stl
|
|||||||
[
|
[
|
||||||
(
|
(
|
||||||
m.pass_user_type.__doc__,
|
m.pass_user_type.__doc__,
|
||||||
'pass_user_type(arg0: Annotated[Any, "test_cases_for_stubgen::user_type"]) -> None\n',
|
'pass_user_type(arg0: Annotated[Any, "test_cases_for_stubgen::UserType"]) -> None\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.return_user_type.__doc__,
|
m.return_user_type.__doc__,
|
||||||
'return_user_type() -> Annotated[Any, "test_cases_for_stubgen::user_type"]\n',
|
'return_user_type() -> Annotated[Any, "test_cases_for_stubgen::UserType"]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapIntUserType.keys.__doc__,
|
m.MapIntUserType.keys.__doc__,
|
||||||
@ -21,15 +21,15 @@ from pybind11_tests import stl as test_stl
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapIntUserType.values.__doc__,
|
m.MapIntUserType.values.__doc__,
|
||||||
'values(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ValuesView[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n',
|
'values(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ValuesView[Annotated[Any, "test_cases_for_stubgen::UserType"]]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapIntUserType.items.__doc__,
|
m.MapIntUserType.items.__doc__,
|
||||||
'items(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ItemsView[int, Annotated[Any, "test_cases_for_stubgen::user_type"]]\n',
|
'items(self: pybind11_tests.cases_for_stubgen.MapIntUserType) -> pybind11_tests.cases_for_stubgen.ItemsView[int, Annotated[Any, "test_cases_for_stubgen::UserType"]]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapUserTypeInt.keys.__doc__,
|
m.MapUserTypeInt.keys.__doc__,
|
||||||
'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.KeysView[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n',
|
'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.KeysView[Annotated[Any, "test_cases_for_stubgen::UserType"]]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapUserTypeInt.values.__doc__,
|
m.MapUserTypeInt.values.__doc__,
|
||||||
@ -37,7 +37,7 @@ from pybind11_tests import stl as test_stl
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapUserTypeInt.items.__doc__,
|
m.MapUserTypeInt.items.__doc__,
|
||||||
'items(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.ItemsView[Annotated[Any, "test_cases_for_stubgen::user_type"], int]\n',
|
'items(self: pybind11_tests.cases_for_stubgen.MapUserTypeInt) -> pybind11_tests.cases_for_stubgen.ItemsView[Annotated[Any, "test_cases_for_stubgen::UserType"], int]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapFloatUserType.keys.__doc__,
|
m.MapFloatUserType.keys.__doc__,
|
||||||
@ -45,15 +45,15 @@ from pybind11_tests import stl as test_stl
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapFloatUserType.values.__doc__,
|
m.MapFloatUserType.values.__doc__,
|
||||||
'values(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n',
|
'values(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[Annotated[Any, "test_cases_for_stubgen::UserType"]]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapFloatUserType.__iter__.__doc__,
|
m.MapFloatUserType.__iter__.__doc__,
|
||||||
'__iter__(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[tuple[float, Annotated[Any, "test_cases_for_stubgen::user_type"]]]\n',
|
'__iter__(self: pybind11_tests.cases_for_stubgen.MapFloatUserType) -> Iterator[tuple[float, Annotated[Any, "test_cases_for_stubgen::UserType"]]]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapUserTypeFloat.keys.__doc__,
|
m.MapUserTypeFloat.keys.__doc__,
|
||||||
'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[Annotated[Any, "test_cases_for_stubgen::user_type"]]\n',
|
'keys(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[Annotated[Any, "test_cases_for_stubgen::UserType"]]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapUserTypeFloat.values.__doc__,
|
m.MapUserTypeFloat.values.__doc__,
|
||||||
@ -61,7 +61,7 @@ from pybind11_tests import stl as test_stl
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
m.MapUserTypeFloat.__iter__.__doc__,
|
m.MapUserTypeFloat.__iter__.__doc__,
|
||||||
'__iter__(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[tuple[Annotated[Any, "test_cases_for_stubgen::user_type"], float]]\n',
|
'__iter__(self: pybind11_tests.cases_for_stubgen.MapUserTypeFloat) -> Iterator[tuple[Annotated[Any, "test_cases_for_stubgen::UserType"], float]]\n',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
test_stl.cast_array.__doc__,
|
test_stl.cast_array.__doc__,
|
||||||
|
Loading…
Reference in New Issue
Block a user