Skip to content

Commit

Permalink
clif/pybind11/gen_type_info.py: PYBIND11_MAKE_OPAQUE
Browse files Browse the repository at this point in the history
No unit test changes, due to special circumstances (role eliminations).

However, this CL was used in a PyCLIF-pybind11 TGP (cl/667456010, 2024-08-26):

http://tap/OCL:667456010:BASE:667610796:1724689781533:d2626456:

```
    571 Failing Targets
    147 Broken Targets
```

PiperOrigin-RevId: 668978487
  • Loading branch information
rwgk committed Sep 6, 2024
1 parent 53e0b17 commit 3af2676
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions clif/pybind11/gen_type_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def generate_type_trait(self, type_trait: str) -> Generator[str, None, None]:

def generate_type_caster(self) -> Generator[str, None, None]:
# Work around potential name collisions in
# `PYBIND11_SMART_HOLDER_TYPE_CASTERS()` invocation, e.g. a collision
# `PYBIND11_MAKE_OPAQUE()` invocation, e.g. a collision
# between a `std::tuple` alias in the global namespace (to work around
# b/118736768) and `pybind11::tuple`.
if self.module_path:
Expand All @@ -79,7 +79,9 @@ def generate_type_caster(self) -> Generator[str, None, None]:
py_name_fq = self.py_name
using_name = f'PyCLIF_py_name_{py_name_fq}'.replace('.', '_')
yield f'using {using_name} = {self.cpp_name};'
yield f'PYBIND11_SMART_HOLDER_TYPE_CASTERS({using_name})'
# This fully specializes the `type_caster`, to avoid falling back to other
# partial specializations:
yield f'PYBIND11_MAKE_OPAQUE({using_name})'
if not self.cpp_copyable:
yield from self.generate_type_trait('is_copy_constructible')
if not self.cpp_movable:
Expand Down

0 comments on commit 3af2676

Please sign in to comment.