61namespace welder::inline v0::rods::luacats {
88 template <
auto Bases, std::size_t... I>
91 ((out += (out.empty() ?
"" :
", ") +
qualified_name(Bases[I])), ...);
92 return std::define_static_string(out);
102 template <
class T, std::size_t... J>
104 std::index_sequence<J...>) {
106 static constexpr const char* names[]{
107 std::define_static_string(std::meta::identifier_of(fields[J]))...};
108 static constexpr const char* types[]{
109 lua_type(std::meta::type_of(fields[J]))...};
110 for (std::size_t i{0}; i <
sizeof...(J); ++i) {
116 args += (args.empty() ?
"" :
", ");
123 template <
class T, std::size_t... J>
126 static constexpr const char* names[]{
127 std::define_static_string(std::meta::identifier_of(fields[J]))...};
128 static constexpr const char* types[]{
129 lua_type(std::meta::type_of(fields[J]))...};
131 for (std::size_t i{0}; i <
sizeof...(J); ++i) {
160 template <
class T,
auto Bases, std::size_t... I>
162 const char*
doc, std::index_sequence<I...> seq) {
172 template <
class T, std::meta::info Decl,
auto Bases, std::size_t... I>
174 const char*
doc, std::index_sequence<I...> seq) {
195 template <
class T,
auto Bases, std::size_t... I>
197 const char* name,
const char*
doc,
198 std::index_sequence<I...> seq) {
209 template <
class T, std::meta::info Decl,
auto Bases, std::size_t... I>
211 const char* name,
const char*
doc,
212 std::index_sequence<I...> seq) {
227 std::define_static_string(std::meta::has_identifier(^^T)
238 template <
class T, auto Ctors,
bool HasDefault,
bool Aggregate>
240 if constexpr (HasDefault) {
244 w.
ctors.push_back(std::move(o));
246 template for (
constexpr auto ctor : std::define_static_array(Ctors)) {
249 if constexpr (Aggregate) {
251 static constexpr auto seq{std::make_index_sequence<
257 w.
ctors.push_back(std::move(o));
263 template <std::meta::info Mem,
class Style = ::welder::naming::none>
274 if constexpr (std::meta::is_const_type(std::meta::type_of(Mem)))
275 d = d.empty() ?
"(read-only)" : d +
" (read-only)";
284 template <auto Fns,
class Style = ::welder::naming::none>
288 std::vector<func_overload> sigs{};
300 template <auto Fns,
class Style = ::welder::naming::none>
302 std::vector<func_overload> sigs{};
317 template for (
constexpr auto fn : std::define_static_array(Fns)) {
319 w.
fields +=
"---@operator ";
327 using R = [:std::meta::return_type_of(fn):];
328 if constexpr (!std::is_void_v<R>) {
360 const char* name,
const char*
doc) {
372 template <std::meta::info Enum,
class Style = ::welder::naming::none>
378 constexpr long long v{
static_cast<long long>(std::to_underlying([:Enum:]))};
379 w.
values += std::to_string(v);
401 template <auto Fns,
class Style = ::welder::naming::none>
403 std::vector<func_overload> sigs{};
415 template <std::meta::info Var,
class Style = ::welder::naming::none>
420 out +=
lua_type(std::meta::type_of(Var));
422 out += (m.
prefix.empty() ? std::string{} : m.
prefix +
".") +
430 const std::string prefix{m.
prefix.empty() ? std::string{name}
461 template <std::meta::info Ns,
class Style = ::welder::naming::none>
463 static_assert(std::meta::is_namespace(Ns),
464 "welder: luacats::generate<Ns>: Ns must reflect a namespace");
474static_assert(::welder::rod<rod>,
475 "welder::rods::luacats::rod must satisfy welder::rod");
Backend-agnostic selection layer: the reflection predicates and selectors that decide what participat...
The contract a rod (a welder backend, welder::rods::…::rod) must satisfy to plug into the generic dri...
Language-agnostic documentation layer: read [[=welder::doc(...)]] annotations off reflected entities ...
The LuaCATS document assembler: how a ---@meta stub is built up in memory.
consteval auto aggregate_fields()
The fields an aggregate is initialized from: its non-static data members in declaration order (all pu...
consteval bool is_unary_operator(std::meta::info f)
Whether a member operator is unary (0 parameters) vs binary (1 parameter).
void render_overload_group(std::string &out, const std::string &callee, const std::vector< func_overload > &sigs)
Emit one documented function <callee>(…) for overload group sigs, with a ---@overload fun(…) line per...
constexpr bool is_native_lua
Whether the backend converts U without welder registering a type: scalars, strings and char*.
consteval auto param_lua_types()
The LuaCATS type name of each parameter of Fn, as a splice-ready array parallel to param_docs<Fn>().
consteval const char * lua_type(std::meta::info type)
lua_type_string as a static-storage C string, callable on a constant type reflection.
consteval std::string qualified_name(std::meta::info ent)
The dotted LuaCATS name of a namespace-or-type reflection: its own identifier prefixed by each enclos...
std::string one_line(const char *text)
A one-line description for a @field/@param/@return tail: newlines in text collapse to spaces (LuaCATS...
func_overload build_overload(const std::string &ret_override)
Build the func_overload for function/constructor Fn.
void collect_overloads(std::vector< func_overload > &out, std::index_sequence< I... >)
Append build_overload for each member of overload group Grp to out.
void emit_doc_comment(std::string &out, const char *text)
Append text as --- comment lines (each source line prefixed), so a multiline summary lands as a LuaC...
consteval const char * operator_luacats(std::meta::info f)
A member operator's LuaCATS ---@operator name, or nullptr if not rendered.
consteval detail::doc_spec< N > doc(const char(&s)[N])
Attach a docstring to a namespace, class, function, or function parameter.
lang
The target languages welder ships rods for — but not the whole value space.
@ lua
Lua (via the sol2 and LuaBridge3 backends).
@ static_method
a static member function → transform_static_method.
@ function
a free function → transform_function.
@ variable
a namespace variable → transform_variable.
@ method
a member function → transform_method.
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_o...
consteval const char * name_of()
The final bound name of Ent (a K-kind entity) for language L under name style Style.
consteval const char * doc_of()
The doc text on Ent (a class, namespace, function, or parameter), or nullptr.
std::string qualified
Dotted LuaCATS class name.
std::vector< func_overload > ctors
The .new overloads, grouped on flush.
std::string * sink
Flush target override; null = doc->body.
std::string bases
Comma-joined base names, or empty.
std::string fields
Accumulated ---@field / ---@operator lines.
std::string methods
Accumulated function statements.
std::string cls_doc
The class doc.
std::string trailing
Nested types' flushed blocks (after methods).
The growing LuaCATS document shared by every writer handle.
void declare_table(std::string_view prefix, const char *doc=nullptr)
Record (once) a module table to declare, updating its doc if given.
void record_type_name(std::string_view raw, std::string_view styled)
Register a welded type's declared name so references to it are reconciled at render.
An enum handle: the value table text accumulated by add_enumerator, flushed as a ---@enum block by RA...
std::string * sink
Flush target override; null = doc->body (a nested enum flushes into its outer's trailing,...
std::string values
Accumulated Name = value, lines.
One overload of a callee, pre-rendered into the pieces a group needs: the summary doc,...
std::string args
The function callee(<args>) name list.
std::string ret_line
The ---@return … line (empty when void).
std::string fun_sig
The fun(a: T, …): R signature.
std::string params
---@param … lines (may be empty).
A module handle: the shared document plus this (sub)module's dotted table path.
No deferred module state.
static void add_function(module_type &m, const char *name=nullptr)
Emit free-function overload group Fns as one documented module-level function (further overloads as -...
static enum_writer make_nested_enum(module_type &m, class_writer &outer, const char *name, const char *doc)
Open the enum table declaration for a nested member enum, declared under the OUTER's dotted name and ...
static class_writer make_class(module_type &m, const char *name, const char *doc, std::index_sequence< I... > seq)
Open a ---@class block for T and register its raw→styled name for later type-reference reconciliation...
class_writer class_handle_type
The class / enum handles the per-class / per-enum hooks write into — exactly what make_class / make_e...
static class_writer make_class(module_type &m, const char *name, const char *doc, std::index_sequence< I... > seq)
The declaring-entity-aware form the carriage prefers: Decl is ^^T, or the namespace-scope alias a cla...
static consteval const char * special_method_name(std::meta::info op_fn)
Member operator → its ---@operator name, or nullptr (also gates eligibility, like every backend).
static module_type add_submodule(module_type &m, const char *name)
Declare a nested submodule table under m and return its writer.
static constexpr bool has_native_caster
is_native_lua drives the shared bindability gate.
static class_writer make_nested_class(module_type &m, class_writer &outer, const char *name, const char *doc, std::index_sequence< I... > seq)
Open a ---@class block for a nested member type, declared under the OUTER's dotted name (mod....
static void finish_enum(enum_writer &)
No finalizer needed — the enum_writer flushes on destruction.
static enum_writer make_enum(module_type &m, const char *name, const char *doc)
Open an enum table declaration for E and register its raw→styled name.
static void close_module(module_type &, session &)
Close the session (no-op; the document accumulates directly).
static class_writer make_nested_class(module_type &m, class_writer &outer, const char *name, const char *doc, std::index_sequence< I... > seq)
The declaring-entity-aware nested form the carriage prefers: Decl is ^^T, or the member alias an (oth...
static void add_variable(module_type &m, session &, const char *name=nullptr)
Emit a ---@type-annotated <name> = nil module variable declaration.
static void set_module_doc(module_type &m, const char *doc)
Declare the (sub)module table, carrying doc as its comment.
static void add_operator(class_writer &w)
Emit operator overload group Fns as ---@operator name(rhs): R lines on the class block (one line per ...
module_writer module_type
static void add_enumerator(enum_writer &w)
Emit an Name = <int> line for enumerator Enum.
static void add_constructors(class_writer &w)
Emit the whole .new(…) constructor overload set (the driver-passed pieces: a no-argument overload whe...
static void add_field(class_writer &w)
Emit a ---@field line for data member Mem (const → a (read-only) note, since LuaCATS has no const mod...
static session open_module(module_type &)
Open a per-module session (no deferred state).
static void generate(std::ostream &os)
Emit the LuaCATS ---@meta stub for top-level namespace Ns to os.
static constexpr lang language
Stubs are for the Lua binding.
enum_writer enum_handle_type
static consteval const char * _bases_string(std::index_sequence< I... >)
The comma-joined LuaCATS names of a class's welded bases (for ---@class X : …).
static void add_method(class_writer &w)
Emit method overload group Fns as one documented Class:name(…) (further overloads as ---@overload lin...
static void _aggregate_param_lines(std::string &out, std::string &args, std::index_sequence< J... >)
Precompute an aggregate's ---@param lines and its .new argument list.
static std::string _aggregate_fun_params(std::index_sequence< J... >)
The <field>: <type>, … list for an aggregate's .new fun(…) signature (its ---@overload line).
static void add_static_method(class_writer &w)
Emit static-method overload group Fns as a documented Class.name(…) (dotted, no self).
welder's binding entry point, parameterized on a rod.
The low-level rendering primitives of the LuaCATS stub backend: the C++→LuaCATS type map**,...
welder's binding entry point: the welder::welder struct.