[Pyobjc-dev] Access to 'hidden' class-methods
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-01-11 22:32:48
|
Some time ago there was a discussion about access to class-methods with the same name as an instance-method. Currently this is not possible. One of suggestions was to add pyobjc-specific attributes to proxy objects. I've implemented, but not yet fully tested this. After I check this in you can do: NSObject.pyobjc_classMethods.description() # Call +description a = NSObject.new() a.pyobjc_classMethods.description() # Also call +description a.pyobjc_instanceMethods.description() # Call -description I've not yet added an pyobjc_instanceMethods attribute to class-proxies. Another restriction is that reflection doesn't work yet for the contents of these attributes, dir(NSObject.pyobjc_classMethods) will not return a list of class methods. I'm not yet completely happy with this solution because you cannot override these hidden methods in subclasses, that is you cannot define a class-method 'description' in your subclass of NSObject(*). But because this should rarely be necessary I can live with this. Ronald (*) Hmm, now that I think of it, you should be able to override the class-method description, you just cannot name your version 'description': The objc.selector function has an optional argument for specifying the selector. I've not yet tested if this actually works and now that I think of it, the testsuite doesn't seem to contain a test for overriding a class-method at all. |