[CI] Now using clang-format from pip (#662)

This commit is contained in:
Philippe Tillet
2022-09-15 16:24:37 -07:00
committed by GitHub
parent 43be75ad42
commit 80e3fb5270
15 changed files with 126 additions and 125 deletions

View File

@@ -1336,9 +1336,12 @@ template <typename StringType, bool IsView = false> struct string_caster {
#endif
}
object utfNbytes = reinterpret_steal<object>(PyUnicode_AsEncodedString(
load_src.ptr(),
UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr));
object utfNbytes = reinterpret_steal<object>(
PyUnicode_AsEncodedString(load_src.ptr(),
UTF_N == 8 ? "utf-8"
: UTF_N == 16 ? "utf-16"
: "utf-32",
nullptr));
if (!utfNbytes) {
PyErr_Clear();
return false;
@@ -1377,8 +1380,7 @@ template <typename StringType, bool IsView = false> struct string_caster {
private:
static handle decode_utfN(const char *buffer, ssize_t nbytes) {
#if !defined(PYPY_VERSION)
return UTF_N == 8
? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr)
return UTF_N == 8 ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr)
: UTF_N == 16
? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr)
: PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr);
@@ -1388,9 +1390,11 @@ private:
// versions require a non-const char * arguments, which is also a nuisance,
// so bypass the whole thing by just passing the encoding as a string value,
// which works properly:
return PyUnicode_Decode(
buffer, nbytes,
UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr);
return PyUnicode_Decode(buffer, nbytes,
UTF_N == 8 ? "utf-8"
: UTF_N == 16 ? "utf-16"
: "utf-32",
nullptr);
#endif
}
@@ -1496,7 +1500,8 @@ public:
unsigned char v0 = static_cast<unsigned char>(value[0]);
size_t char0_bytes =
!(v0 & 0x80) ? 1 : // low bits only: 0-127
(v0 & 0xE0) == 0xC0 ? 2 : // 0b110xxxxx - start of 2-byte sequence
(v0 & 0xE0) == 0xC0 ? 2
: // 0b110xxxxx - start of 2-byte sequence
(v0 & 0xF0) == 0xE0 ? 3
: // 0b1110xxxx - start of 3-byte sequence
4; // 0b11110xxx - start of 4-byte sequence

View File

@@ -808,9 +808,9 @@ struct is_fmt_numeric<T, enable_if_t<std::is_arithmetic<T>::value>> {
? 0
: 1 + (std::is_integral<T>::value
? detail::log2(sizeof(T)) * 2 + std::is_unsigned<T>::value
: 8 + (std::is_same<T, double>::value
? 1
: std::is_same<T, long double>::value ? 2 : 0));
: 8 + (std::is_same<T, double>::value ? 1
: std::is_same<T, long double>::value ? 2
: 0));
};
NAMESPACE_END(detail)

View File

@@ -164,7 +164,9 @@ template <typename Type_> struct EigenProps {
static constexpr EigenIndex
inner_stride = if_zero<StrideType::InnerStrideAtCompileTime, 1>::value,
outer_stride = if_zero < StrideType::OuterStrideAtCompileTime,
vector ? size : row_major ? cols : rows > ::value;
vector ? size
: row_major ? cols
: rows > ::value;
static constexpr bool dynamic_stride =
inner_stride == Eigen::Dynamic && outer_stride == Eigen::Dynamic;
static constexpr bool requires_row_major =
@@ -471,13 +473,12 @@ private:
using props = EigenProps<Type>;
using Scalar = typename props::Scalar;
using MapType = Eigen::Map<PlainObjectType, 0, StrideType>;
using Array =
array_t<Scalar, array::forcecast |
((props::row_major ? props::inner_stride
: props::outer_stride) == 1
using Array = array_t<
Scalar,
array::forcecast |
((props::row_major ? props::inner_stride : props::outer_stride) == 1
? array::c_style
: (props::row_major ? props::outer_stride
: props::inner_stride) == 1
: (props::row_major ? props::outer_stride : props::inner_stride) == 1
? array::f_style
: 0)>;
static constexpr bool need_writeable = is_eigen_mutable_map<Type>::value;

View File

@@ -1299,10 +1299,10 @@ private:
#define PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, Name) \
::pybind11::detail::field_descriptor { \
Name, offsetof(T, Field), sizeof(decltype(std::declval<T>().Field)), \
::pybind11::format_descriptor<decltype( \
std::declval<T>().Field)>::format(), \
::pybind11::detail::npy_format_descriptor<decltype( \
std::declval<T>().Field)>::dtype() \
::pybind11::format_descriptor< \
decltype(std::declval<T>().Field)>::format(), \
::pybind11::detail::npy_format_descriptor< \
decltype(std::declval<T>().Field)>::dtype() \
}
// Extract name, offset and format descriptor for a struct field
@@ -1576,8 +1576,7 @@ broadcast_trivial broadcast(const std::array<buffer_info, N> &buffers,
}
}
return trivial_broadcast_c
? broadcast_trivial::c_trivial
return trivial_broadcast_c ? broadcast_trivial::c_trivial
: trivial_broadcast_f ? broadcast_trivial::f_trivial
: broadcast_trivial::non_trivial;
}

