welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
welder::detail::accessor_spec Struct Reference

The stored form of a getter / setter mark: which property half the function supplies, for which languages, under which (optional) explicit name. More...

#include <welder/annotations.hpp>

Public Member Functions

template<class... Args>
consteval accessor_spec operator() (Args &&... args) const
 Scope the mark by language and/or force an explicit property name.

Public Attributes

accessor_role role {}
 Which half this function supplies.
unsigned mask = 0
 The languages it applies to; 0 == all.
char name [accessor_name_capacity] {}
 The explicit property name; empty == derive.

Detailed Description

The stored form of a getter / setter mark: which property half the function supplies, for which languages, under which (optional) explicit name.

Each marker is a constexpr object usable bare as an annotation (all languages, name derived from the function's identifier) or called with an optional run of lang markers and an optional trailing explicit name — the weld_as argument grammar with the name optional:

[[=welder::getter]] // all languages, derived name
[[=welder::getter("radius")]] // explicit name, verbatim
[[=welder::setter(welder::lang::py)]] // Python only, derived name
[[=welder::getter(welder::lang::py, "radius")]] // Python only, explicit name
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...
@ py
Python (via the pybind11 and nanobind backends).
Definition lang.hpp:43

Repeat the annotation for a different name (or admission) per language. An explicit name is used verbatim — it never flows through a name style — exactly like weld_as (which is diagnosed on an accessor: the explicit property name is the rename tool there). An empty name means "derive from the function's identifier" (strip a leading get/set word, keep the rest in the identifier's own convention).

Definition at line 385 of file annotations.hpp.

Member Function Documentation

◆ operator()()

template<class... Args>
accessor_spec welder::detail::accessor_spec::operator() ( Args &&... args) const
inlineconsteval

Scope the mark by language and/or force an explicit property name.

Template Parameters
Argsthe leading lang markers, then the optional name (deduced).
Parameters
argszero or more languages, optionally followed by the name.
Returns
a scoped/named accessor_spec of the same role.

Definition at line 395 of file annotations.hpp.

References welder::detail::accessor_mask(), welder::detail::accessor_name(), name, and role.

Member Data Documentation

◆ mask

unsigned welder::detail::accessor_spec::mask = 0

The languages it applies to; 0 == all.

Definition at line 387 of file annotations.hpp.

◆ name

char welder::detail::accessor_spec::name[accessor_name_capacity] {}

The explicit property name; empty == derive.

Definition at line 388 of file annotations.hpp.

Referenced by operator()().

◆ role

accessor_role welder::detail::accessor_spec::role {}

Which half this function supplies.

Definition at line 386 of file annotations.hpp.

Referenced by operator()().


The documentation for this struct was generated from the following file: