Export values and nested types as attributes on the Python class itself.
Unlike properties which install descriptors that get or set member data from or on instances, these attributes are set directly on the Python type object when the class is frozen and are immutable. In Python, they are reached as Foo.CONSTANT or Outer.Inner, without an instance.
Nested enums work the same way, but are exported with PY_CLASS_ENUM(), which is documented in Enum Definitions.
Static Constants | |
These macros allow you to expose compile-time constant values as static attributes of Python classes. The values are converted to Python objects using PyExportTraits and become accessible as class-level attributes in Python. | |
| #define | PY_CLASS_STATIC_CONST(i_cppClass, s_name, v_value) |
| Export a static constant value as a class attribute. | |
Inner Classes | |||||||||||||||||||||
Macros for adding inner classes (nested classes) to Python-exported classes. These macros establish class relationships where inner classes become attributes of their outer class in Python. The basic form is PY_CLASS_INNER_CLASS( i_outerCppClass, i_innerCppClass )
#define PY_CLASS_INNER_CLASS(i_outerCppClass, i_innerCppClass) Exports an inner class with default name and no documentation. Definition pyobject_macros.h:4201 with:
The
| |||||||||||||||||||||
| #define | PY_CLASS_INNER_CLASS_EX(t_outerCppClass, t_innerCppClass, s_name, s_doc, i_uniqueSuffix) | ||||||||||||||||||||
| Exports an inner class with full customization of name, documentation, and symbol suffix. | |||||||||||||||||||||
| #define | PY_CLASS_INNER_CLASS_NAME_DOC(i_outerCppClass, i_innerCppClass, s_name, s_doc) | ||||||||||||||||||||
| Exports an inner class with custom name and documentation. | |||||||||||||||||||||
| #define | PY_CLASS_INNER_CLASS_NAME(i_outerCppClass, i_innerCppClass, s_name) | ||||||||||||||||||||
| Exports an inner class with custom name but no documentation. | |||||||||||||||||||||
| #define | PY_CLASS_INNER_CLASS_DOC(i_outerCppClass, i_innerCppClass, s_doc) | ||||||||||||||||||||
| Exports an inner class with default name and custom documentation. | |||||||||||||||||||||
| #define | PY_CLASS_INNER_CLASS(i_outerCppClass, i_innerCppClass) | ||||||||||||||||||||
| Exports an inner class with default name and no documentation. | |||||||||||||||||||||
| #define PY_CLASS_STATIC_CONST | ( | i_cppClass, | |
| s_name, | |||
| v_value ) |
Export a static constant value as a class attribute.
Adds a static constant to a Python class that can be accessed as a class attribute. The constant value is converted to a Python object at module initialization time and becomes accessible via the class in Python.
| i_cppClass | Python binding class identifier (must be declared with PY_DECLARE_CLASS_*) |
| s_name | Name of the constant as it will appear in Python (string literal) |
| v_value | The constant value to export (must be convertible via PyExportTraits::build) |
Definition at line 4030 of file pyobject_macros.h.
| #define PY_CLASS_INNER_CLASS_EX | ( | t_outerCppClass, | |
| t_innerCppClass, | |||
| s_name, | |||
| s_doc, | |||
| i_uniqueSuffix ) |
Exports an inner class with full customization of name, documentation, and symbol suffix.
This is the most flexible inner class macro, allowing complete control over all parameters. The inner class becomes accessible as an attribute of the outer class in Python. In contrast to the convenience macros, here you can provide fully qualified typenames, at the cost of having to provide a unique suffix.
| t_outerCppClass | C++ class that will contain the inner class |
| t_innerCppClass | C++ class to be exported as inner class |
| s_name | Python name for the inner class (null-terminated C string literal) |
| s_doc | Python docstring for the inner class (null-terminated C string literal, deprecated: should be nullptr) |
| i_uniqueSuffix | Unique C++ identifier to generate unique symbols for the registration code. This prevents symbol collisions when multiple inner class exports exist. |
Definition at line 4119 of file pyobject_macros.h.
| #define PY_CLASS_INNER_CLASS_NAME_DOC | ( | i_outerCppClass, | |
| i_innerCppClass, | |||
| s_name, | |||
| s_doc ) |
Exports an inner class with custom name and documentation.
Convenience macro that automatically generates a unique suffix from the class names. Provides full control over the Python name and documentation string.
| i_outerCppClass | C++ class that will contain the inner class (unqualified name) |
| i_innerCppClass | C++ class to be exported as inner class (unqualified name) |
| s_name | Python name for the inner class (null-terminated C string literal) |
| s_doc | Python docstring for the inner class (null-terminated C string literal, may be nullptr) |
Definition at line 4144 of file pyobject_macros.h.
| #define PY_CLASS_INNER_CLASS_NAME | ( | i_outerCppClass, | |
| i_innerCppClass, | |||
| s_name ) |
Exports an inner class with custom name but no documentation.
Convenience macro for cases where you want to customize the Python name, but don't need to provide additional documentation.
| i_outerCppClass | C++ class that will contain the inner class (unqualified name) |
| i_innerCppClass | C++ class to be exported as inner class (unqualified name) |
| s_name | Python name for the inner class (null-terminated C string literal) |
Definition at line 4163 of file pyobject_macros.h.
| #define PY_CLASS_INNER_CLASS_DOC | ( | i_outerCppClass, | |
| i_innerCppClass, | |||
| s_doc ) |
Exports an inner class with default name and custom documentation.
The inner class will use its C++ class name as the Python name, but allows you to provide custom documentation.
| i_outerCppClass | C++ class that will contain the inner class (unqualified name) |
| i_innerCppClass | C++ class to be exported as inner class (unqualified name) |
| s_doc | Python docstring for the inner class (null-terminated C string literal) |
Definition at line 4184 of file pyobject_macros.h.
| #define PY_CLASS_INNER_CLASS | ( | i_outerCppClass, | |
| i_innerCppClass ) |
Exports an inner class with default name and no documentation.
The simplest inner class export macro. Uses the C++ class name as the Python name and doesn't provide additional documentation beyond what was set during class declaration.
| i_outerCppClass | C++ class that will contain the inner class (unqualified name) |
| i_innerCppClass | C++ class to be exported as inner class (unqualified name) |
Definition at line 4201 of file pyobject_macros.h.