MLIR 22.0.0git
mlir::python::PyObjectRef< T > Class Template Reference

Template for a reference to a concrete type which captures a python reference to its underlying python object. More...

#include "Bindings/Python/IRModule.h"

Inheritance diagram for mlir::python::PyObjectRef< T >:

Public Types

using NBTypedT = nanobind::typed<nanobind::object, T>

Public Member Functions

 PyObjectRef (T *referrent, nanobind::object object)
 PyObjectRef (PyObjectRef &&other) noexcept
 PyObjectRef (const PyObjectRef &other)
 ~PyObjectRef ()=default
int getRefCount ()
nanobind::object releaseObject ()
 Releases the object held by this instance, returning it.
T * get ()
T * operator-> ()
nanobind::object getObject ()
 operator bool () const

Detailed Description

template<typename T>
class mlir::python::PyObjectRef< T >

Template for a reference to a concrete type which captures a python reference to its underlying python object.

Definition at line 53 of file IRModule.h.

Member Typedef Documentation

◆ NBTypedT

template<typename T>
using mlir::python::PyObjectRef< T >::NBTypedT = nanobind::typed<nanobind::object, T>

Definition at line 97 of file IRModule.h.

Constructor & Destructor Documentation

◆ PyObjectRef() [1/3]

template<typename T>
mlir::python::PyObjectRef< T >::PyObjectRef ( T * referrent,
nanobind::object object )
inline

Definition at line 55 of file IRModule.h.

◆ PyObjectRef() [2/3]

template<typename T>
mlir::python::PyObjectRef< T >::PyObjectRef ( PyObjectRef< T > && other)
inlinenoexcept

Definition at line 61 of file IRModule.h.

◆ PyObjectRef() [3/3]

template<typename T>
mlir::python::PyObjectRef< T >::PyObjectRef ( const PyObjectRef< T > & other)
inline

Definition at line 66 of file IRModule.h.

◆ ~PyObjectRef()

template<typename T>
mlir::python::PyObjectRef< T >::~PyObjectRef ( )
default

Member Function Documentation

◆ get()

template<typename T>
T * mlir::python::PyObjectRef< T >::get ( )
inline

Definition at line 86 of file IRModule.h.

Referenced by maybeInsertOperation().

◆ getObject()

template<typename T>
nanobind::object mlir::python::PyObjectRef< T >::getObject ( )
inline

Definition at line 91 of file IRModule.h.

Referenced by mlir::python::PyOperation::create().

◆ getRefCount()

template<typename T>
int mlir::python::PyObjectRef< T >::getRefCount ( )
inline

Definition at line 70 of file IRModule.h.

◆ operator bool()

template<typename T>
mlir::python::PyObjectRef< T >::operator bool ( ) const
inline

Definition at line 95 of file IRModule.h.

◆ operator->()

template<typename T>
T * mlir::python::PyObjectRef< T >::operator-> ( )
inline

Definition at line 87 of file IRModule.h.

◆ releaseObject()

template<typename T>
nanobind::object mlir::python::PyObjectRef< T >::releaseObject ( )
inline

Releases the object held by this instance, returning it.

This is the proper thing to return from a function that wants to return the reference. Note that this does not work from initializers.

Definition at line 79 of file IRModule.h.

Referenced by mlir::python::PyMlirContext::createFromCapsule(), mlir::python::PyModule::createFromCapsule(), and mlir::python::PyOperation::createFromCapsule().


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