#include <cpython_ref.h>
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}
Public Member Functions | |
MAXON_METHOD void | Init (const CPythonLibraryInterface *lib, REFTYPE refType, NativePyObject *pyObject) |
MAXON_METHOD void | Incref () |
MAXON_METHOD void | Decref () |
MAXON_METHOD Int64 | GetRefCount () |
MAXON_METHOD const 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 Public Member Functions | |
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) |
Private Member Functions | |
MAXON_INTERFACE (CPyInterface, MAXON_REFERENCE_NORMAL, "net.maxon.python.interface.cpyref") | |
|
private |
|
static |
Creates a CPyRef reference by a given NativePyObject. GIL must be held.
[in] | lib | The NativePyObject's library origin. |
[in] | refType | Ref count handler information. |
|
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. |
|
static |
Creates a temporary CPyTempRef reference by a given NativePyObject. GIL must be held.
[in] | lib | The NativePyObject's library origin. |
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. |
MAXON_METHOD void Incref | ( | ) |
Increments the reference count. Instance must be already initialized. GIL must be held.
MAXON_METHOD void Decref | ( | ) |
Decrements the reference count. Instance must be already initialized. GIL must be held.
MAXON_METHOD Int64 GetRefCount | ( | ) |
Decrements the reference count. Instance must be already initialized. GIL must be held.
MAXON_METHOD const CPythonLibraryInterface* GetLibrary | ( | ) | const |
Returns the library pointer with which the instance got initialized.
MAXON_METHOD CPyTypeRef GetTypeRef | ( | ) | const |
Returns the type object of the wrapped NativePyObject. GIL must be held.
MAXON_METHOD NativePyObject* GetPyObject | ( | ) | const |
Returns the internal NativePyObject with which the instance got initialized. No reference count change is performed.
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.
MAXON_FUNCTION T* Get | ( | void | ) | 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.
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.