This is a base class for all Python extension types. More...

#include <utils.h>

Inheritance diagram for frepple::utils::PythonExtensionBase:

Public Member Functions

virtual PyObject * call (const PythonObject &args, const PythonObject &kwds)
 
virtual int compare (const PyObject *other) const
 
virtual PyObject * getattro (const Attribute &attr)
 
Py_ssize_t getReferenceCount () const
 
void initType (const MetaClass *t)
 
void initType (PyTypeObject *t)
 
virtual PyObject * iternext ()
 
 PythonExtensionBase ()
 
void resetReferenceCount ()
 
virtual int setattro (const Attribute &attr, const PythonObject &field)
 
virtual PyObject * str () const
 
virtual ~PythonExtensionBase ()
 

Static Protected Member Functions

static PythonTyperegisterPythonType (int, const type_info *)
 

Static Protected Attributes

static vector< PythonType * > table
 

Detailed Description

This is a base class for all Python extension types.

When creating you own extensions, inherit from the PythonExtension template class instead of this one.

It inherits from the PyObject C struct, defined in the Python C API.
These functions aren't called directly from Python. Python first calls a handler C-function and the handler function will use a virtual call to run the correct C++-method.

Our extensions don't use the usual Python heap allocator. They are created and initialized with the regular C++ new and delete. A special deallocator is called from Python to delete objects when their reference count reaches zero.

Definition at line 3196 of file utils.h.

Constructor & Destructor Documentation

frepple::utils::PythonExtensionBase::PythonExtensionBase ( )
inline

Default constructor

Definition at line 3200 of file utils.h.

virtual frepple::utils::PythonExtensionBase::~PythonExtensionBase ( )
inlinevirtual

Destructor.

Definition at line 3203 of file utils.h.

Member Function Documentation

virtual PyObject* frepple::utils::PythonExtensionBase::call ( const PythonObject args,
const PythonObject kwds 
)
inlinevirtual

Default call method.
Subclasses are expected to implement an override if the type supports calls.

Definition at line 3276 of file utils.h.

virtual int frepple::utils::PythonExtensionBase::compare ( const PyObject *  other) const
inlinevirtual
Py_ssize_t frepple::utils::PythonExtensionBase::getReferenceCount ( ) const
inline

Returns the current reference count.

Definition at line 3219 of file utils.h.

void frepple::utils::PythonExtensionBase::initType ( const MetaClass t)
inline

Initialize the object to a certain Python type.

Definition at line 3222 of file utils.h.

void frepple::utils::PythonExtensionBase::initType ( PyTypeObject *  t)
inline

Initialize the object to a certain Python type.

Definition at line 3228 of file utils.h.

virtual PyObject* frepple::utils::PythonExtensionBase::iternext ( )
inlinevirtual

Default iternext method.
Subclasses are expected to implement an override if the type supports iteration.

Definition at line 3266 of file utils.h.

PythonType * frepple::utils::PythonExtensionBase::registerPythonType ( int  size,
const type_info *  t 
)
staticprotected

Definition at line 473 of file pythonutils.cpp.

void frepple::utils::PythonExtensionBase::resetReferenceCount ( )
inline

A function to force an object to be destroyed by the Python garbage collection.
Be very careful to use this!

Definition at line 3216 of file utils.h.

Member Data Documentation

vector< PythonType * > frepple::utils::PythonExtensionBase::table
staticprotected

Definition at line 3293 of file utils.h.


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