[Pyrex] How to deal with a void *
Travis Caldwell
travis_caldwell2000 at yahoo.com
Fri May 12 09:36:51 CEST 2006
Thanks a lot for all the help.
I think that the extension type suits my needs the best.
What Lenard points out about having the doSomthings() be class methods
seems like it is very clean.
In general, Pyrex looks great. It's been forever since I've used C and
being able to wrap C libs using a Python like syntax is an amazing
feature.
_Travis_Caldwell_
--- Lenard Lindstrom <len-l at telus.net> wrote:
> If the void pointer is wrapped in an extension type then functions
> dependent on it can be called from methods. This is very OO.
>
> cdef class Resource:
> cdef void *r
> def __new__(self, ...):
> self.r = initResource(....)
> def doSomething(self, ....):
> doSomething(self.r, ....)
> ....
>
> It can also automatically release the resource from a __dealloc__
> method.
>
> Lenard Lindstrom
> <len-l at telus.net>
>
> On 12 May 2006 at 14:58, Greg Ewing wrote:
>
> > Tomasz Primke wrote:
> >
> > > Have you tried:
> > >
> > > cdef void *foo
> > > cdef unsigned long int *bar
> > >
> > > foo = initResource()
> > > bar = <unsigned long int*> foo
> >
> > I don't think that will help the OP, because it
> > sounded like he wanted to be able to pass his
> > void * through Python code.
> >
> > The only two safe ways of doing that have already
> > been suggested: wrap it in an extension type, or
> > wrap it in a PyCObject.
> >
>
>
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Pyrex
mailing list