[Pythonmac-SIG] Calldll

David Ascher da@ski.org
Fri, 20 Aug 1999 09:43:19 -0700 (Pacific Daylight Time)


On Fri, 20 Aug 1999, Jack Jansen wrote:

> > There is something that has been bothering me about calldll for a 
> > while, and that is I seem to be unable to access records using it. 
> > For instance I can call Get/SetCurrentProcess, But I cannot access 
> > the Process Information Record.
> > 
> > I presume I have to set up a struct that matches the PIR, but how do 
> > I deal with pointers?
> 
> I've included David Ascher in the cc-list to this posting, because he's 
> working on a thing called (I think) AutoStruct that does most of what you 
> want, and gives you (from Python) a nice interface (struct.member) to the 
> structs as well.

Right.  It's still very much in a state of flux, but getting input on what
should be in there for the first alpha release is good.

> The one thing that would be difficult (I think, but maybe David can
> comment on this) is if your struct contains pointers to C objects that
> you would like to be wrapped in the corresponding Python object. For
> instance, look at a imaginary function that returns a WindowPtr and x,
> y coordinates:
>
>
> struct {
> 	WindowPtr	win;
> 	int		x, y;
> };

Am I correct that the C function in question returns a pointer to such a
struct?  (in other words, that a struct is used to return multiple
values?)

> What you would really like is if the "win" object was wrapped into the Python 
> Win.Window object. From C you would do this as
> 	return Py_BuildValue("O&ii", WinObj_New, str.win, str.x, str.y);
>
> So if there were a way in which the AutoStruct could be told that there's 
> something called a WINDOWPTR (or whatever magic cookie) and that the routines 
> to convert it from/to C are WinObj_New and WinObj_Convert, with the standard 
> O& calling sequence, then we'd be all set and calldll could do almost anything 
> that the prebuilt toolbox modules can do (I think callbacks are the only 
> exception).

I'm not sure I understand this bit (and alas I'm in a rush today).  With
calldll, I'm pretty sure everything is doable =). (calldll is not
something I'm using for my stuff because I'm working on CE, where calldll
is not yet done -- and hard to write -- there are lots of chips to
support).

I'll think about it -- if any of you are going to be at the O'Reilly
conference, feel free to ask me more about AutoStruct.

--david

----------------------------------------------------------------
This message brought to you by the National Non-Sequitur Society
We may not make sense, but the panda is a giant racoon.
----------------------------da@ski.org--------------------------