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

The annotation vocabulary users attach to their types — weld, policy, mark, doc, returns, tparam. More...

#include <welder/diag.hpp>
#include <welder/lang.hpp>
Include dependency graph for annotations.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  welder::detail::weld_spec
 The stored form of a weld annotation: the mask of target languages. More...
struct  welder::detail::policy_spec
 The stored form of a policy annotation. More...
struct  welder::detail::weld_protected_spec
 The stored form of a policy::weld_protected annotation: the languages a type's protected members are admitted for. More...
struct  welder::detail::exclude_spec
 The stored form of an exclude mark: the languages a member is hidden from. More...
struct  welder::detail::include_spec
 The stored form of an include mark: the languages a member is opted into. More...
struct  welder::detail::only_spec
 The stored form of an only mark: the complete set of languages a member may bind for — implicitly, not for any other. More...
struct  welder::detail::trust_bindable_spec
 The stored form of a trust_bindable member mark. More...
struct  welder::detail::fixed_string< N >
 A string literal captured by value, length included, so it can live in a structural annotation constant. More...
struct  welder::detail::doc_spec< N >
 The stored form of a doc annotation: a summary docstring. More...
struct  welder::detail::return_doc_spec< N >
 The stored form of a returns annotation: a function's return-value doc. More...
struct  welder::detail::tparam_spec< N, M >
 The stored form of a tparam annotation: one template parameter's doc. More...
struct  welder::detail::weld_as_spec< N >
 The stored form of a weld_as annotation: a forced target-language name. More...
struct  welder::detail::return_policy_spec
 The stored form of a return_policy annotation: a return-value policy, optionally scoped to some languages. More...
struct  welder::detail::keep_alive_spec
 The stored form of a keep_alive annotation: a lifetime dependency between two of a call's entities, addressed by pybind11/nanobind's index convention (0 = the return value, 1 = the first argument — the implicit this for a method — 2 = the second, …). More...

Namespaces

namespace  welder
namespace  welder::detail
 The stored forms of the annotation vocabulary.
namespace  welder::policy
 The policy annotation values.
namespace  welder::mark
 The bare mark annotation objects — use directly or call to scope by language.
namespace  welder::rv
 The return-value policy values, the user-facing spelling of rv_kind.

Typedefs

using welder::size_type = decltype(sizeof(0))
 std::size_t named without a standard-library include, keeping this vocabulary header std-free (see the file note).

Enumerations

enum class  welder::policy_kind : unsigned char { welder::automatic , welder::opt_in }
 How greedily a type's members are reflected for binding. More...
enum class  welder::rv_kind : unsigned char {
  welder::automatic , welder::automatic_reference , welder::take_ownership , welder::copy ,
  welder::move , welder::reference , welder::reference_internal , welder::none
}
 How a bound callable's returned object is owned/converted in the target language — welder's backend-neutral spelling of the return-value policy. More...

Functions

consteval unsigned welder::lang_bit (lang l)
 The single-language bit for l within a language mask.
template<class... Ls>
consteval unsigned welder::lang_mask (Ls... ls)
 The mask naming the languages ls.
template<class... Ls>
consteval detail::weld_spec welder::weld (Ls... ls)
 Build a weld annotation naming the target languages.
template<size_type N>
consteval detail::doc_spec< N > welder::doc (const char(&s)[N])
 Attach a docstring to a namespace, class, function, or function parameter.
template<size_type N>
consteval detail::return_doc_spec< N > welder::returns (const char(&s)[N])
 Document a function's return value.
template<size_type N, size_type M>
consteval detail::tparam_spec< N, M > welder::tparam (const char(&name)[N], const char(&text)[M])
 Document a template parameter (repeatable, ordered).
template<size_type N>
consteval detail::weld_as_spec< N > welder::weld_as (const char(&s)[N])
 Force s as the target name in every welded language.
consteval unsigned welder::detail::weld_as_mask ()
 The language mask of a weld_as argument list: the OR of its leading lang markers (the trailing name contributes nothing; no markers → 0 = all).
template<size_type N>
consteval unsigned welder::detail::weld_as_mask (const char(&)[N])
template<class... Rest>
consteval unsigned welder::detail::weld_as_mask (lang l, Rest &&... rest)
template<size_type N>
consteval fixed_string< N > welder::detail::weld_as_name (const char(&s)[N])
 The verbatim name of a weld_as argument list: the trailing string, reached by dropping the leading lang markers (its extent N preserved by reference).
template<class... Rest>
consteval auto welder::detail::weld_as_name (lang, Rest &&... rest)
template<class... Args>
consteval auto welder::weld_as (Args &&... args)
 Force a verbatim target name, optionally scoped to one or more languages.
consteval unsigned welder::detail::return_policy_mask (rv_kind)
 The language mask of a return_policy argument list: the OR of its leading lang markers (the trailing kind contributes nothing; no markers → 0 = all).
template<class... Rest>
consteval unsigned welder::detail::return_policy_mask (lang l, Rest... rest)
consteval rv_kind welder::detail::return_policy_kind (rv_kind k)
 The policy of a return_policy argument list: the trailing kind, reached by dropping the leading lang markers.
template<class... Rest>
consteval rv_kind welder::detail::return_policy_kind (lang, Rest... rest)
template<class... Args>
consteval detail::return_policy_spec welder::return_policy (Args... args)
 Force a return-value policy on a callable, optionally scoped to one or more languages.
consteval detail::keep_alive_spec welder::keep_alive (unsigned nurse, unsigned patient)
 Keep the call entity patient alive at least until nurse is collected.

Variables

constexpr detail::policy_spec welder::policy::automatic {policy_kind::automatic}
constexpr detail::policy_spec welder::policy::opt_in {policy_kind::opt_in}
constexpr detail::weld_protected_spec welder::policy::weld_protected {}
 Admit the type's protected members into resolution — bare (all languages) or called with languages to scope it.
template<class T>
constexpr bool welder::trust_bindable = false
 The type-level trust customization point: specialize to true to trust T wherever it appears (member, parameter, return, container element, …).
constexpr detail::exclude_spec welder::mark::exclude {}
constexpr detail::include_spec welder::mark::include {}
constexpr detail::only_spec welder::mark::only {}
constexpr detail::trust_bindable_spec welder::mark::trust_bindable {}
constexpr rv_kind welder::rv::automatic {rv_kind::automatic}
constexpr rv_kind welder::rv::automatic_reference {rv_kind::automatic_reference}
constexpr rv_kind welder::rv::take_ownership {rv_kind::take_ownership}
constexpr rv_kind welder::rv::copy {rv_kind::copy}
constexpr rv_kind welder::rv::move {rv_kind::move}
constexpr rv_kind welder::rv::reference {rv_kind::reference}
constexpr rv_kind welder::rv::reference_internal {rv_kind::reference_internal}
constexpr rv_kind welder::rv::none {rv_kind::none}

Detailed Description

The annotation vocabulary users attach to their types — weld, policy, mark, doc, returns, tparam.

Users spell these through the factory functions and the policy / mark objects below; the stored forms each one produces (the *_spec structs the reflection layer reads back) are implementation detail, tucked into welder::detail so they don't crowd the public welder:: namespace.

Like <welder/lang.hpp>, this header is kept std-include-free so a future welder C++20 module can re-export it without leaking std into importers.

Definition in file annotations.hpp.