[CI] Now using clang-format from pip (#662)
This commit is contained in:
@@ -1336,9 +1336,12 @@ template <typename StringType, bool IsView = false> struct string_caster {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
object utfNbytes = reinterpret_steal<object>(PyUnicode_AsEncodedString(
|
object utfNbytes = reinterpret_steal<object>(
|
||||||
load_src.ptr(),
|
PyUnicode_AsEncodedString(load_src.ptr(),
|
||||||
UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr));
|
UTF_N == 8 ? "utf-8"
|
||||||
|
: UTF_N == 16 ? "utf-16"
|
||||||
|
: "utf-32",
|
||||||
|
nullptr));
|
||||||
if (!utfNbytes) {
|
if (!utfNbytes) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
return false;
|
return false;
|
||||||
@@ -1377,8 +1380,7 @@ template <typename StringType, bool IsView = false> struct string_caster {
|
|||||||
private:
|
private:
|
||||||
static handle decode_utfN(const char *buffer, ssize_t nbytes) {
|
static handle decode_utfN(const char *buffer, ssize_t nbytes) {
|
||||||
#if !defined(PYPY_VERSION)
|
#if !defined(PYPY_VERSION)
|
||||||
return UTF_N == 8
|
return UTF_N == 8 ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr)
|
||||||
? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr)
|
|
||||||
: UTF_N == 16
|
: UTF_N == 16
|
||||||
? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr)
|
? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr)
|
||||||
: PyUnicode_DecodeUTF32(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,
|
// 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,
|
// so bypass the whole thing by just passing the encoding as a string value,
|
||||||
// which works properly:
|
// which works properly:
|
||||||
return PyUnicode_Decode(
|
return PyUnicode_Decode(buffer, nbytes,
|
||||||
buffer, nbytes,
|
UTF_N == 8 ? "utf-8"
|
||||||
UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr);
|
: UTF_N == 16 ? "utf-16"
|
||||||
|
: "utf-32",
|
||||||
|
nullptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1496,7 +1500,8 @@ public:
|
|||||||
unsigned char v0 = static_cast<unsigned char>(value[0]);
|
unsigned char v0 = static_cast<unsigned char>(value[0]);
|
||||||
size_t char0_bytes =
|
size_t char0_bytes =
|
||||||
!(v0 & 0x80) ? 1 : // low bits only: 0-127
|
!(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
|
(v0 & 0xF0) == 0xE0 ? 3
|
||||||
: // 0b1110xxxx - start of 3-byte sequence
|
: // 0b1110xxxx - start of 3-byte sequence
|
||||||
4; // 0b11110xxx - start of 4-byte sequence
|
4; // 0b11110xxx - start of 4-byte sequence
|
||||||
|
@@ -808,9 +808,9 @@ struct is_fmt_numeric<T, enable_if_t<std::is_arithmetic<T>::value>> {
|
|||||||
? 0
|
? 0
|
||||||
: 1 + (std::is_integral<T>::value
|
: 1 + (std::is_integral<T>::value
|
||||||
? detail::log2(sizeof(T)) * 2 + std::is_unsigned<T>::value
|
? detail::log2(sizeof(T)) * 2 + std::is_unsigned<T>::value
|
||||||
: 8 + (std::is_same<T, double>::value
|
: 8 + (std::is_same<T, double>::value ? 1
|
||||||
? 1
|
: std::is_same<T, long double>::value ? 2
|
||||||
: std::is_same<T, long double>::value ? 2 : 0));
|
: 0));
|
||||||
};
|
};
|
||||||
NAMESPACE_END(detail)
|
NAMESPACE_END(detail)
|
||||||
|
|
||||||
|
@@ -164,7 +164,9 @@ template <typename Type_> struct EigenProps {
|
|||||||
static constexpr EigenIndex
|
static constexpr EigenIndex
|
||||||
inner_stride = if_zero<StrideType::InnerStrideAtCompileTime, 1>::value,
|
inner_stride = if_zero<StrideType::InnerStrideAtCompileTime, 1>::value,
|
||||||
outer_stride = if_zero < StrideType::OuterStrideAtCompileTime,
|
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 =
|
static constexpr bool dynamic_stride =
|
||||||
inner_stride == Eigen::Dynamic && outer_stride == Eigen::Dynamic;
|
inner_stride == Eigen::Dynamic && outer_stride == Eigen::Dynamic;
|
||||||
static constexpr bool requires_row_major =
|
static constexpr bool requires_row_major =
|
||||||
@@ -471,13 +473,12 @@ private:
|
|||||||
using props = EigenProps<Type>;
|
using props = EigenProps<Type>;
|
||||||
using Scalar = typename props::Scalar;
|
using Scalar = typename props::Scalar;
|
||||||
using MapType = Eigen::Map<PlainObjectType, 0, StrideType>;
|
using MapType = Eigen::Map<PlainObjectType, 0, StrideType>;
|
||||||
using Array =
|
using Array = array_t<
|
||||||
array_t<Scalar, array::forcecast |
|
Scalar,
|
||||||
((props::row_major ? props::inner_stride
|
array::forcecast |
|
||||||
: props::outer_stride) == 1
|
((props::row_major ? props::inner_stride : props::outer_stride) == 1
|
||||||
? array::c_style
|
? array::c_style
|
||||||
: (props::row_major ? props::outer_stride
|
: (props::row_major ? props::outer_stride : props::inner_stride) == 1
|
||||||
: props::inner_stride) == 1
|
|
||||||
? array::f_style
|
? array::f_style
|
||||||
: 0)>;
|
: 0)>;
|
||||||
static constexpr bool need_writeable = is_eigen_mutable_map<Type>::value;
|
static constexpr bool need_writeable = is_eigen_mutable_map<Type>::value;
|
||||||
|
@@ -1299,10 +1299,10 @@ private:
|
|||||||
#define PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, Name) \
|
#define PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, Name) \
|
||||||
::pybind11::detail::field_descriptor { \
|
::pybind11::detail::field_descriptor { \
|
||||||
Name, offsetof(T, Field), sizeof(decltype(std::declval<T>().Field)), \
|
Name, offsetof(T, Field), sizeof(decltype(std::declval<T>().Field)), \
|
||||||
::pybind11::format_descriptor<decltype( \
|
::pybind11::format_descriptor< \
|
||||||
std::declval<T>().Field)>::format(), \
|
decltype(std::declval<T>().Field)>::format(), \
|
||||||
::pybind11::detail::npy_format_descriptor<decltype( \
|
::pybind11::detail::npy_format_descriptor< \
|
||||||
std::declval<T>().Field)>::dtype() \
|
decltype(std::declval<T>().Field)>::dtype() \
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract name, offset and format descriptor for a struct field
|
// 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
|
return trivial_broadcast_c ? broadcast_trivial::c_trivial
|
||||||
? broadcast_trivial::c_trivial
|
|
||||||
: trivial_broadcast_f ? broadcast_trivial::f_trivial
|
: trivial_broadcast_f ? broadcast_trivial::f_trivial
|
||||||
: broadcast_trivial::non_trivial;
|
: broadcast_trivial::non_trivial;
|
||||||
}
|
}
|
||||||
|
@@ -102,7 +102,8 @@ template <op_id id, op_type ot, typename L, typename R> struct op_ {
|
|||||||
#if PY_MAJOR_VERSION < 3
|
#if PY_MAJOR_VERSION < 3
|
||||||
if (id == op_truediv || id == op_itruediv)
|
if (id == op_truediv || id == op_itruediv)
|
||||||
cl.def(id == op_itruediv ? "__idiv__"
|
cl.def(id == op_itruediv ? "__idiv__"
|
||||||
: ot == op_l ? "__div__" : "__rdiv__",
|
: ot == op_l ? "__div__"
|
||||||
|
: "__rdiv__",
|
||||||
&op::execute, is_operator(), extra...);
|
&op::execute, is_operator(), extra...);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -116,7 +117,8 @@ template <op_id id, op_type ot, typename L, typename R> struct op_ {
|
|||||||
#if PY_MAJOR_VERSION < 3
|
#if PY_MAJOR_VERSION < 3
|
||||||
if (id == op_truediv || id == op_itruediv)
|
if (id == op_truediv || id == op_itruediv)
|
||||||
cl.def(id == op_itruediv ? "__idiv__"
|
cl.def(id == op_itruediv ? "__idiv__"
|
||||||
: ot == op_l ? "__div__" : "__rdiv__",
|
: ot == op_l ? "__div__"
|
||||||
|
: "__rdiv__",
|
||||||
&op::execute, is_operator(), extra...);
|
&op::execute, is_operator(), extra...);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -1104,8 +1104,8 @@ protected:
|
|||||||
|
|
||||||
/// Set the pointer to operator new if it exists. The cast is needed because it
|
/// Set the pointer to operator new if it exists. The cast is needed because it
|
||||||
/// can be overloaded.
|
/// can be overloaded.
|
||||||
template <typename T, typename = void_t<decltype(
|
template <typename T, typename = void_t<decltype(static_cast<void *(*)(size_t)>(
|
||||||
static_cast<void *(*)(size_t)>(T::operator new))>>
|
T::operator new))>>
|
||||||
void set_operator_new(type_record *r) {
|
void set_operator_new(type_record *r) {
|
||||||
r->operator_new = &T::operator new;
|
r->operator_new = &T::operator new;
|
||||||
}
|
}
|
||||||
@@ -1291,8 +1291,7 @@ public:
|
|||||||
|
|
||||||
template <detail::op_id id, detail::op_type ot, typename L, typename R,
|
template <detail::op_id id, detail::op_type ot, typename L, typename R,
|
||||||
typename... Extra>
|
typename... Extra>
|
||||||
class_ &def_cast(const detail::op_<id, ot, L, R> &op,
|
class_ &def_cast(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
|
||||||
const Extra &... extra) {
|
|
||||||
op.execute_cast(*this, extra...);
|
op.execute_cast(*this, extra...);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -1379,8 +1378,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename D, typename... Extra>
|
template <typename D, typename... Extra>
|
||||||
class_ &def_readwrite_static(const char *name, D *pm,
|
class_ &def_readwrite_static(const char *name, D *pm, const Extra &...extra) {
|
||||||
const Extra &... extra) {
|
|
||||||
cpp_function fget([pm](object) -> const D & { return *pm; }, scope(*this)),
|
cpp_function fget([pm](object) -> const D & { return *pm; }, scope(*this)),
|
||||||
fset([pm](object, const D &value) { *pm = value; }, scope(*this));
|
fset([pm](object, const D &value) { *pm = value; }, scope(*this));
|
||||||
def_property_static(name, fget, fset, return_value_policy::reference,
|
def_property_static(name, fget, fset, return_value_policy::reference,
|
||||||
@@ -1453,8 +1451,7 @@ public:
|
|||||||
/// Uses return_value_policy::reference by default
|
/// Uses return_value_policy::reference by default
|
||||||
template <typename Getter, typename... Extra>
|
template <typename Getter, typename... Extra>
|
||||||
class_ &def_property_static(const char *name, const Getter &fget,
|
class_ &def_property_static(const char *name, const Getter &fget,
|
||||||
const cpp_function &fset,
|
const cpp_function &fset, const Extra &...extra) {
|
||||||
const Extra &... extra) {
|
|
||||||
return def_property_static(name, cpp_function(fget), fset,
|
return def_property_static(name, cpp_function(fget), fset,
|
||||||
return_value_policy::reference, extra...);
|
return_value_policy::reference, extra...);
|
||||||
}
|
}
|
||||||
@@ -1462,8 +1459,7 @@ public:
|
|||||||
/// Uses cpp_function's return_value_policy by default
|
/// Uses cpp_function's return_value_policy by default
|
||||||
template <typename... Extra>
|
template <typename... Extra>
|
||||||
class_ &def_property_static(const char *name, const cpp_function &fget,
|
class_ &def_property_static(const char *name, const cpp_function &fget,
|
||||||
const cpp_function &fset,
|
const cpp_function &fset, const Extra &...extra) {
|
||||||
const Extra &... extra) {
|
|
||||||
static_assert(
|
static_assert(
|
||||||
0 == detail::constexpr_sum(std::is_base_of<arg, Extra>::value...),
|
0 == detail::constexpr_sum(std::is_base_of<arg, Extra>::value...),
|
||||||
"Argument annotations are not allowed for properties");
|
"Argument annotations are not allowed for properties");
|
||||||
|
@@ -1282,10 +1282,8 @@ public:
|
|||||||
template <typename T,
|
template <typename T,
|
||||||
detail::enable_if_t<std::is_integral<T>::value, int> = 0>
|
detail::enable_if_t<std::is_integral<T>::value, int> = 0>
|
||||||
operator T() const {
|
operator T() const {
|
||||||
return std::is_unsigned<T>::value
|
return std::is_unsigned<T>::value ? detail::as_unsigned<T>(m_ptr)
|
||||||
? detail::as_unsigned<T>(m_ptr)
|
: sizeof(T) <= sizeof(long) ? (T)PyLong_AsLong(m_ptr)
|
||||||
: sizeof(T) <= sizeof(long)
|
|
||||||
? (T)PyLong_AsLong(m_ptr)
|
|
||||||
: (T)PYBIND11_LONG_AS_LONGLONG(m_ptr);
|
: (T)PYBIND11_LONG_AS_LONGLONG(m_ptr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user