welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
welder::rods::pybind11::rod< DocStyle >::enum_handle< E > Struct Template Reference

Owning handle for a py::native_enum<E>, plus the scope + name to reach the finalized enum object. More...

#include <welder/rods/python/pybind11/rod.hpp>

Public Member Functions

void value (const char *n, E v)
 Add enumerator n = v to the pending native enum.
void export_values ()
 Export the enumerators into the enclosing scope (unscoped enums).
void finalize ()
 Commit the enum onto scope as name, and stamp the pybind11-stubgen native-enum marker.

Public Attributes

py::object scope
 the enclosing scope: a (sub)module, or — for a nested enum — the enclosing class handle
const char * name
 the enum's Python name
std::unique_ptr< py::native_enum< E > > impl
 the (move-only) native enum

Detailed Description

template<::welder::doc_style DocStyle = ::welder::rods::python::google_style>
template<class E>
struct welder::rods::pybind11::rod< DocStyle >::enum_handle< E >

Owning handle for a py::native_enum<E>, plus the scope + name to reach the finalized enum object.

native_enum binds Python's stdlib enum.IntEnum, so enumerators are int-convertible (int(E.Value)) and compare against ints — matching pybind11's legacy py::enum_ default and the nanobind backend's nb::is_arithmetic(). We use native_enum because plain py::enum_ is discouraged as of pybind11 3.0.

native_enum is move-only and must be explicitly .finalize()d, so it is wrapped here in a movable handle the shared bind_enum driver can hold by value, drive via value()/export_values(), and finalize at the end.

Definition at line 521 of file rod.hpp.

Member Function Documentation

◆ export_values()

template<::welder::doc_style DocStyle = ::welder::rods::python::google_style>
template<class E>
void welder::rods::pybind11::rod< DocStyle >::enum_handle< E >::export_values ( )
inline

Export the enumerators into the enclosing scope (unscoped enums).

Definition at line 532 of file rod.hpp.

References impl.

◆ finalize()

template<::welder::doc_style DocStyle = ::welder::rods::python::google_style>
template<class E>
void welder::rods::pybind11::rod< DocStyle >::enum_handle< E >::finalize ( )
inline

Commit the enum onto scope as name, and stamp the pybind11-stubgen native-enum marker.

Definition at line 536 of file rod.hpp.

References impl, name, and scope.

◆ value()

template<::welder::doc_style DocStyle = ::welder::rods::python::google_style>
template<class E>
void welder::rods::pybind11::rod< DocStyle >::enum_handle< E >::value ( const char * n,
E v )
inline

Add enumerator n = v to the pending native enum.

Parameters
nthe enumerator's Python name.
vthe enumerator value.

Definition at line 530 of file rod.hpp.

References impl.

Member Data Documentation

◆ impl

template<::welder::doc_style DocStyle = ::welder::rods::python::google_style>
template<class E>
std::unique_ptr<py::native_enum<E> > welder::rods::pybind11::rod< DocStyle >::enum_handle< E >::impl

the (move-only) native enum

Definition at line 525 of file rod.hpp.

Referenced by export_values(), finalize(), and value().

◆ name

template<::welder::doc_style DocStyle = ::welder::rods::python::google_style>
template<class E>
const char* welder::rods::pybind11::rod< DocStyle >::enum_handle< E >::name

the enum's Python name

Definition at line 524 of file rod.hpp.

Referenced by finalize().

◆ scope

template<::welder::doc_style DocStyle = ::welder::rods::python::google_style>
template<class E>
py::object welder::rods::pybind11::rod< DocStyle >::enum_handle< E >::scope

the enclosing scope: a (sub)module, or — for a nested enum — the enclosing class handle

Definition at line 522 of file rod.hpp.

Referenced by finalize().


The documentation for this struct was generated from the following file:
  • src/welder/rods/python/pybind11/rod.hpp