mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-14 09:34:46 +00:00
Merge branch 'master' into smart_holder
This commit is contained in:
commit
3754d6436b
@ -516,18 +516,22 @@ template <size_t Nurse, size_t Patient> struct process_attribute<keep_alive<Nurs
|
|||||||
/// Recursively iterate over variadic template arguments
|
/// Recursively iterate over variadic template arguments
|
||||||
template <typename... Args> struct process_attributes {
|
template <typename... Args> struct process_attributes {
|
||||||
static void init(const Args&... args, function_record *r) {
|
static void init(const Args&... args, function_record *r) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
|
||||||
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
|
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
|
||||||
ignore_unused(unused);
|
ignore_unused(unused);
|
||||||
}
|
}
|
||||||
static void init(const Args&... args, type_record *r) {
|
static void init(const Args&... args, type_record *r) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
|
||||||
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
|
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
|
||||||
ignore_unused(unused);
|
ignore_unused(unused);
|
||||||
}
|
}
|
||||||
static void precall(function_call &call) {
|
static void precall(function_call &call) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call);
|
||||||
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::precall(call), 0) ... };
|
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::precall(call), 0) ... };
|
||||||
ignore_unused(unused);
|
ignore_unused(unused);
|
||||||
}
|
}
|
||||||
static void postcall(function_call &call, handle fn_ret) {
|
static void postcall(function_call &call, handle fn_ret) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret);
|
||||||
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0) ... };
|
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0) ... };
|
||||||
ignore_unused(unused);
|
ignore_unused(unused);
|
||||||
}
|
}
|
||||||
@ -545,6 +549,7 @@ template <typename... Extra,
|
|||||||
size_t named = constexpr_sum(std::is_base_of<arg, Extra>::value...),
|
size_t named = constexpr_sum(std::is_base_of<arg, Extra>::value...),
|
||||||
size_t self = constexpr_sum(std::is_same<is_method, Extra>::value...)>
|
size_t self = constexpr_sum(std::is_same<is_method, Extra>::value...)>
|
||||||
constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) {
|
constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(nargs, has_args, has_kwargs);
|
||||||
return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs;
|
return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,6 +627,7 @@ protected:
|
|||||||
/* Implementation: Convert a C++ tuple into a Python tuple */
|
/* Implementation: Convert a C++ tuple into a Python tuple */
|
||||||
template <typename T, size_t... Is>
|
template <typename T, size_t... Is>
|
||||||
static handle cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence<Is...>) {
|
static handle cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence<Is...>) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent);
|
||||||
std::array<object, size> entries{{
|
std::array<object, size> entries{{
|
||||||
reinterpret_steal<object>(make_caster<Ts>::cast(std::get<Is>(std::forward<T>(src)), policy, parent))...
|
reinterpret_steal<object>(make_caster<Ts>::cast(std::get<Is>(std::forward<T>(src)), policy, parent))...
|
||||||
}};
|
}};
|
||||||
|
@ -913,5 +913,18 @@ inline static std::shared_ptr<T> try_get_shared_from_this(std::enable_shared_fro
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER <= 1916
|
||||||
|
|
||||||
|
// warning C4100: Unreferenced formal parameter
|
||||||
|
template <typename... Args>
|
||||||
|
inline constexpr void workaround_incorrect_msvc_c4100(Args &&...) {}
|
||||||
|
|
||||||
|
# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
|
||||||
|
detail::workaround_incorrect_msvc_c4100(__VA_ARGS__)
|
||||||
|
|
||||||
|
#else
|
||||||
|
# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_END(detail)
|
PYBIND11_NAMESPACE_END(detail)
|
||||||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
||||||
|
@ -42,6 +42,7 @@ struct descr {
|
|||||||
template <size_t N1, size_t N2, typename... Ts1, typename... Ts2, size_t... Is1, size_t... Is2>
|
template <size_t N1, size_t N2, typename... Ts1, typename... Ts2, size_t... Is1, size_t... Is2>
|
||||||
constexpr descr<N1 + N2, Ts1..., Ts2...> plus_impl(const descr<N1, Ts1...> &a, const descr<N2, Ts2...> &b,
|
constexpr descr<N1 + N2, Ts1..., Ts2...> plus_impl(const descr<N1, Ts1...> &a, const descr<N2, Ts2...> &b,
|
||||||
index_sequence<Is1...>, index_sequence<Is2...>) {
|
index_sequence<Is1...>, index_sequence<Is2...>) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(b);
|
||||||
return {a.text[Is1]..., b.text[Is2]...};
|
return {a.text[Is1]..., b.text[Is2]...};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ void construct(...) {
|
|||||||
// construct an Alias from the returned base instance.
|
// construct an Alias from the returned base instance.
|
||||||
template <typename Class>
|
template <typename Class>
|
||||||
void construct(value_and_holder &v_h, Cpp<Class> *ptr, bool need_alias) {
|
void construct(value_and_holder &v_h, Cpp<Class> *ptr, bool need_alias) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
|
||||||
no_nullptr(ptr);
|
no_nullptr(ptr);
|
||||||
if (Class::has_alias && need_alias && !is_alias<Class>(ptr)) {
|
if (Class::has_alias && need_alias && !is_alias<Class>(ptr)) {
|
||||||
// We're going to try to construct an alias by moving the cpp type. Whether or not
|
// We're going to try to construct an alias by moving the cpp type. Whether or not
|
||||||
@ -136,6 +137,7 @@ void construct(value_and_holder &v_h, Alias<Class> *alias_ptr, bool) {
|
|||||||
template <typename Class,
|
template <typename Class,
|
||||||
detail::enable_if_t<!detail::type_uses_smart_holder_type_caster<Cpp<Class>>::value, int> = 0>
|
detail::enable_if_t<!detail::type_uses_smart_holder_type_caster<Cpp<Class>>::value, int> = 0>
|
||||||
void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) {
|
void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
|
||||||
auto *ptr = holder_helper<Holder<Class>>::get(holder);
|
auto *ptr = holder_helper<Holder<Class>>::get(holder);
|
||||||
no_nullptr(ptr);
|
no_nullptr(ptr);
|
||||||
// If we need an alias, check that the held pointer is actually an alias instance
|
// If we need an alias, check that the held pointer is actually an alias instance
|
||||||
@ -153,6 +155,7 @@ void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) {
|
|||||||
// need it, we simply move-construct the cpp value into a new instance.
|
// need it, we simply move-construct the cpp value into a new instance.
|
||||||
template <typename Class>
|
template <typename Class>
|
||||||
void construct(value_and_holder &v_h, Cpp<Class> &&result, bool need_alias) {
|
void construct(value_and_holder &v_h, Cpp<Class> &&result, bool need_alias) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
|
||||||
static_assert(std::is_move_constructible<Cpp<Class>>::value,
|
static_assert(std::is_move_constructible<Cpp<Class>>::value,
|
||||||
"pybind11::init() return-by-value factory function requires a movable class");
|
"pybind11::init() return-by-value factory function requires a movable class");
|
||||||
if (Class::has_alias && need_alias)
|
if (Class::has_alias && need_alias)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
|
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter
|
|
||||||
# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
|
# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
|
||||||
# pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
|
# pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
|
||||||
#elif defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
|
#elif defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
|
||||||
|
@ -930,6 +930,7 @@ protected:
|
|||||||
does not have a private operator new implementation. */
|
does not have a private operator new implementation. */
|
||||||
template <typename T, typename = enable_if_t<is_copy_constructible<T>::value>>
|
template <typename T, typename = enable_if_t<is_copy_constructible<T>::value>>
|
||||||
static auto make_copy_constructor(const T *x) -> decltype(new T(*x), Constructor{}) {
|
static auto make_copy_constructor(const T *x) -> decltype(new T(*x), Constructor{}) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x);
|
||||||
return [](const void *arg) -> void * {
|
return [](const void *arg) -> void * {
|
||||||
return new T(*reinterpret_cast<const T *>(arg));
|
return new T(*reinterpret_cast<const T *>(arg));
|
||||||
};
|
};
|
||||||
@ -937,6 +938,7 @@ protected:
|
|||||||
|
|
||||||
template <typename T, typename = enable_if_t<std::is_move_constructible<T>::value>>
|
template <typename T, typename = enable_if_t<std::is_move_constructible<T>::value>>
|
||||||
static auto make_move_constructor(const T *x) -> decltype(new T(std::move(*const_cast<T *>(x))), Constructor{}) {
|
static auto make_move_constructor(const T *x) -> decltype(new T(std::move(*const_cast<T *>(x))), Constructor{}) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x);
|
||||||
return [](const void *arg) -> void * {
|
return [](const void *arg) -> void * {
|
||||||
return new T(std::move(*const_cast<T *>(reinterpret_cast<const T *>(arg))));
|
return new T(std::move(*const_cast<T *>(reinterpret_cast<const T *>(arg))));
|
||||||
};
|
};
|
||||||
|
@ -1466,12 +1466,14 @@ public:
|
|||||||
|
|
||||||
template <typename... Args, typename... Extra>
|
template <typename... Args, typename... Extra>
|
||||||
class_ &def(const detail::initimpl::constructor<Args...> &init, const Extra&... extra) {
|
class_ &def(const detail::initimpl::constructor<Args...> &init, const Extra&... extra) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(init);
|
||||||
init.execute(*this, extra...);
|
init.execute(*this, extra...);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args, typename... Extra>
|
template <typename... Args, typename... Extra>
|
||||||
class_ &def(const detail::initimpl::alias_constructor<Args...> &init, const Extra&... extra) {
|
class_ &def(const detail::initimpl::alias_constructor<Args...> &init, const Extra&... extra) {
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(init);
|
||||||
init.execute(*this, extra...);
|
init.execute(*this, extra...);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user