[Pythonmac-SIG] Calldll

Jack Jansen jack@oratrix.nl
Fri, 20 Aug 1999 13:55:11 +0200


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

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;
};

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).
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm