CPyInterface Class Reference

#include <cpython_ref.h>

Inheritance diagram for CPyInterface:

详细描述

Interface class for CPyRefs which removes the need for manual reference counting. The internally stored PyObject can be disconnected from this wrapper class by calling CPyInterface::Disconnect .

@MAXON_ANNOTATION{refclass=false}

公共成员函数

MAXON_METHOD void  Init (const CPythonLibraryInterface *lib, REFTYPE refType, NativePyObject *pyObject)
MAXON_METHOD void  Incref ()
MAXON_METHOD void  Decref ()
MAXON_METHOD Int64   GetRefCount ()
const MAXON_METHOD CPythonLibraryInterface GetLibrary () const
MAXON_METHOD CPyTypeRef   GetTypeRef () const
MAXON_METHOD NativePyObject GetPyObject () const
MAXON_METHOD NativePyObject Disconnect ()
template<typename T = NativePyObject>
MAXON_FUNCTION T *  Get () const
template<typename T = NativePyObject>
MAXON_FUNCTION T *  GetAndIncref ()

静态公共成员函数

static MAXON_FUNCTION CPyRef   CreateRef27 (const CPythonLibraryInterface *lib, REFTYPE refType, NativePyObject *pyObject)
static MAXON_FUNCTION CPyRef   CreateRef36 (const CPythonLibraryInterface *lib, REFTYPE refType, NativePyObject *pyObject)
static MAXON_FUNCTION CPyRef   CreateRef (const CPythonLibraryInterface *lib, REFTYPE refType, NativePyObject *pyObject)
static MAXON_FUNCTION CPyConstRef   CreateConstRef (const CPythonLibraryInterface *lib, REFTYPE refType, NativePyObject *pyObject)
static MAXON_FUNCTION CPyTempRef   CreateTempRef (const CPythonLibraryInterface *lib, NativePyObject *pyObject)

私有成员函数

  MAXON_INTERFACE ( CPyInterface , MAXON_REFERENCE_NORMAL , "net.maxon.python.interface.cpyref")

成员函数文档编制

◆  MAXON_INTERFACE()

MAXON_INTERFACE ( CPyInterface   ,
MAXON_REFERENCE_NORMAL   ,
"net.maxon.python.interface.cpyref"   
)
private

◆  CreateRef27()

static MAXON_FUNCTION CPyRef CreateRef27 ( const CPythonLibraryInterface lib ,
REFTYPE   refType ,
NativePyObject pyObject  
)
static

Creates a CPyRef reference by a given NativePyObject from a Python 2.7 virtual machine. GIL must be held.

参数
[in] lib The NativePyObject 's library origin.
[in] refType Ref count handler information.
返回
Returns a new wrapper reference.

◆  CreateRef36()

static MAXON_FUNCTION CPyRef CreateRef36 ( const CPythonLibraryInterface lib ,
REFTYPE   refType ,
NativePyObject pyObject  
)
static

Creates a CPyRef reference by a given NativePyObject from a Python 3.6 virtual machine. GIL must be held.

参数
[in] lib The NativePyObject 's library origin.
[in] refType Ref count handler information.
返回
Returns a new wrapper reference.

◆  CreateRef()

static MAXON_FUNCTION CPyRef CreateRef ( const CPythonLibraryInterface lib ,
REFTYPE   refType ,
NativePyObject pyObject  
)
static

Creates a CPyRef reference by a given NativePyObject . GIL must be held. The library version is detected by using the library, is slightly slower than CreateRef27 or CreateRef36.

参数
[in] lib The NativePyObject 's library origin.
[in] refType Ref count handler information.
返回
Returns a new wrapper reference.

◆  CreateConstRef()

static MAXON_FUNCTION CPyConstRef CreateConstRef ( const CPythonLibraryInterface lib ,
REFTYPE   refType ,
NativePyObject pyObject  
)
static

Creates a immutable CPyConstRef reference by a given NativePyObject . GIL must be held.

参数
[in] lib The NativePyObject 's library origin.
[in] refType Ref count handler information.
返回
Returns a new wrapper reference.

◆  CreateTempRef()

static MAXON_FUNCTION CPyTempRef CreateTempRef ( const CPythonLibraryInterface lib ,
NativePyObject pyObject  
)
static

Creates a temporary CPyTempRef reference by a given NativePyObject . GIL must be held.

参数
[in] lib The NativePyObject 's library origin.
返回
Returns a new wrapper reference.

◆  Init()

MAXON_METHOD void Init ( const CPythonLibraryInterface lib ,
REFTYPE   refType ,
NativePyObject pyObject  
)

Initializes the wrapper reference. GIL must be held.

参数
[in] lib The NativePyObject 's library origin.
[in] refType Ref count handler information.

◆  Incref()

MAXON_METHOD void Incref ( )

Increments the reference count. Instance must be already initialized. GIL must be held.

◆  Decref()

MAXON_METHOD void Decref ( )

Decrements the reference count. Instance must be already initialized. GIL must be held.

◆  GetRefCount()

MAXON_METHOD Int64 GetRefCount ( )

Decrements the reference count. Instance must be already initialized. GIL must be held.

返回
Reference count.

◆  GetLibrary()

const MAXON_METHOD CPythonLibraryInterface * GetLibrary ( ) const

Returns the library pointer with which the instance got initialized.

◆  GetTypeRef()

MAXON_METHOD CPyTypeRef GetTypeRef ( ) const

Returns the type object of the wrapped NativePyObject . GIL must be held.

返回
Type reference.

◆  GetPyObject()

MAXON_METHOD NativePyObject * GetPyObject ( ) const

Returns the internal NativePyObject with which the instance got initialized. No reference count change is performed.

返回
Internal NativePyObject

◆  Disconnect()

MAXON_METHOD NativePyObject * Disconnect ( )

Returns the internal NativePyObject with which the instance got initialized. Objects reference count needs to be decremented if not used anymore. The wrapper reference becomes invalid, no other function should be called, and it should be deleted soon as possible. GIL must be held.

返回
Internal NativePyObject

◆  Get()

MAXON_FUNCTION T* Get ( ) const

Returns the internal NativePyObject cast to a target type. GIL must be held. No check is performed if the cast is valid or not. No reference count change is performed.

返回
Internal NativePyObject casted.

◆  GetAndIncref()

MAXON_FUNCTION T* GetAndIncref ( )

Returns the internal NativePyObject cast to a target type. No check is performed if the cast is valid or not. Reference count is incremented before function returns. The wrapper reference stays valid. GIL must be held.

返回
Internal NativePyObject casted.