View File

@@ -102,7 +102,8 @@ template <op_id id, op_type ot, typename L, typename R> struct op_ {
#if PY_MAJOR_VERSION < 3
if (id == op_truediv || id == op_itruediv)
cl.def(id == op_itruediv ? "__idiv__"
: ot == op_l ? "__div__" : "__rdiv__",
: ot == op_l ? "__div__"
: "__rdiv__",
&op::execute, is_operator(), extra...);
#endif
}
@@ -116,7 +117,8 @@ template <op_id id, op_type ot, typename L, typename R> struct op_ {
#if PY_MAJOR_VERSION < 3
if (id == op_truediv || id == op_itruediv)
cl.def(id == op_itruediv ? "__idiv__"
: ot == op_l ? "__div__" : "__rdiv__",
: ot == op_l ? "__div__"
: "__rdiv__",
&op::execute, is_operator(), extra...);
#endif
}

View File

@@ -1104,8 +1104,8 @@ protected:
/// Set the pointer to operator new if it exists. The cast is needed because it
/// can be overloaded.
template <typename T, typename = void_t<decltype(
static_cast<void *(*)(size_t)>(T::operator new))>>
template <typename T, typename = void_t<decltype(static_cast<void *(*)(size_t)>(
T::operator new))>>
void set_operator_new(type_record *r) {
r->operator_new = &T::operator new;
}
@@ -1291,8 +1291,7 @@ public:
template <detail::op_id id, detail::op_type ot, typename L, typename R,
typename... Extra>
class_ &def_cast(const detail::op_<id, ot, L, R> &op,
const Extra &... extra) {
class_ &def_cast(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
op.execute_cast(*this, extra...);
return *this;
}
@@ -1379,8 +1378,7 @@ public:
}
template <typename D, typename... Extra>
class_ &def_readwrite_static(const char *name, D *pm,
const Extra &... extra) {
class_ &def_readwrite_static(const char *name, D *pm, const Extra &...extra) {
cpp_function fget([pm](object) -> const D & { return *pm; }, scope(*this)),
fset([pm](object, const D &value) { *pm = value; }, scope(*this));
def_property_static(name, fget, fset, return_value_policy::reference,
@@ -1453,8 +1451,7 @@ public:
/// Uses return_value_policy::reference by default
template <typename Getter, typename... Extra>
class_ &def_property_static(const char *name, const Getter &fget,
const cpp_function &fset,
const Extra &... extra) {
const cpp_function &fset, const Extra &...extra) {
return def_property_static(name, cpp_function(fget), fset,
return_value_policy::reference, extra...);
}
@@ -1462,8 +1459,7 @@ public:
/// Uses cpp_function's return_value_policy by default
template <typename... Extra>
class_ &def_property_static(const char *name, const cpp_function &fget,
const cpp_function &fset,
const Extra &... extra) {
const cpp_function &fset, const Extra &...extra) {
static_assert(
0 == detail::constexpr_sum(std::is_base_of<arg, Extra>::value...),
"Argument annotations are not allowed for properties");

View File

@@ -1282,10 +1282,8 @@ public:
template <typename T,
detail::enable_if_t<std::is_integral<T>::value, int> = 0>
operator T() const {
return std::is_unsigned<T>::value
? detail::as_unsigned<T>(m_ptr)
: sizeof(T) <= sizeof(long)
? (T)PyLong_AsLong(m_ptr)
return std::is_unsigned<T>::value ? detail::as_unsigned<T>(m_ptr)
: sizeof(T) <= sizeof(long) ? (T)PyLong_AsLong(m_ptr)
: (T)PYBIND11_LONG_AS_LONGLONG(m_ptr);
}
};