welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
welder Namespace Reference

Namespaces

namespace  carriages
namespace  detail
 The stored forms of the annotation vocabulary.
namespace  diag
namespace  mark
 The bare mark annotation objects — use directly or call to scope by language.
namespace  naming
namespace  policy
 The policy annotation values.
namespace  rods
namespace  rv
 The return-value policy values, the user-facing spelling of rv_kind.

Classes

struct  bind_flat_spec
 The stored form of a bind_flat mark (a plain tag — it carries no state). More...
struct  welded_registration
 The default registration oracle of the bindability gate: a program-defined class/enum type counts as registered iff it is welded for the language. More...
struct  welder
 welder's binding entry point, parameterized on a rod. More...

Concepts

concept  caster_oracle
 The one bindability fact a backend must provide: can it natively convert a type without welder registering it?
concept  doc_style
 A style folds a welder::detail::function_doc into one docstring, and a welder::detail::enum_doc (an enum's summary plus its enumerator docs) into the enum's class docstring.
concept  resolution
 The contract a resolution — the carriage's which-participates policy — must satisfy to be injected as welder::carriages::basic_carriage's Resolution argument.
concept  rod
 The contract a rod (a welder backend, welder::rods::…::rod) must satisfy to plug into the generic driver.
concept  rod_binds_containers
 Does rod B implement the optional bind_container hook (i.e.
concept  two_phase_rod
 Does rod B opt into the driver's two-phase namespace sweep — register every welded type's NAME, bind the opaque containers that use them, then fill members?

Typedefs

using size_type = decltype(sizeof(0))
 std::size_t named without a standard-library include, keeping this vocabulary header std-free (see the file note).
using stitch_welding_carriage = carriages::basic_carriage<carriages::marker_resolution>
 The stitch-welding carriage (the default): binds only where welder's weld / policy / marks direct — intermittent, marker-driven, like a stitch weld.
using tack_welding_carriage
 The tack-welding carriage: binds an unmarked library greedily — every reflectable type / function / global, namespaces recursed, bases flattened — ignoring the weld markers, while still enforcing the bindability gate.
using carriage = stitch_welding_carriage
 The default carriage — an alias for welder::stitch_welding_carriage.

Enumerations

enum class  policy_kind : unsigned char { automatic , opt_in }
 How greedily a type's members are reflected for binding. More...
enum class  accessor_role : unsigned char { getter , setter }
 Which half of a property a marked accessor function supplies. More...
enum class  rv_kind : unsigned char {
  automatic , automatic_reference , take_ownership , copy ,
  move , reference , reference_internal , none
}
 How a bound callable's returned object is owned/converted in the target language — welder's backend-neutral spelling of the return-value policy. More...
enum class  container_kind : unsigned char { sequence , map , fixed_sequence }
 Which opaque binder a reference-bound container uses. More...
enum class  lang : unsigned char { py , lua }
 The target languages welder ships rods for — but not the whole value space. More...
enum class  ent_kind {
  class_ , enum_ , enumerator , method ,
  static_method , function , field , variable ,
  submodule
}
 The nameable entity kinds welder distinguishes, one per name-style hook — picked by the driver/rod so name_of calls the right transform. More...

Functions

consteval unsigned lang_bit (lang l)
 The single-language bit for l within a language mask.
template<class... Ls>
consteval unsigned lang_mask (Ls... ls)
 The mask naming the languages ls.
template<size_type N>
consteval detail::doc_spec< N > doc (const char(&s)[N])
 Attach a docstring to a namespace, class, function, or function parameter.
template<size_type N>
consteval detail::return_doc_spec< N > returns (const char(&s)[N])
 Document a function's return value.
template<size_type N, size_type M>
consteval detail::tparam_spec< N, M > tparam (const char(&name)[N], const char(&text)[M])
 Document a template parameter (repeatable, ordered).
template<size_type N>
consteval detail::weld_as_spec< N > weld_as (const char(&s)[N])
 Force s as the target name in every welded language.
template<class... Args>
consteval auto weld_as (Args &&... args)
 Force a verbatim target name, optionally scoped to one or more languages.
template<class... Args>
consteval detail::return_policy_spec return_policy (Args... args)
 Force a return-value policy on a callable, optionally scoped to one or more languages.
consteval detail::keep_alive_spec keep_alive (unsigned nurse, unsigned patient)
 Keep the call entity patient alive at least until nurse is collected.
template<caster_oracle B, class T, lang L, class Reg = welded_registration>
consteval bool bindable ()
 Is T bindable to language L under backend B?
template<caster_oracle B, class T, lang L, class Reg = welded_registration>
consteval void assert_bindable ()
 Hard error the instant welder would bind an unbindable type.
template<caster_oracle B, std::meta::info Fn, lang L, class Reg = welded_registration>
consteval void assert_signature_bindable ()
 Assert every parameter type and the (non-void) return type of Fn binds.
template<caster_oracle B, std::meta::info Member, lang L, class Reg = welded_registration>
consteval void assert_member_bindable ()
 Assert the type of a data member / namespace variable binds, unless trusted.
template<caster_oracle B, std::meta::info Fn, lang L, class Reg = welded_registration>
consteval void assert_callable_bindable ()
 Assert a function/method/operator/constructor signature binds, unless trusted.
template<caster_oracle B, std::meta::info Fn, lang L, class Reg = welded_registration>
consteval void assert_setter_bindable ()
 Assert a property setter's parameter binds, unless trusted — the write half of the getter/setter machinery.
template<caster_oracle B, std::meta::info Fn, std::meta::info Type, lang L, class Reg = welded_registration>
consteval void assert_operands_bindable ()
 Assert the operand types of an operator<=> overload bind, unless the overload is trusted — the comparison-synthesis gate.
consteval bool is_nested_type (std::meta::info type)
 Is type declared at class scope — a nested (member) type?
consteval bool is_reference_container (std::meta::info type)
 Is type one of the containers welder can bind by reference (opaquely)?
consteval container_kind container_kind_of (std::meta::info type)
 The opaque-binder kind of type.
consteval bool container_is_contiguous (std::meta::info type)
 Is type a contiguous sequence — one whose elements live in a single block reachable via .data(), so a scalar element type can be exposed zero-copy through the buffer protocol / an nb::ndarray view?
consteval std::string cleandoc (std::string_view text)
 Normalize a docstring the way Python's inspect.cleandoc (PEP 257) does, so a multiline doc/returns can be indented to line up with the surrounding C++ source without that indentation reaching the target language's docstring.
template<std::meta::info Ent, std::meta::info SpecTmpl>
consteval const char * annotation_text_of ()
 The text of the annotation on Ent whose class template is SpecTmpl, or nullptr if it carries none.
template<std::meta::info Ent>
consteval const char * doc_of ()
 The doc text on Ent (a class, namespace, function, or parameter), or nullptr.
template<std::meta::info Fn>
consteval const char * return_doc_of ()
 The returns text on function Fn (documentation of its return value), or nullptr.
template<std::meta::info Ent>
consteval size_type tparam_count ()
 How many tparam annotations Ent carries.
template<std::meta::info Ent>
consteval auto tparam_docs ()
 The template-parameter docs declared on Ent via [[=welder::tparam("T","…")]], in annotation order.
template<std::meta::info Fn>
consteval auto param_docs ()
 The parameter docs of function Fn, in declaration order.
template<std::meta::info Fn, doc_style Style>
std::string function_docstring ()
 The complete docstring for function Fn under Style.
template<std::meta::info Ent, lang L>
consteval const char * weld_as_of ()
 The verbatim weld_as name forced on Ent for language L, or nullptr.
template<std::meta::info Ent, lang L, class Style, ent_kind K>
consteval const char * name_of ()
 The final bound name of Ent (a K-kind entity) for language L under name style Style.
template<std::meta::info Ent, lang L, class Style, ent_kind K>
constexpr const char * name_of_or (const char *override_)
 Resolve a bound name with a call-site override: override_ wins verbatim, nullptr falls back to name_of.
consteval bool weld_mask_admits (unsigned mask, lang L)
 Does a weld mask admit language L?
consteval bool welded_for (std::meta::info type, lang L)
 Is type welded for language L — i.e.
consteval bool names_template_specialization (std::meta::info mem)
 Is mem a namespace-scope alias naming a class-template specialization — the one way an instantiation can enter a namespace sweep?
consteval bool alias_welded_for (std::meta::info mem, lang L)
 Is the specialization named by alias mem welded for language L — reading the alias's own weld first, the instantiation's (via its template) second?
consteval bool alias_marks_admissible (std::meta::info mem)
 May the annotations on alias-declaration mem appear there?
consteval bool member_alias_marks_admissible (std::meta::info mem)
 May the annotations on member type-alias mem appear there?
consteval policy_kind policy_of (std::meta::info type)
 The reflection policy declared on type, defaulting to automatic.
consteval bool protected_welded (std::meta::info type, lang L)
 Does type admit its protected members for language L — i.e.
consteval bool excluded_for (std::meta::info member, lang L)
 Does member carry an exclude mark covering language L?
consteval bool included_for (std::meta::info member, lang L)
 Does member carry an include mark covering language L?
consteval bool trusted_for (std::meta::info member, lang L)
 Does member carry a trust_bindable mark covering language L?
consteval bool member_no_reassign (std::meta::info member, lang L)
 Is data member member bound read-only for L by a no_reassign mark?
consteval bool has_no_reassign_mark (std::meta::info entity)
 Does entity carry any no_reassign mark at all (any language)?
consteval bool accessor_marked (std::meta::info member, accessor_role role, lang L)
 Does member carry a getter/setter mark of role covering L?
consteval bool is_accessor_for (std::meta::info member, lang L)
 Does member supply either property half for language L — i.e.
consteval bool has_accessor_mark (std::meta::info member)
 Does member carry any getter/setter mark at all (any role, any language)?
consteval std::string accessor_explicit_name (std::meta::info member, accessor_role role, lang L)
 The explicit property name an accessor mark of role forces for L, or "" when the name derives from the function's identifier.
consteval rv_kind return_policy_of (std::meta::info fn, lang L)
 The return-value policy declared on callable fn for language L.
template<std::meta::info Fn, lang L>
consteval void validate_return_policy ()
 Reject a return_policy on Fn (for language L) that contradicts Fn's return type.
consteval bool member_bound (std::meta::info member, lang L, policy_kind pol)
 The core decision a backend asks for each member: does member bind for language L under policy pol?
consteval std::vector< std::meta::info > public_bases (std::meta::info type)
 The types of the public base classes of type.
consteval bool bound_flat (std::meta::info entity)
 Does entity (a type or a member function) carry a bind_flat mark?
consteval bool is_overridable_virtual (std::meta::info member)
 Is member an overridable virtual — a virtual member function that welder routes through the trampoline?
consteval std::vector< std::meta::info > overridable_virtuals (std::meta::info type)
 Every overridable virtual slot of type — the ones welder routes through a trampoline — folding in virtuals inherited from any base.
consteval std::meta::info virtual_slot (std::meta::info type, std::string_view name, std::meta::info fn_type)
 The overridable virtual slot of type named name whose function type is fn_type — the hand-written disambiguator for an overloaded virtual.
consteval std::size_t virtual_slot_count (std::meta::info type)
 The number of overridable virtual member functions of type, inherited ones included.
consteval bool has_virtual_methods (std::meta::info type)
 Does type declare or inherit any overridable virtual method?

Variables

constexpr detail::weld_spec weld {}
 The weld annotation: declare an entity bound, and for which languages.
template<class T>
constexpr bool trust_bindable = false
 The type-level trust customization point: specialize to true to trust T wherever it appears (member, parameter, return, container element, …).
constexpr detail::accessor_spec getter {accessor_role::getter}
 Mark a member function as a property getter (const, no parameters).
constexpr detail::accessor_spec setter {accessor_role::setter}
 Mark a member function as a property setter (exactly one parameter) — the write half of welder::getter, paired by property name.
template<unsigned char Slot>
constexpr lang user_lang {static_cast<lang>(16 + Slot)}
 A user-defined language: the Slot-th identity from the mask's user range (bit 16 + Slot) — for binding a language welder does not ship, without touching welder.
constexpr bind_flat_spec bind_flat {}
 Mark a virtual entity as deliberately bound non-overridably.

Typedef Documentation

◆ carriage

The default carriage — an alias for welder::stitch_welding_carriage.

Definition at line 1730 of file carriage.hpp.

◆ size_type

using welder::size_type = decltype(sizeof(0))

std::size_t named without a standard-library include, keeping this vocabulary header std-free (see the file note).

sizeof yields std::size_t by definition, so decltype(sizeof(0)) is that type — this alias just gives it a readable name for the array-length template parameters below.

Definition at line 24 of file annotations.hpp.

◆ stitch_welding_carriage

The stitch-welding carriage (the default): binds only where welder's weld / policy / marks direct — intermittent, marker-driven, like a stitch weld.

This is welder::welder's default Carriage.

See also
welder::carriages::basic_carriage

Definition at line 1716 of file carriage.hpp.

◆ tack_welding_carriage

Initial value:
A carriage: welder's reflection-driven traversal, parameterized on a Resolution (which markers it obe...
Definition carriage.hpp:468

The tack-welding carriage: binds an unmarked library greedily — every reflectable type / function / global, namespaces recursed, bases flattened — ignoring the weld markers, while still enforcing the bindability gate.

For consuming a third-party library that carries no welder annotations. Public members only, like the stitch default; to tack a library's protected members too (it cannot carry the policy::weld_protected annotation), use carriages::basic_carriage<carriages::greedy_resolution<true>>.

See also
welder::carriages::greedy_resolution for the exact rules and caveats.

Definition at line 1726 of file carriage.hpp.

Enumeration Type Documentation

◆ accessor_role

enum class welder::accessor_role : unsigned char
strong

Which half of a property a marked accessor function supplies.

See also
welder::getter / welder::setter for the annotations; the stored form is welder::detail::accessor_spec.
Enumerator
getter 

The function reads the property's value (const, no parameters).

setter 

The function writes it (exactly one parameter).

Definition at line 70 of file annotations.hpp.

◆ container_kind

enum class welder::container_kind : unsigned char
strong

Which opaque binder a reference-bound container uses.

Enumerator
sequence 

A bind_vector container: std::vector.

map 

A bind_map container: std::map, std::unordered_map.

fixed_sequence 

A fixed-size sequence: std::array<T, N>.

Bound by reference through a hand-written wrapper (neither framework ships a bind_array) — the vector protocol minus the size-changing ops (append/resize).

See also
rod::bind_container

Definition at line 43 of file containers.hpp.

◆ ent_kind

enum class welder::ent_kind
strong

The nameable entity kinds welder distinguishes, one per name-style hook — picked by the driver/rod so name_of calls the right transform.

Enumerator
class_ 

a class/struct type → transform_class.

enum_ 

an enum type → transform_enum.

enumerator 

an enumerator → transform_enumerator.

method 

a member function → transform_method.

static_method 

a static member function → transform_static_method.

function 

a free function → transform_function.

field 

a data member → transform_field.

variable 

a namespace variable → transform_variable.

submodule 

a namespace bound as a submodule → transform_submodule.

Definition at line 320 of file naming.hpp.

◆ lang

enum class welder::lang : unsigned char
strong

The target languages welder ships rods for — but not the whole value space.

A language is a bit index into the unsigned mask the annotation vocabulary stores (lang_bit / lang_mask in <welder/annotations.hpp>), and the value space is deliberately open: these enumerators are the languages welder ships, yet any in-range welder::lang value is a valid language. Indices 0–15 are reserved for welder; an out-of-tree rod binding a language welder doesn't ship mints its identity from the user range (16–31) with welder::user_lang — see the "Extending welder" guide page.

Enumerator
py 

Python (via the pybind11 and nanobind backends).

lua 

Lua (via the sol2 and LuaBridge3 backends).

Definition at line 42 of file lang.hpp.

◆ policy_kind

enum class welder::policy_kind : unsigned char
strong

How greedily a type's members are reflected for binding.

Enumerator
automatic 

Reflect every member unless explicitly excluded (default).

opt_in 

Reflect only members explicitly marked include.

Definition at line 61 of file annotations.hpp.

◆ rv_kind

enum class welder::rv_kind : unsigned char
strong

How a bound callable's returned object is owned/converted in the target language — welder's backend-neutral spelling of the return-value policy.

The names mirror pybind11's return_value_policy / nanobind's rv_policy (the frameworks that have an explicit knob): a rod translates each to its framework's enumerator. The garbage-collected Lua runtimes (sol2, LuaBridge3) have no such knob — ownership there is decided structurally by the C++ return type (a value → a VM-owned copy/move; a pointer/reference → a non-owning view) — so the Lua rods ignore this at runtime, exactly as they ignore welder::doc. What no rod ignores is a contradiction: a reference-category policy on a by-value return references a temporary, so it is a hard error for every language (see validate_return_policy).

See also
welder::return_policy for the annotation; the welder::rv constants for the user-facing spellings.
Enumerator
automatic 

The rod default — emit no explicit policy.

automatic_reference 

Like automatic but never take ownership (used for arguments).

take_ownership 

The target owns the returned pointer and frees it.

copy 

Copy the returned object into a target-owned value.

move 

Move the returned object into a target-owned value.

reference 

A non-owning reference; the caller keeps the C++ object alive.

reference_internal 

A non-owning reference tied to the parent's lifetime (implies keep_alive).

none 

Do not convert (nanobind rv_policy::none); pybind11 has no equivalent.

Definition at line 90 of file annotations.hpp.

Function Documentation

◆ accessor_explicit_name()

std::string welder::accessor_explicit_name ( std::meta::info member,
accessor_role role,
lang L )
consteval

The explicit property name an accessor mark of role forces for L, or "" when the name derives from the function's identifier.

The first covering mark with a non-empty name wins (repeat the annotation for a different name per language, like weld_as).

Parameters
membera reflection of the accessor function.
rolewhich property half to read.
Lthe target language.
Returns
the explicit name (verbatim), or an empty string.

Definition at line 314 of file reflect.hpp.

References lang_bit().

Referenced by welder::detail::property_bound_name(), and welder::detail::property_key().

◆ accessor_marked()

bool welder::accessor_marked ( std::meta::info member,
accessor_role role,
lang L )
consteval

Does member carry a getter/setter mark of role covering L?

The stored detail::accessor_spec is deliberately non-templated (see accessor_name_capacity), so this reads off a dynamic reflection — usable inside member_bound and the overload-set selectors, where the member is a plain value.

Parameters
membera reflection of the member function to test.
rolewhich property half to look for.
Lthe target language.
Returns
true iff a mark of role applies to L (mask 0 covers all languages).

Definition at line 276 of file reflect.hpp.

References lang_bit().

Referenced by is_accessor_for(), and welder::detail::property_entries().

◆ alias_marks_admissible()

bool welder::alias_marks_admissible ( std::meta::info mem)
consteval

May the annotations on alias-declaration mem appear there?

Only weld and weld_as are meaningful on a namespace-scope alias (they override the template's); every other welder mark — policy, exclude / include / only, trust_bindable, doc / returns / tparam, return_policy, keep_alive — belongs on the class template itself, where it applies to all instantiations, and is diagnosed here so it cannot be silently ignored. Non-welder annotations are not welder's business and pass.

Parameters
mema reflection of the alias to check.
Returns
true iff mem carries no welder annotation besides weld/weld_as.

Definition at line 92 of file reflect.hpp.

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

◆ alias_welded_for()

bool welder::alias_welded_for ( std::meta::info mem,
lang L )
consteval

Is the specialization named by alias mem welded for language L — reading the alias's own weld first, the instantiation's (via its template) second?

A weld on the alias-declaration takes precedence over the template's: it is the more specific declaration, and the opt-in for a third-party template you cannot annotate (using VBuf [[=welder::weld(welder::lang::py)]] = vendor::Buf<int>;). With no alias-level weld, the mark on the class template is read through the instantiation as usual.

Parameters
mema reflection of the alias (see names_template_specialization).
Lthe target language.
Returns
true iff the aliased specialization is welded for L.

Definition at line 74 of file reflect.hpp.

References weld_mask_admits(), and welded_for().

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

◆ annotation_text_of()

template<std::meta::info Ent, std::meta::info SpecTmpl>
const char * welder::annotation_text_of ( )
consteval

The text of the annotation on Ent whose class template is SpecTmpl, or nullptr if it carries none.

Ent / SpecTmpl are template parameters rather than runtime arguments because matching requires splicing the annotation's concrete SpecTmpl<N> type, which must be a constant.

Template Parameters
Enta reflection of the entity to read.
SpecTmpla class template whose specialization has a .text member convertible to a C string (detail::doc_spec, detail::return_doc_spec).
Returns
the annotation text, dedented and with static storage (define_static_string, so usable at runtime), or nullptr.

Definition at line 118 of file doc.hpp.

References cleandoc().

Referenced by doc_of(), and return_doc_of().

◆ assert_bindable()

template<caster_oracle B, class T, lang L, class Reg = welded_registration>
void welder::assert_bindable ( )
consteval

Hard error the instant welder would bind an unbindable type.

The offending type is the template argument of the failing instantiation, so it is named in the diagnostic backtrace.

Template Parameters
Bthe rod.
Tthe type being bound.
Lthe target language.
Regthe registration oracle (see welder::bindable).

Definition at line 344 of file bindable.hpp.

References bindable(), and welder::detail::mentions_union().

Referenced by assert_member_bindable(), welder::detail::assert_operands(), welder::detail::assert_params_bindable(), assert_signature_bindable(), and welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace().

◆ assert_callable_bindable()

template<caster_oracle B, std::meta::info Fn, lang L, class Reg = welded_registration>
void welder::assert_callable_bindable ( )
consteval

◆ assert_member_bindable()

template<caster_oracle B, std::meta::info Member, lang L, class Reg = welded_registration>
void welder::assert_member_bindable ( )
consteval

Assert the type of a data member / namespace variable binds, unless trusted.

Template Parameters
Bthe rod.
Membera reflection of the data member or variable.
Lthe target language.

Definition at line 422 of file bindable.hpp.

References assert_bindable(), and trusted_for().

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_members(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace(), and welder::carriages::basic_carriage< carriages::marker_resolution >::bind_variable().

◆ assert_operands_bindable()

template<caster_oracle B, std::meta::info Fn, std::meta::info Type, lang L, class Reg = welded_registration>
void welder::assert_operands_bindable ( )
consteval

Assert the operand types of an operator<=> overload bind, unless the overload is trusted — the comparison-synthesis gate.

Parameters only, and only those that are not the welded type itself: the ordering return type (std::strong_ordering &co.) deliberately never faces the gate, because it never crosses the language boundary — the rod binds synthesized bool-returning comparisons, not the spaceship itself.

Template Parameters
Bthe rod.
Fna reflection of the spaceship overload.
Typethe welded anchor type's reflection.
Lthe target language.

Definition at line 497 of file bindable.hpp.

References welder::detail::assert_operands(), and trusted_for().

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

◆ assert_setter_bindable()

template<caster_oracle B, std::meta::info Fn, lang L, class Reg = welded_registration>
void welder::assert_setter_bindable ( )
consteval

Assert a property setter's parameter binds, unless trusted — the write half of the getter/setter machinery.

Parameters only, sharing the rationale of assert_operands_bindable — the property protocol has no slot for a setter's return value, so every rod discards* it (a fluent T& set_x(…) chains in C++ but writes plainly from the target language) — a return type that never crosses the boundary never faces the gate.

Template Parameters
Bthe rod.
Fna reflection of the setter.
Lthe target language.

Definition at line 453 of file bindable.hpp.

References welder::detail::assert_params_bindable(), and trusted_for().

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

◆ assert_signature_bindable()

template<caster_oracle B, std::meta::info Fn, lang L, class Reg = welded_registration>
void welder::assert_signature_bindable ( )
consteval

Assert every parameter type and the (non-void) return type of Fn binds.

So the function/method/operator/constructor can round-trip through the target language. A constructor has no return type.

Template Parameters
Bthe rod.
Fna reflection of the callable.
Lthe target language.

Definition at line 393 of file bindable.hpp.

References assert_bindable(), and welder::detail::assert_params_bindable().

Referenced by assert_callable_bindable().

◆ bindable()

template<caster_oracle B, class T, lang L, class Reg = welded_registration>
bool welder::bindable ( )
consteval

Is T bindable to language L under backend B?

(public spelling.)

Template Parameters
Bthe rod.
Tthe type to test.
Lthe target language.
Regthe registration oracle: which class/enum types count as registered. Defaults to welder::welded_registration (welded ⇒ registered); the carriage passes its resolution so, e.g., tack welding accepts the types its own greedy pass registers.

Definition at line 330 of file bindable.hpp.

References welder::detail::bindable().

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

◆ bound_flat()

bool welder::bound_flat ( std::meta::info entity)
consteval

Does entity (a type or a member function) carry a bind_flat mark?

Parameters
entitya reflection of the type or member to test.
Returns
true iff entity opts out of trampoline / override routing.

Definition at line 63 of file virtuals.hpp.

Referenced by welder::rods::nanobind::rod< DocStyle >::_make_class_at(), welder::rods::pybind11::rod< DocStyle >::_make_class_at(), is_overridable_virtual(), welder::rods::trampolines::rod::make_class(), and overridable_virtuals().

◆ cleandoc()

std::string welder::cleandoc ( std::string_view text)
consteval

Normalize a docstring the way Python's inspect.cleandoc (PEP 257) does, so a multiline doc/returns can be indented to line up with the surrounding C++ source without that indentation reaching the target language's docstring.

Three steps, matching the Python convention users of the bindings expect:

  • strip leading whitespace from the first line (it typically abuts the opening R"( or the annotation call);
  • remove the whitespace common to every subsequent non-blank line (relative indentation — an indented example block — is preserved);
  • drop leading and trailing blank lines.

A single-line docstring is returned unchanged. Tabs are treated as single characters (not expanded to tab stops): indent doc text with spaces, as C++ source is indented generally.

Parameters
textthe raw docstring text.
Returns
the cleaned text (may be empty if the input was all whitespace).

Definition at line 45 of file doc.hpp.

Referenced by annotation_text_of().

◆ container_is_contiguous()

bool welder::container_is_contiguous ( std::meta::info type)
consteval

Is type a contiguous sequence — one whose elements live in a single block reachable via .data(), so a scalar element type can be exposed zero-copy through the buffer protocol / an nb::ndarray view?

Among the reference containers std::vector and std::array qualify (both store their elements in one block reachable via .data()); the maps are not sequences. The buffer/ndarray path is gated on this and an arithmetic (non-bool) or POD element type. (Kept as its own predicate — rather than folding into container_kind — so a future segmented/opaque sequence stays bindable by reference while correctly getting no buffer view.)

Parameters
typea reflection of the container specialization.

Definition at line 122 of file containers.hpp.

Referenced by welder::rods::nanobind::rod< DocStyle >::_numpy_view(), and welder::rods::pybind11::rod< DocStyle >::bind_container().

◆ container_kind_of()

container_kind welder::container_kind_of ( std::meta::info type)
consteval

The opaque-binder kind of type.

Parameters
typea reflection of the container specialization.
Precondition
is_reference_container(type) is true.
Returns
container_kind::sequence for bind_vector containers, map for bind_map containers.

Definition at line 103 of file containers.hpp.

References welder::detail::reference_containers(), and sequence.

Referenced by welder::rods::nanobind::rod< DocStyle >::bind_container(), and welder::rods::pybind11::rod< DocStyle >::bind_container().

◆ doc()

template<size_type N>
detail::doc_spec< N > welder::doc ( const char(&) s[N])
consteval

Attach a docstring to a namespace, class, function, or function parameter.

Backends surface it in the target language (e.g. a Python __doc__, with parameter docs folded into the function's docstring). Reading the text back is the reflection layer's job (<welder/doc.hpp>).

Usage: [[=welder::doc("Summary line.")]].

Template Parameters
Nthe text length (deduced).
Parameters
sthe docstring text.
Returns
a doc_spec holding the text.

Definition at line 641 of file annotations.hpp.

Referenced by welder::rods::nanobind::rod< DocStyle >::_def_erased_field(), welder::rods::nanobind::rod< DocStyle >::_def_function(), welder::rods::pybind11::rod< DocStyle >::_def_function(), welder::rods::nanobind::rod< DocStyle >::_def_operator(), welder::rods::pybind11::rod< DocStyle >::_def_operator(), welder::rods::nanobind::rod< DocStyle >::_make_class(), welder::rods::pybind11::rod< DocStyle >::_make_class(), welder::rods::nanobind::rod< DocStyle >::_make_class_at(), welder::rods::pybind11::rod< DocStyle >::_make_class_at(), welder::rods::nanobind::rod< DocStyle >::add_field(), welder::rods::pybind11::rod< DocStyle >::add_field(), welder::rods::nanobind::rod< DocStyle >::add_property(), welder::rods::pybind11::rod< DocStyle >::add_property(), welder::rods::luacats::document::declare_table(), welder::rods::luacats::rod::generate(), welder::rods::opaque_containers::rod::generate(), welder::rods::trampolines::rod::generate(), welder::rods::luacats::rod::make_class(), welder::rods::nanobind::rod< DocStyle >::make_class(), welder::rods::pybind11::rod< DocStyle >::make_class(), welder::carriages::basic_carriage< carriages::marker_resolution >::make_class_of(), welder::rods::luacats::rod::make_enum(), welder::rods::nanobind::rod< DocStyle >::make_enum(), welder::rods::pybind11::rod< DocStyle >::make_enum(), welder::rods::luacats::rod::make_nested_class(), welder::rods::nanobind::rod< DocStyle >::make_nested_class(), welder::rods::pybind11::rod< DocStyle >::make_nested_class(), welder::rods::sol2::rod::make_nested_class(), welder::carriages::basic_carriage< carriages::marker_resolution >::make_nested_class_of(), welder::rods::luacats::rod::make_nested_enum(), welder::rods::nanobind::rod< DocStyle >::make_nested_enum(), welder::rods::pybind11::rod< DocStyle >::make_nested_enum(), welder::rods::luacats::render_overload_group(), welder::rods::luacats::rod::set_module_doc(), welder::rods::nanobind::rod< DocStyle >::set_module_doc(), and welder::rods::pybind11::rod< DocStyle >::set_module_doc().

◆ doc_of()

◆ excluded_for()

bool welder::excluded_for ( std::meta::info member,
lang L )
consteval

Does member carry an exclude mark covering language L?

Parameters
membera reflection of the member to test.
Lthe target language.
Returns
true iff an exclude mark applies to L (a mark with mask 0 covers all languages).

Definition at line 188 of file reflect.hpp.

References lang_bit().

Referenced by member_bound().

◆ function_docstring()

template<std::meta::info Fn, doc_style Style>
std::string welder::function_docstring ( )

The complete docstring for function Fn under Style.

Its own doc summary with its parameter docs and returns folded in. Empty when the function carries no documentation at all, so a backend can skip emitting it.

Template Parameters
Fna reflection of the function.
Stylethe docstring style (a doc_style); the caller picks one that fits its target language.
Returns
the assembled docstring, or empty if undocumented.

Definition at line 300 of file doc.hpp.

References doc_of(), param_docs(), and return_doc_of().

Referenced by welder::rods::nanobind::rod< DocStyle >::_def_function(), welder::rods::pybind11::rod< DocStyle >::_def_function(), welder::rods::nanobind::rod< DocStyle >::_def_operator(), and welder::rods::pybind11::rod< DocStyle >::_def_operator().

◆ has_accessor_mark()

bool welder::has_accessor_mark ( std::meta::info member)
consteval

Does member carry any getter/setter mark at all (any role, any language)?

The namespace walk uses this to diagnose accessor marks on free functions, where no property surface exists.

Parameters
membera reflection of the entity to test.
Returns
true iff an accessor mark is present.

Definition at line 300 of file reflect.hpp.

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

◆ has_no_reassign_mark()

bool welder::has_no_reassign_mark ( std::meta::info entity)
consteval

Does entity carry any no_reassign mark at all (any language)?

no_reassign shapes how a nonstatic data member binds (read-only), so it is meaningless on anything else. The carriage uses this to diagnose the mark on a function, a type, a static member, or a namespace-scope variable — a hard error rather than a silent no-op, mirroring has_accessor_mark.

Parameters
entitya reflection of the entity to test.
Returns
true iff a no_reassign mark is present.

Definition at line 260 of file reflect.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_enum(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_function(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_members(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_type(), and welder::carriages::basic_carriage< carriages::marker_resolution >::bind_variable().

◆ has_virtual_methods()

bool welder::has_virtual_methods ( std::meta::info type)
consteval

Does type declare or inherit any overridable virtual method?

Parameters
typea reflection of the class type.
Returns
true iff type has at least one overridable virtual slot.

Definition at line 239 of file virtuals.hpp.

References overridable_virtuals().

Referenced by welder::rods::nanobind::rod< DocStyle >::_make_class_at(), welder::rods::pybind11::rod< DocStyle >::_make_class_at(), and welder::rods::python::construction_type_of().

◆ included_for()

bool welder::included_for ( std::meta::info member,
lang L )
consteval

Does member carry an include mark covering language L?

Parameters
membera reflection of the member to test.
Lthe target language.
Returns
true iff an include mark applies to L (a mark with mask 0 covers all languages).

Definition at line 204 of file reflect.hpp.

References lang_bit().

Referenced by member_bound().

◆ is_accessor_for()

bool welder::is_accessor_for ( std::meta::info member,
lang L )
consteval

Does member supply either property half for language L — i.e.

is it an accessor the property machinery claims (and the method sweep must skip)?

Parameters
membera reflection of the member function to test.
Lthe target language.
Returns
true iff a getter or setter mark covers L.

Definition at line 290 of file reflect.hpp.

References accessor_marked(), getter, and setter.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_members(), welder::detail::collect_accessors(), member_bound(), welder::detail::method_overload_set(), and welder::detail::validate_property_shadowing().

◆ is_nested_type()

bool welder::is_nested_type ( std::meta::info type)
consteval

Is type declared at class scope — a nested (member) type?

Parameters
typea reflection of a class/enum type.
Returns
true iff the immediately enclosing scope is a class.

Definition at line 106 of file carriage.hpp.

Referenced by welder::carriages::greedy_resolution< WeldProtected >::counts_as_registered(), welder::carriages::marker_resolution::counts_as_registered(), and welder::detail::scoped_registration< Resolution, Scope >::counts_as_registered().

◆ is_overridable_virtual()

bool welder::is_overridable_virtual ( std::meta::info member)
consteval

Is member an overridable virtual — a virtual member function that welder routes through the trampoline?

Excludes the (virtual) destructor, which is not an overridable slot, and any method marked bind_flat, which is bound as a plain non-overridable method. A per-declaration predicate; the whole-type slot set is overridable_virtuals, which additionally folds inherited virtuals in.

Parameters
membera reflection of a class member.
Returns
true iff member is a virtual method exposed for Python override.

Definition at line 78 of file virtuals.hpp.

References bound_flat().

◆ is_reference_container()

bool welder::is_reference_container ( std::meta::info type)
consteval

Is type one of the containers welder can bind by reference (opaquely)?

Parameters
typea reflection of the (possibly aliased — dealias first) type.
Returns
true iff type is a specialization of a listed container template.

Definition at line 88 of file containers.hpp.

References welder::detail::reference_containers().

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace(), welder::rods::opaque_containers::collect_into(), welder::rods::opaque_containers::container_depth(), welder::rods::opaque_containers::derive_name(), and welder::rods::opaque_containers::element_ok().

◆ keep_alive()

detail::keep_alive_spec welder::keep_alive ( unsigned nurse,
unsigned patient )
consteval

Keep the call entity patient alive at least until nurse is collected.

Maps to pybind11 keep_alive<Nurse, Patient> / nanobind keep_alive<Nurse, Patient>; indices are 0 = return value, 1 = first argument (a method's implicit this), 2 = second, … Repeatable — attach several to declare several dependencies. Ignored by backends without the concept (the Lua rods).

Usage: [[=welder::keep_alive(1, 2)]] — keep argument 2 alive as long as the receiver (this) lives.

Parameters
nursethe keeper whose collection bounds the dependency.
patientthe dependant kept alive until nurse is collected.
Returns
a keep_alive_spec carrying the two indices.

Definition at line 822 of file annotations.hpp.

◆ lang_bit()

unsigned welder::lang_bit ( lang l)
consteval

The single-language bit for l within a language mask.

Languages are tracked as bits in a mask so a spec can name an arbitrary subset. A value past the mask width is diagnosed at compile time (mint user languages with welder::user_lang, which cannot go out of range).

Parameters
lthe language.
Returns
1u << index-of(l).
Exceptions
diag::lang_out_of_mask_range(a constant-evaluation error) for a value past the mask width — instead of an opaque shift overflow.

Definition at line 41 of file annotations.hpp.

Referenced by accessor_explicit_name(), accessor_marked(), welder::detail::accessor_mask(), excluded_for(), included_for(), lang_mask(), member_bound(), member_no_reassign(), protected_welded(), welder::detail::return_policy_mask(), return_policy_of(), trusted_for(), welder::detail::weld_as_mask(), weld_as_of(), and weld_mask_admits().

◆ lang_mask()

template<class... Ls>
unsigned welder::lang_mask ( Ls... ls)
consteval

The mask naming the languages ls.

Template Parameters
Lsthe language enum types (deduced).
Parameters
lsthe languages to combine.
Returns
the OR of each language's bit; 0 for an empty pack — which, on an exclude/include/trust spec, is the sentinel meaning "all welded languages".

Definition at line 56 of file annotations.hpp.

References lang_bit().

Referenced by welder::detail::exclude_spec::operator()(), welder::detail::include_spec::operator()(), welder::detail::no_reassign_spec::operator()(), welder::detail::only_spec::operator()(), welder::detail::trust_bindable_spec::operator()(), welder::detail::weld_protected_spec::operator()(), and welder::detail::weld_spec::operator()().

◆ member_alias_marks_admissible()

bool welder::member_alias_marks_admissible ( std::meta::info mem)
consteval

May the annotations on member type-alias mem appear there?

A member alias participates by the member rules (the outer's policy plus the alias's own marks) with the bindability gate as the register-or-skip arbiter — so weld_as and the participation marks (exclude / include / only) are meaningful on it. Everything else is not: weld (participation never reads it — nested registration follows the outer), policy / weld_protected (they belong on the target type), trust_bindable / return_policy / keep_alive / doc / returns / tparam (no surface they could apply to). Those are diagnosed rather than silently ignored. Non-welder annotations are not welder's business and pass.

Parameters
mema reflection of the member alias to check.
Returns
true iff mem carries only admissible welder annotations.

Definition at line 124 of file reflect.hpp.

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

◆ member_bound()

bool welder::member_bound ( std::meta::info member,
lang L,
policy_kind pol )
consteval

The core decision a backend asks for each member: does member bind for language L under policy pol?

Parameters
membera reflection of the member to resolve.
Lthe target language.
polthe enclosing type's reflection policy.
Returns
excluded ⇒ false; else an only mark ⇒ true iff it names L (under either policy — only is also the opt-in); else automatictrue; else (opt_in) ⇒ true iff explicitly included — where a getter/setter mark covering L also counts as the opt-in (marking an accessor is an unambiguous statement of intent, like only).
Exceptions
diag::bare_mark_only(a constant-evaluation error) on an uncalled [[=welder::mark::only]] — it must name the languages.

Definition at line 387 of file reflect.hpp.

References automatic, excluded_for(), included_for(), is_accessor_for(), and lang_bit().

Referenced by welder::carriages::greedy_resolution< WeldProtected >::alias_participates(), welder::carriages::marker_resolution::alias_participates(), welder::carriages::greedy_resolution< WeldProtected >::class_member_participates(), welder::carriages::marker_resolution::class_member_participates(), welder::carriages::greedy_resolution< WeldProtected >::counts_as_registered(), welder::detail::entity_bound(), welder::carriages::greedy_resolution< WeldProtected >::member_participates(), welder::carriages::marker_resolution::member_participates(), welder::detail::namespace_has_bindable(), welder::detail::namespace_has_bound(), welder::carriages::greedy_resolution< WeldProtected >::namespace_participates(), welder::carriages::marker_resolution::namespace_participates(), and welder::detail::nested_type_registered().

◆ member_no_reassign()

bool welder::member_no_reassign ( std::meta::info member,
lang L )
consteval

Is data member member bound read-only for L by a no_reassign mark?

no_reassign forces the read-only binding on a mutable member (see detail::no_reassign_spec) — the const-member binding, without the const. A rod's add_field ORs this with the member's const-ness to choose the read-only path, so an in-place mutation still writes through but a rebind is rejected.

Parameters
membera reflection of the data member to test.
Lthe target language.
Returns
true iff a no_reassign mark covers L (mask 0 covers all languages).

Definition at line 243 of file reflect.hpp.

References lang_bit().

Referenced by welder::rods::luabridge::rod::add_field(), welder::rods::luacats::rod::add_field(), welder::rods::nanobind::rod< DocStyle >::add_field(), welder::rods::pybind11::rod< DocStyle >::add_field(), and welder::rods::sol2::rod::add_field().

◆ name_of()

template<std::meta::info Ent, lang L, class Style, ent_kind K>
const char * welder::name_of ( )
consteval

The final bound name of Ent (a K-kind entity) for language L under name style Style.

A [[=welder::weld_as]] override wins and is used verbatim (it never flows through Style); otherwise Ent's identifier is reshaped by Style's hook for kind K. The result has static storage, so both the driver and the rods feed it straight to their frameworks. This is the single place a bound name is decided — the driver uses it for class/enum/submodule names, each rod for its members.

Template Parameters
Enta reflection of the entity to name.
Lthe target language.
Stylethe name style (a welder::naming::name_style).
Kwhich of Style's per-kind hooks to apply.
Returns
the bound name, in static storage.

Definition at line 375 of file naming.hpp.

References class_, enum_, enumerator, field, function, method, static_method, variable, and weld_as_of().

Referenced by welder::rods::nanobind::rod< DocStyle >::_aggregate_arg(), welder::rods::nanobind::rod< DocStyle >::_def_aggregate_init(), welder::rods::luabridge::rod::add_enumerator(), welder::rods::luacats::rod::add_enumerator(), welder::rods::nanobind::rod< DocStyle >::add_enumerator(), welder::rods::pybind11::rod< DocStyle >::add_enumerator(), welder::rods::sol2::rod::add_enumerator(), welder::rods::luabridge::rod::add_field(), welder::rods::luacats::rod::add_field(), welder::rods::nanobind::rod< DocStyle >::add_field(), welder::rods::pybind11::rod< DocStyle >::add_field(), welder::rods::sol2::rod::add_field(), welder::rods::luabridge::rod::add_method(), welder::rods::luacats::rod::add_method(), welder::rods::nanobind::rod< DocStyle >::add_method(), welder::rods::pybind11::rod< DocStyle >::add_method(), welder::rods::sol2::rod::add_method(), welder::rods::luabridge::rod::add_static_method(), welder::rods::luacats::rod::add_static_method(), welder::rods::nanobind::rod< DocStyle >::add_static_method(), welder::rods::pybind11::rod< DocStyle >::add_static_method(), welder::rods::sol2::rod::add_static_method(), welder::detail::alias_bound_name(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace(), and name_of_or().

◆ name_of_or()

template<std::meta::info Ent, lang L, class Style, ent_kind K>
const char * welder::name_of_or ( const char * override_)
constexpr

Resolve a bound name with a call-site override: override_ wins verbatim, nullptr falls back to name_of.

This is the form the driver and every rod use to honor the optional trailing name on weld_type / weld_function / weld_variable / weld_namespace_as_submodule. It exists because the fallback must be lazy: an entity with no identifier — a class/function template instantiation like Box<int> — can only be named by a weld_as or by the call-site override, and a bare override_ ? override_ : name_of<…>() would still constant-evaluate the consteval name_of (and hard-error on identifier_of) even when the override is present. Here the name_of fallback is compiled only when the entity is statically nameable; otherwise a missing override throws at binding time (it cannot be a compile-time diagnostic — whether the runtime pointer is null is unknowable there).

Template Parameters
Enta reflection of the entity to name.
Lthe target language.
Stylethe name style (a welder::naming::name_style).
Kwhich of Style's per-kind hooks to apply.
Parameters
override_the verbatim call-site name, or nullptr for the resolved one.
Returns
the bound name, in static storage (or override_, whose lifetime the caller owns).
Exceptions
std::invalid_argumentwhen the entity has neither an identifier nor a weld_as for L and override_ is nullptr.

Definition at line 424 of file naming.hpp.

References name_of(), and weld_as_of().

Referenced by welder::rods::luabridge::rod::add_function(), welder::rods::luacats::rod::add_function(), welder::rods::nanobind::rod< DocStyle >::add_function(), welder::rods::pybind11::rod< DocStyle >::add_function(), welder::rods::sol2::rod::add_function(), welder::rods::luabridge::rod::add_variable(), welder::rods::luacats::rod::add_variable(), welder::rods::nanobind::rod< DocStyle >::add_variable(), welder::rods::pybind11::rod< DocStyle >::add_variable(), welder::rods::sol2::rod::add_variable(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_enum(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace_as_submodule(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_nested_enum(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_nested_type(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_type(), welder::carriages::basic_carriage< carriages::marker_resolution >::fill_type(), and welder::carriages::basic_carriage< carriages::marker_resolution >::predeclare_type().

◆ names_template_specialization()

bool welder::names_template_specialization ( std::meta::info mem)
consteval

Is mem a namespace-scope alias naming a class-template specialization — the one way an instantiation can enter a namespace sweep?

members_of(ns) enumerates the class template, never its instantiations; a namespace-scope using IntRing = Ring<int>; is therefore welder's vehicle for welding one: the alias supplies both the target-language name (its identifier) and — for text-emitting rods — the C++ spelling of the otherwise unnameable specialization (has_identifier is false on Ring<int> itself).

Parameters
mema reflection of a namespace member.
Returns
true iff mem is a type alias whose target is a class-template specialization.

Definition at line 57 of file reflect.hpp.

Referenced by welder::carriages::basic_carriage< carriages::marker_resolution >::bind_namespace(), and welder::detail::sole_alias_of_target().

◆ overridable_virtuals()

std::vector< std::meta::info > welder::overridable_virtuals ( std::meta::info type)
consteval

Every overridable virtual slot of type — the ones welder routes through a trampoline — folding in virtuals inherited from any base.

Unlike a bare members_of scan this sees a virtual type only inherits (never re-declares), which a trampoline must still cover: a Python subclass of type can override it, and dispatch runs through type's own trampoline, not the base's. A slot is its vtable identity — name + parameter types + cv/ref qualifiers, so a covariant** override is the same slot, kept with its narrowed return type; when a class overrides an inherited virtual, only the most-derived declaration is kept, and its bind_flat mark (not the base's) decides whether the slot is exposed. Protected** virtuals (the NVI hook pattern) are slots like any other — a Python subclass overrides them by plain attribute lookup, no binding involved. Private declarations are excluded: the trampoline's base-class fallback could not name them; a subclass privatizing an inherited virtual thereby withdraws the slot.

Parameters
typea reflection of the class type.
Returns
the most-derived declaration of each exposed overridable virtual.

Definition at line 174 of file virtuals.hpp.

References bound_flat(), and welder::detail::collect_virtuals().

Referenced by has_virtual_methods(), welder::rods::trampolines::rod::make_class(), welder::rods::trampolines::render_trampoline(), welder::rods::python::trampoline_covers(), virtual_slot(), and virtual_slot_count().

◆ param_docs()

template<std::meta::info Fn>
auto welder::param_docs ( )
consteval

The parameter docs of function Fn, in declaration order.

Names and texts use static storage, so the array (and spans over it) stay valid at runtime.

Template Parameters
Fna reflection of the function.
Returns
an array of detail::param_doc, one per parameter, in declaration order.

Definition at line 227 of file doc.hpp.

References doc_of().

Referenced by welder::rods::luacats::arg_list(), welder::rods::luacats::emit_params(), welder::rods::luacats::fun_signature(), and function_docstring().

◆ policy_of()

◆ protected_welded()

bool welder::protected_welded ( std::meta::info type,
lang L )
consteval

Does type admit its protected members for language L — i.e.

does it carry a policy::weld_protected annotation covering L?

Read off the member's declaring class (so a flattened non-welded base admits its own protected members, consistent with how its marks and policy resolve), and — like every annotation — read through a class-template instantiation from the template's declaration. Repeated annotations union. This is only the default arbitration: a resolution with a protected_participates hook replaces it (see the carriage's member_access_admitted). Private members are never admitted, under any resolution.

Parameters
typea reflection of the declaring class.
Lthe target language.
Returns
true iff a weld_protected annotation applies to L (mask 0 covers all languages).

Definition at line 171 of file reflect.hpp.

References lang_bit().

Referenced by welder::carriages::greedy_resolution< WeldProtected >::protected_participates(), and welder::carriages::marker_resolution::protected_participates().

◆ public_bases()

std::vector< std::meta::info > welder::public_bases ( std::meta::info type)
consteval

The types of the public base classes of type.

Private/protected bases are an implementation detail and never participate in a binding. Backends decide how to treat a public base: typically, a base that is itself welded for the target language maps to native inheritance in that backend, while a non-welded base has its members flattened into the derived binding.

Parameters
typea reflection of the derived type.
Returns
the reflected types of type's public direct bases, in declaration order.

Definition at line 418 of file reflect.hpp.

Referenced by welder::rods::sol2::rod::_collect_welded_bases(), welder::detail::aggregate_initializable(), welder::carriages::basic_carriage< carriages::marker_resolution >::bind_members(), welder::detail::collect_accessors(), welder::detail::collect_member_operators(), welder::detail::collect_native_bases(), and welder::detail::validate_property_shadowing().

◆ return_doc_of()

template<std::meta::info Fn>
const char * welder::return_doc_of ( )
consteval

The returns text on function Fn (documentation of its return value), or nullptr.

A distinct spec type, so it does not collide with the summary doc.

Template Parameters
Fna reflection of the function.

Definition at line 148 of file doc.hpp.

References annotation_text_of().

Referenced by welder::rods::luacats::build_overload(), and function_docstring().

◆ return_policy()

template<class... Args>
detail::return_policy_spec welder::return_policy ( Args... args)
consteval

Force a return-value policy on a callable, optionally scoped to one or more languages.

The rv_kind is the last argument; zero or more lang markers precede it. With no marker the policy covers every welded language; with one or several it is scoped to those — repeat the annotation for a different policy per language. Backends without an explicit policy knob (the Lua rods) ignore it, but a reference-category policy on a by-value return is a hard error for every language (it would reference a temporary).

constexpr rv_kind reference_internal
constexpr rv_kind take_ownership
@ py
Python (via the pybind11 and nanobind backends).
Definition lang.hpp:43
consteval detail::return_policy_spec return_policy(Args... args)
Force a return-value policy on a callable, optionally scoped to one or more languages.
Template Parameters
Argsthe leading lang markers then the trailing rv_kind (deduced).
Parameters
argsthe language markers (if any) followed by the policy.
Returns
a return_policy_spec carrying the mask of the named languages and the kind.

Definition at line 802 of file annotations.hpp.

References welder::detail::return_policy_kind(), and welder::detail::return_policy_mask().

◆ return_policy_of()

rv_kind welder::return_policy_of ( std::meta::info fn,
lang L )
consteval

The return-value policy declared on callable fn for language L.

Reads fn's return_policy annotations, honoring the first one whose mask covers L (a mask of 0 covers all languages). Absent any, the policy is rv_kind::automatic — the rod's default, so an unannotated callable binds exactly as before. A rod with an explicit policy knob (the Python backends) translates the result; the Lua rods ignore it (ownership is structural).

Parameters
fna reflection of the function/method/operator.
Lthe target language.
Returns
the resolved policy, or rv_kind::automatic if none applies to L.

Definition at line 337 of file reflect.hpp.

References automatic, and lang_bit().

Referenced by welder::rods::nanobind::rod< DocStyle >::_def_function(), welder::rods::pybind11::rod< DocStyle >::_def_function(), welder::rods::nanobind::rod< DocStyle >::_def_operator(), welder::rods::pybind11::rod< DocStyle >::_def_operator(), welder::rods::nanobind::rod< DocStyle >::_def_truncated(), welder::rods::pybind11::rod< DocStyle >::_def_truncated(), welder::rods::nanobind::rod< DocStyle >::add_property(), welder::rods::pybind11::rod< DocStyle >::add_property(), and validate_return_policy().

◆ returns()

template<size_type N>
detail::return_doc_spec< N > welder::returns ( const char(&) s[N])
consteval

Document a function's return value.

Usage: [[=welder::returns("what the call yields")]] on a function.

Template Parameters
Nthe text length (deduced).
Parameters
sthe return-value documentation.
Returns
a return_doc_spec holding the text.

Definition at line 654 of file annotations.hpp.

◆ tparam()

template<size_type N, size_type M>
detail::tparam_spec< N, M > welder::tparam ( const char(&) name[N],
const char(&) text[M] )
consteval

Document a template parameter (repeatable, ordered).

Usage: [[=welder::tparam("T", "what T is")]] on a class/function template.

Template Parameters
Nthe parameter-name length (deduced).
Mthe text length (deduced).
Parameters
namethe template parameter's name, matching the declaration.
textits documentation.
Returns
a tparam_spec pairing the name with the text.

Definition at line 669 of file annotations.hpp.

◆ tparam_count()

template<std::meta::info Ent>
size_type welder::tparam_count ( )
consteval

How many tparam annotations Ent carries.

They are repeatable and keep declaration order, unlike the single-shot doc/returns specs.

Template Parameters
Enta reflection of the entity.
Returns
the count of tparam annotations.

Definition at line 169 of file doc.hpp.

◆ tparam_docs()

template<std::meta::info Ent>
auto welder::tparam_docs ( )
consteval

The template-parameter docs declared on Ent via [[=welder::tparam("T","…")]], in annotation order.

Note
P2996 refuses annotations_of on an uninstantiated template, so on gcc-16 these read off a concrete entity — in practice an instantiation, which inherits the governing declaration's annotations (see tests/core/template_annotations.cpp). The Doxygen filter reads the same annotations textually, so the C++ docs need no instantiation.
Template Parameters
Enta reflection of the entity.
Returns
an array of detail::tparam_doc, one per tparam annotation, in order.

Definition at line 193 of file doc.hpp.

◆ trusted_for()

bool welder::trusted_for ( std::meta::info member,
lang L )
consteval

Does member carry a trust_bindable mark covering language L?

The user's vouch that the member's type is registered/convertible outside welder's view, so the bindability gate should trust it. See <welder/annotations.hpp>.

Parameters
membera reflection of the member to test.
Lthe target language.
Returns
true iff a trust_bindable mark applies to L (mask 0 covers all languages).

Definition at line 224 of file reflect.hpp.

References lang_bit().

Referenced by assert_callable_bindable(), assert_member_bindable(), assert_operands_bindable(), and assert_setter_bindable().

◆ validate_return_policy()

template<std::meta::info Fn, lang L>
void welder::validate_return_policy ( )
consteval

Reject a return_policy on Fn (for language L) that contradicts Fn's return type.

A reference-category policy (reference / reference_internal) promises the target a view into a live C++ object; on a by-value (prvalue) return there is no such object — only a temporary — so the view would dangle. This is a contradiction in any language, so every rod (Python and Lua alike) runs the check at its per-overload bind site. Anything the framework could plausibly honor passes; only the dangling case is diagnosed.

Template Parameters
Fna reflection of the callable being bound.
Lthe target language.
Exceptions
diag::dangling_return_policy(a constant-evaluation error) on the contradiction.

Definition at line 361 of file reflect.hpp.

References reference, reference_internal, and return_policy_of().

Referenced by welder::rods::luabridge::rod::_add_function(), welder::rods::luabridge::rod::_add_operator_slot(), welder::rods::luabridge::rod::_add_static_function(), welder::rods::nanobind::rod< DocStyle >::_def_function(), welder::rods::pybind11::rod< DocStyle >::_def_function(), welder::rods::nanobind::rod< DocStyle >::_def_operator(), welder::rods::pybind11::rod< DocStyle >::_def_operator(), welder::rods::nanobind::rod< DocStyle >::_def_reflected_operator(), welder::rods::pybind11::rod< DocStyle >::_def_reflected_operator(), welder::rods::sol2::rod::_register_named(), welder::rods::sol2::rod::_register_operator(), welder::rods::luabridge::rod::add_property(), welder::rods::nanobind::rod< DocStyle >::add_property(), welder::rods::pybind11::rod< DocStyle >::add_property(), and welder::rods::sol2::rod::add_property().

◆ virtual_slot()

std::meta::info welder::virtual_slot ( std::meta::info type,
std::string_view name,
std::meta::info fn_type )
consteval

The overridable virtual slot of type named name whose function type is fn_type — the hand-written disambiguator for an overloaded virtual.

^^Base::fn is ill-formed when fn names an overload set (P2996 has no overload-set reflection), so WELDER_PY_OVERRIDE(fn) cannot be used inside the override of an overloaded virtual. This finder selects one overload by its exact function type, for the slot-taking macro form:

std::string send(int code) const override {
(welder::virtual_slot(^^Robot, "send", ^^std::string(int) const)),
send, code);
}
consteval std::meta::info virtual_slot(std::meta::info type, std::string_view name, std::meta::info fn_type)
The overridable virtual slot of type named name whose function type is fn_type — the hand-written dis...
Definition virtuals.hpp:213
#define WELDER_PY_OVERRIDE_AS(SLOT, FUNC,...)
Body of a single virtual override in a WELDER_PY_TRAMPOLINE class, keyed on an explicit slot reflecti...

(The extra parentheses keep any commas inside the expression out of the preprocessor's argument splitting.) Searches overridable_virtuals, so inherited slots are found too.

Parameters
typea reflection of the welded type.
namethe virtual's identifier.
fn_typea reflection of the overload's full function type, trailing qualifiers included (e.g. ^^int(int) const).
Returns
the matching slot's reflection.
Exceptions
diag::no_matching_virtual_slot(a constant-evaluation error) when no slot matches the name/type pair.

Definition at line 213 of file virtuals.hpp.

References overridable_virtuals().

◆ virtual_slot_count()

std::size_t welder::virtual_slot_count ( std::meta::info type)
consteval

The number of overridable virtual member functions of type, inherited ones included.

This is the N in NB_TRAMPOLINE(Base, N) / a trampoline's slot count — the virtuals actually routed through the trampoline, so per-method bind_flat marks (and the destructor) are excluded. Counts inherited virtuals too (see overridable_virtuals), so a subclass whose virtuals all come from a base still reports a non-zero count and gets a correctly sized trampoline.

Parameters
typea reflection of the class type.
Returns
the count of type's overridable virtual member functions.

Definition at line 232 of file virtuals.hpp.

References overridable_virtuals().

◆ weld_as() [1/2]

template<class... Args>
auto welder::weld_as ( Args &&... args)
consteval

Force a verbatim target name, optionally scoped to one or more languages.

The verbatim name is the last argument; zero or more lang markers precede it. With no marker the name covers every welded language; with one or several it is scoped to those. Repeat the annotation to give an entity a different verbatim name per language.

[[=welder::weld_as("do_thing")]] // all languages
[[=welder::weld_as(welder::lang::py, "do_thing")]] // Python only
consteval detail::weld_as_spec< N > weld_as(const char(&s)[N])
Force s as the target name in every welded language.
@ lua
Lua (via the sol2 and LuaBridge3 backends).
Definition lang.hpp:44
Template Parameters
Argsthe leading lang markers then the const char[N] name (deduced).
Parameters
argsthe language markers (if any) followed by the verbatim name.
Returns
a weld_as_spec carrying the mask of the named languages and the name.

Definition at line 736 of file annotations.hpp.

References welder::detail::weld_as_mask(), and welder::detail::weld_as_name().

◆ weld_as() [2/2]

template<size_type N>
detail::weld_as_spec< N > welder::weld_as ( const char(&) s[N])
consteval

Force s as the target name in every welded language.

The bare, all-languages form of weld_as — the common case, spelled as its own overload (like welder::weld() with no languages) so a plain [[=welder::weld_as("do_thing")]] needs none of the variadic marker machinery. A single string argument is more specialized than the variadic form below, so it is the one chosen here.

Template Parameters
Nthe name length including the terminator (deduced).
Parameters
sthe verbatim name.
Returns
a weld_as_spec with mask 0 (all languages).

Definition at line 687 of file annotations.hpp.

◆ weld_as_of()

template<std::meta::info Ent, lang L>
const char * welder::weld_as_of ( )
consteval

The verbatim weld_as name forced on Ent for language L, or nullptr.

Scans Ent's annotations for a detail::weld_as_spec covering L (a mask of 0 covers all languages); the first match wins. The returned string has static storage (define_static_string), so it is usable at runtime.

Template Parameters
Enta reflection of the entity to read.
Lthe target language.
Returns
the forced name, or nullptr if Ent carries no weld_as for L.

Definition at line 343 of file naming.hpp.

References lang_bit().

Referenced by welder::detail::alias_bound_name(), name_of(), and name_of_or().

◆ weld_mask_admits()

bool welder::weld_mask_admits ( unsigned mask,
lang L )
consteval

Does a weld mask admit language L?

An empty mask is the bare [[=welder::weld]] (equivalently welder::weld()): the language-agnostic weld, admitting every language. Any other mask names its languages explicitly.

Parameters
maskthe mask from a detail::weld_spec.
Lthe target language.
Returns
true iff mask is the all-languages sentinel or names L.

Definition at line 28 of file reflect.hpp.

References lang_bit().

Referenced by alias_welded_for(), and welded_for().

◆ welded_for()

bool welder::welded_for ( std::meta::info type,
lang L )
consteval

Variable Documentation

◆ bind_flat

bind_flat_spec welder::bind_flat {}
inlineconstexpr

Mark a virtual entity as deliberately bound non-overridably.

Usage: [[=welder::bind_flat]]. Two granularities:

  • On a type: the whole type is bound non-overridably (produced by C++, never subclassed in Python) — no trampoline is required, and none of its virtuals are exposed for Python override.
  • On a member function: only that virtual is bound flat — it stays a plain bound method, drops out of the trampoline's slot count and coverage requirement, while the type's other virtuals remain overridable. Useful to exclude a single virtual (e.g. one returning a reference) from override routing.

Without it, every welded type carrying an overridable virtual must register a trampoline via welder::rods::python::trampoline_for, or welder's Python rods reject it at compile time.

See also
bind_flat_spec

Definition at line 58 of file virtuals.hpp.

◆ getter

detail::accessor_spec welder::getter {accessor_role::getter}
inlineconstexpr

Mark a member function as a property getter (const, no parameters).

A marked getter binds as an idiomatic read property instead of a method; a same-property setter (matched by name — explicit, or derived from the identifiers with the leading get/set word stripped) makes it read/write, alone it is read-only. Bare = all languages; call it to scope by language and/or force an explicit property name (see welder::detail::accessor_spec). Under policy::opt_in the mark also counts as the member's opt-in (like mark::only); an explicit exclude still beats it. For languages the mark does not cover, the function binds as an ordinary method.

[[=welder::getter]] double radius() const; // property "radius"
[[=welder::setter]] void radius(double v); // …made read/write
constexpr detail::accessor_spec getter
Mark a member function as a property getter (const, no parameters).
constexpr detail::accessor_spec setter
Mark a member function as a property setter (exactly one parameter) — the write half of welder::gette...

Definition at line 618 of file annotations.hpp.

◆ setter

detail::accessor_spec welder::setter {accessor_role::setter}
inlineconstexpr

Mark a member function as a property setter (exactly one parameter) — the write half of welder::getter, paired by property name.

A setter whose property has no participating getter in a language is a hard error (welder binds no write-only properties).

Definition at line 624 of file annotations.hpp.

Referenced by welder::detail::property_entries().

◆ trust_bindable

template<class T>
bool welder::trust_bindable = false
inlineconstexpr

The type-level trust customization point: specialize to true to trust T wherever it appears (member, parameter, return, container element, …).

A plain bool, so it trusts T for every language at once. Usage (at namespace scope, before binding a type that uses T):

template <> inline constexpr bool welder::trust_bindable<Foo> = true;
constexpr bool trust_bindable
The type-level trust customization point: specialize to true to trust T wherever it appears (member,...
Template Parameters
Tthe type to trust everywhere. See welder::detail::trust_bindable_spec for the per-member granularity.

Definition at line 590 of file annotations.hpp.

Referenced by welder::detail::bindable().

◆ user_lang

template<unsigned char Slot>
lang welder::user_lang {static_cast<lang>(16 + Slot)}
inlineconstexpr

A user-defined language: the Slot-th identity from the mask's user range (bit 16 + Slot) — for binding a language welder does not ship, without touching welder.

Constrained so it can never collide with a welder-shipped language and never exceeds the mask width.

Mint it once, in one place — the application that instantiates the rod — and spell both the annotations and the rod's language from that single constant, so the two can never disagree:

inline constexpr welder::lang ruby{welder::user_lang<0>};
struct [[=welder::weld(ruby)]] Gem { ... };
rods_ruby::rod<ruby> // a third-party rod's injectable language parameter
constexpr detail::weld_spec weld
The weld annotation: declare an entity bound, and for which languages.
constexpr lang user_lang
A user-defined language: the Slot-th identity from the mask's user range (bit 16 + Slot) — for bindin...
Definition lang.hpp:69
lang
The target languages welder ships rods for — but not the whole value space.
Definition lang.hpp:42

Two third-party rods that both default to the same slot are re-pointed the same way — pass each a distinct user_lang at the instantiation site.

Template Parameters
Slotthe user-range slot, 0–15.

Definition at line 69 of file lang.hpp.

◆ weld

detail::weld_spec welder::weld {}
inlineconstexpr

The weld annotation: declare an entity bound, and for which languages.

A constexpr object (like mark::exclude and policy::weld_protected), so it is usable bare — welded for every language — or called to scope it:

struct [[=welder::weld]] A { ... }; // every language
struct [[=welder::weld(welder::lang::py)]] B { ... }; // Python only
welder::lang::lua)]] C { ... }; // those two
welder's binding entry point, parameterized on a rod.
Definition welder.hpp:85

Prefer the bare form unless a type really belongs to one language's surface: a project that welds language-agnostically picks up a newly built rod without touching a single annotation. welder::weld() — called with no languages — is the same all-languages mask, so both spellings agree.

See also
detail::weld_spec

Definition at line 552 of file annotations.hpp.