-
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 'pybind:master' into master
- Loading branch information
Showing
17 changed files
with
188 additions
and
71 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: WASM | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-wasm-emscripten: | ||
name: Pyodide wheel | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- uses: pypa/[email protected] | ||
env: | ||
PYODIDE_BUILD_EXPORTS: whole_archive | ||
CFLAGS: -fexceptions | ||
LDFLAGS: -fexceptions | ||
with: | ||
package-dir: tests | ||
only: cp312-pyodide_wasm32 |
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,77 @@ | ||
// Copyright (c) 2016-2024 The Pybind Development Team. | ||
// All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
#pragma once | ||
|
||
#include "common.h" | ||
|
||
#include <cstddef> | ||
#include <typeinfo> | ||
|
||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) | ||
PYBIND11_NAMESPACE_BEGIN(detail) | ||
|
||
struct value_and_holder { | ||
instance *inst = nullptr; | ||
size_t index = 0u; | ||
const detail::type_info *type = nullptr; | ||
void **vh = nullptr; | ||
|
||
// Main constructor for a found value/holder: | ||
value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index) | ||
: inst{i}, index{index}, type{type}, | ||
vh{inst->simple_layout ? inst->simple_value_holder | ||
: &inst->nonsimple.values_and_holders[vpos]} {} | ||
|
||
// Default constructor (used to signal a value-and-holder not found by get_value_and_holder()) | ||
value_and_holder() = default; | ||
|
||
// Used for past-the-end iterator | ||
explicit value_and_holder(size_t index) : index{index} {} | ||
|
||
template <typename V = void> | ||
V *&value_ptr() const { | ||
return reinterpret_cast<V *&>(vh[0]); | ||
} | ||
// True if this `value_and_holder` has a non-null value pointer | ||
explicit operator bool() const { return value_ptr() != nullptr; } | ||
|
||
template <typename H> | ||
H &holder() const { | ||
return reinterpret_cast<H &>(vh[1]); | ||
} | ||
bool holder_constructed() const { | ||
return inst->simple_layout | ||
? inst->simple_holder_constructed | ||
: (inst->nonsimple.status[index] & instance::status_holder_constructed) != 0u; | ||
} | ||
// NOLINTNEXTLINE(readability-make-member-function-const) | ||
void set_holder_constructed(bool v = true) { | ||
if (inst->simple_layout) { | ||
inst->simple_holder_constructed = v; | ||
} else if (v) { | ||
inst->nonsimple.status[index] |= instance::status_holder_constructed; | ||
} else { | ||
inst->nonsimple.status[index] &= (std::uint8_t) ~instance::status_holder_constructed; | ||
} | ||
} | ||
bool instance_registered() const { | ||
return inst->simple_layout | ||
? inst->simple_instance_registered | ||
: ((inst->nonsimple.status[index] & instance::status_instance_registered) != 0); | ||
} | ||
// NOLINTNEXTLINE(readability-make-member-function-const) | ||
void set_instance_registered(bool v = true) { | ||
if (inst->simple_layout) { | ||
inst->simple_instance_registered = v; | ||
} else if (v) { | ||
inst->nonsimple.status[index] |= instance::status_instance_registered; | ||
} else { | ||
inst->nonsimple.status[index] &= (std::uint8_t) ~instance::status_instance_registered; | ||
} | ||
} | ||
}; | ||
|
||
PYBIND11_NAMESPACE_END(detail) | ||
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) |
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,17 @@ | ||
# Warning: this is currently used for pyodide, and is not a general out-of-tree | ||
# builder for the tests (yet). Specifically, wheels can't be built from SDists. | ||
|
||
[build-system] | ||
requires = ["scikit-build-core"] | ||
build-backend = "scikit_build_core.build" | ||
|
||
[project] | ||
name = "pybind11_tests" | ||
version = "0.0.1" | ||
dependencies = ["pytest", "pytest-timeout", "numpy", "scipy"] | ||
|
||
[tool.scikit-build.cmake.define] | ||
PYBIND11_FINDPYTHON = true | ||
|
||
[tool.cibuildwheel] | ||
test-command = "pytest -o timeout=0 -p no:cacheprovider {project}/tests/test_*.py" |
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
Oops, something went wrong.