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

Backend-agnostic selection layer: the reflection predicates and selectors that decide what participates in a binding — which constructors, methods, operators, data members, namespace entities and base classes are eligible, and what their parameter names/types are. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include <meta>
#include <sstream>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>
#include <welder/diag.hpp>
#include <welder/naming.hpp>
#include <welder/reflect.hpp>
Include dependency graph for bind_traits.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  welder::detail::keep_alive_pair
 A keep_alive lifetime dependency: a (nurse, patient) index pair. More...
struct  welder::detail::synthesized_comparison< A, B, S >
struct  welder::detail::field_access< Mem >
 Splice-based accessors for data member Mem — the pointer-to-member-free route the rods bind a protected field through. More...
struct  welder::detail::property_entry
 One resolved property: its getter and its (optional) setter. More...

Namespaces

namespace  welder
namespace  welder::detail
 The stored forms of the annotation vocabulary.

Typedefs

using welder::detail::overload_selector
 The signature of an overload-set selector specialization: the representative overload, the language, and the entity the group binds into.

Enumerations

enum class  welder::detail::cmp_slot : std::uint8_t { welder::detail::lt = 0 , welder::detail::le = 1 , welder::detail::gt = 2 , welder::detail::ge = 3 }
 The rewritten-expression comparison a rod binds for a type whose C++ comparisons come from operator<=>: plain a < b (etc.), so C++'s own operator-rewriting rules ([over.match.oper]) pick the spaceship overload — heterogeneous and reversed operands included — and the target language sees exactly what a C++ caller sees. More...

Functions

template<std::meta::info Fn>
consteval auto welder::detail::param_types ()
 A function's parameter types, as a static array of reflections.
template<std::meta::info Fn>
consteval std::size_t welder::detail::trailing_default_count ()
 How many TRAILING parameters of Fn carry a C++ default argument.
template<std::meta::info Fn>
consteval auto welder::detail::param_names ()
 A function's parameter names, in order.
template<std::meta::info Fn>
consteval auto welder::detail::keep_alive_pairs ()
 The keep_alive dependencies declared on Fn, in declaration order.
template<std::meta::info Fn>
consteval bool welder::detail::all_params_named ()
 Whether every parameter of Fn carries an identifier.
consteval bool welder::detail::is_bindable_constructor (std::meta::info c)
 A non-default, non-copy/move public constructor a backend should expose.
consteval bool welder::detail::is_method_candidate (std::meta::info f)
 The shape of a bindable method: a plain non-private member function.
consteval bool welder::detail::is_operator_candidate (std::meta::info f)
 The shape of a bindable member operator.
consteval bool welder::detail::decays_to (std::meta::info t, std::meta::info type)
 Whether type reflection t is exactly the (welded) type type once stripped of cv/ref qualifiers and aliases.
consteval bool welder::detail::is_free_operator_candidate (std::meta::info f)
 The shape of a bindable freestanding operator: a non-deleted namespace-scope operator function.
consteval bool welder::detail::is_stringifier_for (std::meta::info f, std::meta::info type)
 Whether f is the stream-inserter ("stringifier") shape for type: operator<<(std::ostream&, T).
consteval bool welder::detail::free_operator_anchored (std::meta::info f, std::meta::info type)
 Whether free operator f is anchored on type: some parameter decays to exactly type (an rvalue-reference operand disqualifies — it consumes the object, which no binding call form expresses).
consteval bool welder::detail::free_operator_reflected (std::meta::info f, std::meta::info type)
 Whether anchored free operator f binds reflected for type: type is the right operand and the left is something else (operator*(double, Vec)).
template<auto Fns, std::meta::info Type, bool Reflected>
consteval auto welder::detail::partition_reflected ()
 Split slot group Fns by free_operator_reflected — the entries whose reflectedness equals Reflected, in group order.
consteval std::meta::info welder::detail::enclosing_namespace (std::meta::info type)
 The nearest enclosing namespace of type — the scope its anchored free operators are swept from (for a nested class, the namespace enclosing the outermost class, mirroring where C++ requires such operators to live).
consteval std::meta::info welder::detail::comparison_operand (std::meta::info f, std::meta::info type)
 The operand a comparison synthesized from spaceship overload f takes: the parameter type that is not the anchor type itself — or type for the homogeneous form.
