|
welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
|
welder's binding entry point, parameterized on a rod. More...
#include <welder/welder.hpp>
Public Types | |
| using | rod_type = B |
| The rod this instantiation emits through. | |
| using | name_style = Style |
| The name style this instantiation renames through. | |
| using | carriage_type = Carriage |
| The traversal driver (carriage) this instantiation drives through. | |
| using | module_type = typename B::module_type |
| The rod's module handle (py::module_, sol::table, …). | |
Static Public Member Functions | |
| template<class T> | |
| static auto | weld_type (module_type &m, const char *name=nullptr) |
| Reflect over T and register it on module m. | |
| template<std::meta::info Fn> | |
| static auto | weld_function (module_type &m, const char *name=nullptr) |
| Reflect over free function Fn and register it on module m. | |
| template<std::meta::info Var> | |
| static auto | weld_variable (module_type &m, const char *name=nullptr) |
| Reflect over global/namespace variable Var and register it on module m. | |
| template<std::meta::info Ns> | |
| static module_type & | weld_namespace (module_type &m) |
| Reflect over namespace Ns and expose its members on module m. | |
| template<std::meta::info Ns> | |
| static module_type | weld_namespace_as_submodule (module_type &m, const char *name=nullptr) |
| Define a submodule of m (via the backend) and weld_namespace() Ns into it. | |
| template<std::meta::info Ns, class Pre = decltype(noop), class Post = decltype(noop)> | |
| static module_type & | weld_module (module_type &m, Pre pre=noop, Post post=noop) |
| Build a whole module out of top-level namespace Ns: run pre, weld the namespace into m (adopting a namespace-level doc as the module docstring), run post. | |
Static Public Attributes | |
| static constexpr auto | noop {[](module_type&) {}} |
| A do-nothing module hook; the default for weld_module()'s pre/post. | |
welder's binding entry point, parameterized on a rod.
One struct is all a user drives: pick a rod (e.g. welder::rods::pybind11::rod<>, from that rod's header) and call the static member matching the stage of the usual hand-binding flow you want to automate — welder generates the backend-agnostic boilerplate there, and everything around it stays ordinary hand-written binding code.
(For zero hand-written entry-point code at all, each rod also ships a module.hpp with the WELDER_MODULE entry-point macro.)
Composition / subclassing.** Every entry point is a one-line forward to the injected Carriage (the traversal driver), which owns the resolution and the welded/bindability gates. There are two ways to go beyond the stock flow, both without re-deriving any of that: inject a different carriage as the third template argument (e.g. welder::tack_welding_carriage to bind an unmarked library), or subclass welder::welder — the whole class is static and non-virtual, so deriving simply gives a user's own driver type access to the bound Rod / Style / Carriage (via rod_type / name_style / carriage_type) and to the public entry points, to assemble bespoke routines (a hand-picked subset of a namespace, welded and hand-written registrations interleaved) from the carriage's gated building blocks.
| B | the rod to emit through (any type satisfying welder::rod). |
| Style | the name style every generated name flows through — a class, method, field, … is renamed into the target language's convention (see <welder/naming.hpp>). A [[=welder::weld_as]] override on an entity beats the style and is used verbatim (and a call-site name argument beats even that). Defaults to welder::naming::none (bind C++ identifiers unchanged); a Python binding might pass welder::rods::python::pep8. |
| Carriage | the reflection-driven traversal driver (welder::carriage) — what walks a type/namespace and orchestrates the rod's emission. Defaults to welder::stitch_welding_carriage (marker-directed); inject welder::tack_welding_carriage to bind an unmarked library greedily, or any welder::carriages::basic_carriage<Resolution>. |
Definition at line 85 of file welder.hpp.
| using welder::welder< B, Style, Carriage >::carriage_type = Carriage |
The traversal driver (carriage) this instantiation drives through.
Definition at line 91 of file welder.hpp.
| using welder::welder< B, Style, Carriage >::module_type = typename B::module_type |
The rod's module handle (py::module_, sol::table, …).
Definition at line 93 of file welder.hpp.
| using welder::welder< B, Style, Carriage >::name_style = Style |
The name style this instantiation renames through.
Definition at line 89 of file welder.hpp.
| using welder::welder< B, Style, Carriage >::rod_type = B |
The rod this instantiation emits through.
Definition at line 87 of file welder.hpp.
|
inlinestatic |
Reflect over free function Fn and register it on module m.
The semi-manual analogue of what namespace binding does for a namespace's free functions: bind one hand-picked name directly, without welding the whole enclosing namespace. Fn must reflect a single function (an overload set is ambiguous — reflect a specific overload); under the default (stitch) carriage it must be welded for B::language. Fn's participating same-name overload siblings join the weld (as one group, Fn naming it) — the same set the namespace walk would bind, so the call is consistent on every rod, including the one-value-per-name Lua tables. Shape the set with per-overload marks; Fn itself always welds (the explicit call outranks its own marks).
| Fn | a reflection of the free function. |
| m | the module handle to register onto. |
| name | the target name, used verbatim and taking precedence over any [[=welder::weld_as]] on Fn; nullptr (default) resolves the weld_as/styled name. |
Definition at line 142 of file welder.hpp.
|
inlinestatic |
Build a whole module out of top-level namespace Ns: run pre, weld the namespace into m (adopting a namespace-level doc as the module docstring), run post.
The hooks fold hand-written bindings in around welder's generated body. This fills an existing module handle; pair it with an entry-point macro (the framework's own, or the backend's WELDER_MODULE expansion, which calls this).
| Ns | a reflection of the top-level namespace (its name is meant to be the module name). |
| Pre | the pre-hook callable type. |
| Post | the post-hook callable type. |
| m | the module handle to fill. |
| pre | invoked with m before binding (defaults to noop). |
| post | invoked with m after binding (defaults to noop). |
Definition at line 217 of file welder.hpp.
References noop.
|
inlinestatic |
Reflect over namespace Ns and expose its members on module m.
Classes and enums bind via weld_type(), free functions and namespace variables become module attributes, and a nested namespace holding participating content becomes a submodule. Which members participate is the carriage's call (marker-directed by default, greedy under the tack carriage).
| Ns | a reflection of the namespace. |
| m | the module handle to fill. |
Definition at line 179 of file welder.hpp.
|
inlinestatic |
Define a submodule of m (via the backend) and weld_namespace() Ns into it.
| Ns | a reflection of the namespace. |
| m | the parent module handle. |
| name | the submodule name (verbatim), or nullptr to resolve Ns's styled/weld_as name. |
Definition at line 193 of file welder.hpp.
|
inlinestatic |
Reflect over T and register it on module m.
A class type binds with its constructors, fields, methods, operators and native bases; an enum with its enumerators (see the carriage for the full set). Under the default (stitch) carriage T must be welded for B::language.
| T | the class or enum type to bind. |
| m | the module handle to register onto. |
| name | the target-language name (verbatim, beats weld_as), or nullptr to resolve T's weld_as/styled name. |
Definition at line 111 of file welder.hpp.
|
inlinestatic |
Reflect over global/namespace variable Var and register it on module m.
The semi-manual analogue of what namespace binding does for a namespace's variables: expose one hand-picked global or constant directly. A const/constexpr Var becomes a value snapshot; a mutable one a live get/set property over the C++ global. Under the default (stitch) carriage Var must be welded for B::language.
| Var | a reflection of the namespace-scope variable. |
| m | the module handle to register onto. |
| name | the target name, used verbatim and taking precedence over any [[=welder::weld_as]] on Var; nullptr (default) resolves the weld_as/styled name. |
Definition at line 164 of file welder.hpp.
|
staticconstexpr |
A do-nothing module hook; the default for weld_module()'s pre/post.
Definition at line 96 of file welder.hpp.
Referenced by weld_module().