On 24-jun-2005, at 17:05, has wrote: > Ronald Oussoren wrote: > > >> I'm not happy with the way that the Carbon wrappers work, adding >> Carbon functions as methods of seemingly related classes. This >> makes it harder to map documentation for Carbon to Python. It is >> also ugly. But this might not be a problem with bgen itself. >> >> I'd prefer to see the function wrapped as functions in the Carbon >> module. >> > > That would be my preference as well, at least for any new work. > Stick with plain functions + opaque types. I'd rather deal with a > well designed ADT-based API than a not-so-well designed OO one. > Part of bgen's problem is that it's a victim of its own cleverness: > it tries to do much more than it actually needs to, which ends up > creating additional complexity; i.e. more things to learn, more > things to go wrong.
Exactly. > > > >> If needed one could add convenience methods to type wrappers as >> well, but with a more pythonic interface. That would require more >> work because you'd have to make up a nice interface and document it. >> > > I'd suggest writing any new OO wrappers as Python classes. Less > work than doing it in C, and it'd make it much quicker and easier > to tweak and polish the high-level API design. That's simular as what I was thinking of. What I'd do is create a C extension that contains the wrapper types and function. The wrapper types would be mutable, that is they should have a writeable __dict__. You can then add convienence methods to the wrapper types. Something like:: # CarbonX.py from _CarbonX import * from _CarbonXUtil import Category # simular to the one in PyObjC class FSRef (Category(FSRef)): """ Bla bla class documentation """ def __new__(self, path): return FSRefCreate(path) # Or whatever def islink(self): return ... The C extension might not even be a C extension, PyObjC can already create wrappers for simple functions given their name and signature. PyObjC's scanframework.py could be used to parse header files and create flat wrappers. The only disadvantage of this is that you'd have to depend on PyObjC, but that's not really a problem. Doing this should be fairly easy onces scanframework.py is finished, and that's just a matter of implementing some missing functionality all the hard work has already been done. Ronald _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig