[Pyobjc-dev] aspect/advice -- wrapping methods
Brought to you by:
ronaldoussoren
From: ytrewq1 <yt...@gm...> - 2006-04-15 15:05:11
|
I am able to 'wrap' existing Cocoa methods in classes using objc.classAddMethods 'manually' or via categories. For example, assuming something like: import sys inst =3D SomeCocoaClass.alloc().init() temp =3D inst.someMethod_ class SomeCocoaClass (objc.Category(SomeCocoaClass)): def someMethod_(self, something): sys.stderr.write('here: %s' % something) return temp(self, something) now when someMethod_ is called, Console.app provides some appropriate output. I'd like to automate this wrapping process in the form of a function which I can pass the name of a class and the name of a method to and have the function do the wrapping for me. I've tried a number of approaches, but upon executing the 'wrapped' method, I either get an error about not being able to look up a name (trying to find the original method) or I get an infinite loop (the wrappin= g method keeps calling itself). Does this sound like something that should be doable? If so, any hints or pointers? |