MLIR  17.0.0git
Public Member Functions | Protected Attributes | List of all members
mlir::python::adaptors::pure_subclass Class Reference

Provides a facility like py::class_ for defining a new class in a scope, but this allows extension of an arbitrary Python class, defining methods on it is a similar way. More...

#include "mlir/Bindings/Python/PybindAdaptors.h"

+ Inheritance diagram for mlir::python::adaptors::pure_subclass:
+ Collaboration diagram for mlir::python::adaptors::pure_subclass:

Public Member Functions

 pure_subclass (py::handle scope, const char *derivedClassName, const py::object &superClass)
 
template<typename Func , typename... Extra>
pure_subclassdef (const char *name, Func &&f, const Extra &...extra)
 
template<typename Func , typename... Extra>
pure_subclassdef_property_readonly (const char *name, Func &&f, const Extra &...extra)
 
template<typename Func , typename... Extra>
pure_subclassdef_staticmethod (const char *name, Func &&f, const Extra &...extra)
 
template<typename Func , typename... Extra>
pure_subclassdef_classmethod (const char *name, Func &&f, const Extra &...extra)
 
py::object get_class () const
 

Protected Attributes

py::object superClass
 
py::object thisClass
 

Detailed Description

Provides a facility like py::class_ for defining a new class in a scope, but this allows extension of an arbitrary Python class, defining methods on it is a similar way.

Classes defined in this way are very similar to if defined in Python in the usual way but use Pybind11 machinery to do it. These are not "real" Pybind11 classes but pure Python classes with no relation to a concrete C++ class.

Derived from a discussion upstream: https://github.com/pybind/pybind11/issues/1193 (plus a fair amount of extra curricular poking) TODO: If this proves useful, see about including it in pybind11.

Definition at line 276 of file PybindAdaptors.h.

Constructor & Destructor Documentation

◆ pure_subclass()

mlir::python::adaptors::pure_subclass::pure_subclass ( py::handle  scope,
const char *  derivedClassName,
const py::object &  superClass 
)
inline

Definition at line 278 of file PybindAdaptors.h.

References superClass, and thisClass.

Member Function Documentation

◆ def()

template<typename Func , typename... Extra>
pure_subclass& mlir::python::adaptors::pure_subclass::def ( const char *  name,
Func &&  f,
const Extra &...  extra 
)
inline

Definition at line 291 of file PybindAdaptors.h.

References thisClass.

◆ def_classmethod()

template<typename Func , typename... Extra>
pure_subclass& mlir::python::adaptors::pure_subclass::def_classmethod ( const char *  name,
Func &&  f,
const Extra &...  extra 
)
inline

Definition at line 325 of file PybindAdaptors.h.

References thisClass.

Referenced by populateDialectSparseTensorSubmodule().

◆ def_property_readonly()

template<typename Func , typename... Extra>
pure_subclass& mlir::python::adaptors::pure_subclass::def_property_readonly ( const char *  name,
Func &&  f,
const Extra &...  extra 
)
inline

Definition at line 300 of file PybindAdaptors.h.

References thisClass.

◆ def_staticmethod()

template<typename Func , typename... Extra>
pure_subclass& mlir::python::adaptors::pure_subclass::def_staticmethod ( const char *  name,
Func &&  f,
const Extra &...  extra 
)
inline

◆ get_class()

py::object mlir::python::adaptors::pure_subclass::get_class ( ) const
inline

Definition at line 338 of file PybindAdaptors.h.

References thisClass.

Member Data Documentation

◆ superClass

py::object mlir::python::adaptors::pure_subclass::superClass
protected

Definition at line 341 of file PybindAdaptors.h.

Referenced by pure_subclass().

◆ thisClass

py::object mlir::python::adaptors::pure_subclass::thisClass
protected

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