diff --git a/thirdparty/pybind11/include/pybind11/cast.h b/thirdparty/pybind11/include/pybind11/cast.h index 898047b304..c3b64adec8 100644 --- a/thirdparty/pybind11/include/pybind11/cast.h +++ b/thirdparty/pybind11/include/pybind11/cast.h @@ -225,7 +225,7 @@ public: return PyLong_FromUnsignedLongLong((unsigned long long) src); } - PYBIND11_TYPE_CASTER(T, _::value>("int", "float")); + PYBIND11_TYPE_CASTER(T, _x::value>("int", "float")); }; template struct void_caster { @@ -238,7 +238,7 @@ public: static handle cast(T, return_value_policy /* policy */, handle /* parent */) { return none().inc_ref(); } - PYBIND11_TYPE_CASTER(T, _("None")); + PYBIND11_TYPE_CASTER(T, _x("None")); }; template <> class type_caster : public void_caster {}; @@ -281,7 +281,7 @@ public: template using cast_op_type = void*&; operator void *&() { return value; } - static constexpr auto name = _("capsule"); + static constexpr auto name = _x("capsule"); private: void *value = nullptr; }; @@ -332,7 +332,7 @@ public: static handle cast(bool src, return_value_policy /* policy */, handle /* parent */) { return handle(src ? Py_True : Py_False).inc_ref(); } - PYBIND11_TYPE_CASTER(bool, _("bool")); + PYBIND11_TYPE_CASTER(bool, _x("bool")); }; // Helper class for UTF-{8,16,32} C++ stl strings: @@ -402,7 +402,7 @@ template struct string_caster { return s; } - PYBIND11_TYPE_CASTER(StringType, _(PYBIND11_STRING_NAME)); + PYBIND11_TYPE_CASTER(StringType, _x(PYBIND11_STRING_NAME)); private: static handle decode_utfN(const char *buffer, ssize_t nbytes) { @@ -537,7 +537,7 @@ public: return one_char; } - static constexpr auto name = _(PYBIND11_STRING_NAME); + static constexpr auto name = _x(PYBIND11_STRING_NAME); template using cast_op_type = pybind11::detail::cast_op_type<_T>; }; @@ -574,7 +574,7 @@ public: return cast(*src, policy, parent); } - static constexpr auto name = _("Tuple[") + concat(make_caster::name...) + _("]"); + static constexpr auto name = _x("Tuple[") + concat(make_caster::name...) + _x("]"); template using cast_op_type = type; @@ -757,14 +757,14 @@ template struct is_holder_type : template struct is_holder_type> : std::true_type {}; -template struct handle_type_name { static constexpr auto name = _(); }; -template <> struct handle_type_name { static constexpr auto name = _(PYBIND11_BYTES_NAME); }; -template <> struct handle_type_name { static constexpr auto name = _("int"); }; -template <> struct handle_type_name { static constexpr auto name = _("Iterable"); }; -template <> struct handle_type_name { static constexpr auto name = _("Iterator"); }; -template <> struct handle_type_name { static constexpr auto name = _("None"); }; -template <> struct handle_type_name { static constexpr auto name = _("*args"); }; -template <> struct handle_type_name { static constexpr auto name = _("**kwargs"); }; +template struct handle_type_name { static constexpr auto name = _x(); }; +template <> struct handle_type_name { static constexpr auto name = _x(PYBIND11_BYTES_NAME); }; +template <> struct handle_type_name { static constexpr auto name = _x("int"); }; +template <> struct handle_type_name { static constexpr auto name = _x("Iterable"); }; +template <> struct handle_type_name { static constexpr auto name = _x("Iterator"); }; +template <> struct handle_type_name { static constexpr auto name = _x("None"); }; +template <> struct handle_type_name { static constexpr auto name = _x("*args"); }; +template <> struct handle_type_name { static constexpr auto name = _x("**kwargs"); }; template struct pyobject_caster { diff --git a/thirdparty/pybind11/include/pybind11/chrono.h b/thirdparty/pybind11/include/pybind11/chrono.h index 61bbcbc540..7704b90fb1 100644 --- a/thirdparty/pybind11/include/pybind11/chrono.h +++ b/thirdparty/pybind11/include/pybind11/chrono.h @@ -97,7 +97,7 @@ public: return PyDelta_FromDSU(dd.count(), ss.count(), us.count()); } - PYBIND11_TYPE_CASTER(type, _("datetime.timedelta")); + PYBIND11_TYPE_CASTER(type, _x("datetime.timedelta")); }; inline std::tm *localtime_thread_safe(const std::time_t *time, std::tm *buf) { @@ -195,7 +195,7 @@ public: localtime.tm_sec, us.count()); } - PYBIND11_TYPE_CASTER(type, _("datetime.datetime")); + PYBIND11_TYPE_CASTER(type, _x("datetime.datetime")); }; // Other clocks that are not the system clock are not measured as datetime.datetime objects diff --git a/thirdparty/pybind11/include/pybind11/complex.h b/thirdparty/pybind11/include/pybind11/complex.h index f8327eb373..457f895b04 100644 --- a/thirdparty/pybind11/include/pybind11/complex.h +++ b/thirdparty/pybind11/include/pybind11/complex.h @@ -59,7 +59,7 @@ public: return PyComplex_FromDoubles((double) src.real(), (double) src.imag()); } - PYBIND11_TYPE_CASTER(std::complex, _("complex")); + PYBIND11_TYPE_CASTER(std::complex, _x("complex")); }; PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) diff --git a/thirdparty/pybind11/include/pybind11/detail/descr.h b/thirdparty/pybind11/include/pybind11/detail/descr.h index 7cb8350e7b..abc7b754c9 100644 --- a/thirdparty/pybind11/include/pybind11/detail/descr.h +++ b/thirdparty/pybind11/include/pybind11/detail/descr.h @@ -51,8 +51,8 @@ constexpr descr operator+(const descr &a, c } template -constexpr descr _(char const(&text)[N]) { return descr(text); } -constexpr descr<0> _(char const(&)[1]) { return {}; } +constexpr descr _x(char const(&text)[N]) { return descr(text); } +constexpr descr<0> _x(char const(&)[1]) { return {}; } template struct int_to_str : int_to_str { }; template struct int_to_str<0, Digits...> { @@ -61,24 +61,24 @@ template struct int_to_str<0, Digits...> { // Ternary description (like std::conditional) template -constexpr enable_if_t> _(char const(&text1)[N1], char const(&)[N2]) { - return _(text1); +constexpr enable_if_t> _x(char const(&text1)[N1], char const(&)[N2]) { + return _x(text1); } template -constexpr enable_if_t> _(char const(&)[N1], char const(&text2)[N2]) { - return _(text2); +constexpr enable_if_t> _x(char const(&)[N1], char const(&text2)[N2]) { + return _x(text2); } template -constexpr enable_if_t _(const T1 &d, const T2 &) { return d; } +constexpr enable_if_t _x(const T1 &d, const T2 &) { return d; } template -constexpr enable_if_t _(const T1 &, const T2 &d) { return d; } +constexpr enable_if_t _x(const T1 &, const T2 &d) { return d; } -template auto constexpr _() -> decltype(int_to_str::digits) { +template auto constexpr _x() -> decltype(int_to_str::digits) { return int_to_str::digits; } -template constexpr descr<1, Type> _() { return {'%'}; } +template constexpr descr<1, Type> _x() { return {'%'}; } constexpr descr<0> concat() { return {}; } @@ -88,12 +88,12 @@ constexpr descr concat(const descr &descr) { return descr; } template constexpr auto concat(const descr &d, const Args &...args) -> decltype(std::declval>() + concat(args...)) { - return d + _(", ") + concat(args...); + return d + _x(", ") + concat(args...); } template constexpr descr type_descr(const descr &descr) { - return _("{") + descr + _("}"); + return _x("{") + descr + _x("}"); } PYBIND11_NAMESPACE_END(detail) diff --git a/thirdparty/pybind11/include/pybind11/detail/init.h b/thirdparty/pybind11/include/pybind11/detail/init.h index 3269e04254..7dac70ef5a 100644 --- a/thirdparty/pybind11/include/pybind11/detail/init.h +++ b/thirdparty/pybind11/include/pybind11/detail/init.h @@ -24,7 +24,7 @@ public: template using cast_op_type = value_and_holder &; operator value_and_holder &() { return *value; } - static constexpr auto name = _(); + static constexpr auto name = _x(); private: value_and_holder *value = nullptr; diff --git a/thirdparty/pybind11/include/pybind11/detail/type_caster_base.h b/thirdparty/pybind11/include/pybind11/detail/type_caster_base.h index 7a74133f6e..68a5c9a58b 100644 --- a/thirdparty/pybind11/include/pybind11/detail/type_caster_base.h +++ b/thirdparty/pybind11/include/pybind11/detail/type_caster_base.h @@ -865,7 +865,7 @@ template class type_caster_base : public type_caster_generic { using itype = intrinsic_t; public: - static constexpr auto name = _(); + static constexpr auto name = _x(); type_caster_base() : type_caster_base(typeid(type)) { } explicit type_caster_base(const std::type_info &info) : type_caster_generic(info) { } diff --git a/thirdparty/pybind11/include/pybind11/eigen.h b/thirdparty/pybind11/include/pybind11/eigen.h index 218fe27034..72c383cf28 100644 --- a/thirdparty/pybind11/include/pybind11/eigen.h +++ b/thirdparty/pybind11/include/pybind11/eigen.h @@ -189,20 +189,20 @@ template struct EigenProps { static constexpr bool show_f_contiguous = !show_c_contiguous && show_order && requires_col_major; static constexpr auto descriptor = - _("numpy.ndarray[") + npy_format_descriptor::name + - _("[") + _(_<(size_t) rows>(), _("m")) + - _(", ") + _(_<(size_t) cols>(), _("n")) + - _("]") + + _x("numpy.ndarray[") + npy_format_descriptor::name + + _x("[") + _x(_x<(size_t) rows>(), _x("m")) + + _x(", ") + _x(_x<(size_t) cols>(), _x("n")) + + _x("]") + // For a reference type (e.g. Ref) we have other constraints that might need to be // satisfied: writeable=True (for a mutable reference), and, depending on the map's stride // options, possibly f_contiguous or c_contiguous. We include them in the descriptor output // to provide some hint as to why a TypeError is occurring (otherwise it can be confusing to // see that a function accepts a 'numpy.ndarray[float64[3,2]]' and an error message that you // *gave* a numpy.ndarray of the right type and dimensions. - _(", flags.writeable", "") + - _(", flags.c_contiguous", "") + - _(", flags.f_contiguous", "") + - _("]"); + _x(", flags.writeable", "") + + _x(", flags.c_contiguous", "") + + _x(", flags.f_contiguous", "") + + _x("]"); }; // Casts an Eigen type to numpy array. If given a base, the numpy array references the src data, @@ -590,8 +590,8 @@ struct type_caster::value>> { ).release(); } - PYBIND11_TYPE_CASTER(Type, _<(Type::IsRowMajor) != 0>("scipy.sparse.csr_matrix[", "scipy.sparse.csc_matrix[") - + npy_format_descriptor::name + _("]")); + PYBIND11_TYPE_CASTER(Type, _x<(Type::IsRowMajor) != 0>("scipy.sparse.csr_matrix[", "scipy.sparse.csc_matrix[") + + npy_format_descriptor::name + _x("]")); }; PYBIND11_NAMESPACE_END(detail) diff --git a/thirdparty/pybind11/include/pybind11/functional.h b/thirdparty/pybind11/include/pybind11/functional.h index bc8a8af821..b22464a1ab 100644 --- a/thirdparty/pybind11/include/pybind11/functional.h +++ b/thirdparty/pybind11/include/pybind11/functional.h @@ -109,8 +109,8 @@ public: return cpp_function(std::forward(f_), policy).release(); } - PYBIND11_TYPE_CASTER(type, _("Callable[[") + concat(make_caster::name...) + _("], ") - + make_caster::name + _("]")); + PYBIND11_TYPE_CASTER(type, _x("Callable[[") + concat(make_caster::name...) + _x("], ") + + make_caster::name + _x("]")); }; PYBIND11_NAMESPACE_END(detail) diff --git a/thirdparty/pybind11/include/pybind11/numpy.h b/thirdparty/pybind11/include/pybind11/numpy.h index 7313897fe1..c01444525a 100644 --- a/thirdparty/pybind11/include/pybind11/numpy.h +++ b/thirdparty/pybind11/include/pybind11/numpy.h @@ -44,7 +44,7 @@ class array; // Forward declaration PYBIND11_NAMESPACE_BEGIN(detail) -template <> struct handle_type_name { static constexpr auto name = _("numpy.ndarray"); }; +template <> struct handle_type_name { static constexpr auto name = _x("numpy.ndarray"); }; template struct npy_format_descriptor; @@ -287,7 +287,7 @@ template struct array_info_scalar { using type = T; static constexpr bool is_array = false; static constexpr bool is_empty = false; - static constexpr auto extents = _(""); + static constexpr auto extents = _x(""); static void append_extents(list& /* shape */) { } }; // Computes underlying type and a comma-separated list of extents for array @@ -306,8 +306,8 @@ template struct array_info> { array_info::append_extents(shape); } - static constexpr auto extents = _::is_array>( - concat(_(), array_info::extents), _() + static constexpr auto extents = _x::is_array>( + concat(_x(), array_info::extents), _x() ); }; // For numpy we have special handling for arrays of characters, so we don't include @@ -990,7 +990,7 @@ template struct format_descriptor::is_array>> { static std::string format() { using namespace detail; - static constexpr auto extents = _("(") + array_info::extents + _(")"); + static constexpr auto extents = _x("(") + array_info::extents + _x(")"); return extents.text + format_descriptor>::format(); } }; @@ -1025,28 +1025,28 @@ struct npy_format_descriptor_name; template struct npy_format_descriptor_name::value>> { - static constexpr auto name = _::value>( - _("bool"), _::value>("numpy.int", "numpy.uint") + _() + static constexpr auto name = _x::value>( + _x("bool"), _x::value>("numpy.int", "numpy.uint") + _x() ); }; template struct npy_format_descriptor_name::value>> { - static constexpr auto name = _::value + static constexpr auto name = _x::value || std::is_same::value || std::is_same::value || std::is_same::value>( - _("numpy.float") + _(), _("numpy.longdouble") + _x("numpy.float") + _x(), _x("numpy.longdouble") ); }; template struct npy_format_descriptor_name::value>> { - static constexpr auto name = _::value + static constexpr auto name = _x::value || std::is_same::value || std::is_same::value || std::is_same::value>( - _("numpy.complex") + _(), _("numpy.longcomplex") + _x("numpy.complex") + _x(), _x("numpy.longcomplex") ); }; @@ -1074,7 +1074,7 @@ public: }; #define PYBIND11_DECL_CHAR_FMT \ - static constexpr auto name = _("S") + _(); \ + static constexpr auto name = _x("S") + _x(); \ static pybind11::dtype dtype() { return pybind11::dtype(std::string("S") + std::to_string(N)); } template struct npy_format_descriptor { PYBIND11_DECL_CHAR_FMT }; template struct npy_format_descriptor> { PYBIND11_DECL_CHAR_FMT }; @@ -1086,7 +1086,7 @@ private: public: static_assert(!array_info::is_empty, "Zero-sized arrays are not supported"); - static constexpr auto name = _("(") + array_info::extents + _(")") + base_descr::name; + static constexpr auto name = _x("(") + array_info::extents + _x(")") + base_descr::name; static pybind11::dtype dtype() { list shape; array_info::append_extents(shape); @@ -1668,7 +1668,7 @@ vectorize_extractor(const Func &f, Return (*) (Args ...)) { } template struct handle_type_name> { - static constexpr auto name = _("numpy.ndarray[") + npy_format_descriptor::name + _("]"); + static constexpr auto name = _x("numpy.ndarray[") + npy_format_descriptor::name + _x("]"); }; PYBIND11_NAMESPACE_END(detail) diff --git a/thirdparty/pybind11/include/pybind11/pybind11.h b/thirdparty/pybind11/include/pybind11/pybind11.h index 1cb232d3a7..22f4d481a5 100644 --- a/thirdparty/pybind11/include/pybind11/pybind11.h +++ b/thirdparty/pybind11/include/pybind11/pybind11.h @@ -232,7 +232,7 @@ protected: } /* Generate a readable signature describing the function's arguments and return value types */ - static constexpr auto signature = _("(") + cast_in::arg_names + _(") -> ") + cast_out::name; + static constexpr auto signature = _x("(") + cast_in::arg_names + _x(") -> ") + cast_out::name; PYBIND11_DESCR_CONSTEXPR auto types = decltype(signature)::types(); /* Register the function with Python from generic (non-templated) code */ diff --git a/thirdparty/pybind11/include/pybind11/stl.h b/thirdparty/pybind11/include/pybind11/stl.h index 51994c656b..9802ae9e49 100644 --- a/thirdparty/pybind11/include/pybind11/stl.h +++ b/thirdparty/pybind11/include/pybind11/stl.h @@ -95,7 +95,7 @@ template struct set_caster { return s.release(); } - PYBIND11_TYPE_CASTER(type, _("Set[") + key_conv::name + _("]")); + PYBIND11_TYPE_CASTER(type, _x("Set[") + key_conv::name + _x("]")); }; template struct map_caster { @@ -137,7 +137,7 @@ template struct map_caster { return d.release(); } - PYBIND11_TYPE_CASTER(Type, _("Dict[") + key_conv::name + _(", ") + value_conv::name + _("]")); + PYBIND11_TYPE_CASTER(Type, _x("Dict[") + key_conv::name + _x(", ") + value_conv::name + _x("]")); }; template struct list_caster { @@ -183,7 +183,7 @@ public: return l.release(); } - PYBIND11_TYPE_CASTER(Type, _("List[") + value_conv::name + _("]")); + PYBIND11_TYPE_CASTER(Type, _x("List[") + value_conv::name + _x("]")); }; template struct type_caster> @@ -240,7 +240,7 @@ public: return l.release(); } - PYBIND11_TYPE_CASTER(ArrayType, _("List[") + value_conv::name + _(_(""), _("[") + _() + _("]")) + _("]")); + PYBIND11_TYPE_CASTER(ArrayType, _x("List[") + value_conv::name + _x(_x(""), _x("[") + _x() + _x("]")) + _x("]")); }; template struct type_caster> @@ -290,7 +290,7 @@ template struct optional_caster { return true; } - PYBIND11_TYPE_CASTER(T, _("Optional[") + value_conv::name + _("]")); + PYBIND11_TYPE_CASTER(T, _x("Optional[") + value_conv::name + _x("]")); }; #if defined(PYBIND11_HAS_OPTIONAL) @@ -370,7 +370,7 @@ struct variant_caster> { } using Type = V; - PYBIND11_TYPE_CASTER(Type, _("Union[") + detail::concat(make_caster::name...) + _("]")); + PYBIND11_TYPE_CASTER(Type, _x("Union[") + detail::concat(make_caster::name...) + _x("]")); }; #if defined(PYBIND11_HAS_VARIANT) diff --git a/thirdparty/pybind11/include/pybind11/stl/filesystem.h b/thirdparty/pybind11/include/pybind11/stl/filesystem.h index 431b94b4f7..f0a9ffb80d 100644 --- a/thirdparty/pybind11/include/pybind11/stl/filesystem.h +++ b/thirdparty/pybind11/include/pybind11/stl/filesystem.h @@ -92,7 +92,7 @@ public: return true; } - PYBIND11_TYPE_CASTER(T, _("os.PathLike")); + PYBIND11_TYPE_CASTER(T, _x("os.PathLike")); }; template<> struct type_caster diff --git a/thirdparty/pybind11/tests/pybind11_tests.h b/thirdparty/pybind11/tests/pybind11_tests.h index d970ba8bd4..e7be2a8a62 100644 --- a/thirdparty/pybind11/tests/pybind11_tests.h +++ b/thirdparty/pybind11/tests/pybind11_tests.h @@ -69,7 +69,7 @@ PYBIND11_NAMESPACE_BEGIN(pybind11) PYBIND11_NAMESPACE_BEGIN(detail) template<> class type_caster { public: - PYBIND11_TYPE_CASTER(RValueCaster, _("RValueCaster")); + PYBIND11_TYPE_CASTER(RValueCaster, _x("RValueCaster")); static handle cast(RValueCaster &&, return_value_policy, handle) { return py::str("rvalue").release(); } static handle cast(const RValueCaster &, return_value_policy, handle) { return py::str("lvalue").release(); } }; diff --git a/thirdparty/pybind11/tests/test_builtin_casters.cpp b/thirdparty/pybind11/tests/test_builtin_casters.cpp index 51e410cadd..7f1bcbd3e6 100644 --- a/thirdparty/pybind11/tests/test_builtin_casters.cpp +++ b/thirdparty/pybind11/tests/test_builtin_casters.cpp @@ -24,7 +24,7 @@ PYBIND11_NAMESPACE_BEGIN(detail) template <> class type_caster { public: - static constexpr auto name = _(); + static constexpr auto name = _x(); // Input is unimportant, a new value will always be constructed based on the // cast operator. diff --git a/thirdparty/pybind11/tests/test_copy_move.cpp b/thirdparty/pybind11/tests/test_copy_move.cpp index 859da9df7e..2eb2450c6c 100644 --- a/thirdparty/pybind11/tests/test_copy_move.cpp +++ b/thirdparty/pybind11/tests/test_copy_move.cpp @@ -85,13 +85,13 @@ public: PYBIND11_NAMESPACE_BEGIN(pybind11) PYBIND11_NAMESPACE_BEGIN(detail) template <> struct type_caster { - PYBIND11_TYPE_CASTER(MoveOnlyInt, _("MoveOnlyInt")); + PYBIND11_TYPE_CASTER(MoveOnlyInt, _x("MoveOnlyInt")); bool load(handle src, bool) { value = MoveOnlyInt(src.cast()); return true; } static handle cast(const MoveOnlyInt &m, return_value_policy r, handle p) { return pybind11::cast(m.value, r, p); } }; template <> struct type_caster { - PYBIND11_TYPE_CASTER(MoveOrCopyInt, _("MoveOrCopyInt")); + PYBIND11_TYPE_CASTER(MoveOrCopyInt, _x("MoveOrCopyInt")); bool load(handle src, bool) { value = MoveOrCopyInt(src.cast()); return true; } static handle cast(const MoveOrCopyInt &m, return_value_policy r, handle p) { return pybind11::cast(m.value, r, p); } }; @@ -100,7 +100,7 @@ template <> struct type_caster { protected: CopyOnlyInt value; public: - static constexpr auto name = _("CopyOnlyInt"); + static constexpr auto name = _x("CopyOnlyInt"); bool load(handle src, bool) { value = CopyOnlyInt(src.cast()); return true; } static handle cast(const CopyOnlyInt &m, return_value_policy r, handle p) { return pybind11::cast(m.value, r, p); } static handle cast(const CopyOnlyInt *src, return_value_policy policy, handle parent) { diff --git a/thirdparty/pybind11/tests/test_custom_type_casters.cpp b/thirdparty/pybind11/tests/test_custom_type_casters.cpp index 076777d6f1..6405951eb5 100644 --- a/thirdparty/pybind11/tests/test_custom_type_casters.cpp +++ b/thirdparty/pybind11/tests/test_custom_type_casters.cpp @@ -18,7 +18,7 @@ class ArgAlwaysConverts { }; namespace pybind11 { namespace detail { template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(ArgInspector1, _("ArgInspector1")); + PYBIND11_TYPE_CASTER(ArgInspector1, _x("ArgInspector1")); bool load(handle src, bool convert) { value.arg = "loading ArgInspector1 argument " + @@ -33,7 +33,7 @@ public: }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(ArgInspector2, _("ArgInspector2")); + PYBIND11_TYPE_CASTER(ArgInspector2, _x("ArgInspector2")); bool load(handle src, bool convert) { value.arg = "loading ArgInspector2 argument " + @@ -48,7 +48,7 @@ public: }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(ArgAlwaysConverts, _("ArgAlwaysConverts")); + PYBIND11_TYPE_CASTER(ArgAlwaysConverts, _x("ArgAlwaysConverts")); bool load(handle, bool convert) { return convert; @@ -76,7 +76,7 @@ public: }; namespace pybind11 { namespace detail { template <> struct type_caster { - PYBIND11_TYPE_CASTER(DestructionTester, _("DestructionTester")); + PYBIND11_TYPE_CASTER(DestructionTester, _x("DestructionTester")); bool load(handle, bool) { return true; } static handle cast(const DestructionTester &, return_value_policy, handle) {