frepple::utils::PythonExtensionBase Class Reference

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

#include <utils.h>

Inheritance diagram for frepple::utils::PythonExtensionBase:

List of all members.

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)
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 2980 of file utils.h.


Constructor & Destructor Documentation

frepple::utils::PythonExtensionBase::PythonExtensionBase ( ) [inline]

Default constructor

Definition at line 2984 of file utils.h.

virtual frepple::utils::PythonExtensionBase::~PythonExtensionBase ( ) [inline, virtual]

Destructor.

Definition at line 2987 of file utils.h.


Member Function Documentation

virtual PyObject* frepple::utils::PythonExtensionBase::call ( const PythonObject args,
const PythonObject kwds 
) [inline, virtual]

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

Definition at line 3057 of file utils.h.

virtual int frepple::utils::PythonExtensionBase::compare ( const PyObject *  other) const [inline, virtual]
void frepple::utils::PythonExtensionBase::initType ( const MetaClass t) [inline]

Initialize the object to a certain Python type.

Definition at line 3002 of file utils.h.

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

Initialize the object to a certain Python type.

Definition at line 3008 of file utils.h.

virtual PyObject* frepple::utils::PythonExtensionBase::iternext ( ) [inline, virtual]

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

Definition at line 3047 of file utils.h.

PythonType * frepple::utils::PythonExtensionBase::registerPythonType ( int  size,
const type_info *  t 
) [static, protected]

Definition at line 442 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 2999 of file utils.h.


Member Data Documentation

vector< PythonType * > frepple::utils::PythonExtensionBase::table [static, protected]

Definition at line 3074 of file utils.h.


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

Documentation generated for frePPLe by  doxygen