welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
welder::carriages::basic_carriage< Resolution > Struct Template Reference

A carriage: welder's reflection-driven traversal, parameterized on a Resolution (which markers it obeys). More...

#include <welder/carriage.hpp>

Static Public Member Functions

template<rod B, class E, class Style = naming::none>
static auto bind_enum (typename B::module_type &m, const char *name=nullptr)
 Reflect over enum E and register it via rod B onto module m.
template<rod B, class T, std::meta::info Decl, auto Bases>
static auto make_class_of (typename B::module_type &m, const char *cls_name, const char *doc)
 Call the rod's class-creation primitive, preferring the extended declaring-entity-aware form when the rod provides one.
template<rod B, class T, class Style = naming::none, std::meta::info Decl = std::meta::info{}>
static auto bind_type (typename B::module_type &m, const char *name=nullptr)
 Reflect over T and register it via rod B onto module m.
template<rod B, std::meta::info Fn, class Style = naming::none>
static auto bind_function (typename B::module_type &m, const char *name=nullptr)
 Register free function Fn — with its participating overload siblings — as a module-level function of m.
template<rod B, std::meta::info Var, class Style = naming::none>
static auto bind_variable (typename B::module_type &m, const char *name=nullptr)
 Register a single namespace variable Var as an attribute of m.
template<rod B, std::meta::info Ns, class Style = naming::none>
static void bind_namespace (typename B::module_type &m)
 Reflect over a whole namespace Ns and expose its members on module m.
template<rod B, std::meta::info Ns, class Style = naming::none>
static B::module_type bind_namespace_as_submodule (typename B::module_type &m, const char *name=nullptr)
 Define a submodule of m and bind namespace Ns into it.
template<rod B, std::meta::info Ns, class Style = naming::none, class Pre, class Post>
static void build_module (typename B::module_type &m, Pre pre, Post post)
 Fill an existing module out of top-level namespace Ns: pre hook, bind the namespace, post hook.

Static Private Member Functions

template<rod B, std::meta::info BoundInto, std::meta::info Src, class Style, class Cls>
static void bind_members (Cls &cls)
 Flatten the eligible data members, methods and operators of Src onto the class handle cls (a handle for a type deriving from Src) — public ones, plus protected ones whose access is admitted (see detail::member_access_admitted; private never binds).
template<rod B, class E, class Style, class EnumHandle>
static void emit_enumerators (EnumHandle &e)
 The per-enumerator walk shared by bind_enum and bind_nested_enum: each enumerator resolves like a data member (the enum's policy + its own marks) and is emitted through the rod's add_enumerator.
template<rod B, class T, class Style, class Cls>
static void bind_class_interior (typename B::module_type &m, Cls &cls)
 Everything a class binding contains beyond the class handle itself — shared by bind_type (a module-scope class) and bind_nested_type (a class-scoped one).
template<rod B, std::meta::info Outer, class Style, class Cls>
static void bind_nested_types (typename B::module_type &m, Cls &cls)
 Register the participating member types of Outer onto its class handle cls — the nested-class / nested-enum walk.
template<rod B, class T, class Style, std::meta::info Decl = std::meta::info{}, class OuterCls>
static void bind_nested_type (typename B::module_type &m, OuterCls &outer, const char *name=nullptr)
 Register nested class T onto the class handle of its enclosing type — bind_type's class-scope sibling.
template<rod B, class E, class Style, class OuterCls>
static void bind_nested_enum (typename B::module_type &m, OuterCls &outer, const char *name=nullptr)
 Register nested enum E onto the class handle of its enclosing type — bind_enum's class-scope sibling (see bind_nested_type for the shared rationale; the fallback for a rod without make_nested_enum is the module-scope make_enum).
template<rod B, class T, std::meta::info Decl, auto Bases, class OuterCls>
static auto make_nested_class_of (typename B::module_type &m, OuterCls &outer, const char *cls_name, const char *doc)
 Call the rod's nested-class primitive when it declares one, else fall back to the module-scope factory (flat placement).
template<rod B, class E, class OuterCls>
static auto make_nested_enum_of (typename B::module_type &m, OuterCls &outer, const char *name, const char *doc)
 make_nested_class_of's enum counterpart: the rod's make_nested_enum when present, else the module-scope make_enum.

Detailed Description

template<resolution Resolution>
struct welder::carriages::basic_carriage< Resolution >

A carriage: welder's reflection-driven traversal, parameterized on a Resolution (which markers it obeys).

In welding, the carriage (or tractor) is the mechanism that drives the torch — fed by the rod — steadily along the joint. Here it is the entity that walks a reflected type or namespace and drives a welder::rod's emission primitives along it: it owns all the traversal and emission orchestration (base flattening, the bindability gate, name resolution, sessions), delegating only the which participates decisions to Resolution and the framework-specific emission to the rod. It is a stateless policy struct of static member templates, each parameterized on the rod B and the name style Style.

Two are aliased for welder::welder's Carriage argument (defaulted to welder::stitch_welding_carriage): the marker-directed stitch carriage and the greedy tack carriage (welder::tack_welding_carriage). A user may inject either, or a bespoke basic_carriage<CustomResolution> — the seam is deliberately open. The members cross-reference each other (a namespace's class members bind via bind_type, a nested namespace recurses via bind_namespace), so a replacement is expected to be a coherent whole rather than a partial override.

