[Pythonmac-SIG] creating PyObjC wrapper for ObjC framework?

has hengist.podd at virgin.net
Thu Jan 10 18:00:25 CET 2008


On 10 Jan 2008, at 06:54, Ronald Oussoren wrote:

>> I'm trying to create a PyObjC wrapper for objc-appscript,
>
> Why?

Partly just to know how, as one of objc-appscript's goals is to  
provide a foundation for implementing other appscript bridges, and  
this lets me explore the ins and outs.

Partly so I can do casual testing in an interactive interpreter.  
(Yeah, I'm a slob.)

Partly because I've been toying with the idea of having objc-aem  
provide the basis for appscript support in Jonathan Wight's PyObjC- 
based 'Run Python Script' Automator action.


>> and I'm
>> wondering how to wrap methods that have NSError** arguments, e.g.:
>
> The easiest way is to mark the arguments as 'out' in the Objective-C  
> prototype (and then recompile), that way PyObjC will pick up the  
> right metadata from the ObjC runtime and you won't need the  
> bridgesupport file

Ahh, too easy. Duh.


>> The logical thing would be to convert a returned NSError into a  
>> Python
>> exception, but BridgeSupport's gen_bridge_metadata tool doesn't seem
>> to provide any help here, simply flagging the argument as 'opaque'.
>> Any advice on how to proceed (with or without using BS)?
>
> Don't try to convert the NSError to an exception, that would make  
> your wrapper complete different from other wrappers and hence more  
> likely to cause confusion for users.


Okay. (Is this something that's changed since PyObjC 1.x, or is my  
memory just playing tricks?)

Thanks,

has
-- 
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org



More information about the Pythonmac-SIG mailing list