Library of Assembled Shared Sources
lass::python::EnumDefinitionBase Class Referenceabstract

Base class of all enum definitions. More...

#include <enum_definition.h>

Inheritance diagram for lass::python::EnumDefinitionBase:

Public Member Functions

const char * name () const
 The name of the Python enum type.
 
const char * doc () const
 Optional docstring for the Python enum type.
 
PyObject * type () const
 The Python enum type object, after freezeDefinition() has been called.
 
PyObject * freezeDefinition (const char *moduleName, const char *scopeName)
 Freeze the enum definition and create the Python enum type.
 

Protected Member Functions

 EnumDefinitionBase (const char *name)
 Construct enum definition with name only.
 
 EnumDefinitionBase (const char *name, const char *doc)
 Construct enum definition with name and documentation.
 
TPyObjPtr valueObject (PyObject *obj) const
 Returns the value of an enum instances as a Python object.
 

Detailed Description

Base class of all enum definitions.

If you define your own custom enum definition, you must derive from this class so that you can add your enum to a module or class with PY_MODULE_ENUM() or PY_CLASS_ENUM().

This class is typically not used directly by user code. Use the provided IntEnumDefinition, StrEnumDefinition, IntFlagDefinition, or EnumDefinition template classes instead.

Definition at line 219 of file enum_definition.h.

Constructor & Destructor Documentation

◆ EnumDefinitionBase() [1/2]

◆ EnumDefinitionBase() [2/2]

lass::python::EnumDefinitionBase::EnumDefinitionBase ( const char * name,
const char * doc )
protected

Construct enum definition with name and documentation.

Parameters
namePython class name for the enum type (must have static storage duration)
docOptional docstring for the Python enum type (must have static storage duration, or nullptr)

Definition at line 205 of file enum_definition.cpp.

References doc(), and name().

Member Function Documentation

◆ freezeDefinition()

PyObject * lass::python::EnumDefinitionBase::freezeDefinition ( const char * moduleName,
const char * scopeName )

Freeze the enum definition and create the Python enum type.

Note
This method should not be called directly. Instead, use PY_MODULE_ENUM() or PY_CLASS_ENUM() to add the enum to a module or class, which will call this method at the appropriate time.

Definition at line 247 of file enum_definition.cpp.

◆ valueObject()

TPyObjPtr lass::python::EnumDefinitionBase::valueObject ( PyObject * obj) const
protected

Returns the value of an enum instances as a Python object.

If the object is not an instance of this enum type, a Python exception will be set and a null pointer will be returned.

Definition at line 230 of file enum_definition.cpp.

Referenced by lass::python::EnumDefinition< EnumType, ValueType >::get(), and lass::python::IntEnumDefinition< EnumType >::get().


The documentation for this class was generated from the following files: