frepple::utils::PythonType Class Reference

This class is a wrapper around the type information in Python. More...

#include <utils.h>

Inheritance diagram for frepple::utils::PythonType:
frepple::utils::NonCopyable

List of all members.

Public Types

typedef PyObject *(* createfunc )(PyTypeObject *, PyObject *, PyObject *)

Public Member Functions

void addMethod (const char *, PyCFunctionWithKeywords, int, const char *)
void addMethod (const char *, PyCFunction, int, const char *)
bool operator== (const type_info &i) const
bool operator== (const PythonType &i) const
 PythonType (size_t base_size, const type_info *)
void setBase (PythonType &b)
void setDoc (const string n)
void setName (const string n)
void supportcall ()
void supportcompare ()
void supportcreate (createfunc c)
void supportdealloc (void(*f)(PyObject *))
void supportgetattro ()
void supportiter ()
void supportsetattro ()
void supportstr ()
PyTypeObject * type_object () const
int typeReady (PyObject *m)

Static Public Member Functions

static void evalException ()

Detailed Description

This class is a wrapper around the type information in Python.

In the Python C API this is represented by the PyTypeObject structure. This class defines a number of convenience functions to update and maintain the type information.

Definition at line 804 of file utils.h.


Member Typedef Documentation

typedef PyObject*(* frepple::utils::PythonType::createfunc)(PyTypeObject *, PyObject *, PyObject *)

Type definition for create functions.

Definition at line 916 of file utils.h.


Constructor & Destructor Documentation

frepple::utils::PythonType::PythonType ( size_t  base_size,
const type_info *  tp 
)

Constructor, sets the tp_base_size member.

Definition at line 444 of file pythonutils.cpp.


Member Function Documentation

void frepple::utils::PythonType::addMethod ( const char *  c,
PyCFunctionWithKeywords  f,
int  i,
const char *  d 
)

Add a new method.

Definition at line 470 of file pythonutils.cpp.

void frepple::utils::PythonType::addMethod ( const char *  method_name,
PyCFunction  f,
int  flags,
const char *  doc 
)

Add a new method.

Definition at line 454 of file pythonutils.cpp.

void frepple::utils::PythonType::evalException (  )  [static]

A static function that evaluates an exception and sets the Python error string properly.
This function should only be called from within a catch-block, since internally it rethrows the exception!

Definition at line 498 of file pythonutils.cpp.

bool frepple::utils::PythonType::operator== ( const type_info &  i  )  const [inline]

Comparison operator.

Definition at line 933 of file utils.h.

bool frepple::utils::PythonType::operator== ( const PythonType i  )  const [inline]

Comparison operator.

Definition at line 927 of file utils.h.

void frepple::utils::PythonType::setBase ( PythonType b  )  [inline]

Updates tp_base.

Definition at line 853 of file utils.h.

void frepple::utils::PythonType::setDoc ( const string  n  )  [inline]

Updates tp_doc.

Definition at line 846 of file utils.h.

void frepple::utils::PythonType::setName ( const string  n  )  [inline]

Updates tp_name.

Definition at line 839 of file utils.h.

void frepple::utils::PythonType::supportcall (  )  [inline]

Updates tp_call.
The extension class will need to define a member function with this prototype:
PyObject* call(const PythonObject& args, const PythonObject& kwds)

Definition at line 904 of file utils.h.

void frepple::utils::PythonType::supportcompare (  )  [inline]

Updates tp_compare.
The extension class will need to define a member function with this prototype:
int compare(const PythonObject& other)

Definition at line 885 of file utils.h.

void frepple::utils::PythonType::supportcreate ( createfunc  c  )  [inline]

Updates tp_new with the function passed as argument.

Definition at line 919 of file utils.h.

void frepple::utils::PythonType::supportdealloc ( void(*)(PyObject *)  f  )  [inline]

Updates the deallocator.

Definition at line 859 of file utils.h.

void frepple::utils::PythonType::supportgetattro (  )  [inline]

Updates tp_getattro.
The extension class will need to define a member function with this prototype:
PythonObject getattro(const XMLElement& name)

Definition at line 869 of file utils.h.

void frepple::utils::PythonType::supportiter (  )  [inline]

Updates tp_iter and tp_iternext.
The extension class will need to define a member function with this prototype:
PyObject* iternext()

Definition at line 893 of file utils.h.

void frepple::utils::PythonType::supportsetattro (  )  [inline]

Updates tp_setattro.
The extension class will need to define a member function with this prototype:
int setattro(const Attribute& attr, const PythonObject& field)

Definition at line 877 of file utils.h.

void frepple::utils::PythonType::supportstr (  )  [inline]

Updates tp_str.
The extension class will need to define a member function with this prototype:
PyObject* str()

Definition at line 912 of file utils.h.

PyTypeObject* frepple::utils::PythonType::type_object (  )  const [inline]

Return a pointer to the actual Python PyTypeObject.

Definition at line 830 of file utils.h.

int frepple::utils::PythonType::typeReady ( PyObject *  m  ) 

This method needs to be called after the type information has all been updated. It adds the type to the module that is passed as argument.

Definition at line 476 of file pythonutils.cpp.


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

Generated on 25 Feb 2010 for frePPLe by  doxygen 1.6.1