[C++-sig] can boost::python class imlement buffer protocol?

2009-01-07 Thread Neal Becker
This would require filling in tp_as_buffer field in the PyTypeObject structure 
for the class.  Is this possible?  Any clue how/where this could be done?

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] can boost::python class imlement buffer protocol?

2009-01-07 Thread David Abrahams

on Wed Jan 07 2009, Neal Becker  wrote:

> This would require filling in tp_as_buffer field in the PyTypeObject 
> structure for the
> class.  Is this possible?  Any clue how/where this could be done?

I honestly don't know the answers to these questions, sorry.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] can boost::python class imlement buffer protocol?

2009-01-07 Thread Neal Becker
David Abrahams wrote:

> 
> on Wed Jan 07 2009, Neal Becker  wrote:
> 
>> This would require filling in tp_as_buffer field in the PyTypeObject
>> structure for the
>> class.  Is this possible?  Any clue how/where this could be done?
> 
> I honestly don't know the answers to these questions, sorry.
> 

As a workaround, I currently implemented an 'as_buffer' member function.
For example:

template
inline object as_buffer (ublas::vector & m) {
  return object (handle<> (PyBuffer_FromReadWriteMemory ((void*)(&m.data()[0]), 
m.size()*sizeof(T;
}

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig