|
welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
|
The text-emitting core of welder's trampoline-generator rod: the consteval routine that renders a hand-written-equivalent pybind11/nanobind trampoline for a welded virtual type, plus the small document that accumulates the generated structs and their trampoline_for registrations. More...
Go to the source code of this file.
Classes | |
| struct | welder::rods::trampolines::document |
| The growing generated header: the trampoline struct bodies and their trampoline_for registrations, kept apart so the structs can share one namespace generated { … } block and the registrations sit at global scope. More... | |
Namespaces | |
| namespace | welder |
| namespace | welder::rods |
| namespace | welder::rods::trampolines |
Functions | |
| consteval std::string | welder::rods::trampolines::int_string (std::size_t n) |
| Render a non-negative integer as decimal (constexpr std::to_string is not available on gcc-16 in a constant-evaluated context). | |
| consteval std::string | welder::rods::trampolines::cpp_qualified_name (std::meta::info ent) |
| The fully ::-qualified name of a namespace-scope entity, leading :: included (geometry::Point → "::geometry::Point"). | |
| consteval std::string | welder::rods::trampolines::trampoline_ident (std::meta::info type) |
| A collision-free identifier for type's generated trampoline: its qualified name with :: folded to _ (geometry::Point → geometry_Point_trampoline). | |
| consteval bool | welder::rods::trampolines::is_c_variadic (std::meta::info fn) |
| Is fn a C-style variadic function (R(…, ...))? | |
| consteval std::string | welder::rods::trampolines::qualifier_tokens (std::meta::info fn) |
| The trailing cv / ref-qualifier / noexcept tokens of a member function fn, in grammatical order (" const & noexcept"), each with a leading space. | |
| consteval std::string | welder::rods::trampolines::render_trampoline (std::meta::info type) |
| Render the trampoline struct for welded virtual type type — one override per overridable virtual, each splicing the base's own reflected return/parameter types and forwarding to Python via WELDER_PY_OVERRIDE_AS (the slot-reflection form, so overloaded virtuals dispatch correctly). | |
| consteval std::string | welder::rods::trampolines::render_registration (std::meta::info type) |
| The trampoline_for<type> specialization pointing at type's generated struct. | |
Variables | |
| constexpr const char * | welder::rods::trampolines::generated_namespace |
| The namespace the generated trampoline structs are emitted into (fully qualified). | |
The text-emitting core of welder's trampoline-generator rod: the consteval routine that renders a hand-written-equivalent pybind11/nanobind trampoline for a welded virtual type, plus the small document that accumulates the generated structs and their trampoline_for registrations.
welder cannot synthesize a trampoline as a live C++ class (member-declaration injection is absent from P2996), but it can emit one as source text and let the consuming translation unit compile it — the same build-time text-emission model as the LuaCATS stub rod. The one hard part, reproducing each virtual's signature exactly, is sidestepped: the generated header is itself compiled with reflection, so every return / parameter type is a splice of the base virtual's own reflected type ([: std::meta::type_of(…) :]) rather than a respelled type name — so the override matches the base signature by construction, for arbitrarily hairy types. The cv / ref / noexcept qualifiers are emitted from the matching reflection queries. Slots come from welder::rods::python::overridable_virtuals, so the generated trampoline covers inherited virtuals and honours bind_flat.
The one signature shape reflection cannot reproduce is a C-style variadic virtual (f(…, ...)): P2996 exposes no ellipsis query. Such a virtual, unless it is marked bind_flat, makes the generator emit a static_assert so the omission is a clear compile error rather than a mysterious "marked override, does not override".
Requires the welder vocabulary first (#include <welder/vocabulary.hpp>).
Definition in file document.hpp.