PyBufferFactory.cxx File Reference

#include "PyROOT.h"
#include "PyBufferFactory.h"
#include <map>

Go to the source code of this file.

Defines

#define PYROOT_PREPARE_PYBUFFER_TYPE(name)
#define PYROOT_IMPLEMENT_PYBUFFER_METHODS(name, type, stype, F1, F2)
#define PYROOT_INSTALL_PYBUFFER_METHODS(name, type)
#define PYROOT_IMPLEMENT_PYBUFFER_FROM_MEMORY(name, type)

Functions

Py_ssize_t buffer_length (PyObject *self)
const char * buffer_get (PyObject *self, int idx)
int pyroot_buffer_ass_subscript (PyObject *self, PyObject *idx, PyObject *val)
PyObjectbuffer_setsize (PyObject *self, PyObject *pynlen)
PyObjectbuf_typecode (PyObject *pyobject, void *)

Variables

char * sizeCallback = const_cast< char* >( "_size" )
PyObjectsizeCallbackString_ = PyROOT_PyUnicode_FromString( sizeCallback )
std::map< PyObject *, PyObject * > gSizeCallbacks
PyGetSetDef buffer_getset []
PyMethodDef buffer_methods []


Define Documentation

#define PYROOT_IMPLEMENT_PYBUFFER_FROM_MEMORY ( name,
type   ) 

Value:

PyObject* PyROOT::TPyBufferFactory::PyBuffer_FromMemory( type* address, Py_ssize_t size )\
{                                                                               \
   size = size < 0 ? INT_MAX : size;                                            \
   PyObject* buf = PyBuffer_FromReadWriteMemory( (void*)address, size );        \
   if ( buf ) {                                                                 \
      Py_INCREF( (PyObject*)(void*)&Py##name##Buffer_Type );                    \
      buf->ob_type = &Py##name##Buffer_Type;                                    \
   }                                                                            \
   return buf;                                                                  \
}                                                                               \
                                                                                \
PyObject* PyROOT::TPyBufferFactory::PyBuffer_FromMemory( type* address, PyObject* scb )\
{                                                                               \
   PyObject* buf = PyBuffer_FromMemory( address, Py_ssize_t(0) );               \
   if ( buf != 0 && PyCallable_Check( scb ) ) {                                 \
      Py_INCREF( scb );                                                         \
      gSizeCallbacks[ buf ] = scb;                                              \
   }                                                                            \
   return buf;                                                                  \
}

Definition at line 273 of file PyBufferFactory.cxx.

#define PYROOT_IMPLEMENT_PYBUFFER_METHODS ( name,
type,
stype,
F1,
F2   ) 

Definition at line 108 of file PyBufferFactory.cxx.

#define PYROOT_INSTALL_PYBUFFER_METHODS ( name,
type   ) 

Value:

Py##name##Buffer_Type.tp_name            = (char*)"ROOT.Py"#name"Buffer";    \
   Py##name##Buffer_Type.tp_base            = &PyBuffer_Type;                   \
   Py##name##Buffer_Type.tp_as_buffer       = PyBuffer_Type.tp_as_buffer;       \
   Py##name##Buffer_SeqMethods.sq_item      = (ssizeargfunc)name##_buffer_item; \
   Py##name##Buffer_SeqMethods.sq_ass_item  = (ssizeobjargproc)name##_buffer_ass_item;\
   Py##name##Buffer_SeqMethods.sq_length    = (lenfunc)buffer_length;           \
   Py##name##Buffer_Type.tp_as_sequence     = &Py##name##Buffer_SeqMethods;     \
   if ( PyBuffer_Type.tp_as_mapping ) { /* p2.6 and later */                    \
      Py##name##Buffer_MapMethods.mp_length    = (lenfunc)buffer_length;        \
      Py##name##Buffer_MapMethods.mp_subscript = (binaryfunc)name##_buffer_subscript;\
      Py##name##Buffer_MapMethods.mp_ass_subscript = (objobjargproc)pyroot_buffer_ass_subscript;\
      Py##name##Buffer_Type.tp_as_mapping      = &Py##name##Buffer_MapMethods;  \
   }                                                                            \
   Py##name##Buffer_Type.tp_str             = (reprfunc)name##_buffer_str;      \
   Py##name##Buffer_Type.tp_methods         = buffer_methods;                   \
   Py##name##Buffer_Type.tp_getset          = buffer_getset;                    \
   PyType_Ready( &Py##name##Buffer_Type );

Definition at line 234 of file PyBufferFactory.cxx.

Referenced by PyROOT::TPyBufferFactory::TPyBufferFactory().

#define PYROOT_PREPARE_PYBUFFER_TYPE ( name   ) 

Value:

PyTypeObject      Py##name##Buffer_Type;                                  \
   PySequenceMethods Py##name##Buffer_SeqMethods = *(PyBuffer_Type.tp_as_sequence);\
   PyMappingMethods  Py##name##Buffer_MapMethods;

Definition at line 38 of file PyBufferFactory.cxx.


Function Documentation

PyObject* @30::buf_typecode ( PyObject pyobject,
void *   
) [static]

Definition at line 185 of file PyBufferFactory.cxx.

References PyBytes_FromString.

const char* @30::buffer_get ( PyObject self,
int  idx 
) [static]

Definition at line 81 of file PyBufferFactory.cxx.

References buf, buffer_length(), and if().

Py_ssize_t @30::buffer_length ( PyObject self  )  [static]

Definition at line 53 of file PyBufferFactory.cxx.

References NULL, Py_TYPE, and PyInt_AsSsize_t.

Referenced by buffer_get().

PyObject* @30::buffer_setsize ( PyObject self,
PyObject pynlen 
) [static]

Definition at line 168 of file PyBufferFactory.cxx.

References PyInt_AsSsize_t.

int @30::pyroot_buffer_ass_subscript ( PyObject self,
PyObject idx,
PyObject val 
) [static]

Definition at line 154 of file PyBufferFactory.cxx.

References i, Py_TYPE, PyIndex_Check, and PyNumber_AsSsize_t().


Variable Documentation

PyGetSetDef buffer_getset[] [static]

Initial value:

 {
      { (char*)"typecode", (getter)buf_typecode, NULL, NULL, NULL },
      { (char*)NULL, NULL, NULL, NULL, NULL }
   }

Definition at line 210 of file PyBufferFactory.cxx.

PyMethodDef buffer_methods[] [static]

Initial value:

 {
      { (char*)"SetSize", (PyCFunction)buffer_setsize, METH_O, NULL },
      { (char*)NULL, NULL, 0, NULL }
   }

Definition at line 216 of file PyBufferFactory.cxx.

PyObject_HEAD PyObject* fBase

Definition at line 25 of file PyBufferFactory.cxx.

Referenced by ClassImp().

void* fPtr

Definition at line 26 of file PyBufferFactory.cxx.

Referenced by Reflex::FuncToVoidPtr(), TMatrixTColumn< Element >::GetPtr(), TMatrixTColumn< Element >::operator *=(), Reflex::Literal::operator const char *(), TMatrixTColumn< Element >::operator+=(), TMatrixTColumn< Element >::operator=(), and Reflex::VoidPtrToFunc().

Py_ssize_t fSize

Definition at line 27 of file PyBufferFactory.cxx.

Referenced by ClassImp(), XrdMonDecPacketDecoder::decodeOpen(), XrdXrootdProtocol::do_ReadAll(), doDecoding(), XrdFrmTransfer::Fetch(), TMVA::Option< T * >::GetArraySize(), XrdMonDecSink::loadActiveDictInfo(), main(), TMVA::Option< T * >::Print(), TMVA::Option< T * >::SetValue(), XrdOssSys::StatFS(), and XrdOssSys::StatLS().

std::map< PyObject*, PyObject* > gSizeCallbacks [static]

Definition at line 35 of file PyBufferFactory.cxx.

char* sizeCallback = const_cast< char* >( "_size" ) [static]

Definition at line 31 of file PyBufferFactory.cxx.

PyObject* sizeCallbackString_ = PyROOT_PyUnicode_FromString( sizeCallback ) [static]

Definition at line 32 of file PyBufferFactory.cxx.


Generated on Tue Jul 5 15:55:33 2011 for ROOT_528-00b_version by  doxygen 1.5.1