welder
0.1.0
Bindings for annotated C++ types, from C++26 reflection
Toggle main menu visibility
Loading...
Searching...
No Matches
welder.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <meta>
3
#include <type_traits>
4
5
#include <
welder/carriage.hpp
>
// the traversal driver + stitch/tack carriage aliases
6
#include <
welder/concepts.hpp
>
// the welder::rod contract
7
#include <
welder/naming.hpp
>
// naming::none (the default name style)
8
31
32
namespace
welder::inline v0 {
33
84
template
<rod B,
class
Style = naming::none,
class
Carriage = carriage>
85
struct
welder
{
87
using
rod_type
= B;
89
using
name_style
= Style;
91
using
carriage_type
= Carriage;
93
using
module_type
=
typename
B::module_type;
94
96
static
constexpr
auto
noop
{[](
module_type
&) {}};
97
110
template
<
class
T>
111
static
auto
weld_type
(
module_type
& m,
const
char
* name =
nullptr
) {
112
if
constexpr
(std::is_enum_v<T>)
113
return
Carriage::template bind_enum<B, T, Style>(m, name);
114
else
115
return
Carriage::template bind_type<B, T, Style>(m, name);
116
}
117
141
template
<std::meta::info Fn>
142
static
auto
weld_function
(
module_type
& m,
const
char
* name =
nullptr
) {
143
return
Carriage::template bind_function<B, Fn, Style>(m, name);
144
}
145
163
template
<std::meta::info Var>
164
static
auto
weld_variable
(
module_type
& m,
const
char
* name =
nullptr
) {
165
return
Carriage::template bind_variable<B, Var, Style>(m, name);
166
}
167
178
template
<std::meta::info Ns>
179
static
module_type
&
weld_namespace
(
module_type
& m) {
180
Carriage::template bind_namespace<B, Ns, Style>(m);
181
return
m;
182
}
183
192
template
<std::meta::info Ns>
193
static
module_type
weld_namespace_as_submodule
(
module_type
& m,
194
const
char
* name =
nullptr
) {
195
return
Carriage::template bind_namespace_as_submodule<B, Ns, Style>(m, name);
196
}
197
215
template
<std::meta::info Ns,
class
Pre =
decltype
(noop),
216
class
Post =
decltype
(noop)>
217
static
module_type
&
weld_module
(
module_type
& m, Pre pre =
noop
,
218
Post post =
noop
) {
219
Carriage::template build_module<B, Ns, Style>(m, pre, post);
220
return
m;
221
}
222
};
223
224
}
// namespace welder
carriage.hpp
The carriage: welder's reflection-driven traversal driver, kept separate from the welder::welder<> en...
concepts.hpp
The core interface concepts welder's static polymorphism rests on, gathered in one catalogue: the cus...
welder
Definition
annotations.hpp:18
naming.hpp
Language-agnostic name styling: reshape a C++ identifier into a target language's naming convention,...
welder::welder::weld_namespace_as_submodule
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.
Definition
welder.hpp:193
welder::welder::module_type
typename B::module_type module_type
The rod's module handle (py::module_, sol::table, …).
Definition
welder.hpp:93
welder::welder::weld_module
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 na...
Definition
welder.hpp:217
welder::welder::weld_variable
static auto weld_variable(module_type &m, const char *name=nullptr)
Reflect over global/namespace variable Var and register it on module m.
Definition
welder.hpp:164
welder::welder::noop
static constexpr auto noop
A do-nothing module hook; the default for weld_module()'s pre/post.
Definition
welder.hpp:96
welder::welder::carriage_type
Carriage carriage_type
The traversal driver (carriage) this instantiation drives through.
Definition
welder.hpp:91
welder::welder::weld_type
static auto weld_type(module_type &m, const char *name=nullptr)
Reflect over T and register it on module m.
Definition
welder.hpp:111
welder::welder::weld_namespace
static module_type & weld_namespace(module_type &m)
Reflect over namespace Ns and expose its members on module m.
Definition
welder.hpp:179
welder::welder::weld_function
static auto weld_function(module_type &m, const char *name=nullptr)
Reflect over free function Fn and register it on module m.
Definition
welder.hpp:142
welder::welder::rod_type
B rod_type
The rod this instantiation emits through.
Definition
welder.hpp:87
welder::welder::name_style
Style name_style
The name style this instantiation renames through.
Definition
welder.hpp:89
src
welder
welder.hpp
Generated by
1.17.0