Re: [Pyobjc-dev] Default to returning (void)?
Brought to you by:
ronaldoussoren
From: b.bum <bb...@ma...> - 2004-02-16 16:07:18
|
On Feb 16, 2004, at 7:50 AM, Ronald Oussoren wrote: > On 16-feb-04, at 16:15, Marc-Antoine Parent wrote: >> Le 04-02-16, =E0 00:00, b.bum a =E9crit : > I'm all for adding easy to use names instead of using selector()=20 > directly, we'll have to do that anyway if we want to use syntactic=20 > sugar later on. > > CVS will soon contain the functions that Bob proposed. For once, I may have managed to beat Ronald to this. Let's hope I got=20= it right. I added Accessor() to objc. Accessor is the generic term for the=20 setters and getters in Key-Value Coding. The Accessor() function tries=20= to intelligently determine if it should return the setter or getter=20 signature. I can see two problems with that: - what if it is overriding an already existing setter/getter? In that=20= case, the signature should be determined by the super. - what if the developer wants to return a scalar type? def Accessor(func): """ Return an Objective-C method object that is conformant with=20 key-value coding and key-value observing. """ argCount =3D func.func_code.co_argcount if argCount is 2: return selector(func, signature=3D"v@:@") elif argCount is 1: return selector(func, signature=3D"@@:") elif argCount is 0: raise ValueError, "Too few arguments to function '%s'. Cannot=20= create selector." % foo.func_name else: raise ValueError, "Too many arguments to function '%s'. Cannot=20= create selector." % foo.func_name |