Re: [Pyobjc-dev] Reusing code in ObjC mappings
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-11-14 21:10:47
|
On 14 nov 2003, at 17:46, Bob Ippolito wrote: > I've noticed that it's rather frequent for both a class and instance > method to have a near identical signature and a near identical > mapping.. for example, initWithBytes:length: vs dataWithBytes:length: > > The only difference is really in one line of code.. the class method > will say: > PyObjC_InitSuperCls(&super, > PyObjCSelector_GetClass(method), > PyObjCClass_GetClass(self)); > > and the instance method will say: > PyObjC_InitSuper(&super, > PyObjCSelector_GetClass(method), > PyObjCObject_GetObject(self)); > > There has to be a better way than this, so that we don't have all this > cut+paste code to maintain. Ideas? good point. For this specific example we can detect ``method`` is a class method or not and call the right InitSuper variant. The IMP variant of that code is probably completely the same already! Ronald |