[Pyrex] was: problem with void*....
Greg Ewing
greg at cosc.canterbury.ac.nz
Thu Jun 19 05:53:12 CEST 2003
Geoffrey Bantle <hairbat at yahoo.com> wrote:
> heres the function prototype for what I am currently
> trying to wrap.
>
> extern void vll_send_connect(char *name, char *pass,
^^^^
Be careful, "pass" is a reserved word in Pyrex.
> cdef VSession createSession():
> cdef VSession Connection
> return Connection
I hope this is just a placeholder for something you're going to write
later, because, as it stands, it doesn't create anything. It just
returns an uninitialised pointer.
> cdef class pvlSession:
> def __init__(self):
> self.Connection = createSession()
^^^^^^^^^^
You haven't declared this as a C attribute of pvlSession, so Pyrex
will try to (1) convert the result of createSession() to a Python
object, and (2) use a Python attribute access to store it in
self.Connection. It won't be able to do (1) because it's a void *.
You'll need to declare Connection as a C attribute, e.g.
cdef class pvlSession:
cdef VSession Connection
Typo here, it should be VSession (with a capital S).
> def describe(self):
> print "this Session is", self.Connection
^^^^^^^^^^^^^^^
With the declaration of Connection as a VSession, this won't work,
once again because Pyrex can't automatically convert a void * to a
Python object.
> def pvl_send_connect(User,Password,Address,Vsession Session):
^^^^^^^^^^^^^^^^
Apart from the fact that you've made a typo here (Vsession instead of
VSession), this won't work either, because Pyrex can't automatically
convert a Python object to a void *. Presumably you really wanted to
pass a pvlSession in here rather than a VSession, and then pass its
Connection on to vll_send_connect.
But I'm not sure how to do that, because pvl_send_connect is expecting
a VSession *, i.e. a void ***, which seems like at least one too many
*'s to me. I don't understand what's going on with the VSession in
all of this.
> vll_send_connect(User, Password, Address, &Connection)
^^^^^^^
There's another problem here, because vll_send_connect is expecting a
void * for Password. I can't tell what to do about this without
knowing what it's really expecting.
Can you point us towards any documentation for what you're trying
to wrap?
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg at cosc.canterbury.ac.nz +--------------------------------------+
More information about the Pyrex
mailing list