Template Parameters
Resolutionthe resolution policy (a welder::resolution): marker_resolution or greedy_resolution, or a bespoke one.

Definition at line 467 of file carriage.hpp.

Member Function Documentation

◆ bind_class_interior()

template<resolution Resolution>
template<rod B, class T, class Style, class Cls>
void welder::carriages::basic_carriage< Resolution >::bind_class_interior ( typename B::module_type & m,
Cls & cls )
inlinestaticprivate

Everything a class binding contains beyond the class handle itself — shared by bind_type (a module-scope class) and bind_nested_type (a class-scoped one).

Order matters: nested member types register first — a rod places them on the class handle just created, and pybind11 converts a later constructor/method default argument at registration time, so a nested enum a default argument names must already exist. Then the constructor set (with the no-constructor-left fail-safe), then data members / methods / operators (bind_members).

Template Parameters
Bthe rod.
Tthe type whose binding to fill.
Stylethe name style.
Parameters
mthe module handle (rods without nested placement fall back to it).
clsthe class handle make_class/make_nested_class created.

Definition at line 613 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_nested_type(), and welder::carriages::basic_carriage< carriages::marker_resolution >::bind_type().

◆ bind_enum()

template<resolution Resolution>
template<rod B, class E, class Style = naming::none>
auto welder::carriages::basic_carriage< Resolution >::bind_enum ( typename B::module_type & m,
const char * name = nullptr )
inlinestatic

Reflect over enum E and register it via rod B onto module m.

Emits its docstring, then each enumerator that resolves as bound (an enumerator honors the enum's policy and its own exclude/include marks, exactly like a data member). finish_enum lets the backend apply a whole-enum finalizer — e.g. exporting an unscoped enum's values into the enclosing scope, mirroring C++.

Template Parameters
Bthe rod.
Ethe enum type.
Parameters
mthe module handle to register onto.
namethe target name (used verbatim, beating any weld_as), or nullptr to resolve E's weld_as/styled name.
Returns
the rod's enum handle.

Definition at line 941 of file carriage.hpp.

◆ bind_function()

template<resolution Resolution>
template<rod B, std::meta::info Fn, class Style = naming::none>
auto welder::carriages::basic_carriage< Resolution >::bind_function ( typename B::module_type & m,
const char * name = nullptr )
inlinestatic

Register free function Fn — with its participating overload siblings — as a module-level function of m.

The semi-manual leaf: gate then emit one name, without walking a namespace. Fn (which resolves the group's target name, and is welded even if its own marks would resolve it out — the explicit call is the stronger statement of intent) must be admitted by Resolution for B's language; its participating same-name siblings join the group, keeping the call consistent with the namespace walk on every rod (a one-value-per-name framework registers the complete set). Every group member's signature runs the bindability gate.

Template Parameters
Bthe rod.
Fna reflection of the free function.
Parameters
mthe module handle to register onto.
namethe target name (used verbatim, beating any weld_as), or nullptr to resolve Fn's weld_as/styled name.

Definition at line 1068 of file carriage.hpp.

◆ bind_members()

template<resolution Resolution>
template<rod B, std::meta::info BoundInto, std::meta::info Src, class Style, class Cls>
void welder::carriages::basic_carriage< Resolution >::bind_members ( Cls & cls)
inlinestaticprivate

Flatten the eligible data members, methods and operators of Src onto the class handle cls (a handle for a type deriving from Src) — public ones, plus protected ones whose access is admitted (see detail::member_access_admitted; private never binds).

A base that Resolution treats as native is skipped here (it binds as a base of the class handle); the rest are recursed first so that, on a name clash, the member declared closer to the derived type wins. Constructors are never flattened (the derived type provides its own).

Template Parameters
Bthe rod.
BoundIntothe welded type whose class handle receives the members — held fixed through the flattening recursion, and handed to the resolution hooks as their bound-into context.
Srca reflection of the (base or derived) type whose members to flatten.
Stylethe name style each member's name flows through.
Clsthe rod's class-handle type (deduced).
Parameters
clsthe class handle to register onto.

Definition at line 490 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_class_interior().

◆ bind_namespace()

template<resolution Resolution>
template<rod B, std::meta::info Ns, class Style = naming::none>
void welder::carriages::basic_carriage< Resolution >::bind_namespace ( typename B::module_type & m)
inlinestatic

Reflect over a whole namespace Ns and expose its members on module m.

Resolution decides what participates (marker-directed under marker_resolution, greedy under greedy_resolution); classes bind via bind_type(), free functions and namespace variables become module attributes, and a nested namespace holding participating content becomes a submodule (recursed under its own policy). Members are visited in declaration order.

Template Parameters
Bthe rod.
Nsa reflection of the namespace.
Parameters
mthe module handle to fill.

Definition at line 1138 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace_as_submodule(), and welder::carriages::basic_carriage< carriages::marker_resolution >::build_module().

◆ bind_namespace_as_submodule()

template<resolution Resolution>
template<rod B, std::meta::info Ns, class Style = naming::none>
B::module_type welder::carriages::basic_carriage< Resolution >::bind_namespace_as_submodule ( typename B::module_type & m,
const char * name = nullptr )
inlinestatic

Define a submodule of m and bind namespace Ns into it.

Template Parameters
Bthe rod.
Nsa reflection of the namespace.
Parameters
mthe parent module handle.
namethe submodule name (verbatim), or nullptr to resolve Ns's styled/weld_as name.
Returns
the new submodule handle.

Definition at line 1247 of file carriage.hpp.

◆ bind_nested_enum()

template<resolution Resolution>
template<rod B, class E, class Style, class OuterCls>
void welder::carriages::basic_carriage< Resolution >::bind_nested_enum ( typename B::module_type & m,
OuterCls & outer,
const char * name = nullptr )
inlinestaticprivate

Register nested enum E onto the class handle of its enclosing type — bind_enum's class-scope sibling (see bind_nested_type for the shared rationale; the fallback for a rod without make_nested_enum is the module-scope make_enum).

Template Parameters
Bthe rod.
Ethe nested enum type.
Stylethe name style.
Parameters
mthe module handle (the flat-placement fallback scope).
outerthe enclosing type's class handle.
namethe bound name (an alias-resolved override), or nullptr to resolve E's weld_as/styled name.

Definition at line 851 of file carriage.hpp.

◆ bind_nested_type()

template<resolution Resolution>
template<rod B, class T, class Style, std::meta::info Decl = std::meta::info{}, class OuterCls>
void welder::carriages::basic_carriage< Resolution >::bind_nested_type ( typename B::module_type & m,
OuterCls & outer,
const char * name = nullptr )
inlinestaticprivate

Register nested class T onto the class handle of its enclosing type — bind_type's class-scope sibling.

Same interior (constructors, fail-safes, members, its own nested types — so nesting recurses), differing only in where the class handle is created: a rod implementing the optional make_nested_class places the new class under outer (the Python rods pass the enclosing class as the registration scope, yielding module.Outer.Inner); one that doesn't falls back to the module-scope make_class — a flat sibling under its usual resolved name, so two outers' same-named nested types then collide (rename with weld_as, or implement the hook).

No participates assert here: participation was the caller's member resolution (a nested type needs no weld).

Template Parameters
Bthe rod.
Tthe nested class type.
Stylethe name style.
Declthe declaring entity when it differs from ^^T — the MEMBER ALIAS a type was welded through (the alias is the one spellable name an aliased specialization has, which the text-emitting rods need); a null reflection for the declared-nested route.
Parameters
mthe module handle (the flat-placement fallback scope).
outerthe enclosing type's class handle.
namethe bound name (an alias-resolved override), or nullptr to resolve T's weld_as/styled name.

Definition at line 814 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_nested_types().

◆ bind_nested_types()

template<resolution Resolution>
template<rod B, std::meta::info Outer, class Style, class Cls>
void welder::carriages::basic_carriage< Resolution >::bind_nested_types ( typename B::module_type & m,
Cls & cls )
inlinestaticprivate

Register the participating member types of Outer onto its class handle cls — the nested-class / nested-enum walk.

A nested type resolves like any other class member — the outer's policy plus the type's own exclude/include/only marks (class_member_participates), with the usual access admission — never via its own weld: nested types are interface helpers of their enclosing type, and the enclosing weld is the discovery marker. Deliberately skipped:

  • member type aliases (binding one would re-register its target; the alias-welding route is namespace-scope only);
  • unions (is_class_type excludes them), unnamed types (there is nothing to name them by — bind the member of that type or exclude it), and incomplete member types (nothing to register; a use of one also fails the gate);
  • a flattened base's nested types: a nested type registers exactly once, with its DECLARING class — two derived types flattening one mixin would otherwise register it twice (a framework load error). A flattened signature naming one therefore fails the gate until the declaring base is welded (or the member trusted/excluded).
Template Parameters
Bthe rod.
Outerthe enclosing (welded) type being bound.
Stylethe name style.
Parameters
mthe module handle (the flat-placement fallback scope).
clsthe outer type's class handle.

Definition at line 708 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_class_interior().

◆ bind_type()

template<resolution Resolution>
template<rod B, class T, class Style = naming::none, std::meta::info Decl = std::meta::info{}>
auto welder::carriages::basic_carriage< Resolution >::bind_type ( typename B::module_type & m,
const char * name = nullptr )
inlinestatic

Reflect over T and register it via rod B onto module m.

Emits:

  • native inheritance from T's native ancestors (per Resolution; each a base of the class handle — bind those bases separately, before T);
  • T's own nested member types (classes + enums, recursively) that resolve as bound — like any member, under T's policy + their own marks, no weld of their own (bind_nested_types); a rod with the optional make_nested_class/make_nested_enum primitives places them under T's binding (Python: module.T.Inner), others fall back to flat module-scope placement;
  • the default constructor (if any), each public non-copy/move constructor, and — for a baseless aggregate whose fields all bind — a synthesized field constructor;
  • data members / methods / operators that resolve as bound (public, plus protected where detail::member_access_admitted admits them — see policy::weld_protected; private never), plus the eligible members of every flattened (non-native) public base.
Template Parameters
Bthe rod.
Tthe type to bind.
Declthe declaring entity when it differs from ^^T — the namespace-scope alias a class-template specialization was welded through (set by bind_namespace's alias branch, which has already resolved participation); a null reflection for the direct route.
Parameters
mthe module handle to register onto.
namethe target name (used verbatim, beating any weld_as), or nullptr to resolve T's weld_as/styled name.
Returns
the rod's class handle, so callers can chain further registrations.

Definition at line 1018 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace().

◆ bind_variable()

template<resolution Resolution>
template<rod B, std::meta::info Var, class Style = naming::none>
auto welder::carriages::basic_carriage< Resolution >::bind_variable ( typename B::module_type & m,
const char * name = nullptr )
inlinestatic

Register a single namespace variable Var as an attribute of m.

The semi-manual leaf for a global/constant: a const/constexpr Var becomes a value snapshot, a mutable one a live get/set property (backend-dependent). Var must be admitted by Resolution for B's language; its type runs the bindability gate. The emission runs inside its own per-module session (opened and finalized here), so it composes with a later namespace/module weld onto the same handle.

Template Parameters
Bthe rod.
Vara reflection of the namespace-scope variable.
Parameters
mthe module handle to register onto.
namethe target name (used verbatim, beating any weld_as), or nullptr to resolve Var's weld_as/styled name.

Definition at line 1100 of file carriage.hpp.

◆ build_module()

template<resolution Resolution>
template<rod B, std::meta::info Ns, class Style = naming::none, class Pre, class Post>
void welder::carriages::basic_carriage< Resolution >::build_module ( typename B::module_type & m,
Pre pre,
Post post )
inlinestatic

Fill an existing module out of top-level namespace Ns: pre hook, bind the namespace, post hook.

Template Parameters
Bthe rod.
Nsa reflection of the (asserted top-level) namespace; its name is meant to be the module name.
Stylethe name style each generated name flows through.
Prethe pre-hook callable type.
Postthe post-hook callable type.
Parameters
mthe module handle to fill.
preinvoked with m before the namespace is bound.
postinvoked with m after the namespace is bound.

Definition at line 1274 of file carriage.hpp.

◆ emit_enumerators()

template<resolution Resolution>
template<rod B, class E, class Style, class EnumHandle>
void welder::carriages::basic_carriage< Resolution >::emit_enumerators ( EnumHandle & e)
inlinestaticprivate

The per-enumerator walk shared by bind_enum and bind_nested_enum: each enumerator resolves like a data member (the enum's policy + its own marks) and is emitted through the rod's add_enumerator.

Template Parameters
Bthe rod.
Ethe enum type.
Stylethe name style.
Parameters
ethe rod's enum handle.

Definition at line 586 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_enum(), and welder::carriages::basic_carriage< carriages::marker_resolution >::bind_nested_enum().

◆ make_class_of()

template<resolution Resolution>
template<rod B, class T, std::meta::info Decl, auto Bases>
auto welder::carriages::basic_carriage< Resolution >::make_class_of ( typename B::module_type & m,
const char * cls_name,
const char * doc )
inlinestatic

Call the rod's class-creation primitive, preferring the extended declaring-entity-aware form when the rod provides one.

Decl is the entity the type was declared through^^T, or the namespace-scope alias welding a class-template specialization. A helper (not a lambda in bind_type): std::meta::info is consteval-only, so a lambda referencing such a constexpr local escalates to consteval (P2564) and cannot take the runtime module handle; template parameters do not.

Template Parameters
Bthe rod.
Tthe type to bind.
Declthe declaring entity handed to a spelling-aware rod.
Basesthe native base reflections.
Parameters
mthe module handle to register onto.
cls_namethe resolved target-language name.
docthe class docstring, or nullptr.
Returns
the rod's class handle.

Definition at line 971 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::make_nested_class_of().

◆ make_nested_class_of()

template<resolution Resolution>
template<rod B, class T, std::meta::info Decl, auto Bases, class OuterCls>
auto welder::carriages::basic_carriage< Resolution >::make_nested_class_of ( typename B::module_type & m,
OuterCls & outer,
const char * cls_name,
const char * doc )
inlinestaticprivate

Call the rod's nested-class primitive when it declares one, else fall back to the module-scope factory (flat placement).

A static helper, not a lambda in bind_nested_type, for the same P2564 reason as make_class_of.

A spelling-aware rod may declare the extended, declaring-entity-aware form make_nested_class<T, Decl, Bases> (preferred when Decl is set — the member alias an unnameable specialization was welded through); the flat fallback likewise threads Decl into make_class_of, so a text-emitting rod's extended make_class receives it too.

Template Parameters
Bthe rod.
Tthe nested class type.
Declthe declaring member alias, or a null reflection.
Basesthe native base reflections.
Parameters
mthe module handle.
outerthe enclosing type's class handle.
cls_namethe resolved target-language name.
docthe class docstring, or nullptr.
Returns
the rod's class handle for T.

Definition at line 882 of file carriage.hpp.

◆ make_nested_enum_of()

template<resolution Resolution>
template<rod B, class E, class OuterCls>
auto welder::carriages::basic_carriage< Resolution >::make_nested_enum_of ( typename B::module_type & m,
OuterCls & outer,
const char * name,
const char * doc )
inlinestaticprivate

make_nested_class_of's enum counterpart: the rod's make_nested_enum when present, else the module-scope make_enum.

Template Parameters
Bthe rod.
Ethe nested enum type.
Parameters
mthe module handle.
outerthe enclosing type's class handle.
namethe resolved target-language name.
docthe enum docstring, or nullptr.
Returns
the rod's enum handle for E.

Definition at line 915 of file carriage.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_nested_enum().


The documentation for this struct was generated from the following file: