Re: [Pyobjc-dev] handle function calls with struct arguments?
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ron...@ma...> - 2008-01-29 07:23:25
|
On 27 Jan, 2008, at 5:01, Ian Johnson wrote:
> I am trying to use a framework with some delegate functions that
> pass structs in the call:
>
> - (void) buttonChanged:(WiiButtonType) type isPressed:(BOOL)
> isPressed;
>
> when I try to make this python function:
> def buttonChanged_isPressed_(self, type, isPressed):
> I get an error around pythonify_c_value
>
> if I change it to:
> def buttonChanged_isPressed_(self, *posargs, **kwdargs):
> print posargs
> print kwdargs
>
> the output is () and {}
>
> Does pyobjc not support structs in function calls?
PyObjC supports structs in method and function calls just fine, but
someone has to tell it that a struct is involved. You're actually
lucky that you didn't get a crash :-).
You have to define your callback like this:
def buttonChanged_isPressed_(self, type, isPressed):
pass
buttonChanged_isPressed_ = objc.selector(buttonChanged_isPressed_,
type="v@:ic")
That is, you have to tell the bridge the types of your argument
because the bridge has no information that tells it that the type
isn't "NSObject*".
If you plan to use this library more you can create a wrapper module
that allows you to just "import WiiRemote", you can then define an
objc.informal_protocol in that module that contains the method names
and signatures for the delegate callbacks.
Ronald
>
>
> here is my code in case anyone is interested:
> http://enja.org/enj/enjapen/enjapenAppDelegate.py
>
> and here is the library I am trying to use:
> http://darwiin-remote.svn.sourceforge.net/viewvc/darwiin-remote/WiiRemoteFramework/trunk/WiiRemote.h?view=markup
>
> --
> Ian Johnson
>
> Ignorance is Piss.
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
|