|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-10-02 20:12:28
Mike,
I don't see what the problem is. Your code below looks fine. What do you
mean by "it returns PyObject*'s out of the function call"? What is "it"?
What function call?
Are you perhaps saying that you want to get a pointer to the base address of
the memory held by the buffer? If there is a function to do that in the
Python 'C' API, then use it, I guess. Otherwise, there's a struct in the
Python source associated with instances of Buffer (let's imagine it's called
PyBuffer). Find that struct, cast the PyObject* to a PyBuffer*, and fondle
its private data until you find what you're looking for.
Does that help?
-Dave
P.S. I'm happy to answer questions, but it will be easier for me if you can
spend the time to eliminate vagaries.
===================================================
David Abrahams, C++ library designer for hire
resume: http://users.rcn.com/abrahams/resume.html
C++ Booster (http://www.boost.org)
email: david.abrahams_at_[hidden]
===================================================
----- Original Message -----
From: "Mike Ensor" <MikeEnsor_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, October 02, 2001 8:45 PM
Subject: [boost] How can I switch a PyObject into a void*
> How can I switch a PyObject* in C into a void* varible? Is that possible?
> if not, can I convert it into a char*? I am trying to get a "Buffer"
object
> in python and convert it into a void* type. I have no problem telling how
> long it is, and extracting elements out of the "Buffer", but it returns
> PyObject*'s out of the function call. I can print them out, but that does
> nothing for me.
>
> void ListAddEntry_Binary(e5_List&l, PyObject* pyObjRef)
> {
> int size = PySequence_Size(pyObjRef);
> if(!PyBuffer_Check(pyObjRef))
> {
> std::cout << "PyObject is not a Buffer Object" << std::endl;
> return;
> }
> for(int i=0; i< size; i++)
> {
> std::cout << PySequence_GetItem(pyObjRef, i) << std::endl;
> }
> }
>
>
> that is the code I am currently working with.
>
> Thank you,
> Mike Ensor
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk