-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into internals_std_type_index_modernization
- Loading branch information
Showing
9 changed files
with
89 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ jobs: | |
run: brew install boost | ||
|
||
- name: Update CMake | ||
uses: jwlawson/actions-setup-cmake@v1.13 | ||
uses: jwlawson/actions-setup-cmake@v1.14 | ||
|
||
- name: Cache wheels | ||
if: runner.os == 'macOS' | ||
|
@@ -207,7 +207,7 @@ jobs: | |
debug: ${{ matrix.python-debug }} | ||
|
||
- name: Update CMake | ||
uses: jwlawson/actions-setup-cmake@v1.13 | ||
uses: jwlawson/actions-setup-cmake@v1.14 | ||
|
||
- name: Valgrind cache | ||
if: matrix.valgrind | ||
|
@@ -473,7 +473,7 @@ jobs: | |
run: python3 -m pip install --upgrade pip | ||
|
||
- name: Update CMake | ||
uses: jwlawson/actions-setup-cmake@v1.13 | ||
uses: jwlawson/actions-setup-cmake@v1.14 | ||
|
||
- name: Configure | ||
shell: bash | ||
|
@@ -780,7 +780,7 @@ jobs: | |
architecture: x86 | ||
|
||
- name: Update CMake | ||
uses: jwlawson/actions-setup-cmake@v1.13 | ||
uses: jwlawson/actions-setup-cmake@v1.14 | ||
|
||
- name: Prepare MSVC | ||
uses: ilammy/[email protected] | ||
|
@@ -833,7 +833,7 @@ jobs: | |
architecture: x86 | ||
|
||
- name: Update CMake | ||
uses: jwlawson/actions-setup-cmake@v1.13 | ||
uses: jwlawson/actions-setup-cmake@v1.14 | ||
|
||
- name: Prepare MSVC | ||
uses: ilammy/[email protected] | ||
|
@@ -884,7 +884,7 @@ jobs: | |
python3 -m pip install -r tests/requirements.txt | ||
- name: Update CMake | ||
uses: jwlawson/actions-setup-cmake@v1.13 | ||
uses: jwlawson/actions-setup-cmake@v1.14 | ||
|
||
- name: Configure C++20 | ||
run: > | ||
|
@@ -1032,7 +1032,7 @@ jobs: | |
python-version: ${{ matrix.python }} | ||
|
||
- name: Update CMake | ||
uses: jwlawson/actions-setup-cmake@v1.13 | ||
uses: jwlawson/actions-setup-cmake@v1.14 | ||
|
||
- name: Install ninja-build tool | ||
uses: seanmiddleditch/gha-setup-ninja@v3 | ||
|
@@ -1102,7 +1102,7 @@ jobs: | |
run: clang++ --version | ||
|
||
- name: Update CMake | ||
uses: jwlawson/actions-setup-cmake@v1.13 | ||
uses: jwlawson/actions-setup-cmake@v1.14 | ||
|
||
- name: Run pip installs | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "pybind11_tests.h" | ||
|
||
#include <cstddef> | ||
#include <memory> | ||
#include <vector> | ||
|
||
namespace pybind11_tests { | ||
namespace vector_unique_ptr_member { | ||
|
||
struct DataType {}; | ||
|
||
// Reduced from a use case in the wild. | ||
struct VectorOwner { | ||
static std::unique_ptr<VectorOwner> Create(std::size_t num_elems) { | ||
return std::unique_ptr<VectorOwner>( | ||
new VectorOwner(std::vector<std::unique_ptr<DataType>>(num_elems))); | ||
} | ||
|
||
std::size_t data_size() const { return data_.size(); } | ||
|
||
private: | ||
explicit VectorOwner(std::vector<std::unique_ptr<DataType>> data) : data_(std::move(data)) {} | ||
|
||
const std::vector<std::unique_ptr<DataType>> data_; | ||
}; | ||
|
||
} // namespace vector_unique_ptr_member | ||
} // namespace pybind11_tests | ||
|
||
namespace pybind11 { | ||
namespace detail { | ||
|
||
template <> | ||
struct is_copy_constructible<pybind11_tests::vector_unique_ptr_member::VectorOwner> | ||
: std::false_type {}; | ||
|
||
template <> | ||
struct is_move_constructible<pybind11_tests::vector_unique_ptr_member::VectorOwner> | ||
: std::false_type {}; | ||
|
||
} // namespace detail | ||
} // namespace pybind11 | ||
|
||
using namespace pybind11_tests::vector_unique_ptr_member; | ||
|
||
py::object py_cast_VectorOwner_ptr(VectorOwner *ptr) { return py::cast(ptr); } | ||
|
||
// PYBIND11_SMART_HOLDER_TYPE_CASTERS(VectorOwner) | ||
|
||
TEST_SUBMODULE(vector_unique_ptr_member, m) { | ||
py::class_<VectorOwner>(m, "VectorOwner") | ||
.def_static("Create", &VectorOwner::Create) | ||
.def("data_size", &VectorOwner::data_size); | ||
|
||
m.def("py_cast_VectorOwner_ptr", py_cast_VectorOwner_ptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
|
||
from pybind11_tests import vector_unique_ptr_member as m | ||
|
||
|
||
@pytest.mark.parametrize("num_elems", range(3)) | ||
def test_create(num_elems): | ||
vo = m.VectorOwner.Create(num_elems) | ||
assert vo.data_size() == num_elems | ||
|
||
|
||
def test_cast(): | ||
vo = m.VectorOwner.Create(0) | ||
assert m.py_cast_VectorOwner_ptr(vo) is vo |