Skip to content

Commit

Permalink
Move trampoline life support so that it doesn't need to be virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Nov 20, 2024
1 parent 37cf8d4 commit 49b46e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion robotpy_build/autowrap/render_cls_rpy_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _render_cls_trampoline(
r.write_trim(
f"""
template <typename PyTrampolineBase{ precomma(template_parameter_list) }, typename PyTrampolineCfg>
struct PyTrampoline_{ cls.full_cpp_name_identifier } : PyTrampolineBase, virtual py::trampoline_self_life_support {{
struct PyTrampoline_{ cls.full_cpp_name_identifier } : PyTrampolineBase {{
using PyTrampolineBase::PyTrampolineBase;
"""
)
Expand Down
11 changes: 10 additions & 1 deletion robotpy_build/autowrap/render_pybind11.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,16 @@ def cls_consts(r: RenderBuffer, cls: ClassContext):
def cls_decl(r: RenderBuffer, cls: ClassContext):
if cls.trampoline:
tctx = cls.trampoline
r.writeln(f"using {tctx.var} = {tctx.full_cpp_name};")
# py::trampoline_self_life_support
r.write_trim(
f"""
struct {tctx.var} : {tctx.full_cpp_name}, py::trampoline_self_life_support {{
using RpyBase = {tctx.full_cpp_name};
using RpyBase::RpyBase;
}};
"""
)
r.writeln(
f'static_assert(std::is_abstract<{tctx.var}>::value == false, "{cls.full_cpp_name} " RPYBUILD_BAD_TRAMPOLINE);'
)
Expand Down

0 comments on commit 49b46e7

Please sign in to comment.