Commit Graph

2271 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
5d4b6890a3 Systematically replacing detail::enable_if_t<...smart_holder...> with typename std::enable_if<...smart_holder...>::type. Attempt to work around MSVC 2015 issues, to be tested via GitHub CI. The idea for this change originates from this comment: https://github.com/pybind/pybind11/issues/1616#issuecomment-444536813 2021-02-12 13:46:18 -08:00
Ralf W. Grosse-Kunstleve
7aa604d9d4 Also removing operator T() from smart_holder_type_caster, to fix gcc compilation errors. The only loss is pass_rref in test_class_sh_basic. 2021-02-12 10:36:18 -08:00
Ralf W. Grosse-Kunstleve
baa2e492c7 Using re.match to accommodate variable number of intermediate MvCtor. 2021-02-12 07:25:32 -08:00
Ralf W. Grosse-Kunstleve
14099daa12 Systematically removing _atyp from function names, to make the test code simpler. 2021-02-12 07:05:11 -08:00
Ralf W. Grosse-Kunstleve
4a9eb530b4 Using @pytest.mark.parametrize to run each assert separately (to see all errors, not just the first). 2021-02-12 06:43:15 -08:00
Ralf W. Grosse-Kunstleve
b839f8c80f Adding messages to terse static_asserts, for pre-C++17 compatibility. 2021-02-11 21:00:25 -08:00
Ralf W. Grosse-Kunstleve
3c70b0bfee GitHub CI clang-tidy fixes. 2021-02-11 20:40:15 -08:00
Ralf W. Grosse-Kunstleve
70d69332ed Fixing unfortunate editing mishap. This reverts the last remaining test manipulation in commit 249df7cbdb and makes all existing unit tests pass with smart_holder as default holder. 2021-02-11 19:56:22 -08:00
Ralf W. Grosse-Kunstleve
23036a45eb Removing operator T&&() && from smart_holder_type_caster, for compatibility with the behavior of type_caster_base. Enables reverting 2 of 3 test manipulations applied under commit 249df7cbdb. The manipulation in test_factory_constructors.py is NOT reverted in this commit.
[skip ci]
2021-02-11 18:29:10 -08:00
Ralf W. Grosse-Kunstleve
67c2910308 Adding copy constructor and move constructor tracking to atyp. Preparation for a follow-up change in smart_holder_type_caster, to make this test sensitive to the changing behavior.
[skip ci]
2021-02-11 18:00:33 -08:00
Ralf W. Grosse-Kunstleve
249df7cbdb Manipulating failing ConstructorStats test to pass, to be able to run all tests with ASAN.
This version of the code is ASAN clean with unique_ptr or smart_holder as the default.

This change needs to be reverted after adopting the existing move-only-if-refcount-is-1
logic used by type_caster_base.
2021-02-09 16:14:47 -08:00
Ralf W. Grosse-Kunstleve
a07bf976bb Overlooked flake8 fixes. 2021-02-09 15:57:59 -08:00
Ralf W. Grosse-Kunstleve
7f176cba55 Adding return_value_policy::move to permissible policies for unique_ptr returns. New stats for all tests combined: 3 failed, 467 passed. 2021-02-09 09:02:00 -08:00
Ralf W. Grosse-Kunstleve
caaa7b5131 Changing std::shared_ptr pointer/reference to const pointer/reference. New stats for all tests combined: 4 failed, 466 passed. 2021-02-09 09:01:13 -08:00
Ralf W. Grosse-Kunstleve
c6620cef90 Adding "Lazy allocation for unallocated values" (for old-style __init__) into load_value_and_holder. Deferring destruction of disowned holder until clear_instance, to remain inspectable for "uninitialized" or "disowned" detection. New stats for all tests combined: 5 failed, 465 passed. 2021-02-09 06:47:46 -08:00
Ralf W. Grosse-Kunstleve
233eb9e6a8 Adding unowned_void_ptr_from_direct_conversion to modified_type_caster_generic_load_impl. This fixes the last remaining segfault (test_numpy_dtypes). New stats for all tests combined: 12 failed, 458 passed. 2021-02-09 06:47:46 -08:00
Ralf W. Grosse-Kunstleve
0de26c411a Bug fix: Adding have_value() to smart_holder_type_caster_load. With this test_builtin_casters succeeds. (All 42 tests build, 36 tests succeed, 5 run but have some failures, 1 segfault.) 2021-02-09 06:47:46 -08:00
Ralf W. Grosse-Kunstleve
3cc0a8a598 Introducing check_is_smart_holder_type_caster() function for runtime check, and reinterpreting record.default_holder as "uses_unique_ptr_holder". With this test_smart_ptr succeeds. (All 42 tests build, 35 tests succeed, 5 run but have some failures, 2 segfault.) 2021-02-09 06:47:46 -08:00
Ralf W. Grosse-Kunstleve
357266db8d Adding remaining PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS. static_assert for "necessary conditions" for both types of default holder, static_assert for "strict conditions" guarded by new PYBIND11_STRICT_ASSERTS_CLASS_HOLDER_VS_TYPE_CASTER_MIX. All tests build & run as before with unique_ptr as the default holder, all tests build for smart_holder as the default holder, even with the strict static_assert. 2021-02-09 06:47:46 -08:00
Ralf W. Grosse-Kunstleve
093e0f4514 Adding PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS in test_class.cpp (with this all but one test succeed with PYBIND11_USE_SMART_HOLDER_AS_DEFAULT). 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
bfe36cc7df Softening static_assert, to only check specifically that smart_holder is not mixed with type_caster_base, and unique_ptr/shared_ptr holders are not mixed with smart_holder_type_casters. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
97e41de4e2 Replacing condense_for_macro with much simpler approach. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
1dcf115b22 Using __VA_ARGS__ in PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
75f7eca26e Introducing 1. type_caster_for_class_, used in PYBIND11_MAKE_OPAQUE, and 2. default_holder_type, used in stl_bind.h. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
99e9595a9c Introducing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS. Using it in test_smart_ptr.cpp. With this test_smart_ptr builds with PYBIND11_USE_SMART_HOLDER_AS_DEFAULT and all but one test run successfully. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
1a0c65f753 Simplifying from_unique_ptr(): typename D = std::default_delete<T> is not needed. Factoring out is_std_default_delete<T>() for consistentcy between ensure_compatible_rtti_uqp_del() and from_unique_ptr(). 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
9c95dc4d8f Factoring out struct and class definitions into anonymous namespace. Preparation for building with PYBIND11_USE_SMART_HOLDER_AS_DEFAULT. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
3134dfe779 Disabling shared_ptr&, shared_ptr* tests when building with PYBIND11_USE_SMART_HOLDER_AS_DEFAULT for now, pending work on smart_holder_type_caster<shared_ptr>. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
70eb4ea6e9 Adding enable_if !is_smart_holder_type_caster to existing initimpl::construct(). With this test_factory_constructors.cpp builds with PYBIND11_USE_SMART_HOLDER_AS_DEFAULT. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
8caf0f50df Adding initimpl::construct() overloads, resulting in test_class_sh_factory_constructors feature parity for py::class_ and py::classh. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
b69b4a9f55 Converting as many py::class_ to py::classh as possible, not breaking tests. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
0228080a86 Adding // DANGER ZONE reminders. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
1e4f0fdcaf Removing include/pybind11/detail/smart_holder_type_casters.h from CMakeLists.txt, test_files.py (since it does not exist in this branch). 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
3f5a9c9bf4 Adding test_class_sh_factory_constructors, reproducing test_factory_constructors failure. Using py::class_ in this commit, to be changed to py::classh for debugging. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
6349531306 Commenting out const in def_buffer(... const). With this, test_buffers builds and runs with PYBIND11_USE_SMART_HOLDER_AS_DEFAULT. Explanation why the const needs to be removed, or fix elsewhere, is still needed, but left for later. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
63abf87244 Removing detail/smart_holder_type_casters.h in separate commit. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
c8eb29c8f5 Fixing up cast.h and smart_holder.h after rebase. 2021-02-09 06:47:45 -08:00
Ralf W. Grosse-Kunstleve
b9eb2a46c4 Setting record.default_holder correctly for PYBIND11_USE_SMART_HOLDER_AS_DEFAULT.
With this test_class.cpp builds and even mostly runs, except
`test_multiple_instances_with_same_pointer`, which segfaults because it is
using a `unique_ptr` holder but `smart_holder` `type_caster`.

Also adding `static_assert`s to generate build errors for such situations,
but guarding with `#if 0` to first pivot to test_factory_constructors.cpp.
2021-02-09 06:47:44 -08:00
Ralf W. Grosse-Kunstleve
f373e3d619 Fixing oversight introduced with commit 95425f13d6. 2021-02-09 06:47:44 -08:00
Ralf W. Grosse-Kunstleve
b69f9fed33 Removing test_type_caster_bare_interface, which was moved to the separate PR #2834. 2021-02-09 06:47:44 -08:00
Ralf W. Grosse-Kunstleve
ce79f9126d Introducing PYBIND11_USE_SMART_HOLDER_AS_DEFAULT macro (tested only undefined; there are many errors with the macro defined). 2021-02-09 06:47:44 -08:00
Ralf W. Grosse-Kunstleve
0f316720f7 Adding comment, simplifying naming, cmake addition. 2021-02-09 06:47:44 -08:00
Ralf W. Grosse-Kunstleve
0dfd3a6b7d Copying files as-is from branch test_unique_ptr_member (PR #2672). 2021-02-09 06:47:44 -08:00
Ralf W. Grosse-Kunstleve
72f52be256 Unification of unique_ptr, unique_ptr_with_deleter code in smart_holder_poc.h. Leads to more fitting error messages. Enables use of unique_ptr<T, D> smart_holder_type_casters also for unique_ptr<T>. 2021-02-09 06:47:08 -08:00
Ralf W. Grosse-Kunstleve
a9bfcbdcc3 Adding smart_holder_type_casters for unique_ptr with custom deleter. SEVERE CODE DUPLICATION. This commit is to establish a baseline for consolidating the unique_ptr code. 2021-02-09 06:47:08 -08:00
Ralf W. Grosse-Kunstleve
231bd84fa0 Moving up is_smart_holder_type_caster, to also use in cast_is_temporary_value_reference. 2021-02-09 06:47:08 -08:00
Ralf W. Grosse-Kunstleve
692270a017 Removing test_type_caster_bare_interface, which was moved to the separate PR #2834. 2021-02-09 06:47:08 -08:00
Ralf W. Grosse-Kunstleve
c9d73aaa43 Giving up on idea to use legacy init_instance only if is_base_of<type_caster_generic, type_caster<T>. There are use cases in the wild that define both a custom type_caster and class_. 2021-02-09 06:47:08 -08:00
Ralf W. Grosse-Kunstleve
149e332b3e Adding classu alias for class_<U, std::unique_ptr<U>>. 2021-02-09 06:47:08 -08:00
Ralf W. Grosse-Kunstleve
1e4c2e04ae Fixing oversight. 2021-02-09 06:47:08 -08:00