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

Ronald Oussoren ronaldoussoren at mac.com
Thu Jan 10 07:54:38 CET 2008


On 9 Jan, 2008, at 18:49, has wrote:

> Hi all,
>
> I'm trying to create a PyObjC wrapper for objc-appscript,

Why?

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

(that is someMethod:(out NSError**)error).

Alternatively you can use the annotation 'type_modifier="o"' in an  
exception file for the bridgesupport tool. To be honest I have no idea  
how to do that with the system implementation of the bridgesupport  
tool, I tend to use my own implementation from the pyobjc repository  
(long story).

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

Ronald

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2224 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20080110/bbc61321/attachment.bin 


More information about the Pythonmac-SIG mailing list