mirror of
https://github.com/RYDE-WORK/pybind11.git
synced 2026-02-05 15:03:18 +08:00
fix: AppleClang 12 warnings (#2510)
* fix: AppleClang 12 new warning * Fix: AppleClang X.X.0 will not trigger this warning
This commit is contained in:
parent
4a288ab928
commit
d0ed035cc5
@ -2092,7 +2092,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void process(list &args_list, detail::args_proxy ap) {
|
void process(list &args_list, detail::args_proxy ap) {
|
||||||
for (const auto &a : ap)
|
for (auto a : ap)
|
||||||
args_list.append(a);
|
args_list.append(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2124,7 +2124,7 @@ private:
|
|||||||
void process(list &/*args_list*/, detail::kwargs_proxy kp) {
|
void process(list &/*args_list*/, detail::kwargs_proxy kp) {
|
||||||
if (!kp)
|
if (!kp)
|
||||||
return;
|
return;
|
||||||
for (const auto &k : reinterpret_borrow<dict>(kp)) {
|
for (auto k : reinterpret_borrow<dict>(kp)) {
|
||||||
if (m_kwargs.contains(k.first)) {
|
if (m_kwargs.contains(k.first)) {
|
||||||
#if defined(NDEBUG)
|
#if defined(NDEBUG)
|
||||||
multiple_values_error();
|
multiple_values_error();
|
||||||
|
|||||||
@ -1494,7 +1494,7 @@ struct enum_base {
|
|||||||
handle type = type::handle_of(arg);
|
handle type = type::handle_of(arg);
|
||||||
object type_name = type.attr("__name__");
|
object type_name = type.attr("__name__");
|
||||||
dict entries = type.attr("__entries");
|
dict entries = type.attr("__entries");
|
||||||
for (const auto &kv : entries) {
|
for (auto kv : entries) {
|
||||||
object other = kv.second[int_(0)];
|
object other = kv.second[int_(0)];
|
||||||
if (other.equal(arg))
|
if (other.equal(arg))
|
||||||
return pybind11::str("{}.{}").format(type_name, kv.first);
|
return pybind11::str("{}.{}").format(type_name, kv.first);
|
||||||
@ -1506,7 +1506,7 @@ struct enum_base {
|
|||||||
m_base.attr("name") = property(cpp_function(
|
m_base.attr("name") = property(cpp_function(
|
||||||
[](handle arg) -> str {
|
[](handle arg) -> str {
|
||||||
dict entries = type::handle_of(arg).attr("__entries");
|
dict entries = type::handle_of(arg).attr("__entries");
|
||||||
for (const auto &kv : entries) {
|
for (auto kv : entries) {
|
||||||
if (handle(kv.second[int_(0)]).equal(arg))
|
if (handle(kv.second[int_(0)]).equal(arg))
|
||||||
return pybind11::str(kv.first);
|
return pybind11::str(kv.first);
|
||||||
}
|
}
|
||||||
@ -1521,7 +1521,7 @@ struct enum_base {
|
|||||||
if (((PyTypeObject *) arg.ptr())->tp_doc)
|
if (((PyTypeObject *) arg.ptr())->tp_doc)
|
||||||
docstring += std::string(((PyTypeObject *) arg.ptr())->tp_doc) + "\n\n";
|
docstring += std::string(((PyTypeObject *) arg.ptr())->tp_doc) + "\n\n";
|
||||||
docstring += "Members:";
|
docstring += "Members:";
|
||||||
for (const auto &kv : entries) {
|
for (auto kv : entries) {
|
||||||
auto key = std::string(pybind11::str(kv.first));
|
auto key = std::string(pybind11::str(kv.first));
|
||||||
auto comment = kv.second[int_(1)];
|
auto comment = kv.second[int_(1)];
|
||||||
docstring += "\n\n " + key;
|
docstring += "\n\n " + key;
|
||||||
@ -1535,7 +1535,7 @@ struct enum_base {
|
|||||||
m_base.attr("__members__") = static_property(cpp_function(
|
m_base.attr("__members__") = static_property(cpp_function(
|
||||||
[](handle arg) -> dict {
|
[](handle arg) -> dict {
|
||||||
dict entries = arg.attr("__entries"), m;
|
dict entries = arg.attr("__entries"), m;
|
||||||
for (const auto &kv : entries)
|
for (auto kv : entries)
|
||||||
m[kv.first] = kv.second[int_(0)];
|
m[kv.first] = kv.second[int_(0)];
|
||||||
return m;
|
return m;
|
||||||
}, name("__members__")), none(), none(), ""
|
}, name("__members__")), none(), none(), ""
|
||||||
@ -1623,7 +1623,7 @@ struct enum_base {
|
|||||||
|
|
||||||
PYBIND11_NOINLINE void export_values() {
|
PYBIND11_NOINLINE void export_values() {
|
||||||
dict entries = m_base.attr("__entries");
|
dict entries = m_base.attr("__entries");
|
||||||
for (const auto &kv : entries)
|
for (auto kv : entries)
|
||||||
m_parent.attr(kv.first) = kv.second[int_(0)];
|
m_parent.attr(kv.first) = kv.second[int_(0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -89,7 +89,7 @@ std::string abs(const Vector2&) {
|
|||||||
// Taken from: https://github.com/RobotLocomotion/drake/commit/aaf84b46
|
// Taken from: https://github.com/RobotLocomotion/drake/commit/aaf84b46
|
||||||
// TODO(eric): This could be resolved using a function / functor (e.g. `py::self()`).
|
// TODO(eric): This could be resolved using a function / functor (e.g. `py::self()`).
|
||||||
#if defined(__APPLE__) && defined(__clang__)
|
#if defined(__APPLE__) && defined(__clang__)
|
||||||
#if (__clang_major__ >= 10) && (__clang_minor__ >= 0) && (__clang_patchlevel__ >= 1)
|
#if (__clang_major__ >= 10)
|
||||||
#pragma GCC diagnostic ignored "-Wself-assign-overloaded"
|
#pragma GCC diagnostic ignored "-Wself-assign-overloaded"
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__clang__)
|
#elif defined(__clang__)
|
||||||
|
|||||||
@ -128,7 +128,7 @@ TEST_SUBMODULE(pytypes, m) {
|
|||||||
d["basic_attr"] = o.attr("basic_attr");
|
d["basic_attr"] = o.attr("basic_attr");
|
||||||
|
|
||||||
auto l = py::list();
|
auto l = py::list();
|
||||||
for (const auto &item : o.attr("begin_end")) {
|
for (auto item : o.attr("begin_end")) {
|
||||||
l.append(item);
|
l.append(item);
|
||||||
}
|
}
|
||||||
d["begin_end"] = l;
|
d["begin_end"] = l;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user