CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
Field definition macros
Collaboration diagram for Field definition macros:

Macros

#define BITPACK_USUAL_PREFIX
 Capture the incantations often at the top of a Bitpack structure, especially one with type-directed field proxies.
#define BITPACK_MEMBER_ADD(name, Type, ...)
 Define a named accessor for a field.
#define BITPACK_MEMBER_ADD_ENUM(Type, Base, ...)
 Encapsulate the gyrations required to define an enum class-typed field and its associated field_info_for_type within a Bitpack.
#define BITPACK_MEMBER_ADD_ENUM_BOOL(Type, FalseVal, TrueVal, BitIndex, ...)
 Define a new scoped enumeration type whose underlying type is bool, with the given false and true value names, at the given bit position.
#define BITPACK_MEMBER_ADD_ENUM_BOOL_CLEARED_ASSERTED(Type, BitIndex, ...)
 Define a new boolean scoped enumeration with values named "Cleared" (0) and "Asserted" (1) at the given bit index.
#define BITPACK_MEMBER_ADD_ENUM_BOOL_DISABLED_ENABLED(Type, BitIndex, ...)
 Define a new boolean scoped enumeration with values named "Disabled" (0) and "Enabled" (1) at the given bit index.
#define BITPACK_MEMBER_ADD_NUMERIC(Type, Base, ...)
 Encapsulate the gyrations required to define a Numeric-typed field and its associated field_info_for_type within a Bitpack.
#define BITPACK_MEMBER_ADD_BOOL(Type, BitIndex, ...)
 Define a new type wrapper around bool for a 1-bit field at a given BitIndex.

Detailed Description

Macro Definition Documentation

◆ BITPACK_MEMBER_ADD

#define BITPACK_MEMBER_ADD ( name,
Type,
... )
Value:
template<typename Self> \
constexpr auto name(this Self &&self) \
{ \
return self.template member<Type __VA_OPT__(, {__VA_ARGS__})>(); \
}

Define a named accessor for a field.

Takes the name of the accessor, the type to use for the proxy, and the fields of the FieldInfo (as varargs). If the latter is omitted, this defines an alias for a field whose type is sufficient to resolve the FieldInfo through field_info_for_type.

Definition at line 949 of file bitpack.hh.

◆ BITPACK_MEMBER_ADD_BOOL

#define BITPACK_MEMBER_ADD_BOOL ( Type,
BitIndex,
... )
Value:
BITPACK_MEMBER_ADD_NUMERIC(Type, bool, BitIndex, BitIndex, __VA_ARGS__)
#define BITPACK_MEMBER_ADD_NUMERIC(Type, Base,...)
Encapsulate the gyrations required to define a Numeric-typed field and its associated field_info_for_...
Definition bitpack.hh:1012

Define a new type wrapper around bool for a 1-bit field at a given BitIndex.

FieldInfo fields other than minIndex and maxIndex may be provided as additional arguments.

By contrast to BITPACK_MEMBER_ADD_ENUM_BOOL, the values introduced here are Type{false} and Type{true} rather than custom enumerators.

See BITPACK_MEMBER_ADD_NUMERIC, which this uses, for more details.

Definition at line 1036 of file bitpack.hh.

◆ BITPACK_MEMBER_ADD_ENUM

#define BITPACK_MEMBER_ADD_ENUM ( Type,
Base,
... )
Value:
enum class Type : Base; \
template<> \
constexpr FieldInfo field_info_for_type<Type>() \
{ \
constexpr auto info = FieldInfo{__VA_ARGS__}; \
static_assert(requires { Field<Type, info>(); }); \
return info; \
} \
enum class Type : Base

Encapsulate the gyrations required to define an enum class-typed field and its associated field_info_for_type within a Bitpack.

Takes the name of the enum class to define, its underlying type, and then the fields of a FieldInfo as varargs; the enumerators should follow the macro invocation, surrounded in curly braces and terminated with a semicolon.

Definition at line 963 of file bitpack.hh.

◆ BITPACK_MEMBER_ADD_ENUM_BOOL

#define BITPACK_MEMBER_ADD_ENUM_BOOL ( Type,
FalseVal,
TrueVal,
BitIndex,
... )
Value:
BITPACK_MEMBER_ADD_ENUM(Type, bool, BitIndex, BitIndex, __VA_ARGS__) \
{ \
FalseVal = false, TrueVal = true, \
}
#define BITPACK_MEMBER_ADD_ENUM(Type, Base,...)
Encapsulate the gyrations required to define an enum class-typed field and its associated field_info_...
Definition bitpack.hh:963

Define a new scoped enumeration type whose underlying type is bool, with the given false and true value names, at the given bit position.

FieldInfo fields other than minIndex and maxIndex may be provided as additional arguments.

Contrast BITPACK_MEMBER_ADD_BOOL, which does not introduce the custom enumerator values like our FalseVal and TrueVal.

See BITPACK_MEMBER_ADD_ENUM, which this uses, for more details.

Definition at line 986 of file bitpack.hh.

◆ BITPACK_MEMBER_ADD_ENUM_BOOL_CLEARED_ASSERTED

#define BITPACK_MEMBER_ADD_ENUM_BOOL_CLEARED_ASSERTED ( Type,
BitIndex,
... )
Value:
BITPACK_MEMBER_ADD_ENUM_BOOL(Type, Cleared, Asserted, BitIndex, __VA_ARGS__)
#define BITPACK_MEMBER_ADD_ENUM_BOOL(Type, FalseVal, TrueVal, BitIndex,...)
Define a new scoped enumeration type whose underlying type is bool, with the given false and true val...
Definition bitpack.hh:986

Define a new boolean scoped enumeration with values named "Cleared" (0) and "Asserted" (1) at the given bit index.

Definition at line 996 of file bitpack.hh.

◆ BITPACK_MEMBER_ADD_ENUM_BOOL_DISABLED_ENABLED

#define BITPACK_MEMBER_ADD_ENUM_BOOL_DISABLED_ENABLED ( Type,
BitIndex,
... )
Value:
BITPACK_MEMBER_ADD_ENUM_BOOL(Type, Disabled, Enabled, BitIndex, __VA_ARGS__)

Define a new boolean scoped enumeration with values named "Disabled" (0) and "Enabled" (1) at the given bit index.

Definition at line 1003 of file bitpack.hh.

◆ BITPACK_MEMBER_ADD_NUMERIC

#define BITPACK_MEMBER_ADD_NUMERIC ( Type,
Base,
... )
Value:
struct Type : Numeric<Base> \
{ \
using Numeric::Numeric; \
}; \
template<> \
constexpr FieldInfo field_info_for_type<Type>() \
{ \
constexpr auto info = FieldInfo{__VA_ARGS__}; \
static_assert(requires { Field<Type, info>(); }); \
return info; \
}

Encapsulate the gyrations required to define a Numeric-typed field and its associated field_info_for_type within a Bitpack.

Takes the name of the struct to define, the Numeric's underlying type, and then the fields of a FieldInfo as varargs.

Definition at line 1012 of file bitpack.hh.

◆ BITPACK_USUAL_PREFIX

#define BITPACK_USUAL_PREFIX
Value:
using Bitpack::operator=; \
template<typename FieldType> \
static constexpr FieldInfo field_info_for_type() = delete;
constexpr Bitpack()
Construct a Bitpack value with an underlying Storage of all zero bits.
Definition bitpack.hh:329

Capture the incantations often at the top of a Bitpack structure, especially one with type-directed field proxies.

Definition at line 935 of file bitpack.hh.