From: "Jack Jansen"
And to give a complete example of how useful this would be consider the following. I'll give a mac-centric example, because I don't know enough about calldll on windows (and I don't think there's a unix version yet).
Assume you're using Python to extend Photoshop. Assume Photoshop has an API to allow the plugin to get at the screen. Let's assume that there's a C call extern GrafPtr ps_GetDrawableSurface(void); to get at the datastructure you need to draw to. These GrafPtr's are (in Mac/Modules/qd/_Quickdraw.c) wrapped in Carbon.Qd.GrafPortType objects in Python.
In the current situation, if you would want to wrap this ps_GetDrawableSurface function you would need to write a C wrapper (which means you would need a C compiler, etc etc) because you would need to convert the return value with ("O&", GrafObj_new). If we had something like ("O@", typeobject) calldll could be extended so you could do something like psapilib = calldll.getlibrary(....) ps_GetDrawableSurface = calldll.newcall(psapilib.ps_GetDrawableSurface, Carbon.Qd.GrafPortType)
(newcall() arguments are funcpointer, return value type, arg1 type, ...)
You cannot do this currently, because there is no way to get from the type object (which is the only thing you have available in Python) to the functions you need to pass to O&.
In Python 2.2, the type object can itself be an instance, and you could call classmethods on it... I'm doing something similar on windows. Thomas