Re: [Pyobjc-dev] NSDocument based app
Brought to you by:
ronaldoussoren
From: Jack J. <Jac...@cw...> - 2002-11-06 11:26:14
|
On Wednesday, Nov 6, 2002, at 11:19 Europe/Amsterdam, Ronald Oussoren wrote: >> So (void *) arguments are broken? Hmm... well I can avoid that in my >> example app by using the print panel rather than the sheet. The panel >> doesn't require a call back. There are a few things that use the >> (void *)contextInfo paradigm though, so we should probably fix it. >> What's the current scheme? >> > Not really broken, just not working as you want :-) Problem is that it > hard to automaticly translate from a Python object to a void*: Do you > want to pass the object itself (like you probably want to do here) or > should the object be translated to some native type (like you'd want > to do with 'int write(int fd, void* buf, int len)'). > > The current scheme is that you'll have to manually write methods that > do the right thing. But, I'll probably add a mechanism to get this > type of void* arguments to work without writing C code. What I tend to do if I run into this situation when wrapping an API is the following: - If the Python object is None I pass NULL, else - If the Python object conforms to the buffer protocol we use bf_getreadbuffer() or bf_getwritebuffer(), else - if it's a PyCObject we use PyCObject_AsVoidPtr(). -- - Jack Jansen <Jac...@or...> http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - |