welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
welder::rods::trampolines::rod Struct Reference

The trampoline-generator rod: a stateless welder::rod that, instead of registering a live module, appends a compilable trampoline struct (plus its trampoline_for registration) for every welded virtual type it visits. More...

#include <welder/rods/python/trampolines/rod.hpp>

Classes

struct  module_handle
 A copyable handle onto the growing document that the driver threads through every emission primitive (the rod's module_type). More...
struct  class_handle
 The class handle the driver threads to the per-member hooks. More...
struct  enum_handle
 The enum handle. More...
struct  session
 No deferred module state. More...

Public Types

using module_type = module_handle
template<class>
using class_handle_type = class_handle
 The class / enum handles the per-class / per-enum hooks receive — exactly what make_class / make_enum return (a generator handle carries no type parameter).
template<class>
using enum_handle_type = enum_handle

Static Public Member Functions

static consteval const char * special_method_name (std::meta::info)
 No operators are emitted (they are covered as virtuals when overridable), so none are "special".
template<class T, auto Bases, std::size_t... I>
static class_handle make_class (module_type &m, const char *, const char *, std::index_sequence< I... >)
 Emit T's trampoline iff it has overridable virtuals and is not a whole-type bind_flat.
template<class T, std::meta::info Decl, auto Bases, std::size_t... I>
static class_handle make_class (module_type &m, const char *, const char *, std::index_sequence< I... >)
 The declaring-entity-aware form the carriage prefers (see bind_type): Decl is the spelling of T^^T for a directly-declared class, or the namespace-scope alias through which a class-template specialization was welded.
template<class T, auto Ctors, bool HasDefault, bool Aggregate>
static void add_constructors (class_handle &)
template<std::meta::info, class = ::welder::naming::none>
static void add_field (class_handle &)
template<auto Fns, class = ::welder::naming::none>
static void add_method (class_handle &)
template<auto Fns, class = ::welder::naming::none>
static void add_static_method (class_handle &)
template<auto Fns>
static void add_operator (class_handle &)
template<class E>
static enum_handle make_enum (module_type &, const char *, const char *)
template<std::meta::info, class = ::welder::naming::none>
static void add_enumerator (enum_handle &)
template<class E>
static void finish_enum (enum_handle &)
static session open_module (module_type &)
static void set_module_doc (module_type &, const char *)
template<auto Fns, class = ::welder::naming::none>
static void add_function (module_type &, const char *=nullptr)
template<std::meta::info, class = ::welder::naming::none>
static void add_variable (module_type &, session &, const char *=nullptr)
static module_type add_submodule (module_type &m, const char *name)
 Recurse into a nested namespace, carrying the document handle through.
static void close_module (module_type &, session &)
template<std::meta::info Ns, class Style = ::welder::naming::none>
static void generate (std::ostream &os)
 Emit the trampoline header for the welded types in namespace Ns to os.

Static Public Attributes

static constexpr lang language {lang::py}
 Trampolines are a Python concept.
template<class T>
static constexpr bool has_native_caster = true
 Permissive: the generator only reproduces virtual signatures (via splices, which work for any type), so it does not need the backend's bindability oracle — disabling the gate lets it run over the same types the Python rods bind without re-deriving their caster logic.

Detailed Description

The trampoline-generator rod: a stateless welder::rod that, instead of registering a live module, appends a compilable trampoline struct (plus its trampoline_for registration) for every welded virtual type it visits.

Only make_class does work — it emits the trampoline for a type carrying overridable virtuals (skipping a whole-type bind_flat). Every other primitive is a no-op: members, constructors, enums, free functions and variables contribute no trampolines.

Definition at line 56 of file rod.hpp.

Member Typedef Documentation

◆ class_handle_type

The class / enum handles the per-class / per-enum hooks receive — exactly what make_class / make_enum return (a generator handle carries no type parameter).

Named as associated types so the welder::rod concept can shape-check the per-handle hooks against them.

Definition at line 81 of file rod.hpp.

◆ enum_handle_type

Definition at line 82 of file rod.hpp.

◆ module_type

Member Function Documentation

◆ add_constructors()

template<class T, auto Ctors, bool HasDefault, bool Aggregate>
void welder::rods::trampolines::rod::add_constructors ( class_handle & )
inlinestatic

Definition at line 130 of file rod.hpp.

◆ add_enumerator()

template<std::meta::info, class = ::welder::naming::none>
void welder::rods::trampolines::rod::add_enumerator ( enum_handle & )
inlinestatic

Definition at line 146 of file rod.hpp.

◆ add_field()

template<std::meta::info, class = ::welder::naming::none>
void welder::rods::trampolines::rod::add_field ( class_handle & )
inlinestatic

Definition at line 132 of file rod.hpp.

◆ add_function()

template<auto Fns, class = ::welder::naming::none>
void welder::rods::trampolines::rod::add_function ( module_type & ,
const char * = nullptr )
inlinestatic

Definition at line 154 of file rod.hpp.

◆ add_method()

template<auto Fns, class = ::welder::naming::none>
void welder::rods::trampolines::rod::add_method ( class_handle & )
inlinestatic

Definition at line 134 of file rod.hpp.

◆ add_operator()

template<auto Fns>
void welder::rods::trampolines::rod::add_operator ( class_handle & )
inlinestatic

Definition at line 137 of file rod.hpp.

◆ add_static_method()

template<auto Fns, class = ::welder::naming::none>
void welder::rods::trampolines::rod::add_static_method ( class_handle & )
inlinestatic

Definition at line 136 of file rod.hpp.

◆ add_submodule()

module_type welder::rods::trampolines::rod::add_submodule ( module_type & m,
const char * name )
inlinestatic

Recurse into a nested namespace, carrying the document handle through.

See also
welder::rod

Definition at line 160 of file rod.hpp.

References welder::rods::trampolines::rod::module_handle::doc, and welder::rods::trampolines::rod::module_handle::prefix.

◆ add_variable()

template<std::meta::info, class = ::welder::naming::none>
void welder::rods::trampolines::rod::add_variable ( module_type & ,
session & ,
const char * = nullptr )
inlinestatic

Definition at line 156 of file rod.hpp.

◆ close_module()

void welder::rods::trampolines::rod::close_module ( module_type & ,
session &  )
inlinestatic

Definition at line 164 of file rod.hpp.

◆ finish_enum()

template<class E>
void welder::rods::trampolines::rod::finish_enum ( enum_handle & )
inlinestatic

Definition at line 147 of file rod.hpp.

◆ generate()

template<std::meta::info Ns, class Style = ::welder::naming::none>
void welder::rods::trampolines::rod::generate ( std::ostream & os)
inlinestatic

Emit the trampoline header for the welded types in namespace Ns to os.

Runs welder's generic driver over Ns with this text-emitting backend, so the header carries a trampoline for exactly the welded virtual types the Python rods bind — inherited virtuals covered, bind_flat honoured. Style is accepted for signature parity with the other rods but unused (a trampoline needs no target-language names).

Template Parameters
Nsa reflection of the (top-level) namespace to scan.
Parameters
osthe stream to write the finished header to.

Definition at line 178 of file rod.hpp.

References welder::doc().

◆ make_class() [1/2]

template<class T, std::meta::info Decl, auto Bases, std::size_t... I>
class_handle welder::rods::trampolines::rod::make_class ( module_type & m,
const char * ,
const char * ,
std::index_sequence< I... >  )
inlinestatic

The declaring-entity-aware form the carriage prefers (see bind_type): Decl is the spelling of T^^T for a directly-declared class, or the namespace-scope alias through which a class-template specialization was welded.

The generated text derives everything from Decl (base clause, trampoline_for key, slot re-derivations), which is what lets it name a specialization at all: Ring<int> has no identifier, ::ns::IntRing does. bind_flat is read through the dealiased type (marks live on the template).

Definition at line 121 of file rod.hpp.

References welder::rods::python::bound_flat(), welder::rods::trampolines::rod::module_handle::doc, and welder::rods::python::overridable_virtuals().

◆ make_class() [2/2]

template<class T, auto Bases, std::size_t... I>
class_handle welder::rods::trampolines::rod::make_class ( module_type & m,
const char * ,
const char * ,
std::index_sequence< I... >  )
inlinestatic

Emit T's trampoline iff it has overridable virtuals and is not a whole-type bind_flat.

Bases / name / doc are unused (a trampoline derives from T alone and needs no target-language name).

See also
welder::rod

Definition at line 105 of file rod.hpp.

References welder::rods::python::bound_flat(), welder::rods::trampolines::rod::module_handle::doc, and welder::rods::python::overridable_virtuals().

◆ make_enum()

template<class E>
enum_handle welder::rods::trampolines::rod::make_enum ( module_type & ,
const char * ,
const char *  )
inlinestatic

Definition at line 142 of file rod.hpp.

◆ open_module()

session welder::rods::trampolines::rod::open_module ( module_type & )
inlinestatic

Definition at line 151 of file rod.hpp.

◆ set_module_doc()

void welder::rods::trampolines::rod::set_module_doc ( module_type & ,
const char *  )
inlinestatic

Definition at line 152 of file rod.hpp.

◆ special_method_name()

consteval const char * welder::rods::trampolines::rod::special_method_name ( std::meta::info )
inlinestaticconsteval

No operators are emitted (they are covered as virtuals when overridable), so none are "special".

See also
welder::rod

Definition at line 95 of file rod.hpp.

Member Data Documentation

◆ has_native_caster

template<class T>
bool welder::rods::trampolines::rod::has_native_caster = true
staticconstexpr

Permissive: the generator only reproduces virtual signatures (via splices, which work for any type), so it does not need the backend's bindability oracle — disabling the gate lets it run over the same types the Python rods bind without re-deriving their caster logic.

See also
welder::caster_oracle

Definition at line 91 of file rod.hpp.

◆ language

lang welder::rods::trampolines::rod::language {lang::py}
staticconstexpr

Trampolines are a Python concept.

Definition at line 57 of file rod.hpp.


The documentation for this struct was generated from the following file:
  • src/welder/rods/python/trampolines/rod.hpp