Skip to content

Commit 49b46e7

Browse files
committed
Move trampoline life support so that it doesn't need to be virtual
1 parent 37cf8d4 commit 49b46e7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

robotpy_build/autowrap/render_cls_rpy_include.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def _render_cls_trampoline(
194194
r.write_trim(
195195
f"""
196196
template <typename PyTrampolineBase{ precomma(template_parameter_list) }, typename PyTrampolineCfg>
197-
struct PyTrampoline_{ cls.full_cpp_name_identifier } : PyTrampolineBase, virtual py::trampoline_self_life_support {{
197+
struct PyTrampoline_{ cls.full_cpp_name_identifier } : PyTrampolineBase {{
198198
using PyTrampolineBase::PyTrampolineBase;
199199
"""
200200
)

robotpy_build/autowrap/render_pybind11.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,16 @@ def cls_consts(r: RenderBuffer, cls: ClassContext):
292292
def cls_decl(r: RenderBuffer, cls: ClassContext):
293293
if cls.trampoline:
294294
tctx = cls.trampoline
295-
r.writeln(f"using {tctx.var} = {tctx.full_cpp_name};")
295+
# py::trampoline_self_life_support
296+
r.write_trim(
297+
f"""
298+
struct {tctx.var} : {tctx.full_cpp_name}, py::trampoline_self_life_support {{
299+
using RpyBase = {tctx.full_cpp_name};
300+
using RpyBase::RpyBase;
301+
}};
302+
303+
"""
304+
)
296305
r.writeln(
297306
f'static_assert(std::is_abstract<{tctx.var}>::value == false, "{cls.full_cpp_name} " RPYBUILD_BAD_TRAMPOLINE);'
298307
)

0 commit comments

Comments
 (0)