Re: [Pyobjc-dev] Some PyObC tweaks for using EOF and custom frameworks
Brought to you by:
ronaldoussoren
From: b.bum <bb...@ma...> - 2003-08-11 20:43:25
|
On Sunday, August 10, 2003, at 12:07, Ronald Oussoren wrote: > If all 'unvalidated' objects are an instance of EOFault we could try > to add a category on that class. That would have to be implemented in > a seperate C module, the code fragment below failed to compile when I > added this to objc_support.m: > > @class EOFault; > @interface EOFault (PyObjCSupport) > -(PyObject*)__pyobjc_PythonObject__; > @end Actually, this could be done from the Python side via the addClassMethod API in the objc module -- or, at the least, that code can be used as a model for implementing this without using a category. It would allow the method to be added to a class conditioned on whether or not the class exists. If __pyobjc_PythonObject__ as implemented on NSObject will "just work", then there is no need to provide an alternative implementation: % python Python 2.3b1 (#1, Jul 27 2003, 10:44:20) [GCC 3.3 20030304 (Apple Computer, Inc. build 1481)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import objc >>> from Foundation import * >>> x = NSBundle.mainBundle() >>> x.description() u'NSBundle </usr/bin> (loaded)' >>> objc.classAddMethods(NSBundle, [NSObject.description]) >>> x.description() u'<NSBundle: 0x35b120>' |