On Feb 23, 2005, at 10:39, Naveen Michaud-Agrawal wrote:
> --- Bob Ippolito <bob@...> wrote:
>> On Feb 23, 2005, at 1:42 AM, Ronald Oussoren wrote:
>>> On 22-feb-05, at 23:48, Bob Ippolito wrote:
>>>> On Feb 22, 2005, at 17:40, Naveen Michaud-Agrawal
>>>>> Thanks for your help earlier. I ported example
>>>>> Now I am trying to call some CoreGraphics
>>>>> that return extra information by passing by
>>>>> The problem is that I can't figure out the call
>>>>> signature for loadBundleFunctions, and also the
>>>>> appropriate way to call the function in python.
>>>>> there a byref function ala ctypes?
>>>> No there isn't. ctypes works perfectly fine on
>> OS X, so you could
>>>> use it.
>>> Depends on what he means by byref function ;-).
>> I'm pretty sure that
>>> 'n' (in), 'o' (out) and 'N' (inout) are supposed
>> to work as specifiers
>>> in signature strings. This definitely works for
>> methods, e.g. "v@..."
>>> is a method that has one byref integer argument,
>> you'd call that as
>>> 'obj.someMethod_(1)'. The pointer argument must
>> point to 1 value of
>>> the basic type, not to an array of them.
>> It's not quite equivalent. For example, how do you
>> pass NULL to an
>> in/out? If you pass None, you will end up with a
>> pointer to a NULL
>> value rather than NULL itself.
>> If we did support a byref argument, we could get rid
>> of the majority of
>> the strange rules with arguments and return
> OK, granted that was a made up call signature. What
> I'm really trying to do is write a program that can
> automatically tile an application's windows
> (particularly iTerm) in a way similar to the ion
> window manager for X11. For that I need to call some
> of the undocumented CoreGraphics functions to access
> other application's windows. Eventually it will be in
> rewritten in objective c, but for now I just want to
> test various tiling algorithms using pyobjc.
> For a single byref argument I figured out the
> signature string and python call signature. For
> example, to call the following function to retrieve
> the current workspace
> extern OSStatus CGSGetWorkspace(const CGSConnection
> cid, int *workspace);
> the following seems to work:
> FUNCTIONS=[ ( u'_CGSDefaultConnection', 'oi'), \
> ( u'CGSGetWorkspace',
type specifiers (n, o, N) are only for pointer arguments... that's not
a valid signature, I'm surprised PyObjC will accept it. It shouldn't.
> CoreGraphics = new.module("CoreGraphics")
> p =
> bndl = objc.loadBundle("CoreGraphics",
> CoreGraphics.__dict__, bundle_path=p)
> objc.loadBundleFunctions(bndl, CoreGraphics.__dict__,
> FUNCTIONS, skip_undefined=False)
> connection = CoreGraphics._CGSDefaultConnection()
> wid = 0
> err, wid = CoreGraphics.CGSGetWorkspace(connection,
> wid now seems to have the correct workspace number
> (I'm using Virtue Desktops -
> virtuedesktops.sourceforge.net - for multiple
> Now my next problem is that i need to pass in an array
> of ints by pointer to get a list of windows (assuming
> I already know the count):
> extern OSStatus CGSGetWorkspaceWindowList(const
> CGSConnection cid, int workspaceNumber, int count,
> int* list, int* outCount);
> How would I pass in a presized array of integers?
> Also, I noticed the byref typecode 'R' is not
I'm pretty sure loadBundleFunctions can't do that. Use ctypes.
>>> import ctypes
>>> as =
ApplicationServices', handle 90810000 at 41d78>
<ctypes._CdeclFuncPtr object at 0x289e0>