mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-15 01:44:44 +00:00
3b35ce475f
17 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Ralf W. Grosse-Kunstleve
|
bd8985aa0f
|
[smart_holder] Introduce PYBIND11_SMART_HOLDER_DISABLE option. (#5348)
* Step 1: Establish new `PYBIND11_SMART_HOLDER_ENABLED` macro, but only under include/pybind11/ At the stage `PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT` and `PYBIND11_SMART_HOLDER_ENABLED` are still equivalent. * Systematically replace all `PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT` with `PYBIND11_SMART_HOLDER_ENABLED` under tests/ and ubench/ As at the previous stage, `PYBIND11_HAS_INTERNALS_WITH_SMART_HOLDER_SUPPORT` and `PYBIND11_SMART_HOLDER_ENABLED` are still equivalent. * Introduce `PYBIND11_SMART_HOLDER_DISABLE` option. * `#ifdef` out entire `wrap()` function to avoid `unused-parameter` warning-as-error under macos-13 ``` /Users/runner/work/pybind11/pybind11/tests/test_class_sh_trampoline_basic.cpp:67:23: error: unused parameter 'm' [-Werror,-Wunused-parameter] void wrap(py::module_ m, const char *py_class_name) { ^ /Users/runner/work/pybind11/pybind11/tests/test_class_sh_trampoline_basic.cpp:67:38: error: unused parameter 'py_class_name' [-Werror,-Wunused-parameter] void wrap(py::module_ m, const char *py_class_name) { ^ 2 errors generated. ``` |
||
Ralf W. Grosse-Kunstleve
|
04d9f84f26
|
[smart_holder] Fix handling of const unique_ptr<T, D> & (do not disown). (#5332)
* Replace `unique_ptr_cref_roundtrip()` with `pass_unique_ptr_cref()`, `rtrn_unique_ptr_cref()` to make the current behavior obvious. * add in unique_ptr_storage, unique_ptr_storage_deleter * Add shared_ptr_storage (with that disowning fails as expected). * Add load_as_const_unique_ptr() * Restore original struct_smart_holder.h * factor out `smart_holder::extract_deleter()` * Better error message. * Misc cleanup/tidying. * Use `re.match("ctor_arg(_MvCtor)*_MvCtor", ...)` for compatibility with MSVC, NVHPC, ICC * Add small comments. * Fix small, inconsequential oversight in test code. * Apply suggestion by @iwanders under PR #5334 * Remove `std::move()` in `smart_holder::extract_deleter()` * Add `static_assert()` following a suggestion by @iwanders under PR #5334 |
||
Ralf W. Grosse-Kunstleve
|
7c6fe49106
|
find . -name '*.h' -o -name '*.cpp' -o -name '*.py' | xargs -n 1 -- sed -i 's/PYBIND11_HAVE_/PYBIND11_HAS_/g' (#5286) | ||
Ralf W. Grosse-Kunstleve
|
48f25275c4
|
[smart_holder] Bake smart_holder functionality into class_ and type_caster_base (#5257)
* Put bakein branch @
|
||
Ralf W. Grosse-Kunstleve
|
39fbe468ae |
Merge branch 'master' into sh_merge_master
Includes follow-on to pybind/pybind11#5189: Backport the smart_holder-specific changes from google/pybind11k#30093 and google/pybind11k#30098. |
||
Ivor Wanders
|
e5ce9631b1
|
[smart_holder] Unique ptr deleter roundtrip tests and fix (#4921)
* Roundtrip through unique pointer with custom deleter. Currently failing. * Ensure the custom deleter is copied back to the unique pointer. Feels like there's still a gap around the raw pointer flavour, but this at least makes the unit test of the previous commit succeed. * Add deleter roundtrip for const atyp. Currently failing, custom deleter is lost. * Fix storing deleter for const unique ptr. Unit test from the previous commit passes. * Remove SFINEA deleter assignment. At the construction of the smart holder, it is either a del_fun, or a default constructed deleter, so this complexity is unnecessary. * Clang format. * Fixes for ci. Clang 3.6 requires the extra constructors in the custom_deleter. * fix(smart_holder): Loosen requirement on deleter to be default constructible. And some other PR feedback. * fix(smart_holder): Custom deleter in unit tests traces constructions. * fix(smart_holder): Use pybind11_fail instead of assert. * fix(smart_holder): Add unit tests for the default constructible deleter. * fix(smart_holder): Use regex matching for deleter constructors in unit tests. |
||
Xiaofei Wang
|
f1e2e55bda
|
[smart_holder] Make smart holder type caster of unique_ptr accept automatic_reference (#4775)
* Also accept automatic_reference * Add a test case * Remove the test case * Add another test case * Fix test case |
||
Ralf W. Grosse-Kunstleve
|
05c8b9b7a8 |
Automatic pre-commit run --all-files and clang-tidy changes (NO manual changes).
|
||
Dustin Spicuzza
|
9e43db614f
|
fix: names of types held by smart holder should be the actual type (#3588)
Required for pybind11-stubgen to work properly |
||
Ralf W. Grosse-Kunstleve
|
b4e1ac9a94 | clang-tidy fixes related to PR #3250 | ||
Ralf W. Grosse-Kunstleve
|
119db695ca | Follow-on to PR #3148 (cang-tidy). | ||
Ralf W. Grosse-Kunstleve
|
2eeac0c369 | Applying clang-tidy fixes needed after merging PR #3051 (mostly automatically). | ||
Ralf W. Grosse-Kunstleve
|
8d1e0b3903
|
[smart_holder] clang-tidy fixes (related to recent clang-tidy changes on master). (#3053)
* clang-tidy fixes (related to recent clang-tidy changes on master). * More clang-tidy fixes. |
||
Ralf W. Grosse-Kunstleve
|
2ada792085 | Pure clang-format cleanup (after #2904), NO other changes. | ||
Robert Haschke
|
784092dfd2
|
Missing cast from const unique_ptr& (#2904)
* Add roundtrip tests for unique_ptr * Implementation for casting from const std::unique_ptr& ... forwarding to smart_holder_type_caster<T>::cast(T*) |
||
Ralf W. Grosse-Kunstleve
|
6a7e9f42fe
|
Changing all but one std::runtime_error to std::invalid_argument, which appears as ValueError in the Python interpreter. Adding test_cannot_disown_use_count_ne_1 . (#2883)
|
||
Ralf W. Grosse-Kunstleve
|
1bafd5db5f
|
Adding py::smart_holder (for smart-pointer interoperability). (#2672)
* Adding test_unique_ptr_member (for desired PyCLIF behavior). See also: https://github.com/pybind/pybind11/issues/2583 Does not build with upstream master or https://github.com/pybind/pybind11/pull/2047, but builds with https://github.com/RobotLocomotion/pybind11 and almost runs: ``` Running tests in directory "/usr/local/google/home/rwgk/forked/EricCousineau-TRI/pybind11/tests": ================================================================================= test session starts ================================================================================= platform linux -- Python 3.8.5, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 rootdir: /usr/local/google/home/rwgk/forked/EricCousineau-TRI/pybind11/tests, inifile: pytest.ini collected 2 items test_unique_ptr_member.py .F [100%] ====================================================================================== FAILURES ======================================================================================= _____________________________________________________________________________ test_pointee_and_ptr_owner ______________________________________________________________________________ def test_pointee_and_ptr_owner(): obj = m.pointee() assert obj.get_int() == 213 m.ptr_owner(obj) with pytest.raises(ValueError) as exc_info: > obj.get_int() E Failed: DID NOT RAISE <class 'ValueError'> test_unique_ptr_member.py:17: Failed ============================================================================= 1 failed, 1 passed in 0.06s ============================================================================= ``` * unique_ptr or shared_ptr return * new test_variant_unique_shared with vptr_holder prototype * moving prototype code to pybind11/vptr_holder.h, adding type_caster specialization to make the bindings involving unique_ptr passing compile, but load and cast implementations are missing * disabling GitHub Actions on pull_request (for this PR) * disabling AppVeyor (for this PR) * TRIGGER_SEGSEV macro, annotations for GET_STACK (vptr::get), GET_INT_STACK (pointee) * adding test_promotion_of_disowned_to_shared * Copying tests as-is from xxx_value_ptr_xxx_holder branch. https://github.com/rwgk/pybind11/tree/xxx_value_ptr_xxx_holder Systematically exercising returning and passing unique_ptr<T>, shared_ptr<T> with unique_ptr, shared_ptr holder. Observations: test_holder_unique_ptr: make_unique_pointee OK pass_unique_pointee BUILD_FAIL (as documented) make_shared_pointee Abort free(): double free detected pass_shared_pointee RuntimeError: Unable to load a custom holder type from a default-holder instance test_holder_shared_ptr: make_unique_pointee Segmentation fault (#1138) pass_unique_pointee BUILD_FAIL (as documented) make_shared_pointee OK pass_shared_pointee OK * Copying tests as-is from xxx_value_ptr_xxx_holder branch. https://github.com/rwgk/pybind11/tree/xxx_value_ptr_xxx_holder Systematically exercising casting between shared_ptr<base>, shared_ptr<derived>. * Demonstration of Undefined Behavior in handling of shared_ptr holder. Based on https://godbolt.org/z/4fdjaW by jorgbrown@ (thanks Jorg!). * Additional demonstration of Undefined Behavior in handling of shared_ptr holder. * fixing up-down mixup in comment * Demonstration of Undefined Behavior in handling of polymorphic pointers. (This demo does NOT involve smart pointers at all, unlike the otherwise similar test_smart_ptr_private_first_base.) * minor test_private_first_base.cpp simplification (after discovering that this can be wrapped with Boost.Python, using boost::noncopyable) * pybind11 equivalent of Boost.Python test similar to reproducer under #1333 * Snapshot of WIP, TODO: shared_ptr deleter with on/off switch * Adding vptr_deleter. * Adding from/as unique_ptr<T> and unique_ptr<T, D>. * Adding from_shared_ptr. Some polishing. * New tests/core/smart_holder_poc_test.cpp, using Catch2. * Adding in vptr_deleter_guard_flag. * Improved labeling of TEST_CASEs. * Shuffling existing TEST_CASEs into systematic matrix. * Implementing all [S]uccess tests. * Implementing all [E]xception tests. * Testing of exceptions not covered by the from-as matrix. * Adding top-level comment. * Converting from methods to factory functions (no functional change). * Removing obsolete and very incomplete test (replaced by Catch2-based test). * Removing stray file. * Adding type_caster_bare_interface_demo. * Adding shared_ptr<mpty>, shared_ptr<mpty const> casters. * Adding unique_ptr<mpty>, unique_ptr<mpty const> casters. * Pure copy of `class class_` implementation in pybind11.h (master commit |