[Pyrex] was: problem with void*....

Geoffrey Bantle hairbat at yahoo.com
Fri Jun 20 08:28:31 CEST 2003


--- Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
> 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.

Darn, I thought I had changed that. Will fix.

> 
> > 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.

What I am trying to do is find a way to be able to
pass the pointer to a VSession around in python to the
different wrapped functions (vll_set_session for one.)
I was able to achieve this with Swig but I am a bit
unhappy with Swig as a solution at the moment and
would like something a bit more 'pythony'.

The relevant functions prototypes
void vll_send_connect(char *name, char *pass, void
*address, VSession * *connection);

void vll_send_acsept_connect(VNodeID avatar, void
*address, VSession * *connection);

void vll_session_set(VSession session);
void vll_session_destroy(VSession session);

from what I can tell (and have heard from Eskil
Steenberg, Verse's designer and author of the 2.0
codebase) VSession is just a way to keep track of
network connections. I probably don't need to do
anything in python except pass them to and from
functions.

> 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.
> 

What would one do with void pointers normally?

<SNIP>
> 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.

The triple pointer might be a mistake on Eskil's part,
although it wouldn't make much sense considering hes
using the same source as he gives us and has verse
running on his machines. I am going to try to trace
through the source files tommorow picking it apart and
see what Information I can glean from them about this.
Hopefully I will get something usefull despite my
meager C knowledge.

How would one normally deal with a situation where the
C api your wrapping expects a pointer but pyrex is not
able to convert it to a PyObject?

> 
> >    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.

Its expecting a string actually. I need to fix that in
the verse headers and make it char *address.
 
> Can you point us towards any documentation for what
> you're trying
> to wrap?

the verse 2.0 spec
http://www.blender.org/modules.php?op=modload&name=phpBB2&file=viewtopic&t=1501&start=0

the sourceforge verse page is for verse 1.0 which is
completley different codebase, this is the current
information.

the latest verse2 sources...
http://www.blender.org/modules/verse/verse2.zip

Thanks for all the help,

Cheers,
Geoffrey Bantle.


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com




More information about the Pyrex mailing list