template<auto Fns, std::meta::info Type>
consteval bool welder::detail::has_heterogeneous_comparison ()
 Whether spaceship group Fns contains a heterogeneous overload (an operand that is not Type itself) — the trigger for a reversed-operand fallback on rods whose framework registers by exact signature shape.
template<class T, std::meta::info Fn>
std::string welder::detail::stringify (const T &self)
 The stringifier wrapper every runtime rod binds for a swept ostream inserter (see is_stringifier_for): run the specific participating overload Fn into a string stream and hand back the text — the body of Python's __str__ and Lua's __tostring.
template<class Resolution>
consteval bool welder::detail::member_access_admitted (std::meta::info mem, lang L, std::meta::info bound_into)
 Is mem's access level admitted for binding under Resolution?
consteval bool welder::detail::is_unary_operator (std::meta::info f)
 Whether an operator function is unary vs binary.
template<class T>
consteval auto welder::detail::aggregate_fields ()
 The fields an aggregate is initialized from: its non-static data members in declaration order (all public, by the aggregate rules).
template<class T, lang L, class Resolution>
consteval bool welder::detail::aggregate_initializable ()
 Whether to synthesize an aggregate field constructor for T (language L, resolution Resolution).
template<class T>
consteval std::size_t welder::detail::aggregate_required_arity ()
 How many leading fields the synthesized aggregate field constructor REQUIRES: everything up to and including the last field without a default member initializer.
template<class T>
consteval std::size_t welder::detail::aggregate_defaults_from ()
 The field index from which a value-extracting backend (the Python rods) can attach the NSDMI defaults as real parameter default values.
consteval bool welder::detail::is_bindable_kind (std::meta::info mem)
 The member kinds welder can expose from a namespace.
consteval bool welder::detail::entity_bound (std::meta::info mem, lang L, policy_kind pol)
 Whether a leaf entity binds: a welded candidate that also resolves as bound.
consteval bool welder::detail::namespace_has_bound (std::meta::info ns, lang L)
 Whether ns holds anything that would bind, directly or nested.
consteval bool welder::detail::namespace_has_bindable (std::meta::info ns, lang L)
 The greedy twin of namespace_has_bound: whether ns holds any bindable kind (ignoring the weld marker), directly or nested.
template<class Resolution>
consteval std::vector< std::meta::info > welder::detail::method_overload_set (std::meta::info fn, lang L, std::meta::info bound_into)
 The participating method overloads sharing fn's name and static-ness, from the class where fn is declared, in declaration order.
template<class Resolution>
consteval void welder::detail::collect_member_operators (std::meta::info src, lang L, std::meta::info bound_into, std::vector< std::meta::info > &out)
 Collect the participating member operators visible on bound_into's binding: src's own, preceded by those of its flattened (non-native according to Resolution) bases, recursively — mirroring bind_members' flattening, so a slot's group spans exactly what the class surface exposes.
template<class Resolution>
consteval std::vector< std::meta::info > welder::detail::operator_entries (std::meta::info type, lang L)
 Every participating operator entry of type's binding — member operators (own + flattened bases') and the anchored free operators of the type's enclosing namespace — in one list, so the carriage can slot-group across all sources (a one-value-per-slot backend must receive each slot whole).
template<class Resolution>
consteval std::vector< std::meta::info > welder::detail::operator_slot_set (std::meta::info fn, lang L, std::meta::info bound_into)
 The participating operator entries sharing fn's target slot (same operator and arity — hence the same special-method name) on bound_into's binding, across every source operator_entries sweeps (member + free).
template<class Resolution>
consteval std::vector< std::meta::info > welder::detail::stringifier_entries (std::meta::info type, lang L)
 The participating stringifier entries for type: free operator<<(std::ostream&, T) overloads of its enclosing namespace, resolved like the anchored operators.
template<class Resolution>
consteval std::array< bool, 4 > welder::detail::covered_comparison_slots (std::meta::info type, lang L)
 Which relational slots (lt, le, gt, ge — indexed by cmp_slot) are already covered by an explicit participating operator on type's binding.
template<class Resolution>
consteval std::vector< std::meta::info > welder::detail::function_overload_set (std::meta::info fn, lang L, std::meta::info bound_into)
 The participating free-function overloads sharing fn's name, from fn's declaring namespace, in declaration order.
template<overload_selector Select, std::meta::info Fn, lang L, std::meta::info BoundInto>
consteval auto welder::detail::overload_group ()
 Select's overload set for Fn as a fixed-size, splice-ready static array.
template<overload_selector Select>
consteval bool welder::detail::is_overload_leader (std::meta::info fn, lang L, std::meta::info bound_into)
 Whether fn is the first (declaration order) member of its Select overload set — the single visit on which the carriage emits the whole group.
template<class Resolution, std::meta::info Fn, lang L>
consteval auto welder::detail::manual_function_group ()
 The semi-manual (weld_function<Fn>) group: Fn first — the user's named entity resolves the group's target name — then Fn's participating siblings.
template<class Resolution, std::meta::info Type, lang L, policy_kind Pol>
consteval auto welder::detail::ctor_group ()
 The participating constructors of Type under policy Pol: every bindable-shape constructor (see is_bindable_constructor) the resolution admits, in declaration order.
template<class Resolution, std::meta::info Type, lang L>
consteval bool welder::detail::default_ctor_admitted ()
 Whether the resolution admits Type's DEFAULT constructor.
template<class Resolution, std::meta::info Type, lang L>
consteval bool welder::detail::copy_ctor_admitted ()
 Whether the resolution admits Type's copy constructor — the marks half of the copy decision; the carriage pairs it with std::is_copy_constructible_v<T> (which also rules out abstract, deleted-copy and inaccessible-copy types) and hands the result to the rod's add_constructors as its Copyable flag.
template<std::meta::info Type>
consteval void welder::detail::validate_move_ctor_marks ()
 Reject an include/only mark on a move constructor of Type.
consteval bool welder::detail::carries_weld_as (std::meta::info m)
 Does m carry a (templated) weld_as annotation?
consteval std::vector< std::string > welder::detail::property_key (std::meta::info mem, accessor_role role, lang L)
 The pairing key of accessor mem's property for language L: the case-normalized word sequence of its explicit name (when the mark carries one) or of its identifier with the leading get/set word stripped.
template<class Resolution>
consteval void welder::detail::collect_accessors (std::meta::info src, lang L, std::meta::info bound_into, std::vector< std::meta::info > &out)
 Collect the participating accessor-marked member functions visible on bound_into's binding: src's own, preceded by its flattened (non-native) bases' — mirroring bind_members' flattening, exactly like collect_member_operators.
template<class Resolution>
consteval void welder::detail::validate_property_shadowing (std::meta::info src, lang L, std::meta::info bound_into, const std::vector< std::vector< std::string > > &keys)
 Guard the property surface against name shadowing: no property's key may equal a bound data member's or (non-accessor) method's identifier key on the same class surface (own + flattened bases).
template<class Resolution>
consteval std::vector< property_entrywelder::detail::property_entries (std::meta::info type, lang L)
 The resolved properties of type for language L: every participating accessor collected (own + flattened bases), shape-validated, and paired by property key — getters first (in declaration order, which fixes the emission order), then each setter matched to its getter.
template<std::meta::info Getter, lang L, class Style>
consteval const char * welder::detail::property_bound_name ()
 The bound name of the property Getter defines, for language L under name style Style: the mark's explicit name verbatim when present (never styled — the accessor analogue of weld_as), else the getter's identifier styled through Style's field hook (a property is attribute-shaped) with the leading get/set word then stripped in the styled spelling's own convention (see welder::naming::strip_accessor_word).
consteval void welder::detail::collect_native_bases (std::meta::info type, lang L, std::vector< std::meta::info > &out)
 Collect the native bases of type for L: its nearest welded ancestors.
template<std::meta::info Type, lang L>
consteval auto welder::detail::native_base_types ()
 The native bases of Type for L as a static array of type reflections.

Detailed Description

Backend-agnostic selection layer: the reflection predicates and selectors that decide what participates in a binding — which constructors, methods, operators, data members, namespace entities and base classes are eligible, and what their parameter names/types are.

It answers "what", never "how": no backend API appears here, so every backend (pybind11, nanobind, sol2) shares this vocabulary and only supplies the emission primitives.

Note
Like <welder/reflect.hpp>, this depends on the welder vocabulary (lang, policy_kind, …) but does NOT include <welder/annotations.hpp>: provide the vocabulary first (#include <welder/vocabulary.hpp>), then this.

Definition in file bind_traits.hpp.