Skip to content

Commit

Permalink
Merging 'master' into 'wrap'
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal committed Oct 6, 2023
2 parents b1fab94 + 8d0790e commit 74eea30
Show file tree
Hide file tree
Showing 165 changed files with 8,150 additions and 1,924 deletions.
2 changes: 2 additions & 0 deletions wrap/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ __pycache__/
*dist*
*.egg-info

**/.DS_Store

# Files related to code coverage stats
**/.coverage

Expand Down
7 changes: 5 additions & 2 deletions wrap/gtwrap/interface_parser/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

from typing import Any, Iterable, List, Union

from pyparsing import Optional, ParseResults, delimitedList # type: ignore
from pyparsing import (Literal, Optional, ParseResults, # type: ignore
delimitedList)

from .template import Template
from .tokens import (COMMA, DEFAULT_ARG, EQUAL, IDENT, LOPBRACK, LPAREN, PAIR,
Expand Down Expand Up @@ -105,8 +106,10 @@ class ReturnType:
The return type can either be a single type or a pair such as <type1, type2>.
"""
# rule to parse optional std:: in front of `pair`
optional_std = Optional(Literal('std::')).suppress()
_pair = (
PAIR.suppress() #
optional_std + PAIR.suppress() #
+ LOPBRACK #
+ Type.rule("type1") #
+ COMMA #
Expand Down
9 changes: 8 additions & 1 deletion wrap/gtwrap/matlab_wrapper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,8 @@ def _collector_return(self,
[instantiated_class.name])
else:
# Get the full namespace
class_name = ".".join(instantiated_class.parent.full_namespaces()[1:])
class_name = ".".join(
instantiated_class.parent.full_namespaces()[1:])

if class_name != "":
class_name += '.'
Expand Down Expand Up @@ -1860,6 +1861,7 @@ def generate_content(self, cc_content, path):
"""
for c in cc_content:
if isinstance(c, list):
# c is a namespace
if len(c) == 0:
continue

Expand All @@ -1875,18 +1877,21 @@ def generate_content(self, cc_content, path):
self.generate_content(sub_content[1], path_to_folder)

elif isinstance(c[1], list):
# c is a wrapped function
path_to_folder = osp.join(path, c[0])

if not osp.isdir(path_to_folder):
try:
os.makedirs(path_to_folder, exist_ok=True)
except OSError:
pass

for sub_content in c[1]:
path_to_file = osp.join(path_to_folder, sub_content[0])
with open(path_to_file, 'w') as f:
f.write(sub_content[1])
else:
# c is a wrapped class
path_to_file = osp.join(path, c[0])

if not osp.isdir(path_to_file):
Expand Down Expand Up @@ -1921,6 +1926,8 @@ def wrap(self, files, path):
for module in modules.values():
# Wrap the full namespace
self.wrap_namespace(module)

# Generate the wrapping code (both C++ and .m files)
self.generate_wrapper(module)

# Generate the corresponding .m and .cpp files
Expand Down
2 changes: 2 additions & 0 deletions wrap/pybind11/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Checks: |
-bugprone-unused-raii,
CheckOptions:
- key: modernize-use-equals-default.IgnoreMacros
value: false
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: true
- key: performance-inefficient-string-concatenation.StrictMode
Expand Down
24 changes: 24 additions & 0 deletions wrap/pybind11/.codespell-ignore-lines
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t>
template <typename ThisT>
auto &this_ = static_cast<ThisT &>(*this);
if (load_impl<ThisT>(temp, false)) {
ssize_t nd = 0;
auto trivial = broadcast(buffers, nd, shape);
auto ndim = (size_t) nd;
int nd;
ssize_t ndim() const { return detail::array_proxy(m_ptr)->nd; }
using op = op_impl<id, ot, Base, L_type, R_type>;
template <op_id id, op_type ot, typename L, typename R>
template <detail::op_id id, detail::op_type ot, typename L, typename R, typename... Extra>
class_ &def(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
class_ &def_cast(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
@pytest.mark.parametrize("access", ["ro", "rw", "static_ro", "static_rw"])
struct IntStruct {
explicit IntStruct(int v) : value(v){};
~IntStruct() { value = -value; }
IntStruct(const IntStruct &) = default;
IntStruct &operator=(const IntStruct &) = default;
py::class_<IntStruct>(m, "IntStruct").def(py::init([](const int i) { return IntStruct(i); }));
py::implicitly_convertible<int, IntStruct>();
m.def("test", [](int expected, const IntStruct &in) {
[](int expected, const IntStruct &in) {
4 changes: 2 additions & 2 deletions wrap/pybind11/.github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ directory inside your pybind11 git clone. Files will be modified in place,
so you can use git to monitor the changes.

```bash
docker run --rm -v $PWD:/mounted_pybind11 -it silkeh/clang:13
apt-get update && apt-get install -y python3-dev python3-pytest
docker run --rm -v $PWD:/mounted_pybind11 -it silkeh/clang:15-bullseye
apt-get update && apt-get install -y git python3-dev python3-pytest
cmake -S /mounted_pybind11/ -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--use-color" -DDOWNLOAD_EIGEN=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=17
cmake --build build -j 2
```
Expand Down
22 changes: 19 additions & 3 deletions wrap/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ body:
- type: markdown
attributes:
value: |
Maintainers will only make a best effort to triage PRs. Please do your best to make the issue as easy to act on as possible, and only open if clearly a problem with pybind11 (ask first if unsure).
Please do your best to make the issue as easy to act on as possible, and only submit here if there is clearly a problem with pybind11 (ask first if unsure). **Note that a reproducer in a PR is much more likely to get immediate attention.**
- type: checkboxes
id: steps
attributes:
Expand All @@ -20,6 +21,13 @@ body:
- label: Consider asking first in the [Gitter chat room](https://gitter.im/pybind/Lobby) or in a [Discussion](https:/pybind/pybind11/discussions/new).
required: false

- type: input
id: version
attributes:
label: What version (or hash if on master) of pybind11 are you using?
validations:
required: true

- type: textarea
id: description
attributes:
Expand All @@ -40,6 +48,14 @@ body:
The code should be minimal, have no external dependencies, isolate the
function(s) that cause breakage. Submit matched and complete C++ and
Python snippets that can be easily compiled and run to diagnose the
issue. If possible, make a PR with a new, failing test to give us a
starting point to work on!
issue. — Note that a reproducer in a PR is much more likely to get
immediate attention: failing tests in the pybind11 CI are the best
starting point for working out fixes.
render: text

- type: input
id: regression
attributes:
label: Is this a regression? Put the last known working version here if it is.
description: Put the last known working version here if this is a regression.
value: Not a regression
Loading

0 comments on commit 74eea30

Please sign in to